Hooks are no longer configured via conf.php
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 3 Nov 2010 18:59:55 +0000 (12:59 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Nov 2010 19:44:29 +0000 (13:44 -0600)
26 files changed:
agora/lib/Api.php
agora/messages/index.php
ansel/config/conf.xml
ansel/lib/Api.php
folks/templates/user/user.php
horde/templates/portal/edit.inc
imp/folders.php
imp/lib/Tree/Flist.php
ingo/filters.php
kronolith/lib/Application.php
kronolith/lib/View/Day.php
kronolith/lib/View/EditEvent.php
kronolith/lib/View/Month.php
kronolith/templates/edit/edit.inc
kronolith/templates/week/head.inc
mnemo/data.php
mnemo/lib/Application.php
mnemo/memo.php
nag/lib/Application.php
passwd/config/conf.xml
passwd/config/hooks.php.dist
passwd/lib/Driver/ldap.php
passwd/main.php
trean/add.php
trean/data.php
trean/templates/browse.php

index fdf2e54..a58f41a 100644 (file)
@@ -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'])) {
index 0fe04b4..276df48 100644 (file)
@@ -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']) {
index 0f369ea..6ff172d 100644 (file)
     libpuzzle pecl extension to use this feature." >7</configstring>
   </configsection>
  </configtab>
-
- <configtab name="hooks" desc="Custom Hooks">
-  <configsection name="hooks">
-    <configboolean name="postupload" required="false" desc="Should we use a
-       custom post upload hook? If so, make sure you define _ansel_hook_postupload()
-       in hooks.php. The hook will be called after the user successfully uploads
-       a set of images and can be used for things like sending notifications to
-       external websites/APIs.">false</configboolean>
-   </configsection>
-  </configtab>
 </configuration>
index 7867267..ce2384d 100644 (file)
@@ -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) {}
     }
 
     /**
index 6dcdb53..a98da6f 100644 (file)
@@ -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;
index 811f8c6..ba96f7b 100644 (file)
@@ -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):
 ?>
index 78a2831..b214daf 100644 (file)
@@ -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");
index 9cfffa9..529734d 100644 (file)
@@ -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);
         }
 
index c71ecd7..54a0e28 100644 (file)
@@ -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) {
index da5e464..a26fc35 100644 (file)
@@ -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');
         }
index fff05fa..6794904 100644 (file)
@@ -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();
index 4c2b335..11b66dd 100644 (file)
@@ -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[] = '<input type="submit" class="button" name="saveAsNew" value="' . _("Save As New") . '" />';
         } 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[] = '<input type="submit" class="button" name="saveAsNew" value="' . _("Save As New") . '" />';
                 }
index 5bb0817..695e3e5 100644 (file)
@@ -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) {
index 398b7f5..12e013e 100644 (file)
@@ -30,8 +30,7 @@ $hide_img = Horde::img('minus.png', _("Hide"), 'style="display:none"');
 
 <table class="striped" cellspacing="0">
 <?php if ($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())): ?>
 <!-- recurrence editing -->
 <tr>
index d42f1e2..3630a65 100644 (file)
@@ -19,8 +19,7 @@ echo $this->link(1)->link(array('title' => _("Next week"), 'class' => 'iconNav',
   <th class="nowrap <?php echo ($day->isToday() ? 'selected-control' : 'control') ?>" width="<?php echo $colwidth ?>%" colspan="<?php echo $day->_totalspan ?>">
 <?php
 if (Kronolith::getDefaultCalendar(Horde_Perms::EDIT) &&
-    (!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())) {
     echo Horde::url('new.php')
         ->add(array('date' => $day->dateString(),
index 50c9de9..46ad375 100644 (file)
@@ -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;
index d8e9391..a620c0c 100644 (file)
@@ -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);
         }
index f1185f4..1fe27c9 100644 (file)
@@ -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();
index 056c0ef..6c72380 100644 (file)
@@ -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')) {
index 26e46d5..9533154 100644 (file)
@@ -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
    <values>
     <value>shown</value>
     <value>hidden</value>
   <configboolean name="strengthtests" desc="Should strength tests be done on
   the new password">false</configboolean>
  </configsection>
-
- <configsection name="hooks">
-  <configboolean name="full_name" desc="If this is checked, the full user name
-  is used to change the password, the user name without the domain part
-  otherwise. This setting is overridden by enabling the hook
-  below.">true</configboolean>
-  <configboolean name="default_username" desc="Use a custom hook for
-  determining the default username">false</configboolean>
-  <configboolean name="username" desc="Use a custom hook to translate the
-  username for the backend">false</configboolean>
-  <configboolean name="userdn" desc="If we are using the LDAP driver, use a
-  custom hook to provide a userdn for binding. By default the LDAP driver
-  finds out the correct userdn for binding by searching for the uid with the
-  configured base or binds with admindn if set.">false</configboolean>
- </configsection>
 </configuration>
index fe759e4..db22815 100644 (file)
@@ -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);
-//     }
-// }
+}
index 7a73d06..20d8fd2 100644 (file)
@@ -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;
             }
         }
index 93e9625..bd1e62f 100644 (file)
@@ -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();
     }
 }
 
index 1ba1f0b..2b94210 100644 (file)
@@ -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)
index 58f6837..0ba672f 100644 (file)
@@ -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;
index 3b7e2de..01ab44d 100644 (file)
@@ -47,8 +47,7 @@ function confirm_delete()
 <?php
 $option_move = Trean::countFolders(Horde_Perms::EDIT);
 $option_copy = $option_move
-    && (!empty($conf['hooks']['permsdenied'])
-        || Trean::hasPermission('max_bookmarks') === true
+    && (Trean::hasPermission('max_bookmarks') === true
         || Trean::hasPermission('max_bookmarks') > $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)):
   <a id="faShow" href="#" onclick="faToggle(); return false;"><?php echo _("Folder Actions") ?></a>
   <a id="faHide" href="#" onclick="faToggle(); return false;"><?php echo _("Folder Actions") ?></a>
   <div id="folderActionsInner">
- <?php if (!empty($conf['hooks']['permsdenied']) ||
-           Trean::hasPermission('max_folders') === true ||
+ <?php if (Trean::hasPermission('max_folders') === true ||
            Trean::hasPermission('max_folders') > Trean::countFolders()): ?>
   <form name="trean_new_subfolder" action="add.php" method="post">
    <?php echo Horde_Util::formInput() ?>