</configsection>
<configsection name="autoshare">
- <configheader>Calendar Auto-Sharing</configheader>
- <configenum name="shareperms" desc="When a new user is created, his
- default calendar can be automatically shared with his group(s). Which
- permissions should the group have?">
- <values>
- <value desc="None (no sharing)">none</value>
- <value desc="Read-only">read</value>
- <value desc="Read and write">edit</value>
- <value desc="Read, write and delete">full</value>
- </values>
- </configenum>
+ <configheader>Share Settings</configheader>
+ <configenum name="shareperms" desc="When a new user is created, his
+ default calendar can be automatically shared with his group(s). Which
+ permissions should the group have?">
+ <values>
+ <value desc="None (no sharing)">none</value>
+ <value desc="Read-only">read</value>
+ <value desc="Read and write">edit</value>
+ <value desc="Read, write and delete">full</value>
+ </values>
+ </configenum>
+ </configsection>
+
+ <configsection name="share">
+ <configboolean name="notify" desc="Notify users and groups per e-mail if
+ they have been granted access to a shared calendar (or tasklist), or are the
+ new owner of the share?">false</configboolean>
</configsection>
<configsection name="holidays">
class Kronolith_Hooks
{
/**
- * AJAX HOOK: Add user-defined AJAX action handlers.
+ * Adds user-defined AJAX action handlers.
*
* @param string $action The AJAX action.
* @param Horde_Variables $vars The URL parameters.
// throw new Horde_Ajax_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');
+// }
}
$perm = $share->getPermission();
$errors = array();
+ if ($GLOBALS['conf']['share']['notify']) {
+ $identity = $GLOBALS['injector']
+ ->getInstance('Horde_Prefs_Identity')
+ ->getIdentity();
+ $userName = $identity->getName();
+ $mail = new Horde_Mime_Mail(
+ array('from' => $identity->getDefaultFromAddress(true),
+ 'charset' => Horde_Nls::getCharset())
+ );
+ $mail->addHeader('User-Agent', 'Kronolith ' . $GLOBALS['registry']->getVersion());
+ }
+
// Process owner and owner permissions.
$old_owner = $share->get('owner');
$new_owner_backend = Horde_Util::getFormData('owner_select', Horde_Util::getFormData('owner_input', $old_owner));
} else {
$share->set('owner', $new_owner);
$share->save();
+ if ($GLOBALS['conf']['share']['notify']) {
+ $to = $GLOBALS['injector']
+ ->getInstance('Horde_Prefs_Identity')
+ ->getIdentity($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"),
+ $userName,
+ $share->get('name'));
+ }
+ $mail->addHeader('Subject', _("Ownership assignment"));
+ $mail->addHeader('To', $to);
+ $mail->setBody($message, Horde_Nls::getCharset());
+ $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
+ }
}
}
$u_delete = Horde_Util::getFormData('u_delete');
$u_delegate = Horde_Util::getFormData('u_delegate');
+ $current = $perm->getUserPermissions();
+ if ($GLOBALS['conf']['share']['notify']) {
+ $mail->addHeader('Subject', _("Access permissions"));
+ }
+
$perm->removeUserPermission(null, null, false);
foreach ($u_names as $key => $user_backend) {
// Apply backend hooks
continue;
}
+ $has_perms = false;
if (!empty($u_show[$key])) {
$perm->addUserPermission($user, Horde_Perms::SHOW, false);
+ $has_perms = true;
}
if (!empty($u_read[$key])) {
$perm->addUserPermission($user, Horde_Perms::READ, false);
+ $has_perms = true;
}
if (!empty($u_edit[$key])) {
$perm->addUserPermission($user, Horde_Perms::EDIT, false);
+ $has_perms = true;
}
if (!empty($u_delete[$key])) {
$perm->addUserPermission($user, Horde_Perms::DELETE, false);
+ $has_perms = true;
}
if (!empty($u_delegate[$key])) {
$perm->addUserPermission($user, Kronolith::PERMS_DELEGATE, false);
+ $has_perms = true;
+ }
+
+ // Notify users that have been added.
+ if ($GLOBALS['conf']['share']['notify'] &&
+ !isset($current[$user]) && $has_perms) {
+ $to = $GLOBALS['injector']
+ ->getInstance('Horde_Prefs_Identity')
+ ->getIdentity($user)
+ ->getDefaultFromAddress(true);
+ try {
+ $message = Horde::callHook('shareUserNotification', array($user, $share));
+ } catch (Horde_Exception_HookNotSet $e) {
+ $message = sprintf(_("%s has given you access to \"%s\"."),
+ $userName,
+ $share->get('name'));
+ }
+ $mail->addHeader('To', $to);
+ $mail->setBody($message, Horde_Nls::getCharset());
+ $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
}
}
$g_delete = Horde_Util::getFormData('g_delete');
$g_delegate = Horde_Util::getFormData('g_delegate');
+ $current = $perm->getGroupPermissions();
$perm->removeGroupPermission(null, null, false);
foreach ($g_names as $key => $group) {
if (empty($group)) {
continue;
}
+ $has_perms = false;
if (!empty($g_show[$key])) {
$perm->addGroupPermission($group, Horde_Perms::SHOW, false);
+ $has_perms = true;
}
if (!empty($g_read[$key])) {
$perm->addGroupPermission($group, Horde_Perms::READ, false);
+ $has_perms = true;
}
if (!empty($g_edit[$key])) {
$perm->addGroupPermission($group, Horde_Perms::EDIT, false);
+ $has_perms = true;
}
if (!empty($g_delete[$key])) {
$perm->addGroupPermission($group, Horde_Perms::DELETE, false);
+ $has_perms = true;
}
if (!empty($g_delegate[$key])) {
$perm->addGroupPermission($group, Kronolith::PERMS_DELEGATE, false);
+ $has_perms = true;
+ }
+
+ // Notify users that have been added.
+ if ($GLOBALS['conf']['share']['notify'] &&
+ !isset($current[$group]) && $has_perms) {
+ $groupOb = Group::singleton()->getGroupById($group);
+ if (!empty($groupOb->data['email'])) {
+ try {
+ $message = Horde::callHook('shareGroupNotification', array($group, $share));
+ } catch (Horde_Exception_HookNotSet $e) {
+ $message = sprintf(_("%s has given your group \"%s\" access to \"%s\"."),
+ $userName,
+ $groupOb->getName(),
+ $share->get('name'));
+ }
+ $mail->addHeader('To', $groupOb->getName() . ' <' . $groupOb->data['email'] . '>');
+ $mail->setBody($message, Horde_Nls::getCharset());
+ $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
+ }
}
}
try {