From: Michael M Slusarz Date: Mon, 23 Nov 2009 19:49:28 +0000 (-0700) Subject: Horde_Prefs:: has moved to git X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=857038183dd82899a0f703287defa6e2f0bf6647;p=horde.git Horde_Prefs:: has moved to git --- diff --git a/ansel/image.php b/ansel/image.php index 23e6a08c0..eb7390ecb 100644 --- a/ansel/image.php +++ b/ansel/image.php @@ -27,7 +27,7 @@ $date = Ansel::getDateParameter(); /* Are we watermarking the image? */ if ($watermark) { - $identity = Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (empty($name)) { $name = Horde_Auth::getAuth(); diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index df933c569..5c8d05f7b 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -709,13 +709,12 @@ class Ansel if ($owner == Horde_Auth::getAuth()) { $owner_title = _("My Galleries"); } elseif (!empty($GLOBALS['conf']['gallery']['customlabel'])) { - $uprefs = Prefs::singleton($GLOBALS['conf']['prefs']['driver'], + $uprefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'ansel', $owner, '', null, false); $fullname = $uprefs->getValue('grouptitle'); if (!$fullname) { - require_once 'Horde/Identity.php'; - $identity = Identity::singleton('none', $owner); + $identity = Horde_Prefs_Identity::singleton('none', $owner); $fullname = $identity->getValue('fullname'); if (!$fullname) { $fullname = $owner; diff --git a/ansel/lib/Form/Ecard.php b/ansel/lib/Form/Ecard.php index bf50f3f2f..7a46d6a86 100644 --- a/ansel/lib/Form/Ecard.php +++ b/ansel/lib/Form/Ecard.php @@ -23,8 +23,7 @@ class Ansel_Form_Ecard extends Horde_Form { if (empty($user)) { $this->addVariable(_("Use the following return address:"), 'ecard_retaddr', 'text', true); } else { - require_once 'Horde/Identity.php'; - $identity = Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $from_addr = $identity->getDefaultFromAddress(); $vars->set('ecard_retaddr', $from_addr); $this->addHidden('', 'ecard_retaddr', 'text', true); diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index d11ca9d9f..afd284524 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -407,9 +407,7 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical */ public function getOwner() { - require_once 'Horde/Identity.php'; - $identity = Identity::singleton('none', $this->data['share_owner']); - return $identity; + return Horde_Prefs_Identity::singleton('none', $this->data['share_owner']); } /** diff --git a/ansel/lib/Image.php b/ansel/lib/Image.php index 0e3d77555..234824896 100644 --- a/ansel/lib/Image.php +++ b/ansel/lib/Image.php @@ -873,8 +873,7 @@ class Ansel_Image } if (empty($watermark)) { - require_once 'Horde/Identity.php'; - $identity = Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (empty($name)) { $name = Horde_Auth::getAuth(); diff --git a/ansel/lib/Report.php b/ansel/lib/Report.php index 7a491733d..9fd0d8f9f 100644 --- a/ansel/lib/Report.php +++ b/ansel/lib/Report.php @@ -55,10 +55,7 @@ class Ansel_Report { */ function _getUserEmail($user = null) { - // Get user email - require_once 'Horde/Identity.php'; - $identity = Identity::singleton('none', $user); - return $identity->getValue('from_addr'); + return Horde_Prefs_Identity::singleton('none', $user)->getValue('from_addr'); } /** diff --git a/ansel/lib/View/List.php b/ansel/lib/View/List.php index d256a3533..155988a4c 100644 --- a/ansel/lib/View/List.php +++ b/ansel/lib/View/List.php @@ -129,12 +129,11 @@ class Ansel_View_List extends Ansel_View_Base if ($owner == Horde_Auth::getAuth() && empty($this->_params['api'])) { $list_title = _("My Galleries"); } elseif (!empty($GLOBALS['conf']['gallery']['customlabel'])) { - $uprefs = &Prefs::singleton($GLOBALS['conf']['prefs']['driver'], + $uprefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'ansel', $owner, '', null, false); $fullname = $uprefs->getValue('grouptitle'); if (!$fullname) { - require_once 'Horde/Identity.php'; - $identity = &Identity::singleton('none', $owner); + $identity = Horde_Prefs_Identity::singleton('none', $owner); $fullname = $identity->getValue('fullname'); if (!$fullname) { $fullname = $owner; diff --git a/ansel/rss.php b/ansel/rss.php index 86ee3f3fb..79ccd0944 100644 --- a/ansel/rss.php +++ b/ansel/rss.php @@ -139,8 +139,7 @@ if (empty($rss)) { if (isset($galleries) && count($galleries)) { $images = $ansel_storage->getRecentImages($galleries); if (!is_a($images, 'PEAR_Error') && count($images)) { - require_once 'Horde/Identity.php'; - $owner = Identity::singleton('none', $id); + $owner = Horde_Prefs_Identity::singleton('none', $id); $name = $owner->getValue('fullname'); $author = $owner->getValue('from_addr'); if (!$name) { diff --git a/ansel/templates/group/owner.inc b/ansel/templates/group/owner.inc index acc1b8994..7678f9bf0 100644 --- a/ansel/templates/group/owner.inc +++ b/ansel/templates/group/owner.inc @@ -3,7 +3,7 @@ if ($group == Horde_Auth::getAuth()) { $owner_title = _("My Galleries"); $custom = ''; } elseif (!empty($GLOBALS['conf']['gallery']['customlabel'])) { - $uprefs = &Prefs::singleton($GLOBALS['conf']['prefs']['driver'], + $uprefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'ansel', $group, '', null, false); $custom = $uprefs->getValue('grouptitle'); diff --git a/fima/lib/Fima.php b/fima/lib/Fima.php index 8b852f20d..6b46d6998 100644 --- a/fima/lib/Fima.php +++ b/fima/lib/Fima.php @@ -716,8 +716,7 @@ class Fima { /* If the user's personal ledger doesn't exist, then create it. */ if (!$GLOBALS['fima_shares']->exists(Horde_Auth::getAuth())) { - require_once 'Horde/Identity.php'; - $identity = &Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (trim($name) == '') { $name = Horde_Auth::getOriginalAuth(); diff --git a/fima/lib/Forms/DeleteLedger.php b/fima/lib/Forms/DeleteLedger.php index 3bff8a490..33afa756d 100644 --- a/fima/lib/Forms/DeleteLedger.php +++ b/fima/lib/Forms/DeleteLedger.php @@ -67,8 +67,7 @@ class Fima_DeleteLedgerForm extends Horde_Form { if (count(Fima::listLedgers(true)) == 0) { // If the default share doesn't exist then create it. if (!$GLOBALS['fima_shares']->exists(Horde_Auth::getAuth())) { - require_once 'Horde/Identity.php'; - $identity = &Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (trim($name) == '') { $name = Horde_Auth::getOriginalAuth(); diff --git a/folks/account/resetpassword.php b/folks/account/resetpassword.php index 685c6855d..9cb5d1446 100644 --- a/folks/account/resetpassword.php +++ b/folks/account/resetpassword.php @@ -50,7 +50,7 @@ $form->setButtons(_("Continue")); // Get user security pass $user = Horde_Util::getFormData('username'); if ($user) { - $u_prefs = Prefs::singleton($conf['prefs']['driver'], 'horde', Horde_Auth::convertUsername($user, true), '', null, false); + $u_prefs = Horde_Prefs::singleton($conf['prefs']['driver'], 'horde', Horde_Auth::convertUsername($user, true), '', null, false); $u_prefs->retrieve(); $answer = $u_prefs->getValue('security_answer'); $question = $u_prefs->getValue('security_question'); diff --git a/folks/lib/Folks.php b/folks/lib/Folks.php index 92bca09f2..bb9aca456 100644 --- a/folks/lib/Folks.php +++ b/folks/lib/Folks.php @@ -260,7 +260,7 @@ class Folks { static public function getUserEmail($user) { // We should always realy on registration data - // $prefs = Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'horde', Horde_Auth::convertUsername($user, true), '', null, false); + // $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'horde', Horde_Auth::convertUsername($user, true), '', null, false); // $prefs->retrieve(); // $email = $prefs->getValue('alternate_email') ? $prefs->getValue('alternate_email') : $prefs->getValue('from_addr'); diff --git a/folks/lib/Friends.php b/folks/lib/Friends.php index 0d6d5a883..a857a2bec 100644 --- a/folks/lib/Friends.php +++ b/folks/lib/Friends.php @@ -144,7 +144,7 @@ class Folks_Friends { return (boolean)$GLOBALS['prefs']->getValue('friends_approval'); } - $prefs = Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'folks', Horde_Auth::convertUsername($user, true), '', null, false); + $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'folks', Horde_Auth::convertUsername($user, true), '', null, false); $prefs->retrieve(); return (boolean)$prefs->getValue('friends_approval'); diff --git a/folks/lib/Friends/prefs.php b/folks/lib/Friends/prefs.php index 5076c64f7..c214cb2ad 100644 --- a/folks/lib/Friends/prefs.php +++ b/folks/lib/Friends/prefs.php @@ -104,7 +104,7 @@ class Folks_Friends_prefs extends Folks_Friends { $user = Horde_Auth::getAuth(); } - $u_prefs = Prefs::singleton($GLOBALS['conf']['prefs']['driver'], $GLOBALS['registry']->getApp(), $user); + $u_prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], $GLOBALS['registry']->getApp(), $user); $u_prefs->retrieve(); $list = $u_prefs->getValue($type); diff --git a/folks/lib/Notification.php b/folks/lib/Notification.php index 8e7fb4a81..ee7a72cc9 100644 --- a/folks/lib/Notification.php +++ b/folks/lib/Notification.php @@ -221,9 +221,7 @@ class Folks_Notification { */ protected function _getUserFromAddr($user) { - require_once 'Horde/Identity.php'; - $identity = Identity::singleton('none', $user); - return $identity->getValue('from_addr'); + return Horde_Prefs_Identity::singleton('none', $user)->getValue('from_addr'); } /** diff --git a/imp/acl.php b/imp/acl.php index d7d5b2494..10d3da024 100644 --- a/imp/acl.php +++ b/imp/acl.php @@ -126,20 +126,18 @@ if (empty($folder)) { $curr_acl = $ACLDriver->getACL($folder); $canEdit = $ACLDriver->canEdit($folder, Horde_Auth::getAuth()); -require_once 'Horde/Prefs/UI.php'; - extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); -Prefs_UI::generateHeader(null, $chunk); +Horde_Prefs_Ui::generateHeader(null, $chunk); /* Set up template. */ $t = new Horde_Template(); $t->setOption('gettext', true); $t->set('aclurl', Horde::applicationUrl('acl.php')); $t->set('forminput', Horde_Util::formInput()); -$t->set('aclnavcell', Horde_Util::bufferOutput(array('Prefs_UI', 'generateNavigationCell'), 'acl')); +$t->set('aclnavcell', Horde_Util::bufferOutput(array('Horde_Prefs_Ui', 'generateNavigationCell'), 'acl')); $t->set('changefolder', Horde::link('#', _("Change Folder"), 'smallheader', '', '', '', '', array('id' => 'changefolder'))); $t->set('sharedimg', Horde::img('shared.png', _("Change Folder"))); $t->set('options', IMP::flistSelect(array('selected' => $folder))); diff --git a/imp/attachment.php b/imp/attachment.php index 4a976c343..eb6062a75 100644 --- a/imp/attachment.php +++ b/imp/attachment.php @@ -71,11 +71,10 @@ if ($conf['compose']['link_attachments_notify']) { } else { /* Load $mail_user's preferences so that we can use their * locale information for the notification message. */ - include_once 'Horde/Prefs.php'; - $prefs = Prefs::singleton($conf['prefs']['driver'], 'horde', $mail_user); + $prefs = Horde_Prefs::singleton($conf['prefs']['driver'], 'horde', $mail_user); $prefs->retrieve(); - $mail_identity = Identity::singleton('none', $mail_user); + $mail_identity = Horde_Prefs_Identity::singleton('none', $mail_user); $mail_address = $mail_identity->getDefaultFromAddress(); /* Ignore missing addresses, which are returned as <>. */ diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index fe0fdd60a..04615b223 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -41,7 +41,7 @@ $action = Horde_Util::getFormData('action'); $get_sig = true; $msg = ''; -$identity = Identity::singleton(array('imp', 'imp')); +$identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); if (!$prefs->isLocked('default_identity')) { $identity_id = Horde_Util::getFormData('identity'); if (!is_null($identity_id)) { diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php index 1580712ba..c31dfa6e1 100644 --- a/imp/compose-mimp.php +++ b/imp/compose-mimp.php @@ -34,7 +34,7 @@ $msg = ''; $header = array(); /* Set the current identity. */ -$identity = Identity::singleton(array('imp', 'imp')); +$identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); if (!$prefs->isLocked('default_identity')) { $identity_id = Horde_Util::getFormData('identity'); if (!is_null($identity_id)) { diff --git a/imp/compose.php b/imp/compose.php index 8672de062..fea1ae2ba 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -68,7 +68,7 @@ $pgp_passphrase_dialog = $pgp_symmetric_passphrase_dialog = $showmenu = $smime_p $cursor_pos = $oldrtemode = $rtemode = $siglocation = null; /* Set the current identity. */ -$identity = Identity::singleton(array('imp', 'imp')); +$identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); if (!$prefs->isLocked('default_identity')) { $identity_id = Horde_Util::getFormData('identity'); if (!is_null($identity_id)) { diff --git a/imp/filterprefs.php b/imp/filterprefs.php index 86d81cf55..46a5dc8e2 100644 --- a/imp/filterprefs.php +++ b/imp/filterprefs.php @@ -11,7 +11,6 @@ require_once dirname(__FILE__) . '/lib/Application.php'; new IMP_Application(array('init' => true)); -require_once 'Horde/Prefs/UI.php'; extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); @@ -48,11 +47,11 @@ case 'update_prefs': $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); $group = 'filters'; -Prefs_UI::generateHeader(null, $chunk); +Horde_Prefs_Ui::generateHeader(null, $chunk); $t = new Horde_Template(); $t->setOption('gettext', true); -$t->set('navcell', Horde_Util::bufferOutput(array('Prefs_UI', 'generateNavigationCell'), 'filters')); +$t->set('navcell', Horde_Util::bufferOutput(array('Horde_Prefs_Ui', 'generateNavigationCell'), 'filters')); $t->set('prefsurl', Horde::getServiceLink('options', 'imp')); $t->set('return_text', _("Return to Options")); diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 4c9caa4c5..7f807f2be 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -355,7 +355,7 @@ class IMP_Compose $identity_id = null; $headers = $contents->getHeaderOb(); if (($fromaddr = Horde_Mime_Address::bareAddress($headers->getValue('from')))) { - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $identity_id = $identity->getMatchingIdentity($fromaddr); } @@ -1295,7 +1295,7 @@ class IMP_Compose if (in_array($type, array('reply_all', '*'))) { /* Filter out our own address from the addresses we reply to. */ - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $all_addrs = array_keys($identity->getAllFromAddresses(true)); /* Build the To: header. It is either 1) the Reply-To address @@ -1510,7 +1510,7 @@ class IMP_Compose * * @param Horde_Mime_Headers $h The headers object for the message. * - * @return mixed See Identity_imp::getMatchingIdentity(). + * @return mixed See Imp_Prefs_Identity::getMatchingIdentity(). */ protected function _getMatchingIdentity($h) { @@ -1519,7 +1519,7 @@ class IMP_Compose $msgAddresses[] = $h->getValue($val); } - $user_identity = Identity::singleton(array('imp', 'imp')); + $user_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); return $user_identity->getMatchingIdentity($msgAddresses); } diff --git a/imp/lib/Crypt/Pgp.php b/imp/lib/Crypt/Pgp.php index d77c76da4..bafb0408a 100644 --- a/imp/lib/Crypt/Pgp.php +++ b/imp/lib/Crypt/Pgp.php @@ -1,6 +1,6 @@ getPersonalPublicKey(); if (!empty($personal_pubkey) && $identity->hasAddress($address)) { $result = $personal_pubkey; diff --git a/imp/lib/Crypt/Smime.php b/imp/lib/Crypt/Smime.php index 856ea493b..fb1bc157d 100644 --- a/imp/lib/Crypt/Smime.php +++ b/imp/lib/Crypt/Smime.php @@ -176,7 +176,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime $key = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true)); } catch (Horde_Exception $e) { /* See if the address points to the user's public key. */ - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $personal_pubkey = $this->getPersonalPublicKey(); if (!empty($personal_pubkey) && $identity->hasAddress($address)) { return $personal_pubkey; diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 4fbe0a6c2..72bd57c8d 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -72,9 +72,6 @@ class IMP Horde::compressOutput(); } - // TODO: Remove once this can be autoloaded - require_once 'Horde/Identity.php'; - // Initialize global $imp_imap object. if (!isset($GLOBALS['imp_imap'])) { $GLOBALS['imp_imap'] = new IMP_Imap(); @@ -1138,7 +1135,7 @@ class IMP static public function isSpecialFolder($mbox) { /* Get the identities. */ - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); return (($mbox == self::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true)) || in_array($mbox, $identity->getAllSentmailFolders())); } diff --git a/imp/lib/Identity/imp.php b/imp/lib/Identity/imp.php deleted file mode 100644 index 42c0ed410..000000000 --- a/imp/lib/Identity/imp.php +++ /dev/null @@ -1,549 +0,0 @@ - - * @author Chuck Hagenbuch - * @package Horde_Identity - */ -class Identity_imp extends Identity -{ - /** - * Cached alias list. - * - * @var array - */ - protected $_aliases = array(); - - /** - * Cached from address list. - * - * @var array - */ - protected $_fromList = array(); - - /** - * Cached names list. - * - * @var array - */ - protected $_names = array(); - - /** - * Cached signature list. - * - * @var array - */ - protected $_signatures = array(); - - /** - * Reads all the user's identities from the prefs object or builds - * a new identity from the standard values given in prefs.php. - */ - public function __construct() - { - parent::__construct(); - $this->_properties = array_merge( - $this->_properties, - array('replyto_addr', 'alias_addr', 'tieto_addr', 'bcc_addr', - 'signature', 'sig_first', 'sig_dashes', 'save_sent_mail', - 'sent_mail_folder') - ); - } - - /** - * Verifies and sanitizes all identity properties. - * - * @param integer $identity The identity to verify. - * - * @return boolean|object True if the properties are valid or a PEAR_Error - * with an error description otherwise. - */ - public function verify($identity = null) - { - $result = parent::verify($identity); - if ($result instanceof PEAR_Error) { - return $result; - } - - if (!isset($identity)) { - $identity = $this->_default; - } - - /* Prepare email validator */ - require_once 'Horde/Form.php'; - $email = new Horde_Form_Type_email(); - $vars = new Horde_Variables(); - $var = new Horde_Form_Variable('', 'replyto_addr', $email, false); - - /* Verify From address. */ - if (!$email->isValid($var, $vars, $this->getValue('from_addr', $identity), $error_message)) { - return PEAR::raiseError($error_message); - } - - /* Verify Reply-to address. */ - if (!$email->isValid($var, $vars, $this->getValue('replyto_addr', $identity), $error_message)) { - return PEAR::raiseError($error_message); - } - - /* Clean up Alias, Tie-to, and BCC addresses. */ - foreach (array('alias_addr', 'tieto_addr', 'bcc_addr') as $val) { - $data = $this->getValue($val, $identity); - if (is_array($data)) { - $data = implode("\n", $data); - } - $data = trim($data); - $data = (empty($data)) ? array() : Horde_Array::prepareAddressList(preg_split("/[\n\r]+/", $data)); - - /* Validate addresses */ - foreach ($data as $address) { - if (!$email->isValid($var, $vars, $address, $error_message)) { - return PEAR::raiseError($error_message); - } - } - - $this->setValue($val, $data, $identity); - } - - return true; - } - - /** - * Returns a complete From: header based on all relevant factors (fullname, - * from address, input fields, locks etc.) - * - * @param integer $ident The identity to retrieve the values from. - * @param string $from_address A default from address to use if no - * identity is selected and the from_addr - * preference is locked. - * - * @return string A full From: header in the format - * 'Fullname '. - * @throws Horde_Exception - */ - public function getFromLine($ident = null, $from_address = '') - { - static $froms = array(); - - if (isset($froms[$ident])) { - return $froms[$ident]; - } - - if (!isset($ident)) { - $address = $from_address; - } - - if (empty($address) || $this->_prefs->isLocked('from_addr')) { - $address = $this->getFromAddress($ident); - $name = $this->getFullname($ident); - } - - try { - $ob = Horde_Mime_Address::parseAddressList($address, array('defserver' => $_SESSION['imp']['maildomain'])); - } catch (Horde_Mime_Exception $e) { - throw new Horde_Exception (_("Your From address is not a valid email address. This can be fixed in your Personal Information options page.")); - } - - if (empty($name)) { - if (!empty($ob[0]['personal'])) { - $name = $ob[0]['personal']; - } else { - $name = $this->getFullname($ident); - } - } - - $from = Horde_Mime_Address::writeAddress($ob[0]['mailbox'], $ob[0]['host'], $name); - - $froms[$ident] = $from; - return $from; - } - - /** - * Returns an array with From: headers from all identities - * - * @return array The From: headers from all identities - */ - public function getAllFromLines() - { - foreach (array_keys($this->_identities) as $ident) { - $list[$ident] = $this->getFromAddress($ident); - } - return $list; - } - - /** - * Returns an array with the necessary values for the identity select - * box in the IMP compose window. - * - * @return array The array with the necessary strings - */ - public function getSelectList() - { - $ids = $this->getAll('id'); - foreach ($ids as $key => $id) { - $list[$key] = $this->getFromAddress($key) . ' (' . $id . ')'; - } - return $list; - } - - /** - * Returns true if the given address belongs to one of the identities. - * This function will search aliases for an identity automatically. - * - * @param string $address The address to search for in the identities. - * - * @return boolean True if the address was found. - */ - public function hasAddress($address) - { - static $list; - - $address = Horde_String::lower($address); - if (!isset($list)) { - $list = $this->getAllFromAddresses(true); - } - - return isset($list[$address]); - } - - /** - * Returns the from address based on the chosen identity. If no - * address can be found it is built from the current user name and - * the specified maildomain. - * - * @param integer $ident The identity to retrieve the address from. - * - * @return string A valid from address. - */ - public function getFromAddress($ident = null) - { - if (!empty($this->_fromList[$ident])) { - return $this->_fromList[$ident]; - } - - $val = $this->getValue('from_addr', $ident); - if (empty($val)) { - $val = $GLOBALS['imp_imap']->ob()->getParam('username'); - } - - if (!strstr($val, '@')) { - $val .= '@' . $_SESSION['imp']['maildomain']; - } - - $this->_fromList[$ident] = $val; - - return $val; - } - - /** - * Returns all aliases based on the chosen identity. - * - * @param integer $ident The identity to retrieve the aliases from. - * - * @return array Aliases for the identity. - */ - public function getAliasAddress($ident) - { - if (empty($this->_aliases[$ident])) { - $this->_aliases[$ident] = @array_merge($this->getValue('alias_addr', $ident), - array($this->getValue('replyto_addr', $ident))); - } - - return $this->_aliases[$ident]; - } - - /** - * Returns an array with all identities' from addresses. - * - * @param boolean $alias Include aliases? - * - * @return array The array with - * KEY - address - * VAL - identity number - */ - public function getAllFromAddresses($alias = false) - { - $list = array(); - - foreach ($this->_identitiesWithDefaultLast() as $key => $identity) { - /* Get From Addresses. */ - $list[Horde_String::lower($this->getFromAddress($key))] = $key; - - /* Get Aliases. */ - if ($alias) { - $addrs = $this->getAliasAddress($key); - if (!empty($addrs)) { - foreach (array_filter($addrs) as $val) { - $list[Horde_String::lower($val)] = $key; - } - } - } - } - - return $list; - } - - /** - * Get all 'tie to' address/identity pairs. - * - * @return array The array with - * KEY - address - * VAL - identity number - */ - public function getAllTieAddresses() - { - $list = array(); - - foreach ($this->_identitiesWithDefaultLast() as $key => $identity) { - $tieaddr = $this->getValue('tieto_addr', $key); - if (!empty($tieaddr)) { - foreach ($tieaddr as $val) { - $list[$val] = $key; - } - } - } - - return $list; - } - - /** - * Returns the list of identities with the default identity positioned - * last. - * - * @return array The identities list with the default identity last. - */ - protected function _identitiesWithDefaultLast() - { - $ids = $this->_identities; - $default = $this->getDefault(); - $tmp = $ids[$default]; - unset($ids[$default]); - $ids[$default] = $tmp; - return $ids; - } - - /** - * Returns the BCC addresses for a given identity. - * - * @param integer $ident The identity to retrieve the Bcc addresses from. - * - * @return array The array of objects (IMAP addresses). - */ - public function getBccAddresses($ident = null) - { - $bcc = $this->getValue('bcc_addr', $ident); - if (empty($bcc)) { - return array(); - } else { - if (!is_array($bcc)) { - $bcc = array($bcc); - } - try { - return Horde_Mime_Address::parseAddressList(implode(', ', $bcc)); - } catch (Horde_Mime_Exception $e) { - return array(); - } - } - } - - /** - * Returns the identity's id that matches the passed addresses. - * - * @param mixed $addresses Either an array or a single string or a - * comma-separated list of email addresses. - * @param boolean $search_ties Search for a matching identity in tied - * addresses too? - * - * @return integer The id of the first identity that from or alias - * addresses match (one of) the passed addresses or - * null if none matches. - */ - public function getMatchingIdentity($addresses, $search_ties = true) - { - static $tie_addresses, $own_addresses; - - if (!isset($tie_addresses)) { - $tie_addresses = $this->getAllTieAddresses(); - $own_addresses = $this->getAllFromAddresses(true); - } - - /* Normalize address list. */ - if (is_array($addresses)) { - $addresses = array_filter($addresses); - } else { - $addresses = array($addresses); - } - - try { - $addr_list = Horde_Mime_Address::parseAddressList(implode(', ', $addresses)); - } catch (Horde_Mime_Exception $e) { - return null; - } - - foreach ($addr_list as $address) { - if (empty($address['mailbox'])) { - continue; - } - $find_address = $address['mailbox']; - if (!empty($address['host'])) { - $find_address .= '@' . $address['host']; - } - $find_address = Horde_String::lower($find_address); - - /* Search 'tieto' addresses first. */ - /* Check for this address explicitly. */ - if ($search_ties && isset($tie_addresses[$find_address])) { - return $tie_addresses[$find_address]; - } - - /* If we didn't find the address, check for the domain. */ - if (!empty($address['host'])) { - $host = '@' . $address['host']; - if ($search_ties && - isset($tie_addresses[$host]) && - ($host != '@')) { - return $tie_addresses[$host]; - } - } - - /* Next, search all from addresses. */ - if (isset($own_addresses[$find_address])) { - return $own_addresses[$find_address]; - } - } - - return null; - } - - /** - * Returns the user's full name. - * - * @param integer $ident The identity to retrieve the name from. - * - * @return string The user's full name. - */ - public function getFullname($ident = null) - { - if (isset($this->_names[$ident])) { - return $this->_names[$ident]; - } - - $this->_names[$ident] = $this->getValue('fullname', $ident); - - return $this->_names[$ident]; - } - - /** - * Returns the full signature based on the current settings for the - * signature itself, the dashes and the position. - * - * @param integer $ident The identity to retrieve the signature from. - * - * @return string The full signature. - * @throws Horde_Exception - */ - public function getSignature($ident = null) - { - if (isset($this->_signatures[$ident])) { - return $this->_signatures[$ident]; - } - - $val = $this->getValue('signature', $ident); - if (!empty($val)) { - $sig_first = $this->getValue('sig_first', $ident); - $sig_dashes = $this->getValue('sig_dashes', $ident); - $val = str_replace("\r\n", "\n", $val); - if ($sig_dashes) { - $val = "-- \n$val"; - } - if (isset($sig_first) && $sig_first) { - $val = "\n" . $val . "\n\n\n"; - } else { - $val = "\n" . $val; - } - } - - try { - $val = Horde::callHook('prefs_hook_signature', array($val), 'imp'); - } catch (Horde_Exception_HookNotSet $e) {} - - $this->_signatures[$ident] = $val; - - return $val; - } - - /** - * Returns an array with the signatures from all identities - * - * @return array The array with all the signatures. - */ - public function getAllSignatures() - { - static $list; - - if (isset($list)) { - return $list; - } - - foreach ($this->_identities as $key => $identity) { - $list[$key] = $this->getSignature($key); - } - - return $list; - } - - /** - * @see Identity::getValue() - */ - public function getValue($key, $identity = null) - { - if ($key == 'sent_mail_folder') { - $folder = parent::getValue('sent_mail_folder', $identity); - return strlen($folder) ? IMP::folderPref($folder, true) : ''; - } - return parent::getValue($key, $identity); - } - - /** - * Returns an array with the sent-mail folder names from all the - * identities. - * - * @return array The array with the folder names. - */ - public function getAllSentmailFolders() - { - $list = array(); - foreach ($this->_identities as $key => $identity) { - if ($folder = $this->getValue('sent_mail_folder', $key)) { - $list[$folder] = 1; - } - } - - /* Get rid of duplicates and empty folders. */ - return array_filter(array_keys($list)); - } - - /** - * Returns true if the mail should be saved and the user is allowed to. - * - * @param integer $ident The identity to retrieve the setting from. - * - * @return boolean True if the sent mail should be saved. - */ - public function saveSentmail($ident = null) - { - if (!$GLOBALS['conf']['user']['allow_folders']) { - return false; - } - - return $this->getValue('save_sent_mail', $ident); - } - -} diff --git a/imp/lib/Imap/Flags.php b/imp/lib/Imap/Flags.php index 1106edb91..40f0919ac 100644 --- a/imp/lib/Imap/Flags.php +++ b/imp/lib/Imap/Flags.php @@ -259,7 +259,7 @@ class IMP_Imap_Flags if (isset($options['personal'])) { if (is_array($options['personal'])) { - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); foreach ($options['personal'] as $val) { if ($identity->hasAddress($val['inner'])) { $process['personal'] = $f['personal']; diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index ce4b61b5b..54641fed0 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -1801,7 +1801,7 @@ class IMP_Imap_Tree } /* Initialize the user's identities. */ - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $this->_eltCache = array( 'trash' => IMP::folderPref($GLOBALS['prefs']->getValue('trash_folder'), true), diff --git a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php index a2ac05376..506bfa896 100644 --- a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php +++ b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php @@ -36,7 +36,7 @@ class IMP_LoginTasks_Task_DeleteSentmailMonthly extends Horde_LoginTasks_Task /* Get list of all folders, parse through and get the list of all old sent-mail folders. Then sort this array according to the date. */ - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $imp_folder = IMP_Folder::singleton(); $sent_mail_folders = $identity->getAllSentmailFolders(); diff --git a/imp/lib/LoginTasks/Task/PurgeSentmail.php b/imp/lib/LoginTasks/Task/PurgeSentmail.php index 01aafea8a..8eeea7c62 100644 --- a/imp/lib/LoginTasks/Task/PurgeSentmail.php +++ b/imp/lib/LoginTasks/Task/PurgeSentmail.php @@ -100,7 +100,7 @@ class IMP_LoginTasks_Task_PurgeSentmail extends Horde_LoginTasks_Task */ protected function _getFolders() { - return Identity::singleton(array('imp', 'imp'))->getAllSentmailfolders(); + return Horde_Prefs_Identity::singleton(array('imp', 'imp'))->getAllSentmailfolders(); } } diff --git a/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php index 47e243e8d..0e73e7870 100644 --- a/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php +++ b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php @@ -35,7 +35,7 @@ class IMP_LoginTasks_Task_RenameSentmailMonthly extends Horde_LoginTasks_Task $success = true; - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $imp_folder = IMP_Folder::singleton(); foreach ($identity->getAllSentmailfolders() as $sent_folder) { @@ -68,7 +68,7 @@ class IMP_LoginTasks_Task_RenameSentmailMonthly extends Horde_LoginTasks_Task { IMP::initialize(); - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $new_folders = $old_folders = array(); foreach ($identity->getAllSentmailfolders() as $folder) { diff --git a/imp/lib/Mime/Viewer/Itip.php b/imp/lib/Mime/Viewer/Itip.php index 2df4ca2e2..f972095b4 100644 --- a/imp/lib/Mime/Viewer/Itip.php +++ b/imp/lib/Mime/Viewer/Itip.php @@ -262,7 +262,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver $vEvent_reply->setAttribute('ORGANIZER', $vEvent->getAttribute('ORGANIZER'), array_pop($organizer)); // Find out who we are and update status. - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $attendees = $vEvent->getAttribute('ATTENDEE'); if (!is_array($attendees)) { $attendees = array($attendees); @@ -399,7 +399,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver array('startStamp' => $startStamp, 'endStamp' => $endStamp)); // Find out who we are and update status. - $identity = Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $email = $identity->getFromAddress(); // Build the reply. @@ -632,7 +632,7 @@ class IMP_Horde_Mime_Viewer_Itip extends Horde_Mime_Viewer_Driver // Check that you are one of the attendees here. $is_attendee = false; if (!($attendees instanceof PEAR_Error) && !empty($attendees)) { - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); for ($i = 0, $c = count($attendees); $i < $c; ++$i) { $attendee = parse_url($attendees[$i]); if (!empty($attendee['path']) && diff --git a/imp/lib/Prefs/Identity.php b/imp/lib/Prefs/Identity.php new file mode 100644 index 000000000..8c131670a --- /dev/null +++ b/imp/lib/Prefs/Identity.php @@ -0,0 +1,550 @@ + + * @author Chuck Hagenbuch + * @category IMP + * @package Horde_Prefs + */ +class Imp_Prefs_Identity extends Horde_Prefs_Identity +{ + /** + * Cached alias list. + * + * @var array + */ + protected $_aliases = array(); + + /** + * Cached from address list. + * + * @var array + */ + protected $_fromList = array(); + + /** + * Cached names list. + * + * @var array + */ + protected $_names = array(); + + /** + * Cached signature list. + * + * @var array + */ + protected $_signatures = array(); + + /** + * Reads all the user's identities from the prefs object or builds + * a new identity from the standard values given in prefs.php. + */ + public function __construct() + { + parent::__construct(); + $this->_properties = array_merge( + $this->_properties, + array('replyto_addr', 'alias_addr', 'tieto_addr', 'bcc_addr', + 'signature', 'sig_first', 'sig_dashes', 'save_sent_mail', + 'sent_mail_folder') + ); + } + + /** + * Verifies and sanitizes all identity properties. + * + * @param integer $identity The identity to verify. + * + * @return boolean|object True if the properties are valid or a PEAR_Error + * with an error description otherwise. + */ + public function verify($identity = null) + { + $result = parent::verify($identity); + if ($result instanceof PEAR_Error) { + return $result; + } + + if (!isset($identity)) { + $identity = $this->_default; + } + + /* Prepare email validator */ + require_once 'Horde/Form.php'; + $email = new Horde_Form_Type_email(); + $vars = new Horde_Variables(); + $var = new Horde_Form_Variable('', 'replyto_addr', $email, false); + + /* Verify From address. */ + if (!$email->isValid($var, $vars, $this->getValue('from_addr', $identity), $error_message)) { + return PEAR::raiseError($error_message); + } + + /* Verify Reply-to address. */ + if (!$email->isValid($var, $vars, $this->getValue('replyto_addr', $identity), $error_message)) { + return PEAR::raiseError($error_message); + } + + /* Clean up Alias, Tie-to, and BCC addresses. */ + foreach (array('alias_addr', 'tieto_addr', 'bcc_addr') as $val) { + $data = $this->getValue($val, $identity); + if (is_array($data)) { + $data = implode("\n", $data); + } + $data = trim($data); + $data = (empty($data)) ? array() : Horde_Array::prepareAddressList(preg_split("/[\n\r]+/", $data)); + + /* Validate addresses */ + foreach ($data as $address) { + if (!$email->isValid($var, $vars, $address, $error_message)) { + return PEAR::raiseError($error_message); + } + } + + $this->setValue($val, $data, $identity); + } + + return true; + } + + /** + * Returns a complete From: header based on all relevant factors (fullname, + * from address, input fields, locks etc.) + * + * @param integer $ident The identity to retrieve the values from. + * @param string $from_address A default from address to use if no + * identity is selected and the from_addr + * preference is locked. + * + * @return string A full From: header in the format + * 'Fullname '. + * @throws Horde_Exception + */ + public function getFromLine($ident = null, $from_address = '') + { + static $froms = array(); + + if (isset($froms[$ident])) { + return $froms[$ident]; + } + + if (!isset($ident)) { + $address = $from_address; + } + + if (empty($address) || $this->_prefs->isLocked('from_addr')) { + $address = $this->getFromAddress($ident); + $name = $this->getFullname($ident); + } + + try { + $ob = Horde_Mime_Address::parseAddressList($address, array('defserver' => $_SESSION['imp']['maildomain'])); + } catch (Horde_Mime_Exception $e) { + throw new Horde_Exception (_("Your From address is not a valid email address. This can be fixed in your Personal Information options page.")); + } + + if (empty($name)) { + if (!empty($ob[0]['personal'])) { + $name = $ob[0]['personal']; + } else { + $name = $this->getFullname($ident); + } + } + + $from = Horde_Mime_Address::writeAddress($ob[0]['mailbox'], $ob[0]['host'], $name); + + $froms[$ident] = $from; + return $from; + } + + /** + * Returns an array with From: headers from all identities + * + * @return array The From: headers from all identities + */ + public function getAllFromLines() + { + foreach (array_keys($this->_identities) as $ident) { + $list[$ident] = $this->getFromAddress($ident); + } + return $list; + } + + /** + * Returns an array with the necessary values for the identity select + * box in the IMP compose window. + * + * @return array The array with the necessary strings + */ + public function getSelectList() + { + $ids = $this->getAll('id'); + foreach ($ids as $key => $id) { + $list[$key] = $this->getFromAddress($key) . ' (' . $id . ')'; + } + return $list; + } + + /** + * Returns true if the given address belongs to one of the identities. + * This function will search aliases for an identity automatically. + * + * @param string $address The address to search for in the identities. + * + * @return boolean True if the address was found. + */ + public function hasAddress($address) + { + static $list; + + $address = Horde_String::lower($address); + if (!isset($list)) { + $list = $this->getAllFromAddresses(true); + } + + return isset($list[$address]); + } + + /** + * Returns the from address based on the chosen identity. If no + * address can be found it is built from the current user name and + * the specified maildomain. + * + * @param integer $ident The identity to retrieve the address from. + * + * @return string A valid from address. + */ + public function getFromAddress($ident = null) + { + if (!empty($this->_fromList[$ident])) { + return $this->_fromList[$ident]; + } + + $val = $this->getValue('from_addr', $ident); + if (empty($val)) { + $val = $GLOBALS['imp_imap']->ob()->getParam('username'); + } + + if (!strstr($val, '@')) { + $val .= '@' . $_SESSION['imp']['maildomain']; + } + + $this->_fromList[$ident] = $val; + + return $val; + } + + /** + * Returns all aliases based on the chosen identity. + * + * @param integer $ident The identity to retrieve the aliases from. + * + * @return array Aliases for the identity. + */ + public function getAliasAddress($ident) + { + if (empty($this->_aliases[$ident])) { + $this->_aliases[$ident] = @array_merge($this->getValue('alias_addr', $ident), + array($this->getValue('replyto_addr', $ident))); + } + + return $this->_aliases[$ident]; + } + + /** + * Returns an array with all identities' from addresses. + * + * @param boolean $alias Include aliases? + * + * @return array The array with + * KEY - address + * VAL - identity number + */ + public function getAllFromAddresses($alias = false) + { + $list = array(); + + foreach ($this->_identitiesWithDefaultLast() as $key => $identity) { + /* Get From Addresses. */ + $list[Horde_String::lower($this->getFromAddress($key))] = $key; + + /* Get Aliases. */ + if ($alias) { + $addrs = $this->getAliasAddress($key); + if (!empty($addrs)) { + foreach (array_filter($addrs) as $val) { + $list[Horde_String::lower($val)] = $key; + } + } + } + } + + return $list; + } + + /** + * Get all 'tie to' address/identity pairs. + * + * @return array The array with + * KEY - address + * VAL - identity number + */ + public function getAllTieAddresses() + { + $list = array(); + + foreach ($this->_identitiesWithDefaultLast() as $key => $identity) { + $tieaddr = $this->getValue('tieto_addr', $key); + if (!empty($tieaddr)) { + foreach ($tieaddr as $val) { + $list[$val] = $key; + } + } + } + + return $list; + } + + /** + * Returns the list of identities with the default identity positioned + * last. + * + * @return array The identities list with the default identity last. + */ + protected function _identitiesWithDefaultLast() + { + $ids = $this->_identities; + $default = $this->getDefault(); + $tmp = $ids[$default]; + unset($ids[$default]); + $ids[$default] = $tmp; + return $ids; + } + + /** + * Returns the BCC addresses for a given identity. + * + * @param integer $ident The identity to retrieve the Bcc addresses from. + * + * @return array The array of objects (IMAP addresses). + */ + public function getBccAddresses($ident = null) + { + $bcc = $this->getValue('bcc_addr', $ident); + if (empty($bcc)) { + return array(); + } else { + if (!is_array($bcc)) { + $bcc = array($bcc); + } + try { + return Horde_Mime_Address::parseAddressList(implode(', ', $bcc)); + } catch (Horde_Mime_Exception $e) { + return array(); + } + } + } + + /** + * Returns the identity's id that matches the passed addresses. + * + * @param mixed $addresses Either an array or a single string or a + * comma-separated list of email addresses. + * @param boolean $search_ties Search for a matching identity in tied + * addresses too? + * + * @return integer The id of the first identity that from or alias + * addresses match (one of) the passed addresses or + * null if none matches. + */ + public function getMatchingIdentity($addresses, $search_ties = true) + { + static $tie_addresses, $own_addresses; + + if (!isset($tie_addresses)) { + $tie_addresses = $this->getAllTieAddresses(); + $own_addresses = $this->getAllFromAddresses(true); + } + + /* Normalize address list. */ + if (is_array($addresses)) { + $addresses = array_filter($addresses); + } else { + $addresses = array($addresses); + } + + try { + $addr_list = Horde_Mime_Address::parseAddressList(implode(', ', $addresses)); + } catch (Horde_Mime_Exception $e) { + return null; + } + + foreach ($addr_list as $address) { + if (empty($address['mailbox'])) { + continue; + } + $find_address = $address['mailbox']; + if (!empty($address['host'])) { + $find_address .= '@' . $address['host']; + } + $find_address = Horde_String::lower($find_address); + + /* Search 'tieto' addresses first. */ + /* Check for this address explicitly. */ + if ($search_ties && isset($tie_addresses[$find_address])) { + return $tie_addresses[$find_address]; + } + + /* If we didn't find the address, check for the domain. */ + if (!empty($address['host'])) { + $host = '@' . $address['host']; + if ($search_ties && + isset($tie_addresses[$host]) && + ($host != '@')) { + return $tie_addresses[$host]; + } + } + + /* Next, search all from addresses. */ + if (isset($own_addresses[$find_address])) { + return $own_addresses[$find_address]; + } + } + + return null; + } + + /** + * Returns the user's full name. + * + * @param integer $ident The identity to retrieve the name from. + * + * @return string The user's full name. + */ + public function getFullname($ident = null) + { + if (isset($this->_names[$ident])) { + return $this->_names[$ident]; + } + + $this->_names[$ident] = $this->getValue('fullname', $ident); + + return $this->_names[$ident]; + } + + /** + * Returns the full signature based on the current settings for the + * signature itself, the dashes and the position. + * + * @param integer $ident The identity to retrieve the signature from. + * + * @return string The full signature. + * @throws Horde_Exception + */ + public function getSignature($ident = null) + { + if (isset($this->_signatures[$ident])) { + return $this->_signatures[$ident]; + } + + $val = $this->getValue('signature', $ident); + if (!empty($val)) { + $sig_first = $this->getValue('sig_first', $ident); + $sig_dashes = $this->getValue('sig_dashes', $ident); + $val = str_replace("\r\n", "\n", $val); + if ($sig_dashes) { + $val = "-- \n$val"; + } + if (isset($sig_first) && $sig_first) { + $val = "\n" . $val . "\n\n\n"; + } else { + $val = "\n" . $val; + } + } + + try { + $val = Horde::callHook('prefs_hook_signature', array($val), 'imp'); + } catch (Horde_Exception_HookNotSet $e) {} + + $this->_signatures[$ident] = $val; + + return $val; + } + + /** + * Returns an array with the signatures from all identities + * + * @return array The array with all the signatures. + */ + public function getAllSignatures() + { + static $list; + + if (isset($list)) { + return $list; + } + + foreach ($this->_identities as $key => $identity) { + $list[$key] = $this->getSignature($key); + } + + return $list; + } + + /** + * @see Horde_Prefs_Identity::getValue() + */ + public function getValue($key, $identity = null) + { + if ($key == 'sent_mail_folder') { + $folder = parent::getValue('sent_mail_folder', $identity); + return strlen($folder) ? IMP::folderPref($folder, true) : ''; + } + return parent::getValue($key, $identity); + } + + /** + * Returns an array with the sent-mail folder names from all the + * identities. + * + * @return array The array with the folder names. + */ + public function getAllSentmailFolders() + { + $list = array(); + foreach ($this->_identities as $key => $identity) { + if ($folder = $this->getValue('sent_mail_folder', $key)) { + $list[$folder] = 1; + } + } + + /* Get rid of duplicates and empty folders. */ + return array_filter(array_keys($list)); + } + + /** + * Returns true if the mail should be saved and the user is allowed to. + * + * @param integer $ident The identity to retrieve the setting from. + * + * @return boolean True if the sent mail should be saved. + */ + public function saveSentmail($ident = null) + { + if (!$GLOBALS['conf']['user']['allow_folders']) { + return false; + } + + return $this->getValue('save_sent_mail', $ident); + } + +} diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index 5933ea68c..9f9ddfe5b 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -110,7 +110,7 @@ class IMP_Spam if (!isset($imp_compose)) { $imp_compose = IMP_Compose::singleton(); - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); try { $from_line = $identity->getFromLine(); } catch (Horde_Exception $e) { diff --git a/imp/lib/UI/Compose.php b/imp/lib/UI/Compose.php index d19ca6984..516a6fbbc 100644 --- a/imp/lib/UI/Compose.php +++ b/imp/lib/UI/Compose.php @@ -45,7 +45,7 @@ class IMP_UI_Compose } $recipients = implode(', ', $recip['list']); - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Preffs_Identity::singleton(array('imp', 'imp')); $from_addr = $identity->getFromAddress(); $headers = $contents->getHeaderOb(); diff --git a/imp/lib/UI/Mailbox.php b/imp/lib/UI/Mailbox.php index 22f489deb..556b283aa 100644 --- a/imp/lib/UI/Mailbox.php +++ b/imp/lib/UI/Mailbox.php @@ -78,7 +78,7 @@ class IMP_UI_Mailbox $ret['from'] = _("Invalid Address"); $ret['error'] = true; } else { - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); if ($identity->hasAddress($from['inner'])) { /* This message was sent by one of the user's identity * addresses - show To: information instead. */ diff --git a/imp/lib/Views/Compose.php b/imp/lib/Views/Compose.php index e64f350f4..ce8105e03 100644 --- a/imp/lib/Views/Compose.php +++ b/imp/lib/Views/Compose.php @@ -37,7 +37,7 @@ class IMP_Views_Compose ); /* Load Identity. */ - $identity = Identity::singleton(array('imp', 'imp')); + $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $selected_identity = $identity->getDefault(); /* Get user identities. */ diff --git a/imp/message-mimp.php b/imp/message-mimp.php index 5b015efd1..551140876 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -162,7 +162,7 @@ if (($actionID == 'c') && !is_null($atc_id)) { } /* Create the Identity object. */ -$user_identity = Identity::singleton(array('imp', 'imp')); +$user_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); /* Develop the list of headers to display. */ $basic_headers = $imp_ui->basicHeaders(); diff --git a/imp/message.php b/imp/message.php index 392c59f82..6b9dc72e6 100644 --- a/imp/message.php +++ b/imp/message.php @@ -44,7 +44,7 @@ $imp_message = IMP_Message::singleton(); Horde_Nls::setTimeZone(); /* Initialize the user's identities. */ -$user_identity = Identity::singleton(array('imp', 'imp')); +$user_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); /* Run through action handlers. */ $actionID = Horde_Util::getFormData('actionID'); diff --git a/imp/pgp.php b/imp/pgp.php index fd6426695..b6a3547f1 100644 --- a/imp/pgp.php +++ b/imp/pgp.php @@ -304,10 +304,9 @@ try { extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); -require_once 'Horde/Prefs/UI.php'; $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); -Prefs_UI::generateHeader('pgp', $chunk); +Horde_Prefs_Ui::generateHeader('pgp', $chunk); /* If PGP preference not active, do NOT show PGP Admin screen. */ $t = new Horde_Template(); @@ -376,7 +375,7 @@ if ($prefs->getValue('use_pgp')) { $t->set('deletekeypair', addslashes(_("Are you sure you want to delete your keypair? (This is NOT recommended!)"))); $t->set('personalkey-delete-help', Horde_Help::link('imp', 'pgp-personalkey-delete')); } else { - $imp_identity = Identity::singleton(array('imp', 'imp')); + $imp_identity = Horde_Prefs_Identity::singleton(array('imp', 'imp')); $t->set('fullname', $imp_identity->getFullname()); $t->set('personalkey-create-name-help', Horde_Help::link('imp', 'pgp-personalkey-create-name')); $t->set('personalkey-create-comment-help', Horde_Help::link('imp', 'pgp-personalkey-create-comment')); diff --git a/imp/smime.php b/imp/smime.php index dde17cb94..53ff52593 100644 --- a/imp/smime.php +++ b/imp/smime.php @@ -223,10 +223,9 @@ try { extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'imp')); -require_once 'Horde/Prefs/UI.php'; $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); -Prefs_UI::generateHeader('smime', $chunk); +Horde_Prefs_Ui::generateHeader('smime', $chunk); $selfURL = Horde::applicationUrl('smime.php'); diff --git a/imp/stationery.php b/imp/stationery.php index 3d894011a..a7bbb01bd 100644 --- a/imp/stationery.php +++ b/imp/stationery.php @@ -11,7 +11,6 @@ require_once dirname(__FILE__) . '/lib/Application.php'; new IMP_Application(array('init' => array('authentication' => 'horde'))); -require_once 'Horde/Prefs/UI.php'; $compose_url = Horde::getServiceLink('options', 'imp'); @@ -106,13 +105,13 @@ extract(Horde::loadConfiguration('prefs.php', array('prefGroups', '_prefs'), 'im $app = 'imp'; $chunk = Horde_Util::nonInputVar('chunk'); -Prefs_UI::generateHeader(null, $chunk); +Horde_Prefs_Ui::generateHeader(null, $chunk); $t = new Horde_Template(); $t->setOption('gettext', true); $t->set('action', Horde::selfUrl()); $t->set('forminput', Horde_Util::formInput()); -$t->set('navcell', Horde_Util::bufferOutput(array('Prefs_UI', 'generateNavigationCell'), 'compose')); +$t->set('navcell', Horde_Util::bufferOutput(array('Horde_Prefs_Ui', 'generateNavigationCell'), 'compose')); $slist = array(); foreach ($stationery_list as $key => $choice) { diff --git a/ingo/lib/Api.php b/ingo/lib/Api.php index ff7c7f141..a8e1189aa 100644 --- a/ingo/lib/Api.php +++ b/ingo/lib/Api.php @@ -144,8 +144,7 @@ class Ingo_Api extends Horde_Registry_Api /* Make sure we have at least one address. */ if (empty($info['addresses'])) { - require_once 'Horde/Identity.php'; - $identity = Identity::singleton('none'); + $identity = Horde_Prefs_Identity::singleton('none'); $info['addresses'] = implode("\n", $identity->getAll('from_addr')); /* Remove empty lines. */ $info['addresses'] = preg_replace('/\n+/', "\n", $info['addresses']); diff --git a/ingo/lib/Storage/Prefs.php b/ingo/lib/Storage/Prefs.php index a6a63318f..6a03166dd 100644 --- a/ingo/lib/Storage/Prefs.php +++ b/ingo/lib/Storage/Prefs.php @@ -34,9 +34,9 @@ class Ingo_Storage_Prefs extends Ingo_Storage */ protected function _retrieve($field, $readonly = false) { - $prefs = &Prefs::singleton($GLOBALS['conf']['prefs']['driver'], - $GLOBALS['registry']->getApp(), - Ingo::getUser(), '', null, false); + $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], + $GLOBALS['registry']->getApp(), + Ingo::getUser(), '', null, false); $prefs->retrieve(); switch ($field) { @@ -131,9 +131,9 @@ class Ingo_Storage_Prefs extends Ingo_Storage */ protected function _store($ob) { - $prefs = &Prefs::singleton($GLOBALS['conf']['prefs']['driver'], - $GLOBALS['registry']->getApp(), - Ingo::getUser(), '', null, false); + $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], + $GLOBALS['registry']->getApp(), + Ingo::getUser(), '', null, false); $prefs->retrieve(); switch ($ob->obType()) { diff --git a/ingo/lib/base.php b/ingo/lib/base.php index 3455e8e0b..957014b72 100644 --- a/ingo/lib/base.php +++ b/ingo/lib/base.php @@ -67,8 +67,7 @@ if ($driver->supportShares()) { /* If personal share doesn't exist then create it. */ $signature = $_SESSION['ingo']['backend']['id'] . ':' . Horde_Auth::getAuth(); if (!$GLOBALS['ingo_shares']->exists($signature)) { - require_once 'Horde/Identity.php'; - $identity = &Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (trim($name) == '') { $name = Horde_Auth::getOriginalAuth(); diff --git a/ingo/vacation.php b/ingo/vacation.php index 16a203621..5cba6cf49 100644 --- a/ingo/vacation.php +++ b/ingo/vacation.php @@ -111,8 +111,7 @@ $form->appendButtons(_("Return to Rules List")); /* Make sure we have at least one address. */ if (!$vacation->getVacationAddresses()) { - require_once 'Horde/Identity.php'; - $identity = &Identity::singleton('none'); + $identity = Horde_Prefs_Identity::singleton('none'); $addresses = implode("\n", $identity->getAll('from_addr')); /* Remove empty lines. */ $addresses = preg_replace('/\n+/', "\n", $addresses); diff --git a/kronolith/attendees.php b/kronolith/attendees.php index 14ba3fe00..5245e6ec8 100644 --- a/kronolith/attendees.php +++ b/kronolith/attendees.php @@ -8,7 +8,6 @@ */ require_once dirname(__FILE__) . '/lib/base.php'; -require_once 'Horde/Identity.php'; // Get the current attendees array from the session cache. $attendees = (isset($_SESSION['kronolith']['attendees']) && @@ -238,7 +237,7 @@ $view = Horde_Util::getFormData('view', 'Day'); $delimg = Horde::img('delete.png', _("Remove Attendee"), null, $registry->getImageDir('horde')); -$ident = &Identity::singleton(); +$ident = Horde_Prefs_Identity::singleton(); $identities = $ident->getAll('id'); $vars = Horde_Variables::getDefaultVariables(); $tabs = new Horde_Ui_Tabs(null, $vars); diff --git a/kronolith/data.php b/kronolith/data.php index c7c535f17..5f635698b 100644 --- a/kronolith/data.php +++ b/kronolith/data.php @@ -149,7 +149,6 @@ case 'export': exit; case Horde_Data::EXPORT_ICALENDAR: - require_once 'Horde/Identity.php'; $iCal = new Horde_iCalendar(); $calNames = array(); diff --git a/kronolith/fb.php b/kronolith/fb.php index 1bebfd214..d9d3d7cdf 100644 --- a/kronolith/fb.php +++ b/kronolith/fb.php @@ -32,7 +32,7 @@ $key = 'kronolith.fb.' . ($user ? 'u.' . $user : 'c.' . $cal); $fb = $cache->get($key, 360); if (!$fb) { if ($user) { - $prefs = &Prefs::singleton($conf['prefs']['driver'], 'kronolith', $user, '', null, false); + $prefs = Horde_Prefs::singleton($conf['prefs']['driver'], 'kronolith', $user, '', null, false); $prefs->retrieve(); Horde_Nls::setTimeZone(); $cal = @unserialize($prefs->getValue('fb_cals')); diff --git a/kronolith/feed/index.php b/kronolith/feed/index.php index 5dfcd055b..4d3c81835 100644 --- a/kronolith/feed/index.php +++ b/kronolith/feed/index.php @@ -24,7 +24,6 @@ function _no_access($status, $reason, $body) $kronolith_authentication = 'none'; $kronolith_session_control = 'readonly'; require_once dirname(__FILE__) . '/../lib/base.php'; -require_once 'Horde/Identity.php'; $calendar = Horde_Util::getFormData('c'); $share = $kronolith_shares->getShare($calendar); @@ -86,8 +85,8 @@ if (isset($conf['urls']['pretty']) && $conf['urls']['pretty'] == 'rewrite') { $self_url = Horde::applicationUrl($self_url, true, -1); $owner = $share->get('owner'); -$identity = Identity::factory('none', $owner); -$history = &Horde_History::singleton(); +$identity = Horde_Prefs_Identity::factory('none', $owner); +$history = Horde_History::singleton(); $now = new Horde_Date(time()); $template = new Horde_Template(); diff --git a/kronolith/lib/Api.php b/kronolith/lib/Api.php index 4f74eca2b..3f5b5d679 100644 --- a/kronolith/lib/Api.php +++ b/kronolith/lib/Api.php @@ -1157,7 +1157,7 @@ class Kronolith_Api extends Horde_Registry_Api if ($alarm_user == $current_user) { $prefs = $GLOBALS['prefs']; } else { - $prefs = Prefs::singleton($GLOBALS['conf']['prefs']['driver'], + $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'kronolith', $alarm_user, null, null, false); } diff --git a/kronolith/lib/Driver/Kolab.php b/kronolith/lib/Driver/Kolab.php index fedc9e88c..fb90f91f4 100644 --- a/kronolith/lib/Driver/Kolab.php +++ b/kronolith/lib/Driver/Kolab.php @@ -1,7 +1,6 @@ exists(Horde_Auth::getAuth())) { - require_once 'Horde/Identity.php'; - $identity = &Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (trim($name) == '') { $name = Horde_Auth::getOriginalAuth(); diff --git a/kronolith/lib/FreeBusy.php b/kronolith/lib/FreeBusy.php index a5d1a676a..0f30d7e9c 100644 --- a/kronolith/lib/FreeBusy.php +++ b/kronolith/lib/FreeBusy.php @@ -24,8 +24,6 @@ class Kronolith_FreeBusy { { global $kronolith_shares; - require_once 'Horde/Identity.php'; - if (!is_array($calendar)) { $calendar = array($calendar); } @@ -59,8 +57,7 @@ class Kronolith_FreeBusy { } /* Get the Identity for the owner of the share. */ - $identity = &Identity::singleton('none', - $user ? $user : $owner); + $identity = Horde_Prefs_Identity::singleton('none', $user ? $user : $owner); $email = $identity->getValue('from_addr'); $cn = $identity->getValue('fullname'); diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index ce5e6c4ed..140cef939 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -961,8 +961,7 @@ class Kronolith if (Horde_Auth::getAuth() && !count($GLOBALS['display_calendars']) && !$GLOBALS['kronolith_shares']->exists(Horde_Auth::getAuth())) { - require_once 'Horde/Identity.php'; - $identity = &Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (trim($name) == '') { $name = Horde_Auth::getOriginalAuth(); @@ -1019,8 +1018,7 @@ class Kronolith static $names = array(); if (!isset($names[$uid])) { - require_once 'Horde/Identity.php'; - $ident = &Identity::singleton('none', $uid); + $ident = Horde_Prefs_Identity::singleton('none', $uid); $ident->setDefault($ident->getDefault()); $names[$uid] = $ident->getValue('fullname'); if (empty($names[$uid])) { @@ -1039,8 +1037,7 @@ class Kronolith static $emails = array(); if (!isset($emails[$uid])) { - require_once 'Horde/Identity.php'; - $ident = &Identity::singleton('none', $uid); + $ident = Horde_Prefs_Identity::singleton('none', $uid); $emails[$uid] = $ident->getValue('from_addr'); if (empty($emails[$uid])) { $emails[$uid] = $uid; @@ -1058,8 +1055,7 @@ class Kronolith static $emails = array(); if (!isset($emails[$uid])) { - require_once 'Horde/Identity.php'; - $ident = &Identity::singleton('none', $uid); + $ident = Horde_Prefs_Identity::singleton('none', $uid); $addrs = $ident->getAll('from_addr'); $addrs[] = $uid; @@ -1393,8 +1389,7 @@ class Kronolith return; } - require_once 'Horde/Identity.php'; - $ident = &Identity::singleton('none', $event->getCreatorId()); + $ident = Horde_Prefs_Identity::singleton('none', $event->getCreatorId()); $myemail = $ident->getValue('from_addr'); if (!$myemail) { @@ -1527,7 +1522,6 @@ class Kronolith } require_once 'Horde/Group.php'; - require_once 'Horde/Identity.php'; $groups = &Group::singleton(); $calendar = $event->getCalendar(); @@ -1537,7 +1531,7 @@ class Kronolith return $share; } - $identity = &Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $from = $identity->getDefaultFromAddress(true); $owner = $share->get('owner'); @@ -1571,7 +1565,7 @@ class Kronolith if (!$vals) { continue; } - $identity = &Identity::singleton('none', $user); + $identity = Horde_Prefs_Identity::singleton('none', $user); $email = $identity->getValue('from_addr'); if (strpos($email, '@') === false) { continue; @@ -1693,9 +1687,9 @@ class Kronolith */ public static function _notificationPref($user, $mode, $calendar = null) { - $prefs = &Prefs::singleton($GLOBALS['conf']['prefs']['driver'], - 'kronolith', $user, '', null, - false); + $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], + 'kronolith', $user, '', null, + false); $prefs->retrieve(); $vals = array('lang' => $prefs->getValue('language'), 'tf' => $prefs->getValue('twentyFour'), diff --git a/kronolith/lib/View/EditEvent.php b/kronolith/lib/View/EditEvent.php index 6d2348dd8..43ccc1b25 100644 --- a/kronolith/lib/View/EditEvent.php +++ b/kronolith/lib/View/EditEvent.php @@ -33,8 +33,7 @@ class Kronolith_View_EditEvent { function html($active = true) { - require_once 'Horde/Identity.php'; - $identity = &Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); if (!$this->event || is_a($this->event, 'PEAR_Error')) { echo '

' . _("The requested event was not found.") . '

'; diff --git a/kronolith/scripts/agenda.php b/kronolith/scripts/agenda.php index 0f6617e30..ee21dab72 100755 --- a/kronolith/scripts/agenda.php +++ b/kronolith/scripts/agenda.php @@ -11,7 +11,6 @@ $kronolith_authentication = 'none'; require_once dirname(__FILE__) . '/../lib/base.php'; -require_once 'Horde/Identity.php'; // Make sure no one runs this from the web. if (!Horde_Cli::runningFromCLI()) { @@ -68,8 +67,8 @@ function send_agendas() // Loop through the users and generate an agenda for them foreach ($users as $user) { - $prefs = Prefs::singleton($GLOBALS['conf']['prefs']['driver'], - 'kronolith', $user); + $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], + 'kronolith', $user); $prefs->retrieve(); $agenda_calendars = $prefs->getValue('daily_agenda'); @@ -83,7 +82,7 @@ function send_agendas() } // try to find an email address for the user - $identity = Identity::singleton('none', $user); + $identity = Horde_Prefs_Identity::singleton('none', $user); $email = $identity->getValue('from_addr'); if (strstr($email, '@')) { list($mailbox, $host) = explode('@', $email); diff --git a/kronolith/scripts/upgrades/convert_to_utc.php b/kronolith/scripts/upgrades/convert_to_utc.php index 52d3a5390..aedc80b48 100755 --- a/kronolith/scripts/upgrades/convert_to_utc.php +++ b/kronolith/scripts/upgrades/convert_to_utc.php @@ -16,7 +16,6 @@ $cli->init(); /* Load required libraries. */ $kronolith_authentication = 'none'; require_once KRONOLITH_BASE . '/../../lib/base.php'; -require_once 'Horde/Prefs.php'; /* Prepare DB stuff. */ PEAR::staticPushErrorHandling(PEAR_ERROR_DIE); @@ -44,8 +43,8 @@ while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { if (!is_null($creator)) { echo "$count\n"; } - $prefs = Prefs::factory($conf['prefs']['driver'], 'horde', - $row['event_creator_id']); + $prefs = Horde_Prefs::factory($conf['prefs']['driver'], 'horde', + $row['event_creator_id']); $timezone = $prefs->getValue('timezone'); if (empty($timezone)) { $timezone = date_default_timezone_get(); diff --git a/nag/ics.php b/nag/ics.php index 3137b0d10..64b64dae3 100644 --- a/nag/ics.php +++ b/nag/ics.php @@ -12,7 +12,6 @@ $nag_session_control = 'none'; require_once dirname(__FILE__) . '/lib/base.php'; -require_once 'Horde/Identity.php'; // We want to always generate UTF-8 iCalendar data. Horde_Nls::setCharset('UTF-8'); @@ -59,7 +58,7 @@ if (!$ics) { Horde::fatal($result, __FILE__, __LINE__); } - $identity = Identity::singleton('none', $share->get('owner')); + $identity = Horde_Prefs_Identity::singleton('none', $share->get('owner')); $storage->tasks->reset(); while ($task = $storage->tasks->each() ) { $iCal->addComponent($task->toiCalendar($iCal)); diff --git a/nag/lib/Api.php b/nag/lib/Api.php index 88ad72342..19c60af4f 100644 --- a/nag/lib/Api.php +++ b/nag/lib/Api.php @@ -1373,8 +1373,7 @@ class Nag_Api extends Horde_Registry_Api $users = array($user); } foreach ($users as $alarm_user) { - $prefs = Prefs::singleton($GLOBALS['conf']['prefs']['driver'], - 'nag', $alarm_user, null, null, false); + $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], 'nag', $alarm_user, null, null, false); Horde_Nls::setLanguageEnvironment($prefs->getValue('language')); $alarm_list[] = $alarm->toAlarm($alarm_user, $prefs); } diff --git a/nag/lib/Forms/DeleteTaskList.php b/nag/lib/Forms/DeleteTaskList.php index f8a4d47ca..5b0352b84 100644 --- a/nag/lib/Forms/DeleteTaskList.php +++ b/nag/lib/Forms/DeleteTaskList.php @@ -67,8 +67,7 @@ class Nag_DeleteTaskListForm extends Horde_Form { if (count(Nag::listTasklists(true)) == 0) { // If the default share doesn't exist then create it. if (!$GLOBALS['nag_shares']->exists(Horde_Auth::getAuth())) { - require_once 'Horde/Identity.php'; - $identity = &Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (trim($name) == '') { $name = Horde_Auth::getOriginalAuth(); diff --git a/nag/lib/Forms/task.php b/nag/lib/Forms/task.php index eefcde88a..6efc6a6be 100644 --- a/nag/lib/Forms/task.php +++ b/nag/lib/Forms/task.php @@ -59,9 +59,8 @@ class Nag_TaskForm extends Horde_Form { $users = array_flip($users); } if (count($users)) { - require_once 'Horde/Identity.php'; foreach (array_keys($users) as $user) { - $identity = &Identity::singleton('none', $user); + $identity = Horde_Prefs_Identity::singleton('none', $user); $fullname = $identity->getValue('fullname'); $users[$user] = strlen($fullname) ? $fullname : $user; } diff --git a/nag/lib/Nag.php b/nag/lib/Nag.php index b586d44fe..8bd594e9d 100644 --- a/nag/lib/Nag.php +++ b/nag/lib/Nag.php @@ -558,8 +558,7 @@ class Nag return ''; } - require_once 'Horde/Identity.php'; - $identity = Identity::singleton('none', $assignee); + $identity = Horde_Prefs_Identity::singleton('none', $assignee); $fullname = $identity->getValue('fullname'); if (!strlen($fullname)) { $fullname = $assignee; @@ -659,8 +658,7 @@ class Nag /* If the user's personal tasklist doesn't exist, then create it. */ if (!$GLOBALS['nag_shares']->exists(Horde_Auth::getAuth())) { - require_once 'Horde/Identity.php'; - $identity = Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (trim($name) == '') { $name = Horde_Auth::getOriginalAuth(); @@ -775,11 +773,10 @@ class Nag } require_once 'Horde/Group.php'; - require_once 'Horde/Identity.php'; $groups = Group::singleton(); $recipients = array(); - $identity = Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $from = $identity->getDefaultFromAddress(true); $owner = $share->get('owner'); @@ -812,7 +809,7 @@ class Nag if (!$vals) { continue; } - $identity = Identity::singleton('none', $user); + $identity = Horde_Prefs_Identity::singleton('none', $user); $email = $identity->getValue('from_addr'); if (strpos($email, '@') === false) { continue; @@ -892,13 +889,12 @@ class Nag $old_task->category, $task->category); } if ($old_task->assignee != $task->assignee) { - require_once 'Horde/Identity.php'; - $identity = Identity::singleton('none', $old_task->assignee); + $identity = Horde_Prefs_Identity::singleton('none', $old_task->assignee); $old_name = $identity->getValue('fullname'); if (!strlen($old_name)) { $old_name = $old_task->assignee; } - $identity = Identity::singleton('none', $task->assignee); + $identity = Horde_Prefs_Identity::singleton('none', $task->assignee); $new_name = $identity->getValue('fullname'); if (!strlen($new_name)) { $new_name = $new_task->assignee; @@ -994,8 +990,7 @@ class Nag static $names = array(); if (!isset($names[$uid])) { - require_once 'Horde/Identity.php'; - $ident = Identity::singleton('none', $uid); + $ident = Horde_Prefs_Identity::singleton('none', $uid); $ident->setDefault($ident->getDefault()); $names[$uid] = $ident->getValue('fullname'); if (empty($names[$uid])) { @@ -1028,9 +1023,9 @@ class Nag */ function _notificationPref($user, $mode, $tasklist = null) { - $prefs = Prefs::singleton($GLOBALS['conf']['prefs']['driver'], - 'nag', $user, '', null, - false); + $prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], + 'nag', $user, '', null, + false); $prefs->retrieve(); $vals = array('lang' => $prefs->getValue('language'), 'tf' => $prefs->getValue('twentyFour'), diff --git a/nag/tasklists/info.php b/nag/tasklists/info.php index 777629576..557604bb3 100644 --- a/nag/tasklists/info.php +++ b/nag/tasklists/info.php @@ -7,7 +7,6 @@ */ require_once dirname(__FILE__) . '/../lib/base.php'; -require_once 'Horde/Identity.php'; // Exit if this isn't an authenticated user. if (!Horde_Auth::getAuth()) { @@ -22,7 +21,7 @@ if (is_a($tasklist, 'PEAR_Error')) { $subscribe_url = Horde::url($registry->get('webroot', 'horde') . '/rpc.php/nag/', true, -1) . $tasklist->get('owner') . '/' . $tasklist->getName() . '.ics'; -$identity = Identity::singleton('none', $tasklist->get('owner')); +$identity = Horde_Prefs_Identity::singleton('none', $tasklist->get('owner')); $owner_name = $identity->getValue('fullname'); if (trim($owner_name) == '') { $owner_name = Horde_Auth::getOriginalAuth(); diff --git a/turba/lib/Driver/Group.php b/turba/lib/Driver/Group.php index 2a220f83e..94dcb8a7f 100644 --- a/turba/lib/Driver/Group.php +++ b/turba/lib/Driver/Group.php @@ -130,13 +130,12 @@ class Turba_Driver_Group extends Turba_Driver function _getAddressBook() { require_once 'Horde/Group.php'; - require_once 'Horde/Identity.php'; $groups = Group::singleton(); $members = $groups->listAllUsers($this->_gid); $addressbook = array(); foreach ($members as $member) { - $identity = &Identity::singleton('none', $member); + $identity = Horde_Prefs_Identity::singleton('none', $member); $name = $identity->getValue('fullname'); $email = $identity->getValue('from_addr'); // We use the email as the key since we could have multiple users diff --git a/turba/lib/Turba.php b/turba/lib/Turba.php index d37dd479d..eca44b8a7 100644 --- a/turba/lib/Turba.php +++ b/turba/lib/Turba.php @@ -275,8 +275,7 @@ class Turba { static $names = array(); if (!isset($names[$uid])) { - require_once 'Horde/Identity.php'; - $ident = Identity::singleton('none', $uid); + $ident = Horde_Prefs_Identity::singleton('none', $uid); $ident->setDefault($ident->getDefault()); $names[$uid] = $ident->getValue('fullname'); if (empty($names[$uid])) { @@ -531,8 +530,7 @@ class Turba { { if (!isset($params['name'])) { /* Sensible default for empty display names */ - require_once 'Horde/Identity.php'; - $identity = Identity::singleton(); + $identity = Horde_Prefs_Identity::singleton(); $name = $identity->getValue('fullname'); if (trim($name) == '') { $name = Horde_Auth::getOriginalAuth(); diff --git a/turba/scripts/import_squirrelmail_file_abook.php b/turba/scripts/import_squirrelmail_file_abook.php index 8c2e0d307..769117614 100755 --- a/turba/scripts/import_squirrelmail_file_abook.php +++ b/turba/scripts/import_squirrelmail_file_abook.php @@ -80,7 +80,7 @@ foreach($files as $file) { // Reset user prefs unset($prefs); - $prefs = &Prefs::factory($conf['prefs']['driver'], 'turba', $user, null, null, false); + $prefs = Horde_Prefs::factory($conf['prefs']['driver'], 'turba', $user, null, null, false); // Reset $cfgSources for current user. unset($cfgSources); diff --git a/turba/scripts/import_squirrelmail_sql_abook.php b/turba/scripts/import_squirrelmail_sql_abook.php index e660441a6..1442651b8 100755 --- a/turba/scripts/import_squirrelmail_sql_abook.php +++ b/turba/scripts/import_squirrelmail_sql_abook.php @@ -78,7 +78,7 @@ while ($row = $handle->fetchRow(DB_FETCHMODE_ASSOC)) { // Reset user prefs unset($prefs); - $prefs = &Prefs::factory($conf['prefs']['driver'], 'turba', $user, null, null, false); + $prefs = Horde_Prefs::factory($conf['prefs']['driver'], 'turba', $user, null, null, false); // Reset $cfgSources for current user. unset($cfgSources);