From: Michael M Slusarz Date: Mon, 27 Jul 2009 00:59:36 +0000 (-0600) Subject: Convert to new hooks code. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d58245fa6817cbbf97fc5169615794d0232ff08f;p=horde.git Convert to new hooks code. --- diff --git a/folks/config/hooks.php.dist b/folks/config/hooks.php.dist index 634c38c03..82ba8f218 100644 --- a/folks/config/hooks.php.dist +++ b/folks/config/hooks.php.dist @@ -1,7 +1,5 @@ + spam_email hook instead."/> + spam_email hook instead."/> - - false - false - false - false - false - false - false - false - false - false - false - false - - - Mail History @@ -404,25 +346,6 @@ Custom Hooks - - false - false - false - - diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index ea842f57a..6a2dfd230 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -11,522 +11,509 @@ * $Id$ */ -// Here is an example signature hook function to set the signature from the -// system taglines file; the string "%TAG%" (if present in a user's signature) -// will be replaced by the content of the file "/usr/share/tagline" (generated -// by the "TaRT" utility). -// -// Notice how we global in the $prefs array to get the user's current -// signature. - -// if (!function_exists('_prefs_hook_signature')) { -// function _prefs_hook_signature($username = null) -// { -// $sig = $GLOBALS['prefs']->getValue('signature'); -// if (preg_match('/%TAG%/', $sig)) { -// $tag = `cat /usr/share/tagline`; -// $sig = preg_replace('|%TAG%|', $tag, $sig); -// } -// return $sig; -// } -// } - -// Example hook to set the value of the add_source pref. Useful when using -// a Turba source with shares enabled (i.e. the example localsql -// configuration). -// if (!function_exists('_prefs_hook_add_source')) { -// function _prefs_hook_add_source($username = null) { -// return $GLOBALS['registry']->call('contacts/getDefaultShare'); -// } -// } - -// This is an example for a post-sending hook that performs an action after -// a message has been sent successfully. -// $message = Base Horde_Mime_part object. -// $headers = Horde_Mime_Headers object. - -// if (!function_exists('_imp_hook_postsent')) { -// function _imp_hook_postsent($message, $headers) -// { -// // Do entire action here -- no return value from this hook. -// } -// } - -// Here is an example _imp_hook_trailer function to set the trailer from the -// system taglines file; the string "@@TAG@@" (if present in a trailer) will be -// replaced by the content of the file "/usr/share/tagline" (generated by the -// "TaRT" utility). - -// if (!function_exists('_imp_hook_trailer')) { -// function _imp_hook_trailer($trailer) -// { -// if (preg_match('/@@TAG@@/', $trailer)) { -// $tag = `cat /usr/share/tagline`; -// $trailer = preg_replace('|@@TAG@@|', $tag, $trailer); -// } -// return $trailer; -// } -// } - -// Here is an another example _imp_hook_trailer function to set the trailer -// from the LDAP directory for each domain. This function replaces the current -// trailer with the data it gets from ispmanDomainSignature. - -// if (!function_exists('_imp_hook_trailer')) { -// function _imp_hook_trailer($trailer) -// { -// $vdomain = Horde_String::lower(preg_replace('|^.*?\.|i', '', getenv('HTTP_HOST'))); -// $ldapServer = 'localhost'; -// $ldapPort = '389'; -// $searchBase = 'ispmanDomain=' . $vdomain . ",o=ispman"; -// -// $old_error = error_reporting(0); -// $ds = ldap_connect($ldapServer, $ldapPort); -// $searchResult = ldap_search($ds, $searchBase, 'uid=' . $vdomain); -// $information = ldap_get_entries($ds, $searchResult); -// $trailer= $information[0]['ispmandomainsignature'][0]; -// ldap_close($ds); -// error_reporting($old_error); -// -// return $trailer; -// } -// } - -// Here is an example of the _imp_hook_fetchmail_filter function to run -// SpamAssassin on email before it is written to the mailbox. -// Note: to use the spamassassin instead of spamd, change 'spamc' to -// 'spamassassin -P' and add any other important arguments, but realize spamc -// is MUCH faster than spamassassin. -// WARNING: Make sure to use the --noadd-from filter on spamd or spamassassin - -// if (!function_exists('_imp_hook_fetchmail_filter')) { -// function _imp_hook_fetchmail_filter($message) -// { -// // Where does SpamAssassin live, and what username should we use -// // for preferences? -// $cmd = '/usr/local/bin/spamc'; -// $username = Horde_Auth::getAuth(); -// -// // If you use the _sam_hook_username() hook, uncomment the next line -// //$username = _sam_hook_username($username); -// $username = escapeshellarg($username); -// -// // Also, we remove the file ourselves; this hook may be called -// // hundreds of times per run depending on how many messages we fetch -// $file = Horde::getTempFile('horde', false); -// -// // Call SpamAssassin; pipe the new message to our tempfile -// $fp = popen("$cmd -u $username > $file", 'w'); -// fwrite($fp, $message); -// pclose($fp); -// -// // Read the new message from the temporary file -// $message = file_get_contents($file); -// unlink($file); -// -// return $message; -// } -// } - -// Here is an example signature hook function to set the signature from the -// system taglines file; the string "%TAG%" (if present in a user's signature) -// will be replaced by the content of the file "/usr/share/tagline" (generated -// by the "TaRT" utility). - -// if (!function_exists('_imp_hook_signature')) { -// function _imp_hook_signature($sig) -// { -// if (preg_match('/%TAG%/', $sig)) { -// $tag = `cat /usr/share/tagline`; -// $sig = preg_replace('/%TAG%/', $tag, $sig); -// } -// -// return $sig; -// } -// } - -// This is an example hook function for adding additional message flags -// in the message listing screen for a mailbox. This example hook -// will add a icon if the message was sent from a user within the same domain. -// -// @param array $data The overview information for a message as returned -// from the IMP_Mailbox::getMailboxArray() call (see -// lib/Mailbox.php for documentation on the structure of -// the array). -// @param string $mode Either 'imp' or 'dimp'. -// -// @return array An array of additional flags to add. These flags must be -// defined in the 'msgflags' preference. On error, return an -// empty array. - -// if (!function_exists('_imp_hook_msglist_flags')) { -// function _imp_hook_msglist_flags($data, $mode) -// { -// $flags = array(); -// -// $from_ob = Horde_Mime_Address::getAddressesFromObject($ob['envelope']['from']); -// if (!empty($from_ob) && -// (strcasecmp($from_ob[0]['hostname'], 'example.com') === 0)) { -// /* The '$indomain' flag in this example must have already been -// * created in the 'msgflags' preference. */ -// $flags = array('$indomain'); -// } -// -// return $flags; -// } - -// This is an example hook function for the IMP redirection scheme. This -// function is called when the user opens a mailbox in IMP, and allows the -// client to be redirected based on the mailbox name. The return value of this -// function should be a valid page within a horde application which will be -// placed in a "Location" header to redirect the client. The only parameter -// is the name of the mailbox which the user has opened. If an empty string -// is returned the user is not redirected. Throw a Horde_Exception on error. - -// if (!function_exists('_imp_hook_mbox_redirect')) { -// function _imp_hook_mbox_redirect($mailbox) -// { -// if ((strpos($mailbox, "INBOX/Calendar") !== false) || -// preg_match("!^user/[^/]+/Calendar!", $mailbox)) { -// return $GLOBALS['registry']->get('webroot', 'kronolith'); -// } elseif ((strpos($mailbox, "INBOX/Tasks") !== false) || -// preg_match("!^user/[^/]+/Tasks!", $mailbox)) { -// return $GLOBALS['registry']->get('webroot', 'nag'); -// } elseif ((strpos($mailbox, "INBOX/Notes") !== false) || -// preg_match("!^user/[^/]+/Notes!", $mailbox)) { -// return $GLOBALS['registry']->get('webroot', 'mnemo'); -// } elseif ((strpos($mailbox, "INBOX/Contacts") !== false) || -// preg_match("!^user/[^/]+/Contacts!", $mailbox)) { -// return $GLOBALS['registry']->get('webroot', 'turba'); -// } -// -// return ''; -// } -// } - -// This is an example hook function for the IMP mailbox icon scheme. This -// function is called when the folder list is created and a "standard" folder -// is to be displayed - it allows custom folder icons to be specified. -// ("Standard" means all folders except the INBOX, sent-mail folders and -// trash folders.) -// If a mailbox name doesn't appear in the below list, the default mailbox -// icon is displayed. - -// if (!function_exists('_imp_hook_mbox_icons')) { -// function _imp_hook_mbox_icons() -// { -// static $newmailboxes; -// -// if (!empty($newmailboxes)) { -// return $newmailboxes; -// } -// -// require_once 'Horde/Kolab.php'; -// -// $kc = new Kolab_Cyrus($GLOBALS['conf']['kolab']['server']); -// $mailboxes = $kc->listMailBoxes(); -// $newmailboxes = array(); -// -// foreach ($mailboxes as $box) { -// $box = preg_replace("/^{[^}]+}/", "", $box); -// if ((strpos($box, "INBOX/Calendar") !== false) || -// preg_match("!^user/[^/]+/Calendar!", $box)) { -// $newmailboxes[$box] = array( -// 'icon' => 'kronolith.png', -// 'icondir' => $GLOBALS['registry']->getImageDir('kronolith') -// 'alt' => _("Calendar") -// ); -// } elseif ((strpos($box, "INBOX/Tasks") !== false) || -// preg_match("!^user/[^/]+/Tasks!", $box)) { -// $newmailboxes[$box] = array( -// 'icon' => 'nag.png', -// 'icondir' => $GLOBALS['registry']->getImageDir('nag') -// 'alt' => _("Tasks") -// ); -// } elseif ((strpos($box, "INBOX/Notes") !== false) || -// preg_match("!^user/[^/]+/Notes!", $box)) { -// $newmailboxes[$box] = array( -// 'icon' => 'mnemo.png', -// 'icondir' => $GLOBALS['registry']->getImageDir('mnemo') -// 'alt' => _("Notes") -// ); -// } elseif ((strpos($box, "INBOX/Contacts") !== false) || -// preg_match("!^user/[^/]+/Contacts!", $box)) { -// $newmailboxes[$box] = array( -// 'icon' => 'turba.png', -// 'icondir' => $GLOBALS['registry']->getImageDir('turba') -// 'alt' => _("Contacts") -// ); -// } -// } -// -// return $newmailboxes; -// } -// } - -// This is an example hook function to set a mailbox read-only. If the hook -// returns true, the given mailbox will be marked read only. - -// if (!function_exists('_imp_hook_mbox_readonly')) { -// function _imp_hook_mbox_readonly($mailbox) -// { -// // Make messages in the 'foo' mailbox readonly. -// return ($mailbox == 'foo'); -// } -// } - -// This is an example hook function for the mailbox view. This functions -// allows additional information to be added/edited from the data that is -// passed to the mailbox display template: -// imp: TODO -// dimp: imp/js/src/mailbox-dimp.js. -// The current entry array is passed in, the value returned should be the -// altered array to use in the template. If you are going to add new columns, -// you also have to update these fields: -// imp: TODO -// dimp: imp/templates/index/dimp.inc to contain the new field in the header -// imp/themes/screen-dimp.css to specify the column width. - -// if (!function_exists('_imp_hook_mailboxarray')) { -// function _imp_hook_mailboxarray($msgs, $view) { -// switch ($view) { -// case 'dimp': -// foreach (array_keys($msgs) as $key) { -// $msgs[$key]['foo'] = true; -// } -// break; -// -// case 'imp': -// // TODO -// break; -// } -// -// return $msg; -// } -// } - -// This is an example hook function to disable composing messages. If the hook -// returns true, message composition will be disabled. - -// if (!function_exists('_imp_hook_disable_compose')) { -// function _imp_hook_disable_compose() -// { -// // Entirely disable composition. -// return false; +class IMP_Hooks +{ + /** + * PREFERENCE HOOK: Dynamically set the signature preference. + * + * @param string $username The username. + * + * @return string The signature text to use. + */ +// function prefs_hook_signature($username = null) +// { +// // Example #1: Set the signature from the system taglines file; the +// // string "%TAG%" (if present in a user's signature) will be replaced +// // by the content of the file "/usr/share/tagline" (generated by the +// // "TaRT" utility). +// $sig = $GLOBALS['prefs']->getValue('signature'); +// if (preg_match('/%TAG%/', $sig)) { +// $tag = `cat /usr/share/tagline`; +// $sig = preg_replace('|%TAG%|', $tag, $sig); +// } +// return $sig; +// } + + + /** + * PREFERENCE HOOK: Dynamically set the add_source preference. + * + * @param string $username The username. + * + * @return string The add_source value. + */ +// function prefs_hook_add_source($username = null) +// { +// // Example #1: Useful hook when using a Turba source with shares +// // enabled (i.e. the example localsql configuration). +// return $GLOBALS['registry']->call('contacts/getDefaultShare'); +// } + + + /** + * Perform an action after a message has been sent successfully. + * + * @param Horde_Mime_Part $message The message content object. + * @param Horde_Mime_Headers $message The message headers object. + */ +// function postsent($message, $headers) +// { +// // Do action here -- no return value from this hook. +// } + + + /** + * Dynamically set/alter the contents of the message trailer text. + * + * @param string $trailer The default trailer text. + * + * @return string The trailer text to be used. + */ +// function trailer($trailer) +// { +// // Example #1: Set the trailer from the system taglines file; the +// // string "%TAG%" (if present in a user's signature) will be replaced +// // by the content of the file "/usr/share/tagline" (generated by the +// // "TaRT" utility). +// if (preg_match('/%TAG%/', $trailer)) { +// $tag = `cat /usr/share/tagline`; +// $sig = preg_replace('|%TAG%|', $tag, $trailer); +// } +// +// return $trailer; +// +// +// // Example #2: Set the trailer using the LDAP directory for each +// // domain. This code replaces the current trailer with the data +// // in 'ispmanDomainSignature'. +// $vdomain = Horde_String::lower(preg_replace('|^.*?\.|i', '', getenv('HTTP_HOST'))); +// $ldapServer = 'localhost'; +// $ldapPort = '389'; +// $searchBase = 'ispmanDomain=' . $vdomain . ",o=ispman"; +// +// $old_error = error_reporting(0); +// $ds = ldap_connect($ldapServer, $ldapPort); +// $searchResult = ldap_search($ds, $searchBase, 'uid=' . $vdomain); +// $information = ldap_get_entries($ds, $searchResult); +// $trailer = $information[0]['ispmandomainsignature'][0]; +// ldap_close($ds); +// error_reporting($old_error); +// +// return $trailer; +// } + + + /** + * Add additional message flags in the message listing screen for a + * mailbox. + * + * @param array $data The overview information for a message as returned + * from the IMP_Mailbox::getMailboxArray() call (see + * lib/Mailbox.php for documentation on the structure + * of the array). + * @param string $mode Either 'imp' or 'dimp'. + * + * @return array An array of additional flags to add. These flags must be + * defined in the 'msgflags' preference. On error, return + * an empty array. + */ +// function msglist_flags($data, $mode) +// { +// // Example #1: Add a icon if the message was sent from a user within +// // the same domain. +// $flags = array(); +// +// $from_ob = Horde_Mime_Address::getAddressesFromObject($ob['envelope']['from']); +// if (!empty($from_ob) && +// (strcasecmp($from_ob[0]['hostname'], 'example.com') === 0)) { +// /* The '$indomain' flag in this example must have already been +// * created in the 'msgflags' preference. */ +// $flags = array('$indomain'); +// } +// +// return $flags; +// } + + + /** + * When a mailbox is opened in IMP, allow redirection based on the mailbox + * name. + * + * @param string $mailbox The mailbox which the user has opened. + * + * @return string A valid page within a Horde application which will be + * placed in a "Location" header to redirect the client. + * Return an empty string if the user is not to be + * redirected. + */ +// function mbox_redirect($mailbox) +// { +// // Example #1: Redirect to various Horde apps based on the mailbox +// // name. +// if ((stripos($mailbox, "INBOX/Calendar") !== false) || +// preg_match("!^user/[^/]+/Calendar!", $mailbox)) { +// return $GLOBALS['registry']->get('webroot', 'kronolith'); +// } elseif ((stripos($mailbox, "INBOX/Tasks") !== false) || +// preg_match("!^user/[^/]+/Tasks!", $mailbox)) { +// return $GLOBALS['registry']->get('webroot', 'nag'); +// } elseif ((strpos($mailbox, "INBOX/Notes") !== false) || +// preg_match("!^user/[^/]+/Notes!", $mailbox)) { +// return $GLOBALS['registry']->get('webroot', 'mnemo'); +// } elseif ((strpos($mailbox, "INBOX/Contacts") !== false) || +// preg_match("!^user/[^/]+/Contacts!", $mailbox)) { +// return $GLOBALS['registry']->get('webroot', 'turba'); +// } +// +// return ''; +// +// +// // Example #2: Kolab defaults. +// require_once 'Horde/Kolab.php'; +// switch (Kolab::getMailboxType($mailbox)) { +// case 'event': +// return $GLOBALS['registry']->get('webroot', 'kronolith'); +// +// case 'task': +// return $GLOBALS['registry']->get('webroot', 'nag'); +// +// case 'note': +// return $GLOBALS['registry']->get('webroot', 'mnemo'); +// +// case 'contact': +// return $GLOBALS['registry']->get('webroot', 'turba'); +// +// case 'prefs': +// return $GLOBALS['registry']->get('webroot', 'horde') . '/services/prefs.php?app=horde'; +// +// default: +// return ''; +// } +// } + + + /** + * Allow a custom folder icon to be specified for "standard" mailboxes + * ("Standard" means all folders except the INBOX, sent-mail folders and + * trash folders.) + * + * @return array A list of mailboxes, with the name as keys and the + * values an array with 'icon', 'icondir', and 'alt' entries. + * If a mailbox name doesn't appear in the list, the default + * mailbox icon is displayed. + */ +// function mbox_icons() +// { +// // Example #1: Redirection scheme for Kolab_Cyrus +// static $newmailboxes; +// +// if (!empty($newmailboxes)) { +// return $newmailboxes; +// } +// +// require_once 'Horde/Kolab.php'; +// $kc = new Kolab_Cyrus($GLOBALS['conf']['kolab']['server']); +// $mailboxes = $kc->listMailBoxes(); +// $newmailboxes = array(); +// +// foreach ($mailboxes as $box) { +// $box = preg_replace("/^{[^}]+}/", "", $box); +// if ((stripos($box, "INBOX/Calendar") !== false) || +// preg_match("!^user/[^/]+/Calendar!", $box)) { +// $newmailboxes[$box] = array( +// 'icon' => 'kronolith.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('kronolith') +// 'alt' => _("Calendar") +// ); +// } elseif ((stripos($box, "INBOX/Tasks") !== false) || +// preg_match("!^user/[^/]+/Tasks!", $box)) { +// $newmailboxes[$box] = array( +// 'icon' => 'nag.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('nag') +// 'alt' => _("Tasks") +// ); +// } elseif ((stripos($box, "INBOX/Notes") !== false) || +// preg_match("!^user/[^/]+/Notes!", $box)) { +// $newmailboxes[$box] = array( +// 'icon' => 'mnemo.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('mnemo') +// 'alt' => _("Notes") +// ); +// } elseif ((stripos($box, "INBOX/Contacts") !== false) || +// preg_match("!^user/[^/]+/Contacts!", $box)) { +// $newmailboxes[$box] = array( +// 'icon' => 'turba.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('turba') +// 'alt' => _("Contacts") +// ); +// } +// } +// +// return $newmailboxes; +// +// +// // Example #2: Default Kolab redirection scheme +// if (!empty($icons)) { +// return $icons; +// } +// +// require_once 'Horde/Kolab.php'; +// $folders = Kolab::listFolders(); +// $icons = array(); +// foreach ($folders as $folder) { +// $name = preg_replace('/^{[^}]+}/', '', $folder[0]); +// +// switch ($folder[1]) { +// case 'event': +// $icons[$name] = array( +// 'icon' => 'kronolith.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('kronolith'), +// 'alt' => _("Calendar") +// ); +// break; +// +// case 'task': +// $icons[$name] = array( +// 'icon' => 'nag.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('nag'), +// 'alt' => _("Tasks") +// ); +// break; +// +// case 'note': +// $icons[$name] = array( +// 'icon' => 'mnemo.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('mnemo'), +// 'alt' => _("Notes") +// ); +// break; +// +// case 'contact': +// $icons[$name] = array( +// 'icon' => 'turba.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('turba'), +// 'alt' => _("Contacts") +// ); +// break; +// +// case 'prefs': +// $icons[$name] = array( +// 'icon' => 'prefs.png', +// 'icondir' => $GLOBALS['registry']->getImageDir('horde'), +// 'alt' => _("Preferences") +// ); +// break; +// } +// } +// +// return $icons; +// } + + + /** + * Mark a mailbox as read-only. + * + * @param string $mailbox The mailbox name. + * + * @return boolean Is the mailbox read-only? + */ +// function mbox_readonly($mailbox) +// { +// // Example #1: Make messages in the 'foo' mailbox readonly. +// return ($mailbox == 'foo'); +// } + + + /** + * Allow additional information to be added/edited from the data that is + * passed to the mailbox display template: + * imp: imp/templates/mailbox/mailbox.html + * dimp: imp/js/src/mailbox-dimp.js. + * + * If you are going to add new columns, you also have to update these + * fields: + * imp: imp/mailbox.php to specify the column width. + * dimp: imp/templates/index/dimp.inc to contain the new field in the + * header + * imp/themes/screen-dimp.css to specify the column width. + * + * @param array $msgs The mailbox data. + * @param string $view Either 'imp' or 'dimp'. + * + * @return array The altered array to use in the template. +// function mailboxarray($msgs, $view) +// { +// // Example #1: Adds a 'foo' entry to each message element. +// switch ($view) { +// case 'dimp': +// case 'imp': +// foreach (array_keys($msgs) as $key) { +// $msgs[$key]['foo'] = true; +// } +// break; +// } +// +// return $msg; // } -// } -// This is an example hook function to hide specified IMAP mailboxes in -// folder listings. If the hook returns false, the mailbox will not be -// displayed. -// if (!function_exists('_imp_hook_display_folder')) { -// function _imp_hook_display_folder($mailbox) { -// return ($mailbox == 'DONOTDISPLAY'); -// } -// } - -// This is an example hook function for the IMP spam reporting email option. -// This function is called when the message is about to be forwarded - it -// will return the email address to forward to. This is handy for spam -// reporting software (e.g. DSPAM) which has different e-mail aliases for -// spam reporting for each user. - -// if (!function_exists('_imp_hook_spam_email')) { -// function _imp_hook_spam_email($action) -// { -// $prefix = ($action == 'spam') ? 'spam-' : 'fp-'; -// return $prefix . Horde_Auth::getBareAuth() . '@example.com'; -// } -// } - -// Default Kolab hooks: -if (!empty($GLOBALS['conf']['kolab']['enabled'])) { - require_once 'Horde/Kolab.php'; - - if (!function_exists('_imp_hook_mbox_redirect')) { - function _imp_hook_mbox_redirect($mailbox) - { - switch (Kolab::getMailboxType($mailbox)) { - case 'event': - return $GLOBALS['registry']->get('webroot', 'kronolith'); - - case 'task': - return $GLOBALS['registry']->get('webroot', 'nag'); - - case 'note': - return $GLOBALS['registry']->get('webroot', 'mnemo'); - - case 'contact': - return $GLOBALS['registry']->get('webroot', 'turba'); - - case 'prefs': - return $GLOBALS['registry']->get('webroot', 'horde') . '/services/prefs.php?app=horde'; - - default: - return ''; - } - } - - function _imp_hook_mbox_icons() - { - static $icons; - - if (!empty($icons)) { - return $icons; - } - - $folders = Kolab::listFolders(); - $icons = array(); - foreach ($folders as $folder) { - $name = preg_replace('/^{[^}]+}/', '', $folder[0]); - - switch ($folder[1]) { - case 'event': - $icons[$name] = array( - 'icon' => 'kronolith.png', - 'icondir' => $GLOBALS['registry']->getImageDir('kronolith'), - 'alt' => _("Calendar") - ); - break; - - case 'task': - $icons[$name] = array( - 'icon' => 'nag.png', - 'icondir' => $GLOBALS['registry']->getImageDir('nag'), - 'alt' => _("Tasks") - ); - break; - - case 'note': - $icons[$name] = array( - 'icon' => 'mnemo.png', - 'icondir' => $GLOBALS['registry']->getImageDir('mnemo'), - 'alt' => _("Notes") - ); - break; - - case 'contact': - $icons[$name] = array( - 'icon' => 'turba.png', - 'icondir' => $GLOBALS['registry']->getImageDir('turba'), - 'alt' => _("Contacts") - ); - break; - - case 'prefs': - $icons[$name] = array( - 'icon' => 'prefs.png', - 'icondir' => $GLOBALS['registry']->getImageDir('horde'), - 'alt' => _("Preferences") - ); - break; - } - } - - return $icons; - } - } - - if (!function_exists('_imp_hook_display_folder')) { - function _imp_hook_display_folder($mailbox) - { - $type = Kolab::getMailboxType($mailbox); - return empty($type) || ($type == 'mail'); - } - } -} + /** + * Dynamically disable composing messages. + * + * @return boolean Is composing disabled? + */ +// function disable_compose() +// { +// // Example #1: Entirely disable composition. +// return false; +// } + + + /** + * Hide specified IMAP mailboxes in folder listings. + * + * @param string $mailbox The mailbox name. + * + * @return boolean If false, do not display the mailbox. + */ +// function display_folder($mailbox) +// { +// // Example #1: Do not display the mailbox 'Foo'. +// return ($mailbox != 'Foo'); +// +// +// // Example #2: Kolab default +// require_once 'Horde/Kolab.php'; +// $type = Kolab::getMailboxType($mailbox); +// return empty($type) || ($type == 'mail'); +// } + + + /** + * Provide email to use for spam reporting. This is handy for spam + * reporting software (e.g. DSPAM) which has different e-mail aliases for + * spam reporting for each user. + * + * @param string $action Either 'spam' or 'ham'. + * + * @return string An e-mail address. + */ +// function spam_email($action) +// { +// // Example #1: Create e-mail for DSPAM setup. +// $prefix = ($action == 'spam') ? 'spam-' : 'fp-'; +// return $prefix . Horde_Auth::getBareAuth() . '@example.com'; +// } + + + /** + * Determine quota for a user. + * + * @param array $params Parameters for the function, set in servers.php. + * + * @return array Tuple with two members: + *
+     * first: disk space used (in bytes)
+     * second: maximum disk space (in bytes)
+     * 
+ */ +// function quota($params = null) +// { +// // Example #1: Sample function for returning the quota. +// // Uses the PECL ssh2 extension. +// $host = $_SESSION['imp']['server']; +// $user = $_SESSION['imp']['user']; +// $pass = Horde_Auth::getCredential('password'); +// $command = $params[0]; +// +// $session = ssh2_connect($host); +// if (!$session) { +// throw new Horde_Exception(_("Connection to server failed."), 'horde.error'); +// } +// +// if (!ssh2_auth_password($session, $user, $pass)) { +// throw new Horde_Exception(_("Authentication failed."), 'horde.error'); +// } +// +// $stream = ssh2_exec($session, $command, false); +// stream_set_blocking($stream, true); +// +// $quota = preg_split('/\s+/', trim(stream_get_contents($stream)), 2); +// return array($quota[1] * 1024, $quota[2] * 1024); +// } + + + /** + * DIMP: Allow additional information to be added to the array that is + * passed to the message text display template: + * imp/templates/chunks/message.php. + * + * @param array $msg The current entry array (see the showMessage() + * function in lib/Views/ShowMessage.php for the + * format. + * + * @return array The altered array to use in the template. + */ +// function dimp_messageview($msg) +// { +// // Example #1: Add a new foo variable +// $msg['foo'] = '
BAR
'; +// return $msg; +// } + + + /** + * DIMP: Allows additional information to be added to the preview view and + * its corresponding template: + * imp/templates/index/index-dimp.inc. + * + * Since the preview pane is dynamically updated via javascript, all + * updates other than the base entries must be provided in javascript code + * to be run at update time. + * + * @param array $msg The current entry array (see the showMessage() + * function in lib/Views/ShowMessage.php for the + * format. + * + * @return array A 2 element array - the first element is the original + * array with any changes made to the initial data. The + * second element is an array of javascript commands, one + * command per array value. + */ +// function dimp_previewview($msg) { +// // Example #1: Alter the subject +// $msg['subject'] .= 'test'; +// +// // Example #2: Update the DOM ID 'foo' with the value 'bar'. 'foo' +// // needs to be manually added to the HTML template. +// $js_code = array( +// "$('foo').update('bar')" +// ); +// +// return array($msg, $js_code); +// } + + + /** + * DIMP: Allows alteration of address formatting in email message headers. + * + * @param stdClass $ob Object with the following possible properties: + *
+     * 'address' - Full address
+     * 'display' - Display address
+     * 'host' - Host name
+     * 'inner' - Trimmed, bare address
+     * 'personal' - Personal string
+     * 
+ * + * @return string The raw string to display for that address. This value + * must be properly escaped (i.e. htmlspecialchars() used + * on the portions of the string where appropriate). + */ +// function dimp_addressformatting($ob) +// { +// // Example #1: Display only the raw text of the personal name +// // or, if not set, the e-mail address. +// return empty($ob['personal']) ? $ob['address'] : $ob['personal']; +// } -// Sample function for returning the quota. Uses the PECL ssh2 -// extension. -// -// @param array $params Parameters for the function, set in servers.php -// -// @return array Tuple with two members: -// first: disk space used (in bytes) -// second: maximum disk space (in bytes) -// In case of an error, throw a Horde_Exception object. -if (!function_exists('_imp_hook_quota')) { - function _imp_hook_quota($params = null) - { - $host = $_SESSION['imp']['server']; - $user = $_SESSION['imp']['user']; - $pass = Horde_Auth::getCredential('password'); - $command = $params[0]; - - $session = ssh2_connect($host); - if (!$session) { - throw new Horde_Exception(_("Connection to server failed."), 'horde.error'); - } - - if (!ssh2_auth_password($session, $user, $pass)) { - throw new Horde_Exception(_("Authentication failed."), 'horde.error'); - } - - $stream = ssh2_exec($session, $command, false); - stream_set_blocking($stream, true); - - $quota = preg_split('/\s+/', trim(stream_get_contents($stream)), 2); - return array($quota[1] * 1024, $quota[2] * 1024); - } } - -// This is an example hook function for the dynamic (dimp) message view. This -// function allows additional information to be added to the array that is -// passed to the message text display template - -// imp/templates/chunks/message.php. The current entry array is passed in -// (see the showMessage() function in lib/Views/ShowMessage.php for the -// format). The value returned should be the altered array to use in the -// template. - -// if (!function_exists('_imp_hook_dimp_messageview')) { -// function _imp_hook_dimp_messageview($msg) { -// // Ex.: Add a new foo variable -// $msg['foo'] = '
BAR
'; -// return $msg; -// } -// } - -// This is an example hook function for the dynamic (dimp) preview view. This -// function allows additional information to be added to the preview view and -// its corresponding template - imp/templates/index/index-dimp.inc. The -// current entry array is passed in (see the showMessage() function in -// lib/Views/ShowMessage.php for the format). Since the preview pane is -// dynamically updated via javascript, all updates other than the base -// entries must be provided in javascript code to be run at update time. The -// expected return is a 2 element array - the first element is the original -// array with any changes made to the initial data. The second element is an -// array of javascript commands, one command per array value. - -// if (!function_exists('_imp_hook_dimp_previewview')) { -// function _imp_hook_dimp_previewview($msg) { -// // Ex.: Alter the subject -// $msg['subject'] .= 'test'; -// -// // Ex.: Update the DOM ID 'foo' with the value 'bar'. 'foo' needs -// // to be manually added to the HTML template. -// $js_code = array( -// "$('foo').update('bar')" -// ); -// -// return array($msg, $js_code); -// } -// } - -// This is an example hook function for the address formatting in email -// message headers. The argument passed to the function is an object with the -// following possible properties: -// 'address' - Full address -// 'display' - Display address -// 'host' - Host name -// 'inner' - Trimmed, bare address -// 'personal' - Personal string -// The return value is the raw string to display for that address. This value -// must be properly escaped (i.e. htmlspecialchars() used on the portions of -// the string where appropriate). - -// if (!function_exists('_imp_hook_dimp_addressformatting')) { -// function _dimp_hook_addressformatting($ob) { -// return empty($ob['personal']) ? $ob['address'] : $ob['personal']; -// } -// } diff --git a/imp/config/servers.php.dist b/imp/config/servers.php.dist index 856497a60..763b2bc43 100644 --- a/imp/config/servers.php.dist +++ b/imp/config/servers.php.dist @@ -95,7 +95,8 @@ * * Currently available drivers: * 'command' -- Use the UNIX quota command to handle quotas. - * 'hook' -- Use the _imp_hook_quota function to handle quotas. + * 'hook' -- Use the quota hook to handle quotas (see + * imp/config/hooks.php). * 'imap' -- Use the IMAP QUOTA extension to handle quotas. * You must be connecting to a IMAP server capable * of the QUOTAROOT command to use this driver. diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index c03ac338d..16cfe50bf 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -367,6 +367,7 @@ class IMP_Compose * * @return boolean Whether the sent message has been saved in the * sent-mail folder. + * @throws Horde_Exception * @throws IMP_Compose_Exception */ public function buildAndSendMessage($body, $header, $charset, $html, @@ -619,11 +620,9 @@ class IMP_Compose $this->_saveRecipients($recipients); /* Call post-sent hook. */ - if (!empty($conf['hooks']['postsent'])) { - try { - Horde::callHook('_imp_hook_postsent', array($save_msg['msg'], $headers), 'imp'); - } catch (Horde_Exception $e) {} - } + try { + Horde::callHook('postsent', array($save_msg['msg'], $headers), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} return $sent_saved; } @@ -639,6 +638,7 @@ class IMP_Compose * @param string $charset The charset that was used for the * headers. * + * @throws Horde_Exception * @throws IMP_Compose_Exception */ public function sendMessage($email, $headers, $message, $charset) @@ -671,14 +671,12 @@ class IMP_Compose $recipients += isset($address['grounpname']) ? count($address['addresses']) : 1; } if ($recipients > $timelimit) { - if (!empty($conf['hooks']['permsdenied'])) { - try { - Horde::callHook('_perms_hook_denied', array('imp:max_timelimit'), 'horde'); - } catch (Horde_Exception $e) { - throw new IMP_Compose_Exception($e); - } + try { + $message = Horde::callHook('perms_denied', array('imp:max_timelimit')); + } catch (Horde_Exception_HookNotSet $e) { + $message = @htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients within %d hours."), $timelimit, $conf['sentmail']['params']['limit_period']), ENT_COMPAT, Horde_Nls::getCharset()); } - throw new IMP_Compose_Exception(@htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients within %d hours."), $timelimit, $conf['sentmail']['params']['limit_period']), ENT_COMPAT, Horde_Nls::getCharset())); + throw new IMP_Compose_Exception($message); } } @@ -816,6 +814,7 @@ class IMP_Compose * 'header' - An array containing the cleaned up 'to', 'cc', and 'bcc' * header strings. * + * @throws Horde_Exception * @throws IMP_Compose_Exception */ public function recipientList($hdr, $exceed = true) @@ -875,14 +874,12 @@ class IMP_Compose $num_recipients += count(explode(',', $recipient)); } if ($num_recipients > $max_recipients) { - if (!empty($conf['hooks']['permsdenied'])) { - try { - Horde::callHook('_perms_hook_denied', array('imp:max_recipients'), 'horde'); - } catch (Horde_Exception $e) { - throw new IMP_Compose_Exception($e); - } + 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, Horde_Nls::getCharset()); } - throw new IMP_Compose_Exception(@htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients."), $max_recipients), ENT_COMPAT, Horde_Nls::getCharset())); + throw new IMP_Compose_Exception($message); } } } @@ -930,6 +927,7 @@ class IMP_Compose * * * @return array TODO + * @throws Horde_Exception * @throws IMP_Compose_Exception */ protected function _createMimeMessage($to, $body, $charset, @@ -957,15 +955,9 @@ class IMP_Compose if (!empty($trailer_file)) { $trailer = Horde_Text_Filter::filter("\n" . file_get_contents($trailer_file), 'environment'); - /* If there is a user defined function, call it with the - * current trailer as an argument. */ - if (!empty($GLOBALS['conf']['hooks']['trailer'])) { - try { - $trailer = Horde::callHook('_imp_hook_trailer', array($trailer), 'imp'); - } catch (Horde_Exception $e) { - throw new IMP_Compose_Exception($e); - } - } + try { + $trailer = Horde::callHook('trailer', array($trailer), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} $body .= $trailer; if (!empty($options['html'])) { diff --git a/imp/lib/Fetchmail.php b/imp/lib/Fetchmail.php index eadf3341f..b0b9bf0e7 100644 --- a/imp/lib/Fetchmail.php +++ b/imp/lib/Fetchmail.php @@ -268,12 +268,6 @@ abstract class IMP_Fetchmail } $msg .= "\n\n" . $body; - /* If there is a user defined function, call it with the current - * message as an argument. */ - if ($GLOBALS['conf']['hooks']['fetchmail_filter']) { - $msg = Horde::callHook('_imp_hook_fetchmail_filter', array($msg), 'imp'); - } - try { $GLOBALS['imp_imap']->ob->append($this->_params['lmailbox'], array(array('data' => $msg, 'flags' => $flags))); return true; diff --git a/imp/lib/Folder.php b/imp/lib/Folder.php index fdfca8241..b453bcd07 100644 --- a/imp/lib/Folder.php +++ b/imp/lib/Folder.php @@ -233,6 +233,7 @@ class IMP_Folder * @param boolean $subscribe Subscribe to folder? * * @return boolean Whether or not the folder was successfully created. + * @throws Horde_Exception */ public function create($folder, $subscribe) { @@ -241,23 +242,17 @@ class IMP_Folder /* Check permissions. */ if (!IMP::hasPermission('create_folders')) { try { - if (!empty($conf['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('imp:create_folders'), 'horde', $message); - } + $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, Horde_Nls::getCharset()); - } catch (Horde_Exception $e) { - $message = $e->getMessage(); } $notification->push($message, 'horde.error', array('content.raw')); return false; } elseif (!IMP::hasPermission('max_folders')) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), IMP::hasPermission('max_folders', true)), ENT_COMPAT, Horde_Nls::getCharset()); try { - if (!empty($conf['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('imp:max_folders'), 'horde', $message); - } - } catch (Horde_Exception $e) { - $message = $e->getMessage(); + $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."), IMP::hasPermission('max_folders', true)), ENT_COMPAT, Horde_Nls::getCharset()); } $notification->push($message, 'horde.error', array('content.raw')); return false; diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index dc308d707..0f9d578e4 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -1563,14 +1563,17 @@ class IMP * Determine the status of composing. * * @return boolean Is compose allowed? + * @throws Horde_Exception */ static public function canCompose() { try { - return empty($conf['hooks']['disable_compose']) || !Horde::callHook('_imp_hook_disable_compose', array(), 'imp'); - } catch (Horde_Exception $e) { + return !Horde::callHook('disable_compose', array(), 'imp'); + } catch (Horde_Exception_HookNotSet $e) { return true; } + + } } diff --git a/imp/lib/Identity/imp.php b/imp/lib/Identity/imp.php index 26bf4c3fe..ea380d4a4 100644 --- a/imp/lib/Identity/imp.php +++ b/imp/lib/Identity/imp.php @@ -446,6 +446,7 @@ class Identity_imp extends Identity * @param integer $ident The identity to retrieve the signature from. * * @return string The full signature. + * @throws Horde_Exception */ public function getSignature($ident = null) { @@ -468,11 +469,9 @@ class Identity_imp extends Identity } } - if (!empty($GLOBALS['conf']['hooks']['signature'])) { - try { - $val = Horde::callHook('_imp_hook_signature', array($val), 'imp'); - } catch (Horde_Exception $e) {} - } + try { + $val = Horde::callHook('prefs_hook_signature', array($val), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} $this->_signatures[$ident] = $val; diff --git a/imp/lib/Imap.php b/imp/lib/Imap.php index f04c251b7..1a2cbef8f 100644 --- a/imp/lib/Imap.php +++ b/imp/lib/Imap.php @@ -237,17 +237,17 @@ class IMP_Imap * @param string $mailbox The mailbox to check. * * @return boolean Is the mailbox read-only? + * @throws Horde_Exception */ public function isReadOnly($mailbox) { if (!isset($this->_readonly[$mailbox])) { + $res = false; + /* These tests work on both regular and search mailboxes. */ try { - $res = !empty($GLOBALS['conf']['hooks']['mbox_readonly']) && - Horde::callHook('_imp_hook_mbox_readonly', array($mailbox), 'imp'); - } catch (Horde_Exception $e) { - $res = false; - } + $res = Horde::callHook('mbox_readonly', array($mailbox), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} /* This check can only be done for regular IMAP mailboxes. */ // TODO: POP3 also? diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index a68abc848..dd8cdebda 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -340,6 +340,7 @@ class IMP_Imap_Tree * @param integer $attributes The mailbox's attributes. * * @return array See above format. + * @throws Horde_Exception */ protected function _makeElt($name, $attributes = 0) { @@ -396,11 +397,9 @@ class IMP_Imap_Tree $elt['l'] = IMP::getLabel($tmp[$elt['c']]); if ($_SESSION['imp']['protocol'] != 'pop') { - if (!empty($GLOBALS['conf']['hooks']['display_folder'])) { - try { - $this->_setInvisible($elt, !Horde::callHook('_imp_hook_display_folder', array($elt['v']), 'imp')); - } catch (Horde_Exception $e) {} - } + try { + $this->_setInvisible($elt, !Horde::callHook('display_folder', array($elt['v']), 'imp')); + } catch (Horde_Exception_HookNotSet $e) {} if ($elt['c'] != 0) { $elt['p'] = implode(is_null($ns_info) ? $this->_delimiter : $ns_info['delimiter'], array_slice($tmp, 0, $elt['c'])); @@ -1633,25 +1632,13 @@ class IMP_Imap_Tree */ public function getCustomIcon($elt) { - static $mbox_icons; - - if (isset($mbox_icons) && !$mbox_icons) { - return false; - } - - /* Call the mailbox icon hook, if requested. */ - if (empty($GLOBALS['conf']['hooks']['mbox_icon'])) { - $mbox_icons = false; - return false; - } + static $mbox_icons = array(); if (!isset($mbox_icons)) { try { - $mbox_icons = Horde::callHook('_imp_hook_mbox_icons', array(), 'imp', false); - if (!$mbox_icons) { - return false; - } - } catch (Horde_Exception $e) {} + $mbox_icons = Horde::callHook('mbox_icons', array(), 'imp', false); + } catch (Horde_Exception $e) { + } catch (Horde_Exception_HookNotSet $e) {} } if (isset($mbox_icons[$elt['v']])) { diff --git a/imp/lib/Quota/Hook.php b/imp/lib/Quota/Hook.php index 7386f7020..165277a85 100644 --- a/imp/lib/Quota/Hook.php +++ b/imp/lib/Quota/Hook.php @@ -30,7 +30,11 @@ class IMP_Quota_Hook extends IMP_Quota */ public function getQuota() { - $quota = Horde::callHook('_imp_hook_quota', $this->_params, 'imp'); + try { + $quota = Horde::callHook('hook_quota', $this->_params, 'imp'); + } catch (Horde_Exception_HookNotSet $e) { + throw new Horde_Exception($e->getMessage()); + } if (count($quota) != 2) { Horde::logMessage('Incorrect number of return values from quota hook.', __FILE__, __LINE__, PEAR_LOG_ERR); diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index a8ec15b21..98cf742eb 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -92,11 +92,11 @@ class IMP_Spam * use it. */ if (!empty($GLOBALS['conf'][$action]['email'])) { $to = $GLOBALS['conf'][$action]['email']; - } elseif (!empty($GLOBALS['conf']['hooks']['spam_email'])) { + } else { /* Call the email generation hook, if requested. */ try { - $to = Horde::callHook('_imp_hook_spam_email', array($action), 'imp'); - } catch (Horde_Exception $e) {} + $to = Horde::callHook('spam_email', array($action), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} } if ($to) { diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index 6c3565158..a9b895028 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -220,6 +220,7 @@ class IMP_Views_ListMessages * @param boolean $search Is this a search mbox? * * @return array TODO + * @throws Horde_Exception */ private function _getOverviewData($imp_mailbox, $folder, $msglist, $search) { @@ -245,11 +246,9 @@ class IMP_Views_ListMessages ); /* Get all the flag information. */ - if (!empty($GLOBALS['conf']['hooks']['msglist_flags'])) { - try { - $ob['flags'] = array_merge($ob['flags'], Horde::callHook('_imp_hook_msglist_flags', array($ob, 'dimp'), 'imp')); - } catch (Horde_Exception $e) {} - } + try { + $ob['flags'] = array_merge($ob['flags'], Horde::callHook('msglist_flags', array($ob, 'dimp'), 'imp')); + } catch (Horde_Exception_HookNotSet $e) {} $imp_flags = IMP_Imap_Flags::singleton(); $flag_parse = $imp_flags->parse(array( @@ -303,11 +302,9 @@ class IMP_Views_ListMessages } /* Allow user to alter template array. */ - if (!empty($GLOBALS['conf']['imp']['hooks']['mailboxarray'])) { - try { - $msgs = Horde::callHook('_imp_hook_mailboxarray', array($msgs, 'dimp'), 'imp'); - } catch (Horde_Exception $e) {} - } + try { + $msgs = Horde::callHook('mailboxarray', array($msgs, 'dimp'), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} return $msgs; } diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php index 44e2213f9..7870a91f3 100644 --- a/imp/lib/Views/ShowMessage.php +++ b/imp/lib/Views/ShowMessage.php @@ -27,13 +27,12 @@ class IMP_Views_ShowMessage } $addr_array = array(); - $call_hook = !empty($GLOBALS['conf']['dimp']['hooks']['addressformatting']); foreach (Horde_Mime_Address::getAddressesFromObject($addrlist) as $ob) { if (!empty($ob['inner'])) { - if ($call_hook) { - $addr_array[] = array('raw' => Horde::callHook('_imp_hook_dimp_addressformatting', array($ob), 'imp')); - } else { + try { + $addr_array[] = array('raw' => Horde::callHook('dimp_addressformatting', array($ob), 'imp')); + } catch (Horde_Exception_HookNotSet $e) { $tmp = array('inner' => $ob['inner']); if (!empty($ob['personal'])) { $tmp['personal'] = $ob['personal']; @@ -88,6 +87,7 @@ class IMP_Views_ShowMessage * 'replyTo' - The Reply-to addresses * 'save_as' - The save link * + * @throws Horde_Exception */ public function showMessage($args) { @@ -332,18 +332,18 @@ class IMP_Views_ShowMessage $result['atc_list'] = $tmp; } - if ($preview && !empty($GLOBALS['conf']['dimp']['hooks']['previewview'])) { + if ($preview) { try { - $res = Horde::callHook('_imp_hook_dimp_previewview', array($result), 'imp'); + $res = Horde::callHook('dimp_previewview', array($result), 'imp'); if (!empty($res)) { $result = $res[0]; $result['js'] = $res[1]; } - } catch (Horde_Exception $e) {} - } elseif (!$preview && !empty($GLOBALS['conf']['dimp']['hooks']['messageview'])) { + } catch (Horde_Exception_HookNotSet $e) {} + } elseif (!$preview) { try { - $result = Horde::callHook('_imp_hook_dimp_messageview', array($result), 'imp'); - } catch (Horde_Exception $e) {} + $result = Horde::callHook('dimp_messageview', array($result), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} } if (!$preview) { diff --git a/imp/mailbox.php b/imp/mailbox.php index 0d8b0313e..bd072f750 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -17,11 +17,9 @@ function _outputSummaries($msgs) static $template; /* Allow user to alter template array. */ - if (!empty($GLOBALS['conf']['imp']['hooks']['mailboxarray'])) { - try { - $msgs = Horde::callHook('_imp_hook_mailboxarray', array($msgs, 'imp'), 'imp'); - } catch (Horde_Exception $e) {} - } + try { + $msgs = Horde::callHook('mailboxarray', array($msgs, 'imp'), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} if (!isset($template)) { $template = new Horde_Template(); @@ -43,18 +41,14 @@ function _outputSummaries($msgs) require_once dirname(__FILE__) . '/lib/base.php'; /* Call the mailbox redirection hook, if requested. */ -if (!empty($conf['hooks']['mbox_redirect'])) { - try { - $redirect = Horde::callHook('_imp_hook_mbox_redirect', array($imp_mbox['mailbox']), 'imp'); - if (!empty($redirect)) { - $redirect = Horde::applicationUrl($redirect, true); - header('Location: ' . $redirect); - exit; - } - } catch (Horde_Exception $e) { - Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR); +try { + $redirect = Horde::callHook('mbox_redirect', array($imp_mbox['mailbox']), 'imp'); + if (!empty($redirect)) { + $redirect = Horde::applicationUrl($redirect, true); + header('Location: ' . $redirect); + exit; } -} +} catch (Horde_Exception_HookNotSet $e) {} /* Is this a search mailbox? */ $search_mbox = $imp_search->isSearchMbox($imp_mbox['mailbox']); @@ -747,11 +741,9 @@ while (list(,$ob) = each($mbox_info['overview'])) { $target = IMP::generateIMPUrl('message.php', $imp_mbox['mailbox'], $ob['uid'], $ob['mailbox']); /* Get all the flag information. */ - if (!empty($GLOBALS['conf']['hooks']['msglist_flags'])) { - try { - $ob['flags'] = array_merge($ob['flags'], Horde::callHook('_imp_hook_msglist_flags', array($ob, 'imp'), 'imp')); - } catch (Horde_Exception $e) {} - } + try { + $ob['flags'] = array_merge($ob['flags'], Horde::callHook('msglist_flags', array($ob, 'imp'), 'imp')); + } catch (Horde_Exception_HookNotSet $e) {} $flag_parse = $imp_flags->parse(array( 'atc' => isset($ob['structure']) ? $ob['structure'] : null, diff --git a/ingo/config/conf.xml b/ingo/config/conf.xml index 7b84ead91..f45f75292 100644 --- a/ingo/config/conf.xml +++ b/ingo/config/conf.xml @@ -55,16 +55,4 @@
- - - Custom Hooks - false - true - diff --git a/ingo/config/hooks.php.dist b/ingo/config/hooks.php.dist index 83ebf9b0a..80247fa74 100644 --- a/ingo/config/hooks.php.dist +++ b/ingo/config/hooks.php.dist @@ -8,17 +8,24 @@ * * For more information please see the horde/config/hooks.php.dist file. * + * TODO: smtpd_access_policy_username + * * $Id$ */ -// Here is an example _ingo_hook_vacation_addresses function to set the -// default addresses used for the vacation module in Ingo. If you don't want -// to lock users to the list of addresses provided by this hook, you also need -// to disable the appropriate setting in Ingo's configuration. +class Ingo_Hooks +{ + /** + * Set the default addresses used for the vacation module. + * + * @param string $user The username. + * + * @return array A list of vacation addresses. + */ +// function vacation_addresses($user = null) +// { +// // Example #1: User has 2 vacation addresses. +// return array($user . '@example.com', $user . '@foobar.com'); +// } -// if (!function_exists('_ingo_hook_vacation_addresses')) { -// function _ingo_hook_vacation_addresses($user = null) -// { -// return array($user . '@example.com', $user . '@foobar.com'); -// } -// } +} diff --git a/ingo/filters.php b/ingo/filters.php index 760affa13..2e29122c0 100644 --- a/ingo/filters.php +++ b/ingo/filters.php @@ -62,24 +62,18 @@ case 'rule_enable': case 'rule_copy': if (!Ingo::hasPermission('allow_rules')) { try { - if (!empty($conf['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('ingo:allow_rules'), 'horde', $message); - } + $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."), ENT_COMPAT, Horde_Nls::getCharset()); - } catch (Horde_Exception $e) { - $message = $e->getMessage(); } $notification->push($message, 'horde.error', array('content.raw')); break 2; } elseif (Ingo::hasPermission('max_rules') !== true && Ingo::hasPermission('max_rules') <= count($filters->getFilterList())) { try { - if (!empty($conf['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('ingo:max_rules'), 'horde', $message); - } + $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."), Ingo::hasPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset()); - } catch (Horde_Exception $e) { - $message = $e->getMessage(); } $notification->push($message, 'horde.error', array('content.raw')); break 2; diff --git a/ingo/lib/Storage/Vacation.php b/ingo/lib/Storage/Vacation.php index 1b22b39cf..a10a6077e 100644 --- a/ingo/lib/Storage/Vacation.php +++ b/ingo/lib/Storage/Vacation.php @@ -63,14 +63,10 @@ class Ingo_Storage_Vacation extends Ingo_Storage_Rule public function getVacationAddresses() { - if (empty($GLOBALS['conf']['hooks']['vacation_addresses'])) { - return $this->_addr; - } - try { - return Horde::callHook('_ingo_hook_vacation_addresses', array(Ingo::getUser()), 'ingo'); - } catch (Horde_Exception $e) { - return array(); + return Horde::callHook('vacation_addresses', array(Ingo::getUser()), 'ingo'); + } catch (Horde_Exception_HookNotSet $e) { + return $this->_addr; } } diff --git a/ingo/rule.php b/ingo/rule.php index c783c9422..9d32fa60d 100644 --- a/ingo/rule.php +++ b/ingo/rule.php @@ -16,12 +16,9 @@ require_once dirname(__FILE__) . '/lib/base.php'; /* Check rule permissions. */ if (!Ingo::hasPermission('allow_rules')) { try { - if (!empty($conf['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('ingo:allow_rules'), 'horde'); - } + $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."), ENT_COMPAT, Horde_Nls::getCharset()); - } catch (Horde_Exception $e) { - $message = $e->getMessage(); } $notification->push($message, 'horde.error', array('content.raw')); header('Location: ' . Horde::applicationUrl('filters.php', true)); @@ -171,12 +168,9 @@ default: if (Ingo::hasPermission('max_rules') !== true && Ingo::hasPermission('max_rules') <= count($filters->getFilterList())) { try { - if (!empty($conf['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('ingo:max_rules'), 'horde'); - } + $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."), Ingo::hasPermission('max_rules')), ENT_COMPAT, Horde_Nls::getCharset()); - } catch (Horde_Exception $e) { - $message = $e->getMessage(); } $notification->push($message, 'horde.error', array('content.raw')); header('Location: ' . Horde::applicationUrl('filters.php', true)); diff --git a/ingo/scripts/ingo-postfix-policyd b/ingo/scripts/ingo-postfix-policyd index b70c76b75..7b4f4ee80 100755 --- a/ingo/scripts/ingo-postfix-policyd +++ b/ingo/scripts/ingo-postfix-policyd @@ -135,8 +135,8 @@ function smtpd_access_policy($query) } try { - $user = Horde::callHook('_ingo_hook_smtpd_access_policy_username', $query, 'ingo'); - } catch (Horde_Exception $e) {} + $user = Horde::callHook('smtpd_access_policy_username', $query, 'ingo'); + } catch (Horde_Exception_HookNotSet $e) {} // Get $user's rules if we don't have them already. if (!isset($whitelists[$user])) { diff --git a/ingo/vacation.php b/ingo/vacation.php index 0b04dcdf3..4c11dfaef 100644 --- a/ingo/vacation.php +++ b/ingo/vacation.php @@ -44,11 +44,8 @@ $v->setHelp('vacation-subject'); $v = &$form->addVariable(_("Reason:"), 'reason', 'longtext', false, false, null, array(10, 40)); $v->setHelp('vacation-reason'); $form->setSection('advanced', _("Advanced Settings")); -if (empty($conf['hooks']['vacation_addresses']) || - empty($conf['hooks']['vacation_only'])) { - $v = &$form->addVariable(_("My email addresses:"), 'addresses', 'longtext', true, false, null, array(5, 40)); - $v->setHelp('vacation-myemail'); -} +$v = &$form->addVariable(_("My email addresses:"), 'addresses', 'longtext', true, false, null, array(5, 40)); +$v->setHelp('vacation-myemail'); $v = &$form->addVariable(_("Addresses to not send responses to:"), 'excludes', 'longtext', false, false, null, array(10, 40)); $v->setHelp('vacation-noresponse'); $v = &$form->addVariable(_("Do not send responses to bulk or list messages?"), 'ignorelist', 'boolean', false); diff --git a/kronolith/data.php b/kronolith/data.php index 8fcbe6385..627b2f723 100644 --- a/kronolith/data.php +++ b/kronolith/data.php @@ -36,12 +36,9 @@ $templates = array( if (Kronolith::hasPermission('max_events') !== true && Kronolith::hasPermission('max_events') <= Kronolith::countEvents()) { try { - if (!empty($conf['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde'); - } + $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."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset()); - } catch (Horde_Exception $e) { - $message = $e->getMessage(); } $notification->push($message, 'horde.warning', array('content.raw')); $templates[Horde_Data::IMPORT_FILE] = array(KRONOLITH_TEMPLATES . '/data/export.inc'); @@ -246,12 +243,9 @@ if (is_array($next_step)) { foreach ($next_step as $row) { if ($max_events !== true && $num_events >= $max_events) { try { - if (!empty($conf['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde'); - } + $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."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset()); - } catch (Horde_Exception $e) { - $message = $e->getMessage(); } $notification->push($message, 'horde.error', array('content.raw')); break; diff --git a/kronolith/edit.php b/kronolith/edit.php index 3291072dc..5bc72cc13 100644 --- a/kronolith/edit.php +++ b/kronolith/edit.php @@ -26,12 +26,9 @@ function _check_max() if (Kronolith::hasPermission('max_events') !== true && Kronolith::hasPermission('max_events') <= Kronolith::countEvents()) { try { - if (!empty($GLOBALS['conf']['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde'); - } + $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."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset()); - } catch (Horde_Exception $e) { - $message = $e->getMessage(); } $GLOBALS['notification']->push($message, 'horde.error', array('content.raw')); return false; diff --git a/kronolith/new.php b/kronolith/new.php index 92d546518..1a5bd66ca 100644 --- a/kronolith/new.php +++ b/kronolith/new.php @@ -14,12 +14,9 @@ require dirname(__FILE__) . '/lib/base.php'; if (Kronolith::hasPermission('max_events') !== true && Kronolith::hasPermission('max_events') <= Kronolith::countEvents()) { try { - if (!empty($conf['hooks']['permsdenied'])) { - Horde::callHook('_perms_hook_denied', array('kronolith:max_events'), 'horde'); - } + $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."), Kronolith::hasPermission('max_events')), ENT_COMPAT, Horde_Nls::getCharset()); - } catch (Horde_Exception $e) { - $message = $e->getMessage(); } $notification->push($message, 'horde.error', array('content.raw')); $url = Horde_Util::addParameter($prefs->getValue('defaultview') . '.php', array('month' => Horde_Util::getFormData('month'), diff --git a/nag/config/hooks.php.dist b/nag/config/hooks.php.dist index cf9e0b261..5e40a79e0 100644 --- a/nag/config/hooks.php.dist +++ b/nag/config/hooks.php.dist @@ -1,26 +1,39 @@ \0', $text); -// $text = preg_replace('/(bug|ticket|request|enhancement|issue):\s*#?(\d+)/i', '\0', $text); +class Nag_Hooks +{ + /** + * TODO + */ +// function format_description($text) +// { +// $text = preg_replace('/#(\d+)/', '\0', $text); +// $text = preg_replace('/(bug|ticket|request|enhancement|issue):\s*#?(\d+)/i', '\0', $text); // -// $text = preg_replace_callback('/\[\[note: ?(.*)\]\]/i', create_function('$m', 'return \'\' . htmlspecialchars($m[0]) . \'\';'), $text); -// $text = preg_replace_callback('/\[\[task: ?(.*)\]\]/i', create_function('$m', 'return \'\' . htmlspecialchars($m[0]) . \'\';'), $text); +// $text = preg_replace_callback('/\[\[note: ?(.*)\]\]/i', create_function('$m', 'return \'\' . htmlspecialchars($m[0]) . \'\';'), $text); +// $text = preg_replace_callback('/\[\[task: ?(.*)\]\]/i', create_function('$m', 'return \'\' . htmlspecialchars($m[0]) . \'\';'), $text); // -// return $text; -// } -// } +// return $text; +// } + + + /** + * TODO + */ +// function description_help() +// { +// return '

To create a link to a bug, use #123 where 123 is the bug number. To create a link to another task, use [[task: name]], where name is the beginning of the task name. To create a link to a note, use [[note: title]] where title is the beginning of the note title.

'; +// } -// if (!function_exists('_nag_hook_description_help')) { -// function _nag_hook_description_help() -// { -// return '

To create a link to a bug, use #123 where 123 is the bug number. To create a link to another task, use [[task: name]], where name is the beginning of the task name. To create a link to a note, use [[note: title]] where title is the beginning of the note title.

'; -// } -// } +} diff --git a/nag/data.php b/nag/data.php index aeafac77f..fb81cd63c 100644 --- a/nag/data.php +++ b/nag/data.php @@ -36,9 +36,10 @@ $templates = array( ); if (Nag::hasPermission('max_tasks') !== true && Nag::hasPermission('max_tasks') <= Nag::countTasks()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), Nag::hasPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset()); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('nag:max_tasks'), 'horde', $message); + 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."), Nag::hasPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset()); } $notification->push($message, 'horde.warning', array('content.raw')); $templates[Horde_Data::IMPORT_FILE] = array(NAG_TEMPLATES . '/data/export.inc'); @@ -164,9 +165,10 @@ if (is_array($next_step)) { $result = null; foreach ($next_step as $row) { if ($max_tasks !== true && $num_tasks >= $max_tasks) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), Nag::hasPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset()); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('nag:max_tasks'), 'horde', $message); + 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."), Nag::hasPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset()); } $notification->push($message, 'horde.error', array('content.raw')); break; diff --git a/nag/lib/Forms/task.php b/nag/lib/Forms/task.php index ac61e066a..32784d0c4 100644 --- a/nag/lib/Forms/task.php +++ b/nag/lib/Forms/task.php @@ -109,8 +109,13 @@ class Nag_TaskForm extends Horde_Form { $this->addVariable(_("Estimated Time"), 'estimate', 'number', false); $this->addVariable(_("Completed?"), 'completed', 'boolean', false); - $this->addVariable(_("Description"), 'desc', 'longtext', false, false, - Horde::callHook('_nag_hook_description_help', array(), 'nag', '')); + + try { + $description = Horde::callHook('description_help', array(), 'nag'); + } catch (Horde_Exception_HookNotSet $e) { + $description = ''; + } + $this->addVariable(_("Description"), 'desc', 'longtext', false, false, $description); $buttons = array(_("Save")); if ($delete) { diff --git a/nag/lib/Task.php b/nag/lib/Task.php index 188cddf04..04d6723b0 100644 --- a/nag/lib/Task.php +++ b/nag/lib/Task.php @@ -424,8 +424,11 @@ class Nag_Task { function getFormattedDescription() { $desc = Horde_Text_Filter::filter($this->desc, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO)); - $desc = Horde::callHook('_nag_hook_format_description', array($desc), 'nag', $desc); - return $desc; + try { + return Horde::callHook('format_description', array($desc), 'nag'); + } catch (Horde_Exception_HookNotSet $e) { + return $desc; + } } /** diff --git a/nag/task.php b/nag/task.php index a4a2d2a9b..047d8e98f 100644 --- a/nag/task.php +++ b/nag/task.php @@ -62,9 +62,10 @@ case 'add_task': /* Check permissions. */ if (Nag::hasPermission('max_tasks') !== true && Nag::hasPermission('max_tasks') <= Nag::countTasks()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), Nag::hasPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset()); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('nag:max_tasks'), 'horde', $message); + 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."), Nag::hasPermission('max_tasks')), ENT_COMPAT, Horde_Nls::getCharset()); } $notification->push($message, 'horde.error', array('content.raw')); header('Location: ' . Horde::applicationUrl('list.php', true)); diff --git a/turba/add.php b/turba/add.php index d3737f350..7ff48c5cf 100644 --- a/turba/add.php +++ b/turba/add.php @@ -42,9 +42,10 @@ if ($source) { $max_contacts = Turba::getExtendedPermission($driver, 'max_contacts'); if ($max_contacts !== true && $max_contacts <= $driver->count()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title']), ENT_COMPAT, Horde_Nls::getCharset()); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('turba:max_contacts'), 'horde', $message); + 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']), ENT_COMPAT, Horde_Nls::getCharset()); } $notification->push($message, 'horde.error', array('content.raw')); $url = $url diff --git a/turba/config/hooks.php.dist b/turba/config/hooks.php.dist deleted file mode 100644 index 119bcebb0..000000000 --- a/turba/config/hooks.php.dist +++ /dev/null @@ -1,40 +0,0 @@ -count()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $driver->title), ENT_COMPAT, Horde_Nls::getCharset()); - if (!empty($conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('turba:max_contacts'), 'horde', $message); + 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), ENT_COMPAT, Horde_Nls::getCharset()); } $notification->push($message, 'horde.error', array('content.raw')); $error = true; diff --git a/turba/lib/View/Browse.php b/turba/lib/View/Browse.php index c313df7b6..72c821eab 100644 --- a/turba/lib/View/Browse.php +++ b/turba/lib/View/Browse.php @@ -145,9 +145,10 @@ class Turba_View_Browse { $max_contacts = Turba::getExtendedPermission($targetDriver, 'max_contacts'); if ($max_contacts !== true && $max_contacts <= $targetDriver->count()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$targetSource]['title']), ENT_COMPAT, Horde_Nls::getCharset()); - if (!empty($this->_conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('turba:max_contacts'), 'horde', $message); + 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']), ENT_COMPAT, Horde_Nls::getCharset()); } $notification->push($message, 'horde.error', array('content.raw')); break; @@ -267,11 +268,11 @@ class Turba_View_Browse { $max_contacts = Turba::getExtendedPermission($driver, 'max_contacts'); if ($max_contacts !== true && $max_contacts <= $driver->count()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title']), ENT_COMPAT, Horde_Nls::getCharset()); - if (!empty($this->_conf['hooks']['permsdenied'])) { - $message = Horde::callHook('_perms_hook_denied', array('turba:max_contacts'), 'horde', $message); + 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']), ENT_COMPAT, Horde_Nls::getCharset()); } - $notification->push($message, 'horde.error', array('content.raw')); break; }