From e8c098c5774eab930c05f93a347f9d99b4c538c4 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 19 Jan 2010 18:14:43 -0700 Subject: [PATCH] Let Horde_Registry_Application handle the 'user' parameter --- framework/Core/lib/Horde/Registry.php | 8 +++++++- kronolith/lib/Application.php | 10 ---------- turba/lib/Application.php | 10 ---------- turba/scripts/import_vcards.php | 8 ++------ 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index a0025c468..abfca3c25 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -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. * * * @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; diff --git a/kronolith/lib/Application.php b/kronolith/lib/Application.php index b6772ce45..f32753d74 100644 --- a/kronolith/lib/Application.php +++ b/kronolith/lib/Application.php @@ -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: - *
-     * 'user' - (string) Set authentication to this user.
-     * 
*/ 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. */ diff --git a/turba/lib/Application.php b/turba/lib/Application.php index 696529952..ef4ed759e 100644 --- a/turba/lib/Application.php +++ b/turba/lib/Application.php @@ -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: - *
-     * 'user' - (string) Set authentication to this user.
-     * 
*/ 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'; diff --git a/turba/scripts/import_vcards.php b/turba/scripts/import_vcards.php index c23e4db84..9d27c03d9 100755 --- a/turba/scripts/import_vcards.php +++ b/turba/scripts/import_vcards.php @@ -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', -- 2.11.0