$mail = new Horde_Mime_Mail(array(
'subject' => $alarm['title'],
- 'body' => empty($alarm['params']['mail']['body']) ? $alarm['text'] : $alarm['params']['mail']['body'],
'to' => $email,
'from' => $email,
'charset' => 'UTF-8'
));
$mail->addHeader('Auto-Submitted', 'auto-generated');
$mail->addHeader('X-Horde-Alarm', $alarm['title'], 'UTF-8');
+ if (isset($alarm['params']['mail']['mimepart'])) {
+ $mail->setBasePart($alarm['params']['mail']['mimepart']);
+ } elseif (empty($alarm['params']['mail']['body'])) {
+ $mail->setBody($alarm['text']);
+ } else {
+ $mail->setBody($alarm['params']['mail']['body']);
+ }
+
$mail->send($this->_mail);
$alarm['internal']['mail']['sent'] = true;
}
}
if (isset($methods['mail'])) {
- $methods['mail']['body'] = sprintf(
- _("We would like to remind you of this upcoming event.\n\n%s\n\nLocation: %s\n\nDate: %s\nTime: %s\n\n%s"),
- $this->getTitle($user),
- $this->location,
- $this->start->strftime($prefs->getValue('date_format')),
- $this->start->format($prefs->getValue('twentyFour') ? 'H:i' : 'h:ia'),
- $this->description);
+ $background = new Horde_Themes_Image('big_alarm.png');
+ $image = new Horde_Mime_Part();
+ $image->setType('image/png');
+ $image->setContents(file_get_contents($background->fs));
+ $image->setContentId();
+ $image->setDisposition('attachment');
+
+ $view = new Horde_View(array('templatePath' => KRONOLITH_TEMPLATES . '/alarm', 'encoding' => 'UTF-8'));
+ new Horde_View_Helper_Text($view);
+ $view->event = $this;
+ $view->imageId = $image->getContentId();
+ $view->user = $user;
+ $view->dateFormat = $prefs->getValue('date_format');
+ $view->timeFormat = $prefs->getValue('twentyFour') ? 'H:i' : 'h:ia';
+ if (!$prefs->isLocked('event_reminder')) {
+ $view->prefsUrl = Horde::url(Horde::getServiceLink('prefs', 'kronolith'), true)->remove(session_name());
+ }
+ if ($this->attendees) {
+ $attendees = array();
+ foreach ($this->attendees as $mail => $attendee) {
+ $attendees[] = empty($attendee['name']) ? $mail : Horde_Mime_Address::trimAddress($attendee['name'] . (strpos($mail, '@') === false ? '' : ' <' . $mail . '>'));
+ }
+ $view->attendees = $attendees;
+ }
+
+ $multipart = new Horde_Mime_Part();
+ $multipart->setType('multipart/alternative');
+ $bodyText = new Horde_Mime_Part();
+ $bodyText->setType('text/plain');
+ $bodyText->setCharset('UTF-8');
+ $bodyText->setContents($view->render('mail.plain.php'));
+ $bodyText->setDisposition('inline');
+ $multipart->addPart($bodyText);
+ $bodyHtml = new Horde_Mime_Part();
+ $bodyHtml->setType('text/html');
+ $bodyHtml->setCharset('UTF-8');
+ $bodyHtml->setContents($view->render('mail.html.php'));
+ $bodyHtml->setDisposition('inline');
+ $related = new Horde_Mime_Part();
+ $related->setType('multipart/related');
+ $related->setContentTypeParameter('start', $bodyHtml->setContentId());
+ $related->addPart($bodyHtml);
+ $related->addPart($image);
+ $multipart->addPart($related);
+ $methods['mail']['mimepart'] = $multipart;
}
return array(
--- /dev/null
+<p><font size="4"><strong><a href="<?php echo $this->event->getViewUrl(array(), true)->remove(session_name()) ?>"><?php echo $this->h($this->event->getTitle($this->user)) ?></a></strong></font></p>
+
+<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
+ <td width="140" valign="top">
+ <img src="cid:<?php echo $this->imageId ?>" />
+ </td>
+ <td valign="top">
+ <table width="100%" border="0" cellpadding="5" cellspacing="0">
+ <?php $i = 0 ?>
+
+ <tr<?php if ($i++ % 2) echo ' bgcolor="#f1f1f1"' ?>>
+ <td nowrap="nowrap" align="right">
+ <font size="2"><strong><?php echo _("Date and time:") ?></strong></font>
+ </td>
+ <td width="5"> </td>
+ <td width="100%"><font size="2"><strong><?php echo $this->event->start->strftime($this->dateFormat) ?>, <?php echo $this->event->start->format($this->timeFormat) ?></strong></font></td>
+ </tr>
+ <?php if (strlen($this->event->location)): ?>
+
+ <tr<?php if ($i++ % 2) echo ' bgcolor="#f1f1f1"' ?>>
+ <td nowrap="nowrap" align="right">
+ <font size="2"><strong><?php echo _("Location:") ?></strong></font>
+ </td>
+ <td width="5"> </td>
+ <td width="100%"><font size="2"><strong><?php echo $this->h($this->event->location) ?></strong></font></td>
+ </tr>
+ <?php endif ?>
+ <?php if ($this->attendees): ?>
+
+ <tr<?php if ($i++ % 2) echo ' bgcolor="#f1f1f1"' ?>>
+ <td nowrap="nowrap" align="right" valign="top">
+ <font size="2"><strong><?php echo _("Attendees:") ?></strong></font>
+ </td>
+ <td width="5"> </td>
+ <td width="100%"><font size="2"><strong>
+ <?php foreach ($this->attendees as $attendee): ?>
+ <?php if (strpos('@', $attendee) === false): ?>
+ <?php echo $this->h($attendee) ?><br />
+ <?php else: ?>
+ <a href="mailto:<?php echo $attendee ?>"><?php echo $this->h($attendee) ?></a><br />
+ <?php endif; ?>
+ <?php endforeach; ?>
+
+ </strong></font></td>
+ </tr>
+ <?php endif ?>
+
+ <?php if (strlen($this->event->description)): ?>
+
+ <tr<?php if ($i++ % 2) echo ' bgcolor="#f1f1f1"' ?>>
+ <td nowrap="nowrap" align="right" valign="top">
+ <font size="2"><strong><?php echo _("Description:") ?></strong></font>
+ </td>
+ <td width="5"> </td>
+ <td width="100%"><font size="2"><strong><?php echo $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($this->event->description, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO, 'callback' => null)) ?></strong></font></td>
+ </tr>
+ <?php endif ?>
+
+ </table>
+ </td>
+</tr></table>
+
+<?php if ($this->prefsUrl): ?>
+<p><font size="1"><?php printf(_("You get this message because your calendar is configured to send you reminders of events with alarms. You can change this if you %slogin to the calendar%s and change your preferences."), '<a href="' . $this->prefsUrl . '">', '</a>') ?></font></p>
+<?php endif ?>
--- /dev/null
+<?php echo _("We would like to remind you of this upcoming event.") ?>
+
+
+<?php echo $this->event->getTitle($this->user) ?>
+
+
+<?php echo _("Location:") ?> <?php echo $this->event->location ?>
+
+
+<?php echo _("Date:") ?> <?php echo $this->event->start->strftime($this->dateFormat) ?>
+
+<?php echo _("Time:") ?> <?php echo $this->event->start->format($this->timeFormat) ?>
+
+
+<?php echo $this->event->description ?>