Horde_Prefs:: has moved to git
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 23 Nov 2009 19:49:28 +0000 (12:49 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 23 Nov 2009 20:35:56 +0000 (13:35 -0700)
69 files changed:
ansel/image.php
ansel/lib/Ansel.php
ansel/lib/Form/Ecard.php
ansel/lib/Gallery.php
ansel/lib/Image.php
ansel/lib/Report.php
ansel/lib/View/List.php
ansel/rss.php
ansel/templates/group/owner.inc
fima/lib/Fima.php
fima/lib/Forms/DeleteLedger.php
folks/account/resetpassword.php
folks/lib/Folks.php
folks/lib/Friends.php
folks/lib/Friends/prefs.php
folks/lib/Notification.php
imp/acl.php
imp/attachment.php
imp/compose-dimp.php
imp/compose-mimp.php
imp/compose.php
imp/filterprefs.php
imp/lib/Compose.php
imp/lib/Crypt/Pgp.php
imp/lib/Crypt/Smime.php
imp/lib/IMP.php
imp/lib/Identity/imp.php [deleted file]
imp/lib/Imap/Flags.php
imp/lib/Imap/Tree.php
imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php
imp/lib/LoginTasks/Task/PurgeSentmail.php
imp/lib/LoginTasks/Task/RenameSentmailMonthly.php
imp/lib/Mime/Viewer/Itip.php
imp/lib/Prefs/Identity.php [new file with mode: 0644]
imp/lib/Spam.php
imp/lib/UI/Compose.php
imp/lib/UI/Mailbox.php
imp/lib/Views/Compose.php
imp/message-mimp.php
imp/message.php
imp/pgp.php
imp/smime.php
imp/stationery.php
ingo/lib/Api.php
ingo/lib/Storage/Prefs.php
ingo/lib/base.php
ingo/vacation.php
kronolith/attendees.php
kronolith/data.php
kronolith/fb.php
kronolith/feed/index.php
kronolith/lib/Api.php
kronolith/lib/Driver/Kolab.php
kronolith/lib/Forms/DeleteCalendar.php
kronolith/lib/FreeBusy.php
kronolith/lib/Kronolith.php
kronolith/lib/View/EditEvent.php
kronolith/scripts/agenda.php
kronolith/scripts/upgrades/convert_to_utc.php
nag/ics.php
nag/lib/Api.php
nag/lib/Forms/DeleteTaskList.php
nag/lib/Forms/task.php
nag/lib/Nag.php
nag/tasklists/info.php
turba/lib/Driver/Group.php
turba/lib/Turba.php
turba/scripts/import_squirrelmail_file_abook.php
turba/scripts/import_squirrelmail_sql_abook.php

index 23e6a08..eb7390e 100644 (file)
@@ -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();
index df933c5..5c8d05f 100644 (file)
@@ -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;
index bf50f3f..7a46d6a 100644 (file)
@@ -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);
index d11ca9d..afd2845 100644 (file)
@@ -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']);
     }
 
     /**
index 0e3d775..2348248 100644 (file)
@@ -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();
index 7a49173..9fd0d8f 100644 (file)
@@ -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');
     }
 
     /**
index d256a35..155988a 100644 (file)
@@ -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;
index 86ee3f3..79ccd09 100644 (file)
@@ -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) {
index acc1b89..7678f9b 100644 (file)
@@ -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');
index 8b852f2..6b46d69 100644 (file)
@@ -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();
index 3bff8a4..33afa75 100644 (file)
@@ -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();
index 685c685..9cb5d14 100644 (file)
@@ -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');
index 92bca09..bb9aca4 100644 (file)
@@ -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');
 
index 0d6d5a8..a857a2b 100644 (file)
@@ -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');
index 5076c64..c214cb2 100644 (file)
@@ -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);
index 8e7fb4a..ee7a72c 100644 (file)
@@ -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');
     }
 
     /**
index d7d5b24..10d3da0 100644 (file)
@@ -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)));
index 4a976c3..eb6062a 100644 (file)
@@ -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 <>. */
index fe0fdd6..04615b2 100644 (file)
@@ -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)) {
index 1580712..c31dfa6 100644 (file)
@@ -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)) {
index 8672de0..fea1ae2 100644 (file)
@@ -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)) {
index 86d81cf..46a5dc8 100644 (file)
@@ -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"));
 
index 4c9caa4..7f807f2 100644 (file)
@@ -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);
     }
 
index d77c76d..bafb040 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * The IMP_Crypt_pgp:: class contains all functions related to handling
+ * The IMP_Crypt_Pgp:: class contains all functions related to handling
  * PGP messages within IMP.
  *
  * Copyright 2002-2009 The Horde Project (http://www.horde.org/)
@@ -195,7 +195,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
             /* TODO: Retrieve by ID. */
 
             /* 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)) {
                 $result = $personal_pubkey;
index 856ea49..fb1bc15 100644 (file)
@@ -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;
index 4fbe0a6..72bd57c 100644 (file)
@@ -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 (file)
index 42c0ed4..0000000
+++ /dev/null
@@ -1,549 +0,0 @@
-<?php
-/**
- * This class provides an IMP-specific interface to all identities a
- * user might have. Its methods take care of any site-specific
- * restrictions configured in prefs.php and conf.php.
- *
- * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Jan Schneider <jan@horde.org>
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @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 <user@example.com>'.
-     * @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);
-    }
-
-}
index 1106edb..40f0919 100644 (file)
@@ -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'];
index ce4b61b..54641fe 100644 (file)
@@ -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),
index a2ac053..506bfa8 100644 (file)
@@ -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();
 
index 01aafea..8eeea7c 100644 (file)
@@ -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();
     }
 
 }
index 47e243e..0e73e78 100644 (file)
@@ -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) {
index 2df4ca2..f972095 100644 (file)
@@ -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 (file)
index 0000000..8c13167
--- /dev/null
@@ -0,0 +1,550 @@
+<?php
+/**
+ * This class provides an IMP-specific interface to all identities a
+ * user might have. Its methods take care of any site-specific
+ * restrictions configured in prefs.php and conf.php.
+ *
+ * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author   Jan Schneider <jan@horde.org>
+ * @author   Chuck Hagenbuch <chuck@horde.org>
+ * @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 <user@example.com>'.
+     * @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);
+    }
+
+}
index 5933ea6..9f9ddfe 100644 (file)
@@ -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) {
index d19ca69..516a6fb 100644 (file)
@@ -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();
index 22f489d..556b283 100644 (file)
@@ -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. */
index e64f350..ce8105e 100644 (file)
@@ -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. */
index 5b015ef..5511408 100644 (file)
@@ -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();
index 392c59f..6b9dc72 100644 (file)
@@ -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');
index fd64266..b6a3547 100644 (file)
@@ -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'));
index dde17cb..53ff525 100644 (file)
@@ -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');
 
index 3d89401..a7bbb01 100644 (file)
@@ -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) {
index ff7c7f1..a8e1189 100644 (file)
@@ -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']);
index a6a6331..6a03166 100644 (file)
@@ -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()) {
index 3455e8e..957014b 100644 (file)
@@ -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();
index 16a2036..5cba6cf 100644 (file)
@@ -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);
index 14ba3fe..5245e6e 100644 (file)
@@ -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);
index c7c535f..5f63569 100644 (file)
@@ -149,7 +149,6 @@ case 'export':
         exit;
 
     case Horde_Data::EXPORT_ICALENDAR:
-        require_once 'Horde/Identity.php';
         $iCal = new Horde_iCalendar();
 
         $calNames = array();
index 1bebfd2..d9d3d7c 100644 (file)
@@ -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'));
index 5dfcd05..4d3c818 100644 (file)
@@ -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();
index 4f74eca..3f5b5d6 100644 (file)
@@ -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);
                     }
index fedc9e8..fb90f91 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 
 require_once 'Horde/Kolab.php';
-require_once 'Horde/Identity.php';
 
 /**
  * Horde Kronolith driver for the Kolab IMAP Server.
index 66d8f25..4d751d4 100644 (file)
@@ -66,8 +66,7 @@ class Kronolith_DeleteCalendarForm extends Horde_Form {
         if (count(Kronolith::listCalendars(true)) == 0) {
             // If the default share doesn't exist then create it.
             if (!$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();
index a5d1a67..0f30d7e 100644 (file)
@@ -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');
 
index ce5e6c4..140cef9 100644 (file)
@@ -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'),
index 6d2348d..43ccc1b 100644 (file)
@@ -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 '<h3>' . _("The requested event was not found.") . '</h3>';
index 0f6617e..ee21dab 100755 (executable)
@@ -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);
index 52d3a53..aedc80b 100755 (executable)
@@ -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();
index 3137b0d..64b64da 100644 (file)
@@ -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));
index 88ad723..19c60af 100644 (file)
@@ -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);
             }
index f8a4d47..5b0352b 100644 (file)
@@ -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();
index eefcde8..6efc6a6 100644 (file)
@@ -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;
             }
index b586d44..8bd594e 100644 (file)
@@ -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'),
index 7776295..557604b 100644 (file)
@@ -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();
index 2a220f8..94dcb8a 100644 (file)
@@ -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
index d37dd47..eca44b8 100644 (file)
@@ -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();
index 8c2e0d3..7691176 100755 (executable)
@@ -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);
index e660441..1442651 100755 (executable)
@@ -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);