From 0490cf02347083dd143269ee528894254fa522a9 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Thu, 2 Dec 2010 19:27:33 +0100 Subject: [PATCH] Build multipart message when sending notifications about shared calendars. --- kronolith/config/hooks.php.dist | 36 ------------------- kronolith/lib/Kronolith.php | 43 +++++++---------------- kronolith/templates/share/notification.html.php | 23 ++++++++++++ kronolith/templates/share/notification.plain.php | 10 ++++++ kronolith/themes/default/graphics/big_share.png | Bin 0 -> 3218 bytes 5 files changed, 46 insertions(+), 66 deletions(-) create mode 100644 kronolith/templates/share/notification.html.php create mode 100644 kronolith/templates/share/notification.plain.php create mode 100644 kronolith/themes/default/graphics/big_share.png 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 0000000000000000000000000000000000000000..02652ca4f4a3ed2b4b41dc2296705bfa12a519fd GIT binary patch literal 3218 zcmV;D3~lp?P)*v;h9>+W(%y3s&GBt-roPFTbt1f zbg%&b%9j6s5dV}e;^N|h!2tilf&YgZ*6f>z!~llF0N>5L`}FPp-oo;#W!u}^ipT(m z$pC=A0FucZg2Mp*nl_%&3;wE8|AQ6V*3rA%N&j>K_MJ?C!2pBA0RM&^^7-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