Use templates when notifying about owner changes.
authorJan Schneider <jan@horde.org>
Tue, 7 Dec 2010 14:47:22 +0000 (15:47 +0100)
committerJan Schneider <jan@horde.org>
Tue, 7 Dec 2010 14:47:22 +0000 (15:47 +0100)
kronolith/lib/Kronolith.php
kronolith/templates/share/notification.html.php
kronolith/templates/share/notification.plain.php

index 84383c3..832da72 100644 (file)
@@ -1707,10 +1707,6 @@ class Kronolith
             $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.
@@ -1726,25 +1722,28 @@ class Kronolith
                 $share->set('owner', $new_owner);
                 $share->save();
                 if ($GLOBALS['conf']['share']['notify']) {
+                    $view->ownerChange = true;
+                    $multipart = Kronolith::buildMimeMessage($view, 'notification', $image);
                     $to = $GLOBALS['injector']
                         ->getInstance('Horde_Core_Factory_Identity')
                         ->create($new_owner)
                         ->getDefaultFromAddress(true);
-                    try {
-                        $message = Horde::callHook('shareOwnerNotification', array($new_owner, $share));
-                    } catch (Horde_Exception_HookNotSet $e) {
-                        $message = sprintf(_("%s has assigned the ownership of \"%s\" to you"),
-                                           $view->user,
-                                           $share->get('name'));
-                    }
-                    $mail->addHeader('Subject', _("Ownership assignment"));
-                    $mail->addHeader('To', $to, 'UTF-8', false);
-                    $mail->setBody($message, 'UTF-8');
+                    $mail->addHeader('Subject', _("Ownership assignment"), 'UTF-8');
+                    $mail->addHeader('To', $to, 'UTF-8');
+                    $mail->setBasePart($multipart);
                     $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
+                    $view->ownerChange = false;
                 }
             }
         }
 
+        if ($GLOBALS['conf']['share']['notify']) {
+            if ($GLOBALS['conf']['share']['hidden']) {
+                $view->subscribe = Horde::url('calendars/subscribe.php', true)->add('calendar', $share->getName());
+            }
+            $multipart = Kronolith::buildMimeMessage($view, 'notification', $image);
+        }
+
         if ($GLOBALS['registry']->isAdmin() ||
             !empty($GLOBALS['conf']['share']['world'])) {
             // Process default permissions.
index 9513310..19b53cf 100644 (file)
@@ -9,12 +9,16 @@
       <tr>
         <td>
           <font size="2">
+            <?php if ($this->ownerChange): ?>
+            <?php printf(_("%s has assigned the ownership of the calendar %s to you."), '<strong>' . $this->h($this->user) . '</strong>', '<strong>' . $this->h($this->calendar) . '</strong>') ?>
+            <?php else: ?>
             <?php printf(_("%s wants to share the calendar %s with you to grant you access to all events in this calendar."), '<strong>' . $this->h($this->user) . '</strong>', '<strong>' . $this->h($this->calendar) . '</strong>') ?>
             <?php if ($this->subscribe): ?>
             <?php echo _("To subscribe to this calendar, you need to click the following link:") ?>
             <br><br>
             <strong><a href="<?php echo $this->h($this->subscribe) ?>"><?php echo $this->h($this->subscribe) ?></a></strong>
             <?php endif ?>
+            <?php endif ?>
           </font>
         </td>
       </tr>
index dbd9424..6aaf435 100644 (file)
@@ -1,6 +1,9 @@
 <?php printf(_("Invitation from %s to the calendar \"%s\""), $this->user, $this->calendar) ?>
 
 
+<?php if ($this->ownerChange): ?>
+<?php printf(_("%s has assigned the ownership of the calendar \"%s\" to you."), $this->user, $this->calendar) ?>
+<?php else: ?>
 <?php printf(_("%s wants to share the calendar \"%s\" with you to grant you access to all events in this calendar."), $this->user, $this->calendar) ?>
 <?php if ($this->subscribe): ?>
  <?php echo _("To subscribe to this calendar, you need to click the following link:") ?>
@@ -8,3 +11,4 @@
 
 <?php echo $this->subscribe ?>
 <?php endif ?>
+<?php endif ?>