From: Jan Schneider Date: Thu, 2 Dec 2010 18:27:33 +0000 (+0100) Subject: Build multipart message when sending notifications about shared calendars. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0490cf02347083dd143269ee528894254fa522a9;p=horde.git Build multipart message when sending notifications about shared calendars. --- diff --git a/kronolith/config/hooks.php.dist b/kronolith/config/hooks.php.dist index a6b01f872..53d6cfb9b 100644 --- a/kronolith/config/hooks.php.dist +++ b/kronolith/config/hooks.php.dist @@ -31,40 +31,4 @@ class Kronolith_Hooks // // throw new Horde_Exception('Unknown action'); // } - - /** - * Generates the e-mail notification message when the share owner changes. - * - * @param string $user The new owner. - * @param Horde_Share $share A calendar or tasklist. - */ -// public function shareOwnerNotification($user, Horde_Share $share) -// { -// return 'Some fancy text including the ' . $user . ' and the ' . $share->get('name'); -// } - - /** - * Generates the e-mail notification message when the share permissions - * change. - * - * @param string $user A user who has been added to the permissions. - * @param Horde_Share $share A calendar or tasklist. - */ -// public function shareUserNotification($user, Horde_Share $share) -// { -// return 'Some fancy text including the ' . $user . ' and the ' . $share->get('name'); -// } - - /** - * Generates the e-mail notification message when the share permissions - * change. - * - * @param mixed $group The id of a group that has been added to the - * permissions. - * @param Horde_Share $share A calendar or tasklist. - */ -// public function shareGroupNotification($group, Horde_Share $share) -// { -// return 'Some fancy text including the ' . $group . ' and the ' . $share->get('name'); -// } } diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 227599a7e..e659ae874 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -1735,12 +1735,21 @@ class Kronolith $identity = $GLOBALS['injector'] ->getInstance('Horde_Core_Factory_Identity') ->create(); - $userName = $identity->getName(); $mail = new Horde_Mime_Mail( array('from' => $identity->getDefaultFromAddress(true), 'charset' => 'UTF-8') ); $mail->addHeader('User-Agent', 'Kronolith ' . $GLOBALS['registry']->getVersion()); + $image = self::getImagePart('big_share.png'); + $view = new Horde_View(array('templatePath' => KRONOLITH_TEMPLATES . '/share')); + new Horde_View_Helper_Text($view); + $view->user = $identity->getName(); + $view->calendar = $share->get('name'); + $view->imageId = $image->getContentId(); + if ($GLOBALS['conf']['share']['hidden']) { + $view->subscribe = Horde::url('calendars/subscribe.php', true)->add('calendar', $share->getName()); + } + $multipart = Kronolith::buildMimeMessage($view, 'notification', $image); } // Process owner and owner permissions. @@ -1764,7 +1773,7 @@ class Kronolith $message = Horde::callHook('shareOwnerNotification', array($new_owner, $share)); } catch (Horde_Exception_HookNotSet $e) { $message = sprintf(_("%s has assigned the ownership of \"%s\" to you"), - $userName, + $view->user, $share->get('name')); } $mail->addHeader('Subject', _("Ownership assignment")); @@ -1859,15 +1868,6 @@ class Kronolith $perm->removeCreatorPermission(Kronolith::PERMS_DELEGATE, false); } - // Build subscription link if necessary. - $subscription = $sublink = ''; - if ($GLOBALS['conf']['share']['hidden']) { - $sublink = Horde::url('calendars/subscribe.php', true)->add('calendar', $share->getName()); - $subscription = "\n" - . _("To subscribe to this calendar, you need to click the following link:") - . ' ' . $sublink; - } - // Process user permissions. $u_names = Horde_Util::getFormData('u_names'); $u_show = Horde_Util::getFormData('u_show'); @@ -1924,16 +1924,8 @@ class Kronolith ->getInstance('Horde_Core_Factory_Identity') ->create($user) ->getDefaultFromAddress(true); - try { - $message = Horde::callHook('shareUserNotification', array($user, $share, $sublink)); - } catch (Horde_Exception_HookNotSet $e) { - $message = sprintf(_("%s has given you access to \"%s\"."), - $userName, - $share->get('name')) - . $subscription; - } $mail->addHeader('To', $to, 'UTF-8', false); - $mail->setBody($message, 'UTF-8'); + $mail->setBasePart($multipart); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); } } @@ -1980,17 +1972,8 @@ class Kronolith !isset($current[$group]) && $has_perms) { $groupOb = $GLOBALS['injector']->getInstance('Horde_Group')->getGroupById($group); if (!empty($groupOb->data['email'])) { - try { - $message = Horde::callHook('shareGroupNotification', array($group, $share, $sublink)); - } catch (Horde_Exception_HookNotSet $e) { - $message = sprintf(_("%s has given your group \"%s\" access to \"%s\"."), - $userName, - $groupOb->getName(), - $share->get('name')) - . $subscription; - } $mail->addHeader('To', $groupOb->getName() . ' <' . $groupOb->data['email'] . '>', 'UTF-8', false); - $mail->setBody($message, 'UTF-8'); + $mail->setBasePart($multipart); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); } } diff --git a/kronolith/templates/share/notification.html.php b/kronolith/templates/share/notification.html.php new file mode 100644 index 000000000..951331030 --- /dev/null +++ b/kronolith/templates/share/notification.html.php @@ -0,0 +1,23 @@ +

h($this->user), $this->h($this->calendar)) ?>

+ + + + +
+ + + + + + +
+ + ' . $this->h($this->user) . '', '' . $this->h($this->calendar) . '') ?> + subscribe): ?> + +

+ h($this->subscribe) ?> + +
+
+
diff --git a/kronolith/templates/share/notification.plain.php b/kronolith/templates/share/notification.plain.php new file mode 100644 index 000000000..dbd942462 --- /dev/null +++ b/kronolith/templates/share/notification.plain.php @@ -0,0 +1,10 @@ +user, $this->calendar) ?> + + +user, $this->calendar) ?> +subscribe): ?> + + + +subscribe ?> + diff --git a/kronolith/themes/default/graphics/big_share.png b/kronolith/themes/default/graphics/big_share.png new file mode 100644 index 000000000..02652ca4f Binary files /dev/null and b/kronolith/themes/default/graphics/big_share.png differ