Let Horde_Registry_Application handle the 'user' parameter
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 20 Jan 2010 01:14:43 +0000 (18:14 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 20 Jan 2010 15:35:07 +0000 (08:35 -0700)
framework/Core/lib/Horde/Registry.php
kronolith/lib/Application.php
turba/lib/Application.php
turba/scripts/import_vcards.php

index a0025c4..abfca3c 100644 (file)
@@ -110,6 +110,7 @@ class Horde_Registry
      *   'none' - Do not start a session
      *   'readonly' - Start session readonly
      *   [DEFAULT] - Start read/write session
+     * 'user' - (string) Set authentication to this user.
      * </pre>
      *
      * @return Horde_Registry_Application  The application object.
@@ -122,7 +123,8 @@ class Horde_Registry
             'authentication' => null,
             'nocompress' => false,
             'nologintasks' => false,
-            'session_control' => null
+            'session_control' => null,
+            'user' => null
         ), $args);
 
         // Registry.
@@ -167,6 +169,10 @@ class Horde_Registry
             Horde::compressOutput();
         }
 
+        if ($args['user']) {
+            Horde_Auth::setAuth($args['user'], array());
+        }
+
         $appob->init();
 
         return $appob;
index b6772ce..f32753d 100644 (file)
@@ -44,19 +44,9 @@ class Kronolith_Application extends Horde_Registry_Application
      *
      * Global variables defined:
      *   $kronolith_shares - TODO
-     *
-     * When calling Horde_Registry::appInit(), the following parameters are
-     * also supported:
-     * <pre>
-     * 'user' - (string) Set authentication to this user.
-     * </pre>
      */
     protected function _init()
     {
-        if (isset($this->initParams['user'])) {
-            Horde_Auth::setAuth($this->initParams['user'], array());
-        }
-
         /* For now, autoloading the Content_* classes depend on there being a
          * registry entry for the 'content' application that contains at least
          * the fileroot entry. */
index 6965299..ef4ed75 100644 (file)
@@ -51,19 +51,9 @@ class Turba_Application extends Horde_Registry_Application
      *   $copymove_source_options - TODO
      *   $copymoveSources - TODO
      *   $turba_shares - TODO
-     *
-     * When calling Horde_Registry::appInit(), the following parameters are
-     * also supported:
-     * <pre>
-     * 'user' - (string) Set authentication to this user.
-     * </pre>
      */
     protected function _init()
     {
-        if (isset($this->initParams['user'])) {
-            Horde_Auth::setAuth($this->initParams['user'], array());
-        }
-
         // Turba source and attribute configuration.
         include TURBA_BASE . '/config/attributes.php';
         include TURBA_BASE . '/config/sources.php';
index c23e4db..9d27c03 100755 (executable)
@@ -14,8 +14,7 @@
  */
 
 // Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.local.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
 
 // Make sure no one runs this from the web.
 if (!Horde_Cli::runningFromCLI()) {
@@ -43,10 +42,7 @@ if (empty($vcard)) {
 }
 
 // Registry.
-$registry = Horde_Registry::singleton();
-
-// Set user.
-Horde_Auth::setAuth($user, array());
+Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $user));
 
 // Import data.
 $result = $registry->call('contacts/import',