From 1af4f91251d937e574a3ee4f07d5289253de84f9 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Tue, 9 Nov 2010 22:24:45 +0100 Subject: [PATCH] Add a subscription link to the message that notifies a user about a calendar that has been shared with him, if we don't show all shared calendars anyway. --- kronolith/calendars/subscribe.php | 24 ++++++++++++++++++++++++ kronolith/docs/CHANGES | 2 ++ kronolith/lib/Ajax/Application.php | 1 - kronolith/lib/Kronolith.php | 19 +++++++++++++++---- 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 kronolith/calendars/subscribe.php diff --git a/kronolith/calendars/subscribe.php b/kronolith/calendars/subscribe.php new file mode 100644 index 000000000..73fa2cebd --- /dev/null +++ b/kronolith/calendars/subscribe.php @@ -0,0 +1,24 @@ + + */ + +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(); diff --git a/kronolith/docs/CHANGES b/kronolith/docs/CHANGES index 272351535..013255c8b 100644 --- a/kronolith/docs/CHANGES +++ b/kronolith/docs/CHANGES @@ -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). diff --git a/kronolith/lib/Ajax/Application.php b/kronolith/lib/Ajax/Application.php index 84f1acae6..8d88f49f1 100644 --- a/kronolith/lib/Ajax/Application.php +++ b/kronolith/lib/Ajax/Application.php @@ -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; diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 65ea2b14f..7e4b66f39 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -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'); -- 2.11.0