<?php
/**
- * $Id$
- *
* Folks Hooks configuration file.
*
* THE HOOKS PROVIDED IN THIS FILE ARE EXAMPLES ONLY. DO NOT ENABLE THEM
* TO MATCH YOUR SPECIFIC NEEDS AND SYSTEM ENVIRONMENT.
*
* For more information please see the horde/config/hooks.php.dist file.
+ *
+ * $Id$
*/
+class Folks_Hooks
+{
// Example count used data hook function. Thera are two examples. One as
// registry calls and one much faster with direct DB access but requres your
// monitorig for application structure changes.
-if (!function_exists('_folks_hook_countService')) {
-
- function _folks_hook_countService($service, $user)
+ function countService($service, $user)
{
switch ($service) {
// DB optimized version
//
-// if (!function_exists('_folks_hook_countService')) {
-//
-// function _folks_hook_countService($service, $user)
+// function countService($service, $user)
// {
// switch ($service) {
//
// registry calls and one much faster with direct DB access but requres your
// monitorig for application structure changes.
-if (!function_exists('_folks_hook_getService')) {
- function _folks_hook_getService($service, $user)
+ function getService($service, $user)
{
switch ($service) {
// DB optimized version
//
-// if (!function_exists('_folks_hook_getService')) {
-// function _folks_hook_getService($service, $user)
+// function getService($service, $user)
// {
// switch ($service) {
//
// paid service and perform autologin or redirect to a wikipage with
// additional information
-if (!function_exists('_folks_hook_prelogin')) {
-
- function _folks_hook_prelogin($app)
+ function prelogin($app)
{
require_once 'Horde/Group.php';
$group = Group::singleton();
// attempts are made to add them to the system. Here we lowecase the useranme
// and check if username or email is already taken
-if (!function_exists('_horde_hook_signup_preprocess')) {
- function _horde_hook_signup_preprocess($info)
+ function signup_preprocess($info)
{
if (isset($info['extra']['username'])) {
$info['extra']['username'] = Horde_String::lower($info['extra']['username']);
// Here we connect to the database and update folks user table
// with additional user data and send confirmation code to check his email
-if (!function_exists('_horde_hook_signup_addextra')) {
- function _horde_hook_signup_addextra($userID, $extra)
+ function signup_addextra($userID, $extra)
{
global $conf;
// If the user has a authentication cookie code. Compara it with one in DB
// and autologin the user.
-if (!function_exists('_horde_hook_post_pushapp')) {
- function _horde_hook_post_pushapp($app)
+ function pushapp()
{
if ($app != 'horde' ||
!isset($_COOKIE['folks_login_code']) ||
continue;
}
} else {
- $profile['count_' . $service] = Horde::callHook('_folks_hook_countService', array($service, $user), 'folks');
+ try {
+ $profile['count_' . $service] = Horde::callHook('countService', array($service, $user), 'folks');
+ } catch (Horde_Exception_HookNotSet $e) {}
if (empty($profile['count_' . $service])) {
continue;
}
}
- $profile['count_' . $service . '_list'] = Horde::callHook('_folks_hook_getService', array($service, $user), 'folks');
+ try {
+ $profile['count_' . $service . '_list'] = Horde::callHook('getService', array($service, $user), 'folks');
+ } catch (Horde_Exception_HookNotSet $e) {}
if (empty($profile['count_' . $service . '_list'])) {
$profile['count_' . $service] = 0;
}
if ($conf['login']['prelogin'] &&
Horde_Auth::getAuth() &&
($app = Horde_Util::getGet('app'))) {
- Horde::callHook('_folks_hook_prelogin', array($app), 'folks');
+ Horde::callHook('prelogin', array($app), 'folks');
}
/*
} else {
$comments_reason = _("Only authenticated users can post comments.");
if ($conf['hooks']['permsdenied']) {
- $comments_reason = Horde::callHook('_perms_hook_denied', array('folks'), 'horde', $comments_reason);
+ $comments_reason = Horde::callHook('perms_denied', array('folks'));
}
}
break;
tokens/signatures process contained in the original mail, etc.). If you
need to dynamically set the email address for each user (e.g. DSPAM),
this setting should be empty and you should look at the
- _imp_hook_spam_email hook instead."/>
+ spam_email hook instead."/>
<configstring name="program" required="false" desc="Should we report the spam
message via an external program (e.g. /usr/local/bin/spamassassin -r)? If you
include the placeholder %u in this string, it will be replaced with the
tokens/signatures process contained in the original mail, etc.). If you
need to dynamically set the email address for each user (e.g. DSPAM),
this setting should be empty and you should look at the
- _imp_hook_spam_email hook instead."/>
+ spam_email hook instead."/>
<configstring name="program" required="false" desc="Should we report the innocent
message via an external program (e.g. /usr/local/bin/spamassassin -k)? If you
include the placeholder %u in this string, it will be replaced with the
</configsection>
</configtab>
- <configtab name="hooks" desc="Custom Hooks">
- <configsection name="hooks">
- <configboolean name="postsent" required="false" desc="Should we
- run a custom function after sending a message? If so, make sure you define
- _imp_hook_postsent() in hooks.php. The hook will be used to do anything
- after a message has been sent successfully and all regular post-sending
- processing has been done. There is an example in
- hooks.php.dist.">false</configboolean>
- <configboolean name="signature" required="false" desc="Should we use a
- custom signature hook? If so, make sure you define _imp_hook_signature() in
- hooks.php. The hook will be used to dynamically set the signature when
- composing a message. There is an example in
- hooks.php.dist.">false</configboolean>
- <configboolean name="trailer" required="false" desc="Should we use a custom
- function to set the trailer text (if trailer text is appended to outgoing
- messages)? If so, make sure you define _imp_hook_trailer() in
- hooks.php. The function will be used to modify the trailer at runtime.
- There are examples in hooks.php.dist.">false</configboolean>
- <configboolean name="fetchmail_filter" required="false" desc="Should we use
- a custom function to filter mail retrieved with the Accounts/Fetchmail icon?
- If so, make sure you define _imp_hook_fetchmail_filter() in hooks.php.
- The function is used to filter mail for spam, viruses, or whatever else
- you set up in the function.">false</configboolean>
- <configboolean name="mbox_redirect" required="false" desc="Should we use
- a custom function to dynamically redirect the user based on what mailbox
- is opened? If so, make sure you define _imp_hook_mbox_redirect() in
- hooks.php.">false</configboolean>
- <configboolean name="mbox_icon" required="false" desc="Should we use
- a custom function to dynamically determine the icons shown for standard
- folders on the folder page? If so, make sure you define
- _imp_hook_mbox_icons() in hooks.php.">false</configboolean>
- <configboolean name="mailboxarray" required="false" desc="Should we run a
- custom function in which array elements can be added to use in the template
- file, while processing the message lists? If so, make sure you define
- _imp_hook_mailboxarray() in config/hooks.php.">false</configboolean>
- <configboolean name="mbox_readonly" required="false" desc="Should we use a
- custom function to dynamically determine whether a given folder is
- read-only? If so, make sure you define _imp_hook_mbox_readonly() in
- hooks.php.">false</configboolean>
- <configboolean name="disable_compose" required="false" desc="Should we use
- a custom function to dynamically determine whether message composition is
- disabled? If so, make sure you define _imp_hook_disable_compose() in
- hooks.php.">false</configboolean>
- <configboolean name="spam_email" required="false" desc="Should we use a
- custom function to dynamically generate the email address to send spam
- reporting emails to? If so, make sure you define _imp_hook_spam_email() in
- hooks.php.">false</configboolean>
- <configboolean name="msglist_flags" required="false" desc="Should we use
- a custom function to provide additional flags to messages in the mailbox
- message list? If so, make sure you define _imp_hook_msglist_flags() in
- hooks.php.">false</configboolean>
- <configboolean name="display_folder" required="false" desc="Should we use
- a custom function to dynamically determine if we show a specified IMAP
- mailbox in the folderlist ? If so, make sure you define
- _imp_hook_display_folder() in hooks.php.">false</configboolean>
- </configsection>
- </configtab>
-
<configtab name="other" desc="Other settings">
<configheader>Mail History</configheader>
<configsection name="maillog">
<configtab name="dimp" desc="Dynamic View (dimp) Options">
<configheader>Custom Hooks</configheader>
<configsection name="dimp">
- <configsection name="hooks">
- <configboolean name="previewview" required="false" desc="Should we
- run a custom function in which array elements can be modified, and
- javascript code be provided to dynamically update page elements in the
- preview pane? If so, make sure you define _imp_hook_dimp_previewview() in
- config/hooks.php. The sample documentation in that file can better explain
- what can be accomplished with this hook.">false</configboolean>
- <configboolean name="messageview" required="false" desc="Should we
- run a custom function in which array elements can be added to use in the
- template file, while displaying the message text? If so, make sure
- you define _imp_hook_dimp_messageview() in config/hooks.php. The elements
- will be available as template tags in the imp/templates/chunks/message.php
- template file.">false</configboolean>
- <configboolean name="addressformatting" required="false" desc="Should we
- run a custom function that is used to format email addresses in message
- headers? If so, make sure you define _imp_hook_dimp_addressformatting() in
- config/hooks.php.">false</configboolean>
- </configsection>
-
<configlist name="css_files" required="false" desc="A list of additional CSS
files to load from the imp/themes/ directory."/>
* $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:
+ * <pre>
+ * first: disk space used (in bytes)
+ * second: maximum disk space (in bytes)
+ * </pre>
+ */
+// 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'] = '<div class="foo">BAR</div>';
+// 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:
+ * <pre>
+ * 'address' - Full address
+ * 'display' - Display address
+ * 'host' - Host name
+ * 'inner' - Trimmed, bare address
+ * 'personal' - Personal string
+ * </pre>
+ *
+ * @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'] = '<div class="foo">BAR</div>';
-// 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'];
-// }
-// }
*
* 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.
*
* @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,
$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;
}
* @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)
$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);
}
}
* 'header' - An array containing the cleaned up 'to', 'cc', and 'bcc'
* header strings.
* </pre>
+ * @throws Horde_Exception
* @throws IMP_Compose_Exception
*/
public function recipientList($hdr, $exceed = true)
$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);
}
}
}
* </pre>
*
* @return array TODO
+ * @throws Horde_Exception
* @throws IMP_Compose_Exception
*/
protected function _createMimeMessage($to, $body, $charset,
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'])) {
}
$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;
* @param boolean $subscribe Subscribe to folder?
*
* @return boolean Whether or not the folder was successfully created.
+ * @throws Horde_Exception
*/
public function create($folder, $subscribe)
{
/* 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;
* 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;
}
+
+
}
}
* @param integer $ident The identity to retrieve the signature from.
*
* @return string The full signature.
+ * @throws Horde_Exception
*/
public function getSignature($ident = null)
{
}
}
- 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;
* @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?
* @param integer $attributes The mailbox's attributes.
*
* @return array See above format.
+ * @throws Horde_Exception
*/
protected function _makeElt($name, $attributes = 0)
{
$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']));
*/
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']])) {
*/
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);
* 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) {
* @param boolean $search Is this a search mbox?
*
* @return array TODO
+ * @throws Horde_Exception
*/
private function _getOverviewData($imp_mailbox, $folder, $msglist, $search)
{
);
/* 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(
}
/* 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;
}
}
$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'];
* 'replyTo' - The Reply-to addresses
* 'save_as' - The save link
* </pre>
+ * @throws Horde_Exception
*/
public function showMessage($args)
{
$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) {
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();
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']);
$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,
</case>
</configswitch>
</configsection>
-
- <configsection name="hooks">
- <configheader>Custom Hooks</configheader>
- <configboolean name="vacation_addresses" required="false" desc="Should we
- use a hook for vacation addresses? If so, make sure you define
- _ingo_hook_vacation_addresses() in horde/config/hooks.php. The hook will be
- used to provide a list of default email addresses for the vacation
- module.">false</configboolean>
- <configboolean name="vacation_only" required="false" desc="Should we use the
- hook only to provide the list of vacation addresses and don't show the
- addresses field to the users?">true</configboolean>
- </configsection>
</configuration>
*
* 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');
-// }
-// }
+}
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;
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;
}
}
/* 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));
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));
}
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])) {
$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);
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');
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;
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;
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'),
<?php
/**
- * Example hooks for Nag
+ * Nag Hooks configuration file.
+ *
+ * THE HOOKS PROVIDED IN THIS FILE ARE EXAMPLES ONLY. DO NOT ENABLE THEM
+ * BLINDLY IF YOU DO NOT KNOW WHAT YOU ARE DOING. YOU HAVE TO CUSTOMIZE THEM
+ * TO MATCH YOUR SPECIFIC NEEDS AND SYSTEM ENVIRONMENT.
+ *
+ * For more information please see the horde/config/hooks.php.dist file.
*
* $Id$
*/
-// if (!function_exists('_nag_hook_format_description')) {
-// function _nag_hook_format_description($text)
-// {
-// $text = preg_replace('/#(\d+)/', '<a href="http://bugs.horde.org/ticket/\1">\0</a>', $text);
-// $text = preg_replace('/(bug|ticket|request|enhancement|issue):\s*#?(\d+)/i', '<a href="http://bugs.horde.org/ticket/\1">\0</a>', $text);
+class Nag_Hooks
+{
+ /**
+ * TODO
+ */
+// function format_description($text)
+// {
+// $text = preg_replace('/#(\d+)/', '<a href="http://bugs.horde.org/ticket/\1">\0</a>', $text);
+// $text = preg_replace('/(bug|ticket|request|enhancement|issue):\s*#?(\d+)/i', '<a href="http://bugs.horde.org/ticket/\1">\0</a>', $text);
//
-// $text = preg_replace_callback('/\[\[note: ?(.*)\]\]/i', create_function('$m', 'return \'<a href="/horde/mnemo/notes/?q=\' . urlencode($m[1]) . \'">\' . htmlspecialchars($m[0]) . \'</a>\';'), $text);
-// $text = preg_replace_callback('/\[\[task: ?(.*)\]\]/i', create_function('$m', 'return \'<a href="/horde/nag/tasks/?q=\' . urlencode($m[1]) . \'">\' . htmlspecialchars($m[0]) . \'</a>\';'), $text);
+// $text = preg_replace_callback('/\[\[note: ?(.*)\]\]/i', create_function('$m', 'return \'<a href="/horde/mnemo/notes/?q=\' . urlencode($m[1]) . \'">\' . htmlspecialchars($m[0]) . \'</a>\';'), $text);
+// $text = preg_replace_callback('/\[\[task: ?(.*)\]\]/i', create_function('$m', 'return \'<a href="/horde/nag/tasks/?q=\' . urlencode($m[1]) . \'">\' . htmlspecialchars($m[0]) . \'</a>\';'), $text);
//
-// return $text;
-// }
-// }
+// return $text;
+// }
+
+
+ /**
+ * TODO
+ */
+// function description_help()
+// {
+// return '<p>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.</p>';
+// }
-// if (!function_exists('_nag_hook_description_help')) {
-// function _nag_hook_description_help()
-// {
-// return '<p>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.</p>';
-// }
-// }
+}
);
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');
$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;
$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) {
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;
+ }
}
/**
/* 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));
$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
+++ /dev/null
-<?php
-/**
- * Turba Hooks configuration file.
- *
- * THE HOOKS PROVIDED IN THIS FILE ARE EXAMPLES ONLY. DO NOT ENABLE THEM
- * BLINDLY IF YOU DO NOT KNOW WHAT YOU ARE DOING. YOU HAVE TO CUSTOMIZE THEM
- * TO MATCH YOUR SPECIFIC NEEDS AND SYSTEM ENVIRONMENT.
- *
- * For more information please see the horde/config/hooks.php.dist file.
- *
- * $Id$
- */
-
-// Here is an example _turba_hook_encode_password (and decode). encode is
-// called when we store a value; decode when we display it. Passwords should
-// be MD5 encoded, but not displayed.
-//
-// IMPORTANT: The last parameter in these examples (&$object) is only
-// passed by Turba 2.1 and later. If you are using Turba 2.0, then you
-// must remove the &$object parameter.
-
-// if (!function_exists('_turba_hook_encode_password')) {
-// function _turba_hook_encode_password($new_password, $old_password, &$contact)
-// {
-// if (is_null($new_password) || $new_password == '' ||
-// $new_password == '[Not Displayed]') {
-// return $old_password;
-// } else {
-// return md5($new_password);
-// }
-// }
-// function _turba_hook_decode_password($password, &$contact)
-// {
-// if (strstr($_SERVER['PHP_SELF'], 'editobject')) {
-// return null;
-// } else {
-// return '[Not Displayed]';
-// }
-// }
-// }
* 'contact_ownership' = false and the __owner field will be automatically
* populated with the current username.
*
- * To integrate with Horde_Share (requires Horde 3.2 or better) set use_shares
- * to true, and uncomment the IMSP Horde_Share hooks in horde/config/hooks.php.
+ * To integrate with Horde_Share, set use_shares to true and uncomment the
+ * IMSP Horde_Share hooks in horde/config/hooks.php.
*/
// Check that IMSP is configured in Horde but fall through if there is no
// configuration at all - in case we don't have at least a 3.0.6 Horde
$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, $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;
$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;
$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;
}