Create Identity injector binder
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Apr 2010 20:55:46 +0000 (14:55 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Apr 2010 21:04:56 +0000 (15:04 -0600)
50 files changed:
agora/messages/abuse.php
agora/messages/index.php
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
fima/lib/Fima.php
fima/lib/Forms/DeleteLedger.php
folks/lib/Notification.php
framework/Alarm/lib/Horde/Alarm.php
framework/Core/lib/Horde/Core/Binder/Identity.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Factory/Identity.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Prefs/Ui.php
framework/Core/lib/Horde/Registry.php
framework/Core/package.xml
framework/Mime/lib/Horde/Mime/Mdn.php
framework/Prefs/lib/Horde/Prefs/Identity.php
framework/Share/Share.php
horde/admin/user.php
horde/scripts/import_squirrelmail_prefs.php
horde/services/confirm.php
horde/services/portal/index.php
horde/services/portal/mobile.php
horde/services/problem.php
imp/attachment.php
imp/lib/Injector/Binder/Identity.php
imp/lib/Prefs/Identity.php
ingo/lib/Api.php
ingo/lib/Application.php
ingo/vacation.php
kronolith/attendees.php
kronolith/lib/FreeBusy.php
kronolith/lib/Kronolith.php
kronolith/lib/View/EditEvent.php
kronolith/scripts/agenda.php
mnemo/lib/Mnemo.php
nag/lib/Forms/task.php
nag/lib/Nag.php
nag/tasklists/info.php
turba/lib/Driver/Group.php
turba/lib/Turba.php
whups/lib/Mail.php
whups/lib/Ticket.php
whups/lib/Whups.php
wicked/lib/Page.php
wicked/lib/Wicked.php

index c989a69..48eb007 100644 (file)
@@ -57,7 +57,7 @@ if ($form->validate()) {
     /* Collect moderators emails, and send them the notify */
     $emails = array();
     foreach ($forum['moderators'] as $moderator) {
-        $identity = Horde_Prefs_Identity::singleton('none', $moderator);
+        $identity = $injector->getInstance('Horde_Prefs_Identity')->getOb($moderator);
         $address = $identity->getValue('from_addr');
         if (!empty($address)) {
             $emails[] = $address;
index 3f042a4..b193dd4 100644 (file)
@@ -77,7 +77,7 @@ $view = new Agora_View();
 if (!$view_bodies) {
     /* Get the author's avatar. */
     if ($conf['avatar']['allow_avatars']) {
-        $identity = Horde_Prefs_Identity::singleton('none', $message['message_author']);
+        $identity = $injector->getInstance('Horde_Prefs_Identity')->getOb($message['message_author']);
         $avatar_path = $identity->getValue('avatar_path');
         $message_author_avatar = Agora::validateAvatar($avatar_path) ? Agora::getAvatarUrl($avatar_path) : false;
         $view->message_author_avatar = $message_author_avatar;
index bf45471..6d5ce8b 100644 (file)
@@ -28,7 +28,7 @@ $date = Ansel::getDateParameter();
 
 /* Are we watermarking the image? */
 if ($watermark) {
-    $identity = Horde_Prefs_Identity::singleton();
+    $identity = $injector->getInstance('Horde_Prefs_Identity')->getOb();
     $name = $identity->getValue('fullname');
     if (empty($name)) {
         $name = Horde_Auth::getAuth();
index d1c64be..363c9bd 100644 (file)
@@ -704,7 +704,7 @@ class Ansel
                                            $owner, '', null, false);
                 $fullname = $uprefs->getValue('grouptitle');
                 if (!$fullname) {
-                    $identity = Horde_Prefs_Identity::singleton('none', $owner);
+                    $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($owner);
                     $fullname = $identity->getValue('fullname');
                     if (!$fullname) {
                         $fullname = $owner;
index 7a46d6a..84f9d4f 100644 (file)
@@ -23,7 +23,7 @@ class Ansel_Form_Ecard extends Horde_Form {
         if (empty($user)) {
             $this->addVariable(_("Use the following return address:"), 'ecard_retaddr', 'text', true);
         } else {
-            $identity = Horde_Prefs_Identity::singleton();
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
             $from_addr = $identity->getDefaultFromAddress();
             $vars->set('ecard_retaddr', $from_addr);
             $this->addHidden('', 'ecard_retaddr', 'text', true);
index e8aecaa..7d87899 100644 (file)
@@ -446,7 +446,7 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical
      */
     public function getOwner()
     {
-        return Horde_Prefs_Identity::singleton('none', $this->data['share_owner']);
+        return $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($this->data['share_owner']);
     }
 
     /**
index b6735c5..915b8c6 100644 (file)
@@ -1013,7 +1013,7 @@ class Ansel_Image Implements Iterator
         }
 
         if (empty($watermark)) {
-            $identity = Horde_Prefs_Identity::singleton();
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
             $name = $identity->getValue('fullname');
             if (empty($name)) {
                 $name = Horde_Auth::getAuth();
index d9e5923..dd0cb4f 100644 (file)
@@ -55,7 +55,7 @@ class Ansel_Report {
      */
     function _getUserEmail($user = null)
     {
-        return Horde_Prefs_Identity::singleton('none', $user)->getValue('from_addr');
+        return $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user)->getValue('from_addr');
     }
 
     /**
index 459b5c4..d83c209 100644 (file)
@@ -158,7 +158,7 @@ class Ansel_View_List extends Ansel_View_Base
                                             'ansel', $this->_owner, '', null, false);
                 $fullname = $uprefs->getValue('grouptitle');
                 if (!$fullname) {
-                    $identity = Horde_Prefs_Identity::singleton('none', $this->_owner);
+                    $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($this->_owner);
                     $fullname = $identity->getValue('fullname');
                     if (!$fullname) {
                         $fullname = $this->_owner;
index 3be9928..f72e0a0 100644 (file)
@@ -137,7 +137,7 @@ if (empty($rss)) {
         if (isset($galleries) && count($galleries)) {
             $images = $ansel_storage->getRecentImages($galleries);
             if (!is_a($images, 'PEAR_Error') && count($images)) {
-                $owner = Horde_Prefs_Identity::singleton('none', $id);
+                $owner = $injector->getInstance('Horde_Prefs_Identity')->getOb($id);
                 $name = $owner->getValue('fullname');
                 $author = $owner->getValue('from_addr');
                 if (!$name) {
index a2af487..97de38f 100644 (file)
@@ -716,7 +716,7 @@ class Fima {
 
                 /* If the user's personal ledger doesn't exist, then create it. */
                 if (!$GLOBALS['fima_shares']->exists(Horde_Auth::getAuth())) {
-                    $identity = Horde_Prefs_Identity::singleton();
+                    $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
                     $name = $identity->getValue('fullname');
                     if (trim($name) == '') {
                         $name = Horde_Auth::getOriginalAuth();
index 33afa75..359808c 100644 (file)
@@ -67,7 +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())) {
-                $identity = Horde_Prefs_Identity::singleton();
+                $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
                 $name = $identity->getValue('fullname');
                 if (trim($name) == '') {
                     $name = Horde_Auth::getOriginalAuth();
index b78d18f..14517cd 100644 (file)
@@ -221,7 +221,7 @@ class Folks_Notification {
      */
     protected function _getUserFromAddr($user)
     {
-        return Horde_Prefs_Identity::singleton('none', $user)->getValue('from_addr');
+        return $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user)->getValue('from_addr');
     }
 
     /**
index 7c3cf71..8daaf85 100644 (file)
@@ -457,7 +457,7 @@ class Horde_Alarm
             if (empty($alarm['user'])) {
                 return;
             }
-            $identity = Horde_Prefs_Identity::singleton('none', $alarm['user']);
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($alarm['user']);
             $email = $identity->getDefaultFromAddress(true);
         } else {
             $email = $alarm['params']['mail']['email'];
diff --git a/framework/Core/lib/Horde/Core/Binder/Identity.php b/framework/Core/lib/Horde/Core/Binder/Identity.php
new file mode 100644 (file)
index 0000000..5516717
--- /dev/null
@@ -0,0 +1,17 @@
+<?php
+/**
+ * @category Horde
+ * @package  Core
+ */
+class Horde_Core_Binder_Identity implements Horde_Injector_Binder
+{
+    public function create(Horde_Injector $injector)
+    {
+        return new Horde_Core_Factory_Identity($injector);
+    }
+
+    public function equals(Horde_Injector_Binder $binder)
+    {
+        return false;
+    }
+}
diff --git a/framework/Core/lib/Horde/Core/Factory/Identity.php b/framework/Core/lib/Horde/Core/Factory/Identity.php
new file mode 100644 (file)
index 0000000..0515215
--- /dev/null
@@ -0,0 +1,95 @@
+<?php
+/**
+ * A Horde_Injector:: based Horde_Identity:: factory.
+ *
+ * PHP version 5
+ *
+ * @category Horde
+ * @package  Core
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Core
+ */
+
+/**
+ * A Horde_Injector:: based Horde_Identity:: factory.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @package  Core
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Core
+ */
+class Horde_Core_Factory_Identity
+{
+    /**
+     * Instances.
+     *
+     * @var array
+     */
+    private $_instances = array();
+
+    /**
+     * The injector.
+     *
+     * @var Horde_Injector
+     */
+    private $_injector;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Injector $injector  The injector to use.
+     */
+    public function __construct(Horde_Injector $injector)
+    {
+        $this->_injector = $injector;
+    }
+
+    /**
+     * Return the Horde_Identity:: instance.
+     *
+     * @param string $user    The user to use, if not the current user.
+     * @param string $driver  The identity driver. Either empty (use default
+     *                        driver) or an application name.
+     *
+     * @return Horde_Identity  The singleton identity instance.
+     * @throws Horde_Exception
+     */
+    public function getOb($user = null, $driver = null)
+    {
+        $class = empty($driver)
+            ? 'Horde_Prefs_Identity'
+            : Horde_String::ucfirst($driver) . '_Prefs_Identity';
+        $key = $class . '|' . $user;
+
+        if (!isset($this->_instances[$key])) {
+            if (!class_exists($class)) {
+                throw new Horde_Exception('Class definition of ' . $class . ' not found.');
+            }
+
+            $params = array(
+                'user' => is_null($user) ? Horde_Auth::getAuth() : $user,
+            );
+
+            if (isset($GLOBALS['prefs']) &&
+                ($params['user'] == Horde_Auth::getAuth())) {
+                $params['prefs'] = $GLOBALS['prefs'];
+            } else {
+                $params['prefs'] = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], $GLOBALS['registry']->getApp(), $user, '', null, false);
+                $params['prefs']->retrieve();
+            }
+
+            $this->_instances[$key] = new $class($params);
+            $this->_instances[$key]->init();
+        }
+
+        return $this->_instances[$key];
+    }
+
+}
index 57861c5..c513e46 100644 (file)
@@ -706,7 +706,7 @@ class Horde_Core_Prefs_Ui
      */
     protected function _identityHeader($members)
     {
-        $identity = Horde_Prefs_Identity::singleton(($this->app == 'horde') ? null : array($this->app, $this->app));
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb(null, $this->app);
         $default_identity = $identity->getDefault();
 
         $t = $GLOBALS['injector']->createInstance('Horde_Template');
@@ -778,7 +778,7 @@ class Horde_Core_Prefs_Ui
     {
         global $conf, $notification, $prefs;
 
-        $identity = Horde_Prefs_Identity::singleton(($this->app == 'horde') ? null : array($this->app, $this->app));
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb(null, $this->app);
 
         if ($this->vars->delete_identity) {
             $id = intval($this->vars->id);
index 61941f4..9cc536f 100644 (file)
@@ -244,6 +244,7 @@ class Horde_Registry
             'Horde_Memcache' => new Horde_Core_Binder_Memcache(),
             'Horde_Notification' => new Horde_Core_Binder_Notification(),
             'Horde_Perms' => new Horde_Core_Binder_Perms(),
+            'Horde_Prefs_Identity' => new Horde_Core_Binder_Identity(),
             // 'Horde_Registry' - initialized below
             'Horde_Secret' => new Horde_Core_Binder_Secret(),
             'Horde_Template' => new Horde_Core_Binder_Template(),
index 59fd59c..ea946b9 100644 (file)
@@ -71,6 +71,7 @@ Application Framework.
        <file name="Dns.php" role="php" />
        <file name="Editor.php" role="php" />
        <file name="History.php" role="php" />
+       <file name="Identity.php" role="php" />
        <file name="Lock.php" role="php" />
        <file name="Logger.php" role="php" />
        <file name="Mail.php" role="php" />
@@ -84,6 +85,7 @@ Application Framework.
       </dir> <!-- /lib/Horde/Core/Binder -->
       <dir name="Factory">
        <file name="Editor.php" role="php" />
+       <file name="Identity.php" role="php" />
        <file name="KolabServer.php" role="php" />
        <file name="KolabSession.php" role="php" />
        <file name="KolabStorage.php" role="php" />
@@ -218,6 +220,7 @@ Application Framework.
    <install name="lib/Horde/Core/Binder/Dns.php" as="Horde/Core/Binder/Dns.php" />
    <install name="lib/Horde/Core/Binder/Editor.php" as="Horde/Core/Binder/Editor.php" />
    <install name="lib/Horde/Core/Binder/History.php" as="Horde/Core/Binder/History.php" />
+   <install name="lib/Horde/Core/Binder/Identity.php" as="Horde/Core/Binder/Identity.php" />
    <install name="lib/Horde/Core/Binder/Lock.php" as="Horde/Core/Binder/Lock.php" />
    <install name="lib/Horde/Core/Binder/Logger.php" as="Horde/Core/Binder/Logger.php" />
    <install name="lib/Horde/Core/Binder/Mail.php" as="Horde/Core/Binder/Mail.php" />
@@ -229,6 +232,7 @@ Application Framework.
    <install name="lib/Horde/Core/Binder/Token.php" as="Horde/Core/Binder/Token.php" />
    <install name="lib/Horde/Core/Binder/Vfs.php" as="Horde/Core/Binder/Vfs.php" />
    <install name="lib/Horde/Core/Factory/Editor.php" as="Horde/Core/Factory/Editor.php" />
+   <install name="lib/Horde/Core/Factory/Identity.php" as="Horde/Core/Factory/Identity.php" />
    <install name="lib/Horde/Core/Factory/KolabServer.php" as="Horde/Core/Factory/KolabServer.php" />
    <install name="lib/Horde/Core/Factory/KolabSession.php" as="Horde/Core/Factory/KolabSession.php" />
    <install name="lib/Horde/Core/Factory/KolabStorage.php" as="Horde/Core/Factory/KolabStorage.php" />
index 3665176..6ca3c29 100644 (file)
@@ -141,7 +141,7 @@ class Horde_Mime_Mdn
                              $mod = array(), $err = array())
     {
         /* Set up some variables we use later. */
-        $identity = Horde_Prefs_Identity::singleton();
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
         $from_addr = $identity->getDefaultFromAddress();
 
         $to = $this->getMdnReturnAddr();
index b40795d..39f771d 100644 (file)
 class Horde_Prefs_Identity
 {
     /**
-     * Singleton instances.
-     *
-     * @var array
-     */
-    static protected $_instances = array();
-
-    /**
      * Array containing all the user's identities.
      *
      * @var array
@@ -64,30 +57,20 @@ class Horde_Prefs_Identity
     /**
      * Constructor.
      *
-     * Reads all the user's identities from the prefs object or builds a new
-     * identity from the standard values given in prefs.php.
-     *
-     * @param string $user  If specified, we read another user's identities
-     *                      instead of the current user.
+     * @param array $params  Parameters:
+     * <pre>
+     * 'prefs' - (Horde_Prefs) [REQUIRED] The prefs object to use.
+     * 'user' - (string) [REQUIRED] The user whose prefs we are handling.
+     * </pre>
      */
-    public function __construct($user = null)
+    public function __construct($params = array())
     {
-        $this->_user = is_null($user)
-            ? Horde_Auth::getAuth()
-            : $user;
-
-        if ((is_null($user) || $user == Horde_Auth::getAuth()) &&
-            isset($GLOBALS['prefs'])) {
-            $this->_prefs = $GLOBALS['prefs'];
-        } else {
-            $this->_prefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'], $GLOBALS['registry']->getApp(), $user, '', null, false);
-            $this->_prefs->retrieve();
-        }
+        $this->_prefs = $params['prefs'];
+        $this->_user = $params['user'];
 
         if (!($this->_identities = @unserialize($this->_prefs->getValue('identities', false)))) {
-            /* Convert identities from the old format. */
-            $this->_identities = @unserialize($this->_prefs->getValue('identities'));
-        } elseif (is_array($this->_identities)) {
+            $this->_identities = $this->_prefs->getDefault('identities');
+        } else {
             $this->_identities = $this->_prefs->convertFromDriver($this->_identities, Horde_Nls::getCharset());
         }
 
@@ -499,79 +482,4 @@ class Horde_Prefs_Identity
         return array(sprintf(_("The email address %s has been added to your identities. You can close this window now."), $verified['from_addr']), 'horde.success');
     }
 
-    /**
-     * Attempts to return a concrete instance based on $type.
-     *
-     * @param mixed $driver  The type of concrete Identity subclass to return.
-     *                       This is based on the storage driver. The code is
-     *                       dynamically included. If $type is an array, then
-     *                       we will look in $driver[0]/lib/Prefs/Identity/
-     *                       for the subclass implementation named
-     *                       $driver[1].php.
-     * @param string $user   If specified, we read another user's identities
-     *                       instead of the current user.
-     *
-     * @return Horde_Prefs_Identity  The newly created instance.
-     * @throws Horde_Exception
-     */
-    static public function factory($driver = 'None', $user = null)
-    {
-        if (is_array($driver)) {
-            list($app, $driv_name) = $driver;
-            $driver = basename($driv_name);
-        } else {
-            $driver = basename($driver);
-        }
-
-        /* Return a base Identity object if no driver is specified. */
-        if (empty($driver) || (strcasecmp($driver, 'none') == 0)) {
-            $instance = new self($user);
-            $instance->init();
-            return $instance;
-        }
-
-        $class = (empty($app) ? 'Horde' : $app) . '_Prefs_Identity';
-
-        if (class_exists($class)) {
-            $instance = new $class($user);
-            $instance->init();
-            return $instance;
-        }
-
-        throw new Horde_Exception('Class definition of ' . $class . ' not found.');
-    }
-
-    /**
-     * Attempts to return a reference to a concrete instance based on
-     * $type. It will only create a new instance if no instance with
-     * the same parameters currently exists.
-     *
-     * This should be used if multiple types of identities (and, thus,
-     * multiple instances) are required.
-     *
-     * This method must be invoked as:
-     *   $var = Horde_Prefs_Identity::singleton()
-     *
-     * @param mixed $type   The type of concrete subclass to return.
-     *                      This is based on the storage driver ($type). The
-     *                      code is dynamically included. If $type is an array,
-     *                      then we will look in $type[0]/lib/Prefs/Identity/
-     *                      for the subclass implementation named
-     *                      $type[1].php.
-     * @param string $user  If specified, we read another user's identities
-     *                      instead of the current user.
-     *
-     * @return Horde_Prefs_Identity  The concrete reference.
-     * @throws Horde_Exception
-     */
-    static public function singleton($type = 'None', $user = null)
-    {
-        $signature = hash('md5', serialize(array($type, $user)));
-        if (!isset(self::$_instances[$signature])) {
-            self::$_instances[$signature] = self::factory($type, $user);
-        }
-
-        return self::$_instances[$signature];
-    }
-
 }
index 8d058fc..ca0544d 100644 (file)
@@ -505,7 +505,7 @@ class Horde_Share {
             }
         }
 
-        return Horde_Prefs_Identity::singleton('none', $share->get('owner'));
+        return $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($share->get('owner'));
     }
 
     /**
index b3ec67a..a297936 100644 (file)
@@ -170,7 +170,7 @@ case 'update':
         $notification->push(sprintf(_("There was a problem updating \"%s\": %s"),
                                     $user_name_1, $result->getMessage()), 'horde.error');
     } else {
-        $identity = Horde_Prefs_Identity::singleton('none', $user_name_1);
+        $identity = $injector->getInstance('Horde_Prefs_Identity')->getOb($user_name_1);
         $identity->setValue('fullname', $fullname);
         $identity->setValue('from_addr', $email);
         $identity->save();
@@ -216,7 +216,7 @@ require HORDE_TEMPLATES . '/common-header.inc';
 require HORDE_TEMPLATES . '/admin/menu.inc';
 
 if (isset($update_form) && $auth->hasCapability('list')) {
-    $identity = Horde_Prefs_Identity::singleton('none', $f_user_name);
+    $identity = $injector->getInstance('Horde_Prefs_Identity')->getOb($f_user_name);
     require HORDE_TEMPLATES . '/admin/user/update.inc';
 } elseif (isset($remove_form) &&
           $auth->hasCapability('list') &&
index b2b4ea0..3caf035 100644 (file)
@@ -26,7 +26,7 @@ function savePrefs($user, $basename, $prefs_cache)
 
     // Import identities
     if (isset($prefs_cache['identities']) && $prefs_cache['identities'] > 1) {
-        $identity = Horde_Prefs_Identity::singleton(array('imp', 'imp'), $user);
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user, 'imp');
         // Intentionally off-by-one
         for ($i = 1; $i < $prefs_cache['identities']; $i++) {
             $new_identity = array('id' => 'Identity #' . ($i + 1),
index 182e455..3684b1f 100644 (file)
@@ -11,7 +11,7 @@
 require_once dirname(__FILE__) . '/../lib/Application.php';
 Horde_Registry::appInit('horde', array('nologintasks' => true));
 
-$identity = Horde_Prefs_Identity::singleton();
+$identity = $injector->getInstance('Horde_Prefs_Identity')->getOb();
 list($message, $type) = $identity->confirmIdentity(Horde_Util::getFormData('h'));
 $notification->push($message, $type);
 
index f48d76d..2560216 100644 (file)
@@ -12,7 +12,7 @@ require_once dirname(__FILE__) . '/../../lib/Application.php';
 Horde_Registry::appInit('horde');
 
 // Get full name.
-$identity = Horde_Prefs_Identity::singleton();
+$identity = $injector->getInstance('Horde_Prefs_Identity')->getOb();
 $fullname = $identity->getValue('fullname');
 if (empty($fullname)) {
     $fullname = Horde_Auth::convertUsername(Horde_Auth::getAuth(), false);
index cd48741..1e44fac 100644 (file)
@@ -13,7 +13,7 @@
 require_once dirname(__FILE__) . '/../../lib/Application.php';
 Horde_Registry::appInit('horde');
 
-$identity = Horde_Prefs_Identity::singleton();
+$identity = $injector->getInstance('Horde_Prefs_Identity')->getOb();
 $fullname = $identity->getValue('fullname');
 if (empty($fullname)) {
     $fullname = Horde_Auth::getAuth();
index 833ece2..2559d29 100644 (file)
@@ -23,7 +23,7 @@ if (!Horde_Menu::showService('problem')) {
     _returnToPage();
 }
 
-$identity = Horde_Prefs_Identity::singleton();
+$identity = $injector->getInstance('Horde_Prefs_Identity')->getOb();
 $email = $identity->getValue('from_addr');
 if (!$email) {
     $email = Horde_Util::getFormData('email', Horde_Auth::getAuth());
index 767f8d4..2f48d18 100644 (file)
@@ -74,7 +74,7 @@ if ($conf['compose']['link_attachments_notify']) {
             $prefs = Horde_Prefs::singleton($conf['prefs']['driver'], 'horde', $mail_user);
             $prefs->retrieve();
 
-            $mail_identity = Horde_Prefs_Identity::singleton('none', $mail_user);
+            $mail_identity = $injector->getInstance('Horde_Prefs_Identity')->getOb($mail_user);
             $mail_address = $mail_identity->getDefaultFromAddress();
 
             /* Ignore missing addresses, which are returned as <>. */
@@ -86,8 +86,8 @@ if ($conf['compose']['link_attachments_notify']) {
                 /* Set up the mail headers and read the log file. */
                 $msg_headers = new Horde_Mime_Headers();
                 $msg_headers->addReceivedHeader(array(
-                    'dns' => $GLOBALS['injector']->getInstance('Net_DNS_Resolver'),
-                    'server' => $GLOBALS['conf']['server']['name']
+                    'dns' => $injector->getInstance('Net_DNS_Resolver'),
+                    'server' => $conf['server']['name']
                 ));
                 $msg_headers->addMessageIdHeader();
                 $msg_headers->addUserAgentHeader();
index bf91a11..30ae14e 100644 (file)
@@ -16,7 +16,7 @@ class IMP_Injector_Binder_Identity implements Horde_Injector_Binder
      */
     public function create(Horde_Injector $injector)
     {
-        return Horde_Prefs_Identity::singleton(array('imp', 'imp'));
+        return $injector->getInstance('Horde_Prefs_Identity')->getOb(null, 'imp');
     }
 
     /**
index 838a16f..71c4527 100644 (file)
@@ -33,10 +33,12 @@ class Imp_Prefs_Identity extends Horde_Prefs_Identity
     /**
      * Reads all the user's identities from the prefs object or builds
      * a new identity from the standard values given in prefs.php.
+     *
+     * @see Horde_Prefs_Identity::__construct()
      */
-    public function __construct()
+    public function __construct($params)
     {
-        parent::__construct();
+        parent::__construct($params);
 
         $this->_properties = array_merge(
             $this->_properties,
index 17b9a3d..e7278d1 100644 (file)
@@ -127,7 +127,7 @@ class Ingo_Api extends Horde_Registry_Api
 
         /* Make sure we have at least one address. */
         if (empty($info['addresses'])) {
-            $identity = Horde_Prefs_Identity::singleton('none');
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
             /* Remove empty lines. */
             $info['addresses'] = preg_replace('/\n{2,}/', "\n", implode("\n", $identity->getAll('from_addr')));
             if (empty($addresses)) {
index 99f021f..7a6638b 100644 (file)
@@ -70,7 +70,7 @@ class Ingo_Application extends Horde_Registry_Application
             /* If personal share doesn't exist then create it. */
             $signature = $_SESSION['ingo']['backend']['id'] . ':' . Horde_Auth::getAuth();
             if (!$GLOBALS['ingo_shares']->exists($signature)) {
-                $identity = Horde_Prefs_Identity::singleton();
+                $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
                 $name = $identity->getValue('fullname');
                 if (trim($name) == '') {
                     $name = Horde_Auth::getOriginalAuth();
index 6ffafda..ed11405 100644 (file)
@@ -105,7 +105,7 @@ $form->appendButtons(_("Return to Rules List"));
 
 /* Make sure we have at least one address. */
 if (!$vacation->getVacationAddresses()) {
-    $identity = Horde_Prefs_Identity::singleton('none');
+    $identity = $injector->getInstance('Horde_Prefs_Identity')->getOb();
     $addresses = implode("\n", $identity->getAll('from_addr'));
     /* Remove empty lines. */
     $addresses = preg_replace('/\n+/', "\n", $addresses);
index 3e347a2..0bd8240 100644 (file)
@@ -179,7 +179,7 @@ $view = Horde_Util::getFormData('view', 'Day');
 // Pre-format our delete image/link.
 $delimg = Horde::img('delete.png', _("Remove Attendee"));
 
-$ident = Horde_Prefs_Identity::singleton();
+$ident = $injector->getInstance('Horde_Prefs_Identity')->getOb();
 $identities = $ident->getAll('id');
 $vars = Horde_Variables::getDefaultVariables();
 $tabs = new Horde_Ui_Tabs(null, $vars);
index a335c3d..5806d4e 100644 (file)
@@ -60,7 +60,7 @@ class Kronolith_FreeBusy
         }
 
         /* Get the Identity for the owner of the share. */
-        $identity = Horde_Prefs_Identity::singleton('none', $user ? $user : $owner);
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user ? $user : $owner);
         $email = $identity->getValue('from_addr');
         $cn = $identity->getValue('fullname');
         if (empty($mail) && empty($cn)) {
index 12556c3..b6f5242 100644 (file)
@@ -1097,7 +1097,7 @@ class Kronolith
         if (Horde_Auth::getAuth() &&
             !count($GLOBALS['display_calendars']) &&
             !$GLOBALS['kronolith_shares']->exists(Horde_Auth::getAuth())) {
-            $identity = Horde_Prefs_Identity::singleton();
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
             $name = $identity->getValue('fullname');
             if (trim($name) == '') {
                 $name = Horde_Auth::getOriginalAuth();
@@ -1154,7 +1154,7 @@ class Kronolith
         static $names = array();
 
         if (!isset($names[$uid])) {
-            $ident = Horde_Prefs_Identity::singleton('none', $uid);
+            $ident = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($uid);
             $ident->setDefault($ident->getDefault());
             $names[$uid] = $ident->getValue('fullname');
             if (empty($names[$uid])) {
@@ -1173,7 +1173,7 @@ class Kronolith
         static $emails = array();
 
         if (!isset($emails[$uid])) {
-            $ident = Horde_Prefs_Identity::singleton('none', $uid);
+            $ident = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($uid);
             $emails[$uid] = $ident->getValue('from_addr');
             if (empty($emails[$uid])) {
                 $emails[$uid] = $uid;
@@ -1191,7 +1191,7 @@ class Kronolith
         static $emails = array();
 
         if (!isset($emails[$uid])) {
-            $ident = Horde_Prefs_Identity::singleton('none', $uid);
+            $ident = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($uid);
 
             $addrs = $ident->getAll('from_addr');
             $addrs[] = $uid;
@@ -1968,7 +1968,7 @@ class Kronolith
             return;
         }
 
-        $ident = Horde_Prefs_Identity::singleton('none', $event->creator);
+        $ident = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($event->creator);
 
         $myemail = $ident->getValue('from_addr');
         if (!$myemail) {
@@ -2122,7 +2122,7 @@ class Kronolith
             throw new Kronolith_Exception($share);
         }
 
-        $identity = Horde_Prefs_Identity::singleton();
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
         $from = $identity->getDefaultFromAddress(true);
 
         $owner = $share->get('owner');
@@ -2158,7 +2158,7 @@ class Kronolith
             if (!$vals) {
                 continue;
             }
-            $identity = Horde_Prefs_Identity::singleton('none', $user);
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user);
             $email = $identity->getValue('from_addr');
             if (strpos($email, '@') === false) {
                 continue;
index 06e4049..f50a587 100644 (file)
@@ -45,7 +45,7 @@ class Kronolith_View_EditEvent {
             exit;
         }
 
-        $identity = Horde_Prefs_Identity::singleton();
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
 
         if ($this->event->hasPermission(Horde_Perms::EDIT)) {
             $calendar_id = $this->event->calendar;
index 9ab6db4..5fb3c12 100755 (executable)
@@ -72,7 +72,7 @@ function send_agendas()
         }
 
         // try to find an email address for the user
-        $identity = Horde_Prefs_Identity::singleton('none', $user);
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user);
         $email = $identity->getValue('from_addr');
         if (strstr($email, '@')) {
             list($mailbox, $host) = explode('@', $email);
index 51e9a00..68f7a92 100644 (file)
@@ -216,7 +216,7 @@ class Mnemo {
         static $names = array();
 
         if (!isset($names[$uid])) {
-            $ident = Horde_Prefs_Identity::singleton('none', $uid);
+            $ident = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($uid);
             $ident->setDefault($ident->getDefault());
             $names[$uid] = $ident->getValue('fullname');
             if (empty($names[$uid])) {
@@ -443,7 +443,7 @@ class Mnemo {
 
                 /* If the user's personal notepad doesn't exist, then create it. */
                 if (!$GLOBALS['mnemo_shares']->exists(Horde_Auth::getAuth())) {
-                    $identity = Horde_Prefs_Identity::singleton();
+                    $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
                     $name = $identity->getValue('fullname');
                     if (trim($name) == '') {
                         $name = Horde_Auth::removeHook(Horde_Auth::getAuth());
index 15cb0d7..6639838 100644 (file)
@@ -65,7 +65,7 @@ class Nag_TaskForm extends Horde_Form {
         }
         if (count($users)) {
             foreach (array_keys($users) as $user) {
-                $identity = Horde_Prefs_Identity::singleton('none', $user);
+                $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user);
                 $fullname = $identity->getValue('fullname');
                 $users[$user] = strlen($fullname) ? $fullname : $user;
             }
index 66a698a..96e1fa6 100644 (file)
@@ -647,7 +647,7 @@ class Nag
             return '';
         }
 
-        $identity = Horde_Prefs_Identity::singleton('none', $assignee);
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($assignee);
         $fullname = $identity->getValue('fullname');
         if (!strlen($fullname)) {
             $fullname = $assignee;
@@ -720,7 +720,7 @@ class Nag
 
                 /* If the user's personal tasklist doesn't exist, then create it. */
                 if (!$GLOBALS['nag_shares']->exists(Horde_Auth::getAuth())) {
-                    $identity = Horde_Prefs_Identity::singleton();
+                    $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
                     $name = $identity->getValue('fullname');
                     if (trim($name) == '') {
                         $name = Horde_Auth::getOriginalAuth();
@@ -838,7 +838,7 @@ class Nag
 
         $groups = Group::singleton();
         $recipients = array();
-        $identity = Horde_Prefs_Identity::singleton();
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
         $from = $identity->getDefaultFromAddress(true);
 
         $owner = $share->get('owner');
@@ -873,7 +873,7 @@ class Nag
             if (!$vals) {
                 continue;
             }
-            $identity = Horde_Prefs_Identity::singleton('none', $user);
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user);
             $email = $identity->getValue('from_addr');
             if (strpos($email, '@') === false) {
                 continue;
@@ -953,12 +953,12 @@ class Nag
                                   $old_task->category, $task->category);
                 }
                 if ($old_task->assignee != $task->assignee) {
-                    $identity = Horde_Prefs_Identity::singleton('none', $old_task->assignee);
+                    $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($old_task->assignee);
                     $old_name = $identity->getValue('fullname');
                     if (!strlen($old_name)) {
                         $old_name = $old_task->assignee;
                     }
-                    $identity = Horde_Prefs_Identity::singleton('none', $task->assignee);
+                    $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($task->assignee);
                     $new_name = $identity->getValue('fullname');
                     if (!strlen($new_name)) {
                         $new_name = $new_task->assignee;
@@ -1050,7 +1050,7 @@ class Nag
         static $names = array();
 
         if (!isset($names[$uid])) {
-            $ident = Horde_Prefs_Identity::singleton('none', $uid);
+            $ident = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($uid);
             $ident->setDefault($ident->getDefault());
             $names[$uid] = $ident->getValue('fullname');
             if (empty($names[$uid])) {
index ca9782e..4fba0d9 100644 (file)
@@ -23,7 +23,7 @@ $subscribe_url = Horde::url($registry->get('webroot', 'horde') . '/rpc.php/nag/'
     . ($tasklist->get('owner') ? $tasklist->get('owner') : '')
     . '/' . $tasklist->getName() . '.ics';
 
-$identity = Horde_Prefs_Identity::singleton('none', $tasklist->get('owner'));
+$identity = $injector->getInstance('Horde_Prefs_Identity')->getOb($tasklist->get('owner'));
 $owner_name = $identity->getValue('fullname');
 if (trim($owner_name) == '') {
     $owner_name = Horde_Auth::getOriginalAuth();
index 94dcb8a..6046604 100644 (file)
@@ -135,7 +135,7 @@ class Turba_Driver_Group extends Turba_Driver
         $members = $groups->listAllUsers($this->_gid);
         $addressbook = array();
         foreach ($members as $member) {
-            $identity = Horde_Prefs_Identity::singleton('none', $member);
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($member);
             $name = $identity->getValue('fullname');
             $email = $identity->getValue('from_addr');
             // We use the email as the key since we could have multiple users
index 1acabc5..0fadf97 100644 (file)
@@ -278,7 +278,7 @@ class Turba {
         static $names = array();
 
         if (!isset($names[$uid])) {
-            $ident = Horde_Prefs_Identity::singleton('none', $uid);
+            $ident = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($uid);
             $ident->setDefault($ident->getDefault());
             $names[$uid] = $ident->getValue('fullname');
             if (empty($names[$uid])) {
@@ -536,7 +536,7 @@ class Turba {
     {
         if (!isset($params['name'])) {
             /* Sensible default for empty display names */
-            $identity = Horde_Prefs_Identity::singleton();
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
             $name = $identity->getValue('fullname');
             if (trim($name) == '') {
                 $name = Horde_Auth::getOriginalAuth();
index d2ba678..1f96b77 100644 (file)
@@ -214,7 +214,7 @@ class Whups_Mail {
 
         if ($auth->hasCapability('list')) {
             foreach ($auth->listUsers() as $user) {
-                $identity = Horde_Prefs_Identity::singleton('none', $user);
+                $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user);
                 $addrs = $identity->getAll('from_addr');
                 foreach ($addrs as $addr) {
                     if (strcasecmp($from, $addr) == 0) {
index 98a8daf..d3e2cd3 100644 (file)
@@ -726,7 +726,7 @@ class Whups_Ticket {
         }
 
         /* Build message template. */
-        $identity = &Horde_Prefs_Identity::singleton();
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
         $name = $identity->getValue('fullname');
         if (empty($name)) {
             $name = Horde_Auth::getBareAuth();
index 61a02c8..257342a 100644 (file)
@@ -571,7 +571,7 @@ class Whups {
                         }
                     } catch (Horde_Mime_Exception $e) {}
                 } else {
-                    $identity = &Horde_Prefs_Identity::singleton('none', $user);
+                    $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($user);
 
                     $results[$user]['name'] = $identity->getValue('fullname');
                     $results[$user]['email'] = $identity->getValue('from_addr');
index 0303171..afa4c42 100644 (file)
@@ -257,7 +257,7 @@ class Page {
             return _("Guest");
         }
 
-        $identity = &Horde_Prefs_Identity::singleton(null, $modify);
+        $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb($modify);
         $name = $identity->getValue('fullname');
         if (!empty($name)) {
             $modify = $name;
index 63ce341..33473fe 100644 (file)
@@ -160,7 +160,7 @@ class Wicked {
             $conf['wicked']['guest_address'] :
             $conf['wicked']['notify_address'];
         if (Horde_Auth::getAuth()) {
-            $identity = Horde_Prefs_Identity::singleton();
+            $identity = $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getOb();
             $from = $identity->getValue('fullname');
             if (empty($from)) {
                 $from = $registry->get('name');