Remove horde/Core dependency in horde/Auth
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 13 Jul 2010 21:36:55 +0000 (15:36 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Jul 2010 04:31:23 +0000 (22:31 -0600)
framework/Auth/lib/Horde/Auth/Cyrsql.php
framework/Auth/lib/Horde/Auth/Cyrus.php
framework/Auth/lib/Horde/Auth/Imap.php
framework/Core/lib/Horde/Core/Factory/Auth.php

index a472fb6..5cb57b4 100644 (file)
@@ -109,6 +109,8 @@ class Horde_Auth_Cyrsql extends Horde_Auth_Sql
      *
      * @param array $params  Parameters:
      * <pre>
+     * 'charset' - (string) Default charset.
+     *             DEFAULT: NONE
      * 'domain_field' - (string) If set to anything other than 'none' this is
      *                  used as field name where domain is stored.
      *                  DEFAULT: 'domain_name'
@@ -138,6 +140,7 @@ class Horde_Auth_Cyrsql extends Horde_Auth_Sql
         unset($params['imap']);
 
         $params = array_merge(array(
+            'charset' => null,
             'domain_field' => 'domain_name',
             'folders' => array(),
             'hidden_accounts' => array('cyrus'),
@@ -245,7 +248,7 @@ class Horde_Auth_Cyrsql extends Horde_Auth_Sql
         }
 
         try {
-            $mailbox = Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, $GLOBALS['registry']->getCharset(), 'utf7-imap');
+            $mailbox = Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, $this->_params['charset'], 'utf7-imap');
             $this->_imap->createMailbox($mailbox);
             $this->_imap->setACL($mailbox, $this->_params['cyradm'], 'lrswipcda');
         } catch (Horde_Imap_Client_Exception $e) {
@@ -257,12 +260,12 @@ class Horde_Auth_Cyrsql extends Horde_Auth_Sql
                 ($this->_params['domain_field'] != 'none')) {
                 list($userName, $domain) = explode('@', $userName);
                 $tmp = $userName . $this->_separator . $value . '@' . $domain;
-Horde_String::convertCharset($userName . $this->_separator . $value . '@' . $domain, $GLOBALS['registry']->getCharset(), 'utf7-imap');
+Horde_String::convertCharset($userName . $this->_separator . $value . '@' . $domain, $this->_params['charset'], 'utf7-imap');
             } else {
                 $tmp = $userName . $this->_separator . $value;
             }
 
-            $tmp = Horde_String::convertCharset($tmp, $GLOBALS['registry']->getCharset(), 'utf7-imap');
+            $tmp = Horde_String::convertCharset($tmp, $this->_params['charset'], 'utf7-imap');
             $this->_imap->createMailbox($tmp);
             $this->_oimap>setACL($tmp, $this->_params['cyradm'], 'lrswipcda');
         }
index 958f1d9..d1e72c9 100644 (file)
@@ -53,8 +53,9 @@ class Horde_Auth_Cyrus extends Horde_Auth_Base
      *
      * @param array $params  Parameters:
      * <pre>
-     * TODO
      * 'backend' - (Horde_Auth_Base) [REQUIRED] The backend object.
+     * 'charset' - (string) Default charset.
+     *             DEFAULT: NONE
      * 'folders' - (array) An array of folders to create under username.
      *             DEFAULT: NONE
      * 'imap' - (Horde_Imap_Client_Base) [REQUIRED] An IMAP client object.
@@ -85,6 +86,7 @@ class Horde_Auth_Cyrus extends Horde_Auth_Base
         unset($params['backend']);
 
         $params = array_merge(array(
+            'charset' => null,
             'separator' => '.',
         ), $params);
 
@@ -119,7 +121,7 @@ class Horde_Auth_Cyrus extends Horde_Auth_Base
     {
         $this->_backend->addUser($userId, $credentials);
 
-        $mailbox = Horde_String::convertCharset('user' . $this->_params['separator'] . $userId, $GLOBALS['registry']->getCharset(), 'utf7-imap');
+        $mailbox = Horde_String::convertCharset('user' . $this->_params['separator'] . $userId, $this->_params['charset'], 'utf7-imap');
 
         try {
             $this->_imap->createMailbox($mailbox);
@@ -131,7 +133,7 @@ class Horde_Auth_Cyrus extends Horde_Auth_Base
             is_array($this->_params['folders'])) {
             foreach ($this->_params['folders'] as $folder) {
                 try {
-                    $this->_imap->createMailbox($mailbox . Horde_String::convertCharset($this->_params['separator'] . $folder, $GLOBALS['registry']->getCharset(), 'utf7-imap'));
+                    $this->_imap->createMailbox($mailbox . Horde_String::convertCharset($this->_params['separator'] . $folder, $this->_params['charset'], 'utf7-imap'));
                 } catch (Horde_Imap_Client_Exception $e) {}
             }
         }
@@ -157,7 +159,7 @@ class Horde_Auth_Cyrus extends Horde_Auth_Base
     {
         $this->_backend->removeUser($userId);
 
-        $mailbox = Horde_String::convertCharset('user' . $this->_params['separator'] . $userId, $GLOBALS['registry']->getCharset(), 'utf7-imap');
+        $mailbox = Horde_String::convertCharset('user' . $this->_params['separator'] . $userId, $this->_params['charset'], 'utf7-imap');
 
         /* Set ACL for mailbox deletion. */
         list($admin) = explode('@', $this->_params['cyradmin']);
index 7627796..14a3203 100644 (file)
@@ -33,6 +33,8 @@ class Horde_Auth_Imap extends Horde_Auth_Base
      *                    DEFAULT: null
      * 'admin_user' - (string) The name of a user with admin privileges.
      *                DEFAULT: null
+     * 'charset' - (string) Default charset.
+     *             DEFAULT: NONE
      * 'hostspec' - (string) The hostname or IP address of the server.
      *              DEFAULT: 'localhost'
      * 'port' - (integer) The server port to which we will connect.
@@ -51,6 +53,7 @@ class Horde_Auth_Imap extends Horde_Auth_Base
         $params = array_merge(array(
             'admin_password' => null,
             'admin_user' => null,
+            'charset' => null,
             'hostspec' => '',
             'port' => null,
             'secure' => 'none',
@@ -99,7 +102,7 @@ class Horde_Auth_Imap extends Horde_Auth_Base
     {
         try {
             $ob = $this->_getOb($this->_params['admin_user'], $this->_params['admin_password']);
-            $mailbox = Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, $GLOBALS['registry']->getCharset(), 'utf7-imap');
+            $mailbox = Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, $this->_params['charset'], 'utf7-imap');
             $ob->createMailbox($mailbox);
             $ob->setACL($mailbox, $this->_params['admin_user'], 'lrswipcda');
         } catch (Horde_Imap_Client_Exception $e) {
@@ -119,7 +122,7 @@ class Horde_Auth_Imap extends Horde_Auth_Base
         try {
             $ob = $this->_getOb($this->_params['admin_user'], $this->_params['admin_password']);
             $ob->setACL($mailbox, $this->_params['admin_user'], 'lrswipcda');
-            $ob->deleteMailbox(Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, $GLOBALS['registry']->getCharset(), 'utf7-imap'));
+            $ob->deleteMailbox(Horde_String::convertCharset($this->_params['userhierarchy'] . $userId, $this->_params['charset'], 'utf7-imap'));
         } catch (Horde_Imap_Client_Exception $e) {
             throw new Horde_Auth_Exception($e);
         }
index b6ade05..2d0d1b3 100644 (file)
@@ -125,6 +125,8 @@ class Horde_Core_Factory_Auth
                 if ($lc_driver == 'cyrus') {
                     $params['backend'] = $this->getOb($params['backend']['driver'], $params['backend']['params']);
                 }
+
+                $params['charset'] = $GLOBALS['registry']->getCharset();
                 break;
 
             case 'http_remote':
@@ -133,6 +135,10 @@ class Horde_Core_Factory_Auth
                 }
                 break;
 
+            case 'imap':
+                $params['charset'] = $GLOBALS['registry']->getCharset();
+                break;
+
             case 'kolab':
                 $params['kolab'] = $this->_injector->getInstance('Horde_Kolab_Session');
                 break;