Add a subscription link to the message that notifies a user about a
authorJan Schneider <jan@horde.org>
Tue, 9 Nov 2010 21:24:45 +0000 (22:24 +0100)
committerJan Schneider <jan@horde.org>
Tue, 9 Nov 2010 21:26:03 +0000 (22:26 +0100)
calendar that has been shared with him, if we don't show all shared
calendars anyway.

kronolith/calendars/subscribe.php [new file with mode: 0644]
kronolith/docs/CHANGES
kronolith/lib/Ajax/Application.php
kronolith/lib/Kronolith.php

diff --git a/kronolith/calendars/subscribe.php b/kronolith/calendars/subscribe.php
new file mode 100644 (file)
index 0000000..73fa2ce
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Jan Schneider <jan@horde.org>
+ */
+
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('kronolith');
+
+$calendar = Horde_Util::getFormData('calendar');
+$url = Horde::url('', true);
+if (Kronolith::showAjaxView()) {
+    $url->setAnchor('calendar:internal|' . $calendar);
+} else {
+    $url->setAnchor('calendar:' . $calendar);
+    if (!in_array($display_calendars, $calendar)) {
+        $url->add('toggle_calendar', $calendar);
+    }
+}
+$url->redirect();
index 2723515..013255c 100644 (file)
@@ -2,6 +2,8 @@
 v3.0-git
 --------
 
+[jan] Send a subscription link with the notification about shared
+      calendars if necessary.
 [jan] Default calendars no longer have the user name as the ID.
 [jan] Create a default calendar if the user doesn't own any yet.
 [jan] Add CalDAV client support (Request #8525).
index 84f1aca..8d88f49 100644 (file)
@@ -799,7 +799,6 @@ class Kronolith_Ajax_Application extends Horde_Core_Ajax_Application
             'fg' => $calendar->foreground(),
             'bg' => $calendar->background(),
             'show' => false,
-            'perms' => Kronolith::permissionToJson($calendar->permission()),
             'edit' => $calendar->hasPermission(Horde_Perms::EDIT),
             'tg' => array_values($tagger->getTags($this->_vars->cal, 'calendar')));
         return $result;
index 65ea2b1..7e4b66f 100644 (file)
@@ -1858,6 +1858,15 @@ 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');
@@ -1915,11 +1924,12 @@ class Kronolith
                     ->create($user)
                     ->getDefaultFromAddress(true);
                 try {
-                    $message = Horde::callHook('shareUserNotification', array($user, $share));
+                    $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'));
+                                       $share->get('name'))
+                        . $subscription;
                 }
                 $mail->addHeader('To', $to, 'UTF-8', false);
                 $mail->setBody($message, 'UTF-8');
@@ -1970,12 +1980,13 @@ class Kronolith
                 $groupOb = $GLOBALS['injector']->getInstance('Horde_Group')->getGroupById($group);
                 if (!empty($groupOb->data['email'])) {
                     try {
-                        $message = Horde::callHook('shareGroupNotification', array($group, $share));
+                        $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'));
+                                           $share->get('name'))
+                            . $subscription;
                     }
                     $mail->addHeader('To', $groupOb->getName() . ' <' . $groupOb->data['email'] . '>', 'UTF-8', false);
                     $mail->setBody($message, 'UTF-8');