From: Michael M Slusarz Date: Wed, 3 Nov 2010 18:59:55 +0000 (-0600) Subject: Hooks are no longer configured via conf.php X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4928316937c4e6ce6bd88e73c48d25f6e65b2e42;p=horde.git Hooks are no longer configured via conf.php --- diff --git a/agora/lib/Api.php b/agora/lib/Api.php index fdf2e54ce..a58f41a11 100644 --- a/agora/lib/Api.php +++ b/agora/lib/Api.php @@ -453,11 +453,11 @@ class Agora_Api extends Horde_Registry_Api /* Check post permissions. */ if (!$messages->hasPermission(Horde_Perms::EDIT)) { - $message = sprintf(_("You don't have permission to post messages in forum %s."), $params['forum_id']); - if (!empty($GLOBALS['conf']['hooks']['permsdenied'])) { - $message = Horde::callHook('perms_denied', array('agora'), 'horde', $message); + 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']); } - return $message; } if (isset($params['message_id'])) { diff --git a/agora/messages/index.php b/agora/messages/index.php index 0fe04b485..276df486c 100644 --- a/agora/messages/index.php +++ b/agora/messages/index.php @@ -192,9 +192,10 @@ $view->rss = Horde_Util::addParameter(Horde::url('rss/messages.php', true, -1), /* Display an edit-dialogue if the thread is not locked and we can edit messages in them. */ if (!$messages->hasPermission(Horde_Perms::EDIT)) { - $message = sprintf(_("You don't have permission to post messages in forum %s."), $forum['forum_name']); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('perms_denied', array('agora'), 'horde', $message); + 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; } elseif ($message['locked']) { diff --git a/ansel/config/conf.xml b/ansel/config/conf.xml index 0f369ea1e..6ff172dfc 100644 --- a/ansel/config/conf.xml +++ b/ansel/config/conf.xml @@ -263,14 +263,4 @@ libpuzzle pecl extension to use this feature." >7 - - - - false - - diff --git a/ansel/lib/Api.php b/ansel/lib/Api.php index 7867267ed..ce2384d72 100644 --- a/ansel/lib/Api.php +++ b/ansel/lib/Api.php @@ -370,10 +370,8 @@ class Ansel_Api extends Horde_Registry_Api $image_id = $gallery->addImage($image_data, !empty($params['default'])); /* Call the postupload hook if needed */ - if (!empty($GLOBALS['conf']['hooks']['postupload']) && empty($params['skiphook'])) { - try { - Horde::callHook('postupload', array($image_id)); - } catch (Horde_Exception_HookNotSet $e) {} + if (empty($params['skiphook'])) { + $this->postBatchUpload($image_id); } return array('image_id' => (int)$image_id, @@ -391,9 +389,9 @@ class Ansel_Api extends Horde_Registry_Api */ public function postBatchUpload($image_ids) { - if (!empty($conf['hooks']['postupload'])) { - return Horde::callHook('_ansel_hook_postupload', array($image_ids), 'ansel'); - } + try { + Horde::callHook('postupload', array($image_ids), 'ansel'); + } catch (Horde_Exception_HookNotSet $e) {} } /** diff --git a/folks/templates/user/user.php b/folks/templates/user/user.php index 6dcdb53cb..a98da6fe9 100644 --- a/folks/templates/user/user.php +++ b/folks/templates/user/user.php @@ -380,9 +380,10 @@ case 'authenticated': $comments_reason = sprintf(_("You are on %s blacklist."), $user); } } else { - $comments_reason = _("Only authenticated users can post comments."); - if ($conf['hooks']['permsdenied']) { + try { $comments_reason = Horde::callHook('perms_denied', array('folks')); + } catch (Horde_Exception_HookNotSet $e) { + $comments_reason = _("Only authenticated users can post comments."); } } break; diff --git a/horde/templates/portal/edit.inc b/horde/templates/portal/edit.inc index 811f8c64e..ba96f7b46 100644 --- a/horde/templates/portal/edit.inc +++ b/horde/templates/portal/edit.inc @@ -3,9 +3,7 @@ $rows = $layout->rows(); $max_blocks = $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_blocks'); list($current_row, $current_col) = $layout->getCurrentBlock(); -$allow_add = !empty($conf['hooks']['permsdenied']) || - ($max_blocks === true) || - ($max_blocks > $layout->count()); +$allow_add = ($max_blocks === true) || ($max_blocks > $layout->count()); $columns = 0; for ($row = 0; $row < $rows; ++$row): ?> diff --git a/imp/folders.php b/imp/folders.php index 78a283161..b214dafce 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -382,7 +382,7 @@ if ($a_template->get('javascript')) { $a_template->set('go', _("Go")); } -$a_template->set('create_folder', !empty($conf['hooks']['permsdenied']) || ($injector->getInstance('Horde_Perms')->hasAppPermission('create_folders') && $injector->getInstance('Horde_Perms')->hasAppPermission('max_folders'))); +$a_template->set('create_folder', $injector->getInstance('Horde_Perms')->hasAppPermission('create_folders') && $injector->getInstance('Horde_Perms')->hasAppPermission('max_folders')); if ($prefs->getValue('subscribe')) { $a_template->set('subscribe', true); $subToggleText = ($showAll) ? _("Hide Unsubscribed") : _("Show Unsubscribed"); diff --git a/imp/lib/Tree/Flist.php b/imp/lib/Tree/Flist.php index 9cfffa98d..529734df1 100644 --- a/imp/lib/Tree/Flist.php +++ b/imp/lib/Tree/Flist.php @@ -92,9 +92,8 @@ class IMP_Tree_Flist extends Horde_Tree_Select /* New folder entry. */ if ($this->getOption('new_folder') && - (!empty($conf['hooks']['permsdenied']) || - ($injector->getInstance('Horde_Perms')->hasAppPermission('create_folders') && - $injector->getInstance('Horde_Perms')->hasAppPermission('max_folders')))) { + ($injector->getInstance('Horde_Perms')->hasAppPermission('create_folders') && + $injector->getInstance('Horde_Perms')->hasAppPermission('max_folders'))) { $t->set('new_mbox', true); } diff --git a/ingo/filters.php b/ingo/filters.php index c71ecd729..54a0e2806 100644 --- a/ingo/filters.php +++ b/ingo/filters.php @@ -257,8 +257,7 @@ if (count($filter_list) == 0) { /* Create copy link. */ if (!is_null($copyurl) && - (!empty($conf['hooks']['permsdenied']) || - $perms->hasAppPermission('max_rules') === true || + ($perms->hasAppPermission('max_rules') === true || $perms->hasAppPermission('max_rules') > count($filter_list))) { $entry['copylink'] = Horde::link($copyurl, sprintf(_("Copy %s"), $name)); $entry['copyimg'] = Horde::img('copy.png', sprintf(_("Copy %s"), $name)); @@ -314,10 +313,9 @@ if (count($filter_list) == 0) { $actions = $ingo_script->availableActions(); $createrule = (!empty($actions) && - (!empty($conf['hooks']['permsdenied']) || - ($perms->hasAppPermission('allow_rules') && - ($perms->hasAppPermission('max_rules') === true || - $perms->hasAppPermission('max_rules') > count($filter_list))))); + ($perms->hasAppPermission('allow_rules') && + ($perms->hasAppPermission('max_rules') === true || + $perms->hasAppPermission('max_rules') > count($filter_list)))); $canapply = $ingo_script->canApply(); require INGO_TEMPLATES . '/filters/footer.inc'; if ($on_demand && $edit_allowed) { diff --git a/kronolith/lib/Application.php b/kronolith/lib/Application.php index da5e46435..a26fc3578 100644 --- a/kronolith/lib/Application.php +++ b/kronolith/lib/Application.php @@ -105,8 +105,7 @@ class Kronolith_Application extends Horde_Registry_Application $menu->add(Horde::url($prefs->getValue('defaultview') . '.php'), _("_Today"), 'today.png', null, null, null, '__noselection'); if (Kronolith::getDefaultCalendar(Horde_Perms::EDIT) && - (!empty($conf['hooks']['permsdenied']) || - $injector->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || + ($injector->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || $injector->getInstance('Horde_Perms')->hasAppPermission('max_events') > self::countEvents())) { $menu->add(Horde::url('new.php')->add('url', Horde::selfUrl(true, false, true)), _("_New Event"), 'new.png'); } diff --git a/kronolith/lib/View/Day.php b/kronolith/lib/View/Day.php index fff05fa06..6794904c3 100644 --- a/kronolith/lib/View/Day.php +++ b/kronolith/lib/View/Day.php @@ -73,8 +73,7 @@ class Kronolith_View_Day extends Kronolith_Day { $started = false; $first_row = true; $addLinks = Kronolith::getDefaultCalendar(Horde_Perms::EDIT) && - (!empty($GLOBALS['conf']['hooks']['permsdenied']) || - $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || + ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents()); $showLocation = Kronolith::viewShowLocation(); $showTime = Kronolith::viewShowTime(); diff --git a/kronolith/lib/View/EditEvent.php b/kronolith/lib/View/EditEvent.php index 4c2b3353a..11b66dd79 100644 --- a/kronolith/lib/View/EditEvent.php +++ b/kronolith/lib/View/EditEvent.php @@ -78,8 +78,7 @@ class Kronolith_View_EditEvent { $buttons = array(); if (!$this->event->hasPermission(Horde_Perms::EDIT) && - (!empty($GLOBALS['conf']['hooks']['permsdenied']) || - $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || + ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) { $buttons[] = ''; } else { @@ -88,8 +87,7 @@ class Kronolith_View_EditEvent { } if ($this->event->initialized) { if (!$this->event->recurs() && - (!empty($conf['hooks']['permsdenied']) || - $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || + ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) { $buttons[] = ''; } diff --git a/kronolith/lib/View/Month.php b/kronolith/lib/View/Month.php index 5bb0817be..695e3e5b6 100644 --- a/kronolith/lib/View/Month.php +++ b/kronolith/lib/View/Month.php @@ -119,8 +119,7 @@ class Kronolith_View_Month { $sidebyside = $prefs->getValue('show_shared_side_by_side'); $twentyFour = $prefs->getValue('twentyFour'); $addLinks = Kronolith::getDefaultCalendar(Horde_Perms::EDIT) && - (!empty($GLOBALS['conf']['hooks']['permsdenied']) || - $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || + ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents()); if ($sidebyside) { diff --git a/kronolith/templates/edit/edit.inc b/kronolith/templates/edit/edit.inc index 398b7f50b..12e013ecb 100644 --- a/kronolith/templates/edit/edit.inc +++ b/kronolith/templates/edit/edit.inc @@ -30,8 +30,7 @@ $hide_img = Horde::img('minus.png', _("Hide"), 'style="display:none"'); recurs() && - (!empty($conf['hooks']['permsdenied']) || - $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || + ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())): ?> diff --git a/kronolith/templates/week/head.inc b/kronolith/templates/week/head.inc index d42f1e209..3630a65f8 100644 --- a/kronolith/templates/week/head.inc +++ b/kronolith/templates/week/head.inc @@ -19,8 +19,7 @@ echo $this->link(1)->link(array('title' => _("Next week"), 'class' => 'iconNav',
getInstance('Horde_Perms')->hasAppPermission('max_events') === true || + ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') === true || $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_events') > Kronolith::countEvents())) { echo Horde::url('new.php') ->add(array('date' => $day->dateString(), diff --git a/mnemo/data.php b/mnemo/data.php index 50c9de9f7..46ad37586 100644 --- a/mnemo/data.php +++ b/mnemo/data.php @@ -34,9 +34,10 @@ $templates = array( ); if ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true && $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) { - $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes'))); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message); + 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')); $templates[Horde_Data::IMPORT_FILE] = array(MNEMO_TEMPLATES . '/data/export.inc'); @@ -121,9 +122,10 @@ if (is_array($next_step)) { $num_memos = Mnemo::countMemos(); foreach ($next_step as $row) { if ($max_memos !== true && $num_memos >= $max_memos) { - $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes'))); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message); + 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')); break; diff --git a/mnemo/lib/Application.php b/mnemo/lib/Application.php index d8e9391bf..a620c0c56 100644 --- a/mnemo/lib/Application.php +++ b/mnemo/lib/Application.php @@ -79,8 +79,7 @@ class Mnemo_Application extends Horde_Registry_Application $menu->add(Horde::url('list.php'), _("_List Notes"), 'mnemo.png', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null); if (Mnemo::getDefaultNotepad(Horde_Perms::EDIT) && - (!empty($conf['hooks']['permsdenied']) || - $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') === true || + ($injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') === true || $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') > Mnemo::countMemos())) { $menu->add(Horde::url(Horde_Util::addParameter('memo.php', 'actionID', 'add_memo')), _("_New Note"), 'add.png', null, null, null, Horde_Util::getFormData('memo') ? '__noselection' : null); } diff --git a/mnemo/memo.php b/mnemo/memo.php index f1185f41b..1fe27c997 100644 --- a/mnemo/memo.php +++ b/mnemo/memo.php @@ -72,9 +72,11 @@ case 'add_memo': /* Check permissions. */ if ($injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true && $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) { - $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes'))); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message); + + 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::url('list.php', true)->redirect(); diff --git a/nag/lib/Application.php b/nag/lib/Application.php index 056c0ef82..6c72380aa 100644 --- a/nag/lib/Application.php +++ b/nag/lib/Application.php @@ -83,8 +83,7 @@ class Nag_Application extends Horde_Registry_Application $menu->add(Horde::url('list.php'), _("_List Tasks"), 'nag.png', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null); if (Nag::getDefaultTasklist(Horde_Perms::EDIT) && - (!empty($conf['hooks']['permsdenied']) || - $injector->getInstance('Horde_Perms')->hasAppPermission('max_tasks') === true || + ($injector->getInstance('Horde_Perms')->hasAppPermission('max_tasks') === true || $injector->getInstance('Horde_Perms')->hasAppPermission('max_tasks') > Nag::countTasks())) { $menu->add(Horde::url('task.php')->add('actionID', 'add_task'), _("_New Task"), 'add.png', null, null, null, Horde_Util::getFormData('task') ? '__noselection' : null); if ($GLOBALS['browser']->hasFeature('dom')) { diff --git a/passwd/config/conf.xml b/passwd/config/conf.xml index 26e46d578..95331543e 100644 --- a/passwd/config/conf.xml +++ b/passwd/config/conf.xml @@ -18,7 +18,7 @@ 'shown', 'hidden'. If the backend list is hidden then you can use the 'preferred' mechanism to auto-select from it based on an HTTP virtualhost or another piece of data. If it is shown, the user will be able to pick from - any of the options.">hidden + any of the options.">hidden shown hidden @@ -39,19 +39,4 @@ false - - - true - false - false - false - diff --git a/passwd/config/hooks.php.dist b/passwd/config/hooks.php.dist index fe759e458..db2281588 100644 --- a/passwd/config/hooks.php.dist +++ b/passwd/config/hooks.php.dist @@ -8,72 +8,82 @@ * * For more information please see the horde/config/hooks.php.dist file. * - * $Horde: passwd/config/hooks.php.dist,v 1.1.2.2 2009/06/12 08:43:47 jan Exp $ + * $Id$ */ - -// Here is an example _passwd_hook_username function to translate what the -// user enters, in the username box, into what the backend expects. If we want -// to add @example.com to the end of the username then enable the hook and use -// this function. - -// if (!function_exists('_passwd_hook_username')) { -// function _passwd_hook_username($userid, &$driver) -// { -// return $userid . '@example.com'; -// } -// } - -// Here is another, more involed example of _passwd_hook_username. This one -// demonstrates how to return a different $userid based on the driver type. It -// also demonstrates how to do this using the composite driver. - -//if (!function_exists('_passwd_hook_username')) { -// function _passwd_hook_username($userid, &$driver) -// { -// if (is_a($driver, 'Passwd_Driver_http')) { +class Passwd_Hooks +{ + /** + * Username hook. + * + * @param string $userid The username. + * @param TODO $driver TODO + * + * @return string TODO + */ +// public function username($userid, $driver) +// { +// // Example #1: Translate what the user enters, in the username box, +// // into what the backend expects. +// return $userid . '@example.com'; +// +// +// // Example #2: Return a different $userid based on the driver type. +// // Uses the composite driver. +// if ($driver instanceof Passwd_Driver_http) { // return $userid . '@example.com'; -// } elseif (is_a($driver, 'Passwd_Driver_composite')) { +// } +// +// if ($driver instanceof Passwd_Driver_composite) { // foreach ($driver->_params['drivers'] as $backend => $config) { // if ($backend == 'http') { // $driver->_params['drivers']['http']['params']['be_username'] = $userid . '@example.com'; // break; // } // } - // Return the userid unmodified by default. -// return $userid; -// } else { -// return $userid; // } -// } -//} +// +// return $userid; +// } + + + /** + * Default username hook. + * + * @param string $userid The username. + * + * @return string TODO + */ +// public function default_username($userid) +// { +// // Example: Set the username the passwd module sees when resetting +// // passwords based on userid and realm. The default is to take a +// // username of user@domain.tld and change it to user. If we want to +// // leave it untouched, enable the hook and use this function. +// return $userid; +// } -// Here is an example _passwd_hook_default_username function to set the -// username the passwd module sees when resetting passwords based on userid -// and realm. The default is to take a username of user@domain.tld and change -// it to user. If we want to leave it untouched, enable the hook and use this -// function. -// if (!function_exists('_passwd_hook_default_username')) { -// function _passwd_hook_default_username($userid) -// { -// return $userid; -// } -// } + /** + * Userdn hook. + * + * @param string $authid The authenticated username. + * + * @return string TODO + */ +// public function userdn($authid) +// { +// // Example: Provide LDAP server with a userdn so that you do not have +// // to perform anonymous binds. +// return 'uid=' . $authid . ',o=example.com'; +// } -// Here is an example _passwd_hook_userdn function that you can use to provide -// your ldap server with a userdn so that you do not have to perform anonymous -// binds. The function takes Auth::getAuth() as a parameter -// if (!function_exists('_passwd_hook_userdn')) { -// function _passwd_hook_userdn($auth) -// { -// return 'uid=' . $auth . ',o=example.com'; -// } -// } + /** + * TODO + */ +// function password_changed($user, $oldpassword, $newpassword) +// { +// Horde::logMessage(sprintf('User %s has changed his password.', $user), 'NOTICE'); +// } -// if (!function_exists('_passwd_password_changed')) { -// function _passwd_password_changed($user, $oldpassword, $newpassword) -// { -// Horde::logMessage(sprintf('User %s has changed his password.', $user), __FILE__, __LINE__, PEAR_LOG_NOTICE); -// } -// } +} diff --git a/passwd/lib/Driver/ldap.php b/passwd/lib/Driver/ldap.php index 7a73d0698..20d8fd248 100644 --- a/passwd/lib/Driver/ldap.php +++ b/passwd/lib/Driver/ldap.php @@ -157,13 +157,11 @@ class Passwd_Driver_ldap extends Passwd_Driver { } // Get the user's dn. - if ($GLOBALS['conf']['hooks']['userdn']) { - $this->_userdn = Horde::callHook('_passwd_hook_userdn', - array($username), - 'passwd'); - } else { + try { + $this->_userdn = Horde::callHook('userdn', array($username), 'passwd'); + } catch (Horde_Exception_HookNotSet $e) { $this->_userdn = $this->_lookupdn($username, $old_password); - if (is_a($this->_userdn, 'PEAR_Error')) { + if ($this->_userdn instanceof PEAR_Error) { return $this->_userdn; } } diff --git a/passwd/main.php b/passwd/main.php index 93e96253d..bd1e62f87 100644 --- a/passwd/main.php +++ b/passwd/main.php @@ -43,12 +43,10 @@ do { if ($conf['user']['change'] === true) { $userid = Horde_Util::getFormData('userid'); } else { - if ($conf['hooks']['default_username']) { - $userid = Horde::callHook('_passwd_hook_default_username', - array(Auth::getAuth()), - 'passwd'); - } else { - $userid = $registry->getAuth($conf['hooks']['full_name'] ? null : 'bare'); + try { + $userid = Horde::callHook('default_username', array($registry->getAuth()), 'passwd'); + } catch (Horde_Exception_HookNotSet $e) { + $userid = $registry->getAuth(); } } @@ -195,16 +193,10 @@ do { break; } - $backend_userid = $userid; - - if ($conf['hooks']['username']) { - $backend_userid = Horde::callHook('_passwd_hook_username', - array($userid, &$daemon), - 'passwd'); - if (is_a($backend_userid, 'PEAR_Error')) { - $notification->push($backend_userid, 'horde.error'); - break; - } + try { + $backend_userid = Horde::callHook('username', array($userid, $daemon), 'passwd'); + } catch (Horde_Exception_HookNotSet $e) { + $backend_userid = $userid; } $res = $daemon->changePassword($backend_userid, $old_password, @@ -219,9 +211,9 @@ do { $notification->push(sprintf(_("Password changed on %s."), $backends[$backend_key]['name']), 'horde.success'); - Horde::callHook('_passwd_password_changed', - array($backend_userid, $old_password, $new_password0), - 'passwd'); + try { + Horde::callHook('password_changed', array($backend_userid, $old_password, $new_password0), 'passwd'); + } catch (Horde_Exception_HookNotSet $e) {} $return_to = Horde_Util::getFormData('return_to'); if (!empty($return_to)) { @@ -259,12 +251,10 @@ if ($conf['backend']['backend_list'] == 'shown') { // Extract userid to be shown in the username field. if (empty($userid)) { - if ($conf['hooks']['default_username']) { - $userid = Horde::callHook('_passwd_hook_default_username', - array(Auth::getAuth()), - 'passwd'); - } else { - $userid = $registry->getAuth($conf['hooks']['full_name'] ? null : 'bare'); + try { + $userid = Horde::callHook('default_username', array($registry->getAuth()), 'passwd'); + } catch (Horde_Exception_HookNotSet $e) { + $userid = $registry->getAuth(); } } diff --git a/trean/add.php b/trean/add.php index 1ba1f0bfb..2b9421000 100644 --- a/trean/add.php +++ b/trean/add.php @@ -20,9 +20,10 @@ case 'add_bookmark': /* Check permissions. */ if (Trean::hasPermission('max_bookmarks') !== true && Trean::hasPermission('max_bookmarks') <= $trean_shares->countBookmarks()) { - $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks'))); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('trean:max_bookmarks'), 'horde', $message); + 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::url('browse.php', true)->redirect(); @@ -83,9 +84,10 @@ case 'add_folder': /* Check permissions. */ if (Trean::hasPermission('max_folders') !== true && Trean::hasPermission('max_folders') <= Trean::countFolders()) { - $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders'))); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('trean:max_folders'), 'horde', $message); + 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::url('browse.php', true) diff --git a/trean/data.php b/trean/data.php index 58f6837d6..0ba672f77 100644 --- a/trean/data.php +++ b/trean/data.php @@ -53,18 +53,20 @@ Horde_Registry::appInit('trean'); $folders_exceeded = Trean::hasPermission('max_folders') !== true && Trean::hasPermission('max_folders') <= Trean::countFolders(); if ($folders_exceeded) { - $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders'))); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('trean:max_folders'), 'horde', $message); + 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')); } $bookmarks_exceeded = Trean::hasPermission('max_bookmarks') !== true && Trean::hasPermission('max_bookmarks') <= $trean_shares->countBookmarks(); if ($bookmarks_exceeded) { - $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks'))); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('trean:max_bookmarks'), 'horde', $message); + 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')); } @@ -104,9 +106,10 @@ case 'import': continue; } if ($max_folders !== true && $num_folders >= $max_folders) { - $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders'))); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('trean:max_folders'), 'horde', $message); + 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')); $stop_folders = true; @@ -129,9 +132,10 @@ case 'import': $line, $temp)) { /* A bookmark. */ if ($max_bookmarks !== true && $num_bookmarks >= $max_bookmarks) { - $message = htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks'))); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('trean:max_bookmarks'), 'horde', $message); + 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')); $stop_bookmarks = true; diff --git a/trean/templates/browse.php b/trean/templates/browse.php index 3b7e2de5e..01ab44dbd 100644 --- a/trean/templates/browse.php +++ b/trean/templates/browse.php @@ -47,8 +47,7 @@ function confirm_delete() $GLOBALS['trean_shares']->countBookmarks()); $option_edit = (!empty($GLOBALS['folder']) ? $GLOBALS['folder']->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT) : false); @@ -73,8 +72,7 @@ if (!empty($folder)):
- Trean::countFolders()): ?>