/* Check post permissions. */
if (!$messages->hasPermission(Horde_Perms::EDIT)) {
- try {
- return Horde::callHook('perms_denied', array('agora'));
- } catch (Horde_Exception_HookNotSet $e) {
- return sprintf(_("You don't have permission to post messages in forum %s."), $params['forum_id']);
- }
+ Horde::permissionDeniedError('agora', null);
+ return PEAR::raiseError(sprintf(_("You don't have permission to post messages in forum %s."), $params['forum_id']));
}
if (isset($params['message_id'])) {
/* Display an edit-dialogue if the thread is not locked and we can edit messages in them. */
if (!$messages->hasPermission(Horde_Perms::EDIT)) {
- try {
- $message = Horde::callHook('perms_denied', array('agora'), 'horde');
- } catch (Horde_Exception_HookNotset $e) {
- $message = sprintf(_("You don't have permission to post messages in forum %s."), $forum['forum_name']);
- }
- $view->form = $message;
+ Horde::permissionDeniedError('agora', null);
+ $view->form = sprintf(_("You don't have permission to post messages in forum %s."), $forum['forum_name']);
} elseif ($message['locked']) {
$view->form = _("Thread locked.");
} else {
$comments_reason = sprintf(_("You are on %s blacklist."), $user);
}
} else {
- try {
- $comments_reason = Horde::callHook('perms_denied', array('folks'));
- } catch (Horde_Exception_HookNotSet $e) {
- $comments_reason = _("Only authenticated users can post comments.");
- }
+ Horde::permissionDeniedError('folks', null);
+ $comments_reason = _("Only authenticated users can post comments.");
}
break;
$max_blocks = $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_blocks');
if (($max_blocks !== true) &&
($max_blocks <= $this->count())) {
- try {
- $message = Horde::callHook('perms_denied', array('horde:max_blocks'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(Horde_Block_Translation::ngettext("You are not allowed to create more than %d block.", "You are not allowed to create more than %d blocks.", $max_blocks), $max_blocks));
- }
- $GLOBALS['notification']->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'horde',
+ 'max_blocks',
+ sprintf(Horde_Block_Translation::ngettext("You are not allowed to create more than %d block.", "You are not allowed to create more than %d blocks.", $max_blocks), $max_blocks)
+ );
break;
}
return self::endBuffer();
}
+ /**
+ * Process a permission denied error, running a user-defined hook if
+ * necessary.
+ *
+ * @param string $app Application name.
+ * @param string $perm Permission name.
+ * @param string $error An error message to output via the notification
+ * system.
+ */
+ static public function permissionDeniedError($app, $perm, $error = null)
+ {
+ try {
+ self::callHook('perms_denied', array($app, $perm));
+ } catch (Horde_Exception_HookNotSet $e) {}
+
+ if (!is_null($error)) {
+ $GLOBALS['notification']->push($error, 'horde.warning');
+ }
+ }
+
}
/**
* Hook called if a user tries to make an action that is under permission
* control that they don't have sufficient permissions for. It can be
- * used to show the user a custom message including HTML code (you have to
- * take care about HTML escaping on your own), or to interrupt the code
- * flow and send the user to a different page.
+ * used to show the user a custom message including HTML code (via the
+ * notification system), or to interrupt the code flow and send the user
+ * to a different page.
*
+ * @param string $app Horde application.
* @param string $permission Permission that failed.
- *
- * @return string An error message.
*/
-// public function perms_denied($permission)
+// public function perms_denied($app, $permission)
// {
-// // Example #1: Provide link to upgrade script.
-// $app = (($pos = strpos($? $mission, ':')) === false)
-// ? $permission
-// : substr($permission, 0, $pos);
-//
-// // TODO: Notification
-// return sprintf('Permission denied. Click <a href="http://www.example.com/upgrade.php?app=%s">HERE</a> to upgrade %s.', $app, $GLOBALS['registry']->get('name'));
+// // Example #1: Provide link to upgrade script in notification
+// // message.
+// $GLOBALS['notification']->push(sprintf('Permission denied. Click <a href="http://www.example.com/upgrade.php?app=%s">HERE</a> to upgrade %s.', $app, $GLOBALS['registry']->get('name')), 'horde.error', array('content.raw'));
// }
* function will be called to dynamically include users in the group.
*
* @param string $groupName TODO
- * @param string $userName TODO
+ * @param string $userName TODO
*
* @return TODO
*/
}
if ($recipients > $timelimit) {
- try {
- $error = Horde::callHook('perms_denied', array('imp:max_timelimit'));
- } catch (Horde_Exception_HookNotSet $e) {
- $error = @htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients within %d hours."), $timelimit, $GLOBALS['conf']['sentmail']['params']['limit_period']), ENT_COMPAT, 'UTF-8');
- }
- throw new IMP_Compose_Exception($error);
+ Horde::permissionDeniedError('imp', 'max_timelimit');
+ throw new IMP_Compose_Exception(sprintf(_("You are not allowed to send messages to more than %d recipients within %d hours."), $timelimit, $GLOBALS['conf']['sentmail']['params']['limit_period']));
}
}
$num_recipients += count(explode(',', $recipient));
}
if ($num_recipients > $max_recipients) {
- try {
- $message = Horde::callHook('perms_denied', array('imp:max_recipients'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients."), $max_recipients), ENT_COMPAT, 'UTF-8');
- }
- throw new IMP_Compose_Exception($message);
+ Horde::permissionDeniedError('imp', 'max_recipients');
+ throw new IMP_Compose_Exception(sprintf(_("You are not allowed to send messages to more than %d recipients."), $max_recipients));
}
}
}
*/
public function create($folder, $subscribe)
{
- global $conf, $notification;
+ global $conf, $injector, $notification;
/* Check permissions. */
- if (!$GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('create_folders')) {
- try {
- $message = Horde::callHook('perms_denied', array('imp:create_folders'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(_("You are not allowed to create folders."), ENT_COMPAT, 'UTF-8');
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ $perms = $injector->getInstance('Horde_Perms');
+ if (!$perms->hasAppPermission('create_folders')) {
+ Horde::permissionDeniedError(
+ 'imp',
+ 'create_folders',
+ _("You are not allowed to create folders.")
+ );
return false;
- } elseif (!$GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_folders')) {
- try {
- $message = Horde::callHook('perms_denied', array('imp:max_folders'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_folders', array('opts' => array('value' => true)))), ENT_COMPAT, 'UTF-8');
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ } elseif (!$perms->hasAppPermission('max_folders')) {
+ Horde::permissionDeniedError(
+ 'imp',
+ 'max_folders',
+ sprintf(_("You are not allowed to create more than %d folders."), $perms->hasAppPermission('max_folders', array('opts' => array('value' => true))))
+ );
return false;
}
case 'rule_copy':
if (!$perms->hasAppPermission('allow_rules')) {
- try {
- $message = Horde::callHook('perms_denied', array('ingo:allow_rules'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(_("You are not allowed to create or edit custom rules."));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'ingo',
+ 'allow_rules',
+ _("You are not allowed to create or edit custom rules.")
+ );
break 2;
} elseif ($perms->hasAppPermission('max_rules') !== true &&
$perms->hasAppPermission('max_rules') <= count($filters->getFilterList())) {
- try {
- $message = Horde::callHook('perms_denied', array('ingo:max_rules'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), $perms->hasAppPermission('max_rules')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'ingo',
+ 'max_rules',
+ sprintf(_("You are not allowed to create more than %d rules."), $perms->hasAppPermission('max_rules'))
+ );
break 2;
} else {
$tmp = $filters->getFilter($vars->rulenumber);
/* Check rule permissions. */
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if (!$perms->hasAppPermission('allow_rules')) {
- try {
- $message = Horde::callHook('perms_denied', array('ingo:allow_rules'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(_("You are not allowed to create or edit custom rules."));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'ingo',
+ 'allow_rules',
+ _("You are not allowed to create or edit custom rules.")
+ );
Horde::url('filters.php', true)->redirect();
}
if (!isset($vars->edit)) {
if ($perms->hasAppPermission('max_rules') !== true &&
$perms->hasAppPermission('max_rules') <= count($filters->getFilterList())) {
- try {
- $message = Horde::callHook('perms_denied', array('ingo:max_rules'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), $perms->hasAppPermission('max_rules')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'ingo',
+ 'max_rules',
+ sprintf(_("You are not allowed to create more than %d rules."), $perms->hasAppPermission('max_rules'))
+ );
header('Location: ' . Horde::url('filters.php', true));
exit;
}
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($perms->hasAppPermission('max_events') !== true &&
$perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
- try {
- $message = Horde::callHook('perms_denied', array('kronolith:max_events'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
- }
- $GLOBALS['notification']->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'kronolith',
+ 'max_events',
+ sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events'))
+ );
break;
}
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($perms->hasAppPermission('max_events') !== true &&
$perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
- try {
- $message = Horde::callHook('perms_denied', array('kronolith:max_events'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
- }
- $notification->push($message, 'horde.warning', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'kronolith',
+ 'max_events',
+ sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events'))
+ );
$templates[Horde_Data::IMPORT_FILE] = array(KRONOLITH_TEMPLATES . '/data/export.inc');
} else {
$templates[Horde_Data::IMPORT_FILE] = array(KRONOLITH_TEMPLATES . '/data/import.inc', KRONOLITH_TEMPLATES . '/data/export.inc');
$recurrences = array();
foreach ($next_step as $row) {
if ($max_events !== true && $num_events >= $max_events) {
- try {
- $message = Horde::callHook('perms_denied', array('kronolith:max_events'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'kronolith',
+ 'max_events',
+ sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events'))
+ );
break;
}
try {
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($perms->hasAppPermission('max_events') !== true &&
$perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
- try {
- $message = Horde::callHook('perms_denied', array('kronolith:max_events'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
- }
- $GLOBALS['notification']->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'kronolith',
+ 'max_events',
+ sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events'))
+ );
return false;
}
return true;
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($perms->hasAppPermission('max_events') !== true &&
$perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
- try {
- $message = Horde::callHook('perms_denied', array('kronolith:max_events'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
- }
- $GLOBALS['notification']->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'kronolith',
+ 'max_events',
+ sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events'))
+ );
return $result;
}
}
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($perms->hasAppPermission('max_events') !== true &&
$perms->hasAppPermission('max_events') <= Kronolith::countEvents()) {
- try {
- $message = Horde::callHook('perms_denied', array('kronolith:max_events'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'kronolith',
+ 'max_events',
+ sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events'))
+ );
$url->redirect();
}
);
if ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true &&
$GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) {
- try {
- $message = Horde::callHook('perms_denied', array('mnemo:max_notes'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes')));
- }
- $notification->push($message, 'horde.warning', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'mnemo',
+ 'max_notes',
+ sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes'))
+ );
$templates[Horde_Data::IMPORT_FILE] = array(MNEMO_TEMPLATES . '/data/export.inc');
} else {
$templates[Horde_Data::IMPORT_FILE] = array(MNEMO_TEMPLATES . '/data/import.inc', MNEMO_TEMPLATES . '/data/export.inc');
$num_memos = Mnemo::countMemos();
foreach ($next_step as $row) {
if ($max_memos !== true && $num_memos >= $max_memos) {
- try {
- $message = Horde::callHook('perms_denied', array('mnemo:max_notes'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'mnemo',
+ 'max_notes',
+ sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes'))
+ );
break;
}
/* Check permissions. */
if ($injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true &&
$injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) {
-
- try {
- $message = Horde::callHook('perms_denied', array('mnemo:max_notes'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'mnemo',
+ 'max_notes',
+ sprintf(_("You are not allowed to create more than %d notes."), $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes'))
+ );
Horde::url('list.php', true)->redirect();
}
/* Set up the note attributes. */
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($perms->hasAppPermission('max_tasks') !== true &&
$perms->hasAppPermission('max_tasks') <= Nag::countTasks()) {
- try {
- $message = Horde::callHook('perms_denied', array('nag:max_tasks'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')));
- }
- $notification->push($message, 'horde.warning', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'nag',
+ 'max_tasks',
+ sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks'))
+ );
$templates[Horde_Data::IMPORT_FILE] = array(NAG_TEMPLATES . '/data/export.inc');
} else {
$templates[Horde_Data::IMPORT_FILE] = array(NAG_TEMPLATES . '/data/import.inc', NAG_TEMPLATES . '/data/export.inc');
$result = null;
foreach ($next_step as $row) {
if ($max_tasks !== true && $num_tasks >= $max_tasks) {
- try {
- $message = Horde::callHook('perms_denied', array('nag:max_tasks'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'nag',
+ 'max_tasks',
+ sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks'))
+ );
break;
}
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($perms->hasAppPermission('max_tasks') !== true &&
$perms->hasAppPermission('max_tasks') <= Nag::countTasks()) {
- try {
- $message = Horde::callHook('perms_denied', array('nag:max_tasks'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'nag',
+ 'max_tasks',
+ sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks'))
+ );
Horde::url('list.php', true)->redirect();
}
/* Check permissions. */
if (Trean::hasPermission('max_bookmarks') !== true &&
Trean::hasPermission('max_bookmarks') <= $trean_shares->countBookmarks()) {
- try {
- $message = Horde::callHook('perms_denied', array('trean:max_bookmarks'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'trean',
+ 'max_bookmarks',
+ sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks'))
+ );
Horde::url('browse.php', true)->redirect();
}
/* Check permissions. */
if (Trean::hasPermission('max_folders') !== true &&
Trean::hasPermission('max_folders') <= Trean::countFolders()) {
- try {
- $message = Horde::callHook('perms_denied', array('trean:max_folders'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'trean',
+ 'max_folders',
+ sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders'))
+ );
Horde::url('browse.php', true)
->add('f', $parent_id)
->redirect();
$folders_exceeded = Trean::hasPermission('max_folders') !== true &&
Trean::hasPermission('max_folders') <= Trean::countFolders();
if ($folders_exceeded) {
- try {
- $message = Horde::callHook('perms_denied', array('trean:max_folders'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders')));
- }
- $notification->push($message, 'horde.warning', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'trean',
+ 'max_folders',
+ sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders'))
+ );
}
$bookmarks_exceeded = Trean::hasPermission('max_bookmarks') !== true &&
Trean::hasPermission('max_bookmarks') <= $trean_shares->countBookmarks();
if ($bookmarks_exceeded) {
- try {
- $message = Horde::callHook('perms_denied', array('trean:max_bookmarks'),);
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')));
- }
- $notification->push($message, 'horde.warning', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'trean',
+ 'max_bookmarks',
+ sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks'))
+ );
}
switch (Horde_Util::getFormData('actionID')) {
continue;
}
if ($max_folders !== true && $num_folders >= $max_folders) {
- try {
- $message = Horde::callHook('perms_denied', array('trean:max_folders'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'trean',
+ 'max_folders',
+ sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders'))
+ );
$stop_folders = true;
continue;
}
$line, $temp)) {
/* A bookmark. */
if ($max_bookmarks !== true && $num_bookmarks >= $max_bookmarks) {
- try {
- $message = Horde::callHook('perms_denied', array('trean:max_bookmarks'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'trean',
+ 'max_bookmarks',
+ sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks'))
+ );
$stop_bookmarks = true;
break;
}
$max_contacts = Turba::getExtendedPermission($driver, 'max_contacts');
if ($max_contacts !== true &&
$max_contacts <= count($driver)) {
- try {
- $message = Horde::callHook('perms_denied', array('turba:max_contacts'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title']));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'turba',
+ 'max_contacts',
+ sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title'])
+ );
$url = $url
? Horde::url($url, true)
: Horde::url('index.php', true);
$max_contacts = Turba::getExtendedPermission($driver, 'max_contacts');
if ($max_contacts !== true &&
$max_contacts <= count($driver)) {
- try {
- $message = Horde::callHook('perms_denied', array('turba:max_contacts'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $driver->title));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'turba',
+ 'max_contacts',
+ sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $driver->title)
+ );
$error = true;
break;
}
}
$max_contacts = Turba::getExtendedPermission($targetDriver, 'max_contacts');
- if ($max_contacts !== true
- && $max_contacts <= count($targetDriver)) {
- try {
- $message = Horde::callHook('perms_denied', array('turba:max_contacts'));
- } catch (Horde_Exception_HookNotSet $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$targetSource]['title']));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ if ($max_contacts !== true &&
+ $max_contacts <= count($targetDriver)) {
+ Horde::permissionDeniedError(
+ 'turba',
+ 'max_contacts',
+ sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$targetSource]['title'])
+ );
break;
}
$max_contacts = Turba::getExtendedPermission($driver, 'max_contacts');
if ($max_contacts !== true &&
$max_contacts <= count($driver)) {
- try {
- $message = Horde::callHook('perms_denied', array('turba:max_contacts'));
- } catch (Horde_Exception $e) {
- $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title']));
- }
- $notification->push($message, 'horde.error', array('content.raw'));
+ Horde::permissionDeniedError(
+ 'turba',
+ 'max_contacts',
+ sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title'])
+ );
break;
}