From: Jan Schneider Date: Thu, 11 Nov 2010 21:31:24 +0000 (+0100) Subject: Nicer alarm mails, at least for events. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4ffc65c107be47e20c1b9e1748f04b80618f7491;p=horde.git Nicer alarm mails, at least for events. --- diff --git a/framework/Alarm/lib/Horde/Alarm/Handler/Mail.php b/framework/Alarm/lib/Horde/Alarm/Handler/Mail.php index 943aed72f..c867950b3 100644 --- a/framework/Alarm/lib/Horde/Alarm/Handler/Mail.php +++ b/framework/Alarm/lib/Horde/Alarm/Handler/Mail.php @@ -81,13 +81,20 @@ class Horde_Alarm_Handler_Mail extends Horde_Alarm_Handler $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; diff --git a/kronolith/lib/Event.php b/kronolith/lib/Event.php index 447df9a33..ef1369af1 100644 --- a/kronolith/lib/Event.php +++ b/kronolith/lib/Event.php @@ -1573,13 +1573,51 @@ abstract class Kronolith_Event } } 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( diff --git a/kronolith/templates/alarm/mail.html.php b/kronolith/templates/alarm/mail.html.php new file mode 100644 index 000000000..cf9d2f4d4 --- /dev/null +++ b/kronolith/templates/alarm/mail.html.php @@ -0,0 +1,65 @@ +

h($this->event->getTitle($this->user)) ?>

+ + + + +
+ + + + + + > + + + + + event->location)): ?> + + > + + + + + + attendees): ?> + + > + + + + + + + event->description)): ?> + + > + + + + + + +
+ +  event->start->strftime($this->dateFormat) ?>, event->start->format($this->timeFormat) ?>
+ +  h($this->event->location) ?>
+ +   + attendees as $attendee): ?> + + h($attendee) ?>
+ + h($attendee) ?>
+ + + +
+ +  getInstance('Horde_Core_Factory_TextFilter')->filter($this->event->description, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO, 'callback' => null)) ?>
+
+ +prefsUrl): ?> +

prefsUrl . '">', '') ?>

+ diff --git a/kronolith/templates/alarm/mail.plain.php b/kronolith/templates/alarm/mail.plain.php new file mode 100644 index 000000000..84a2712df --- /dev/null +++ b/kronolith/templates/alarm/mail.plain.php @@ -0,0 +1,15 @@ + + + +event->getTitle($this->user) ?> + + + event->location ?> + + + event->start->strftime($this->dateFormat) ?> + + event->start->format($this->timeFormat) ?> + + +event->description ?> diff --git a/kronolith/themes/graphics/big_alarm.png b/kronolith/themes/graphics/big_alarm.png new file mode 100644 index 000000000..641a1ddc1 Binary files /dev/null and b/kronolith/themes/graphics/big_alarm.png differ