Further flesh out base Horde initialization.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 13 Jan 2010 23:31:33 +0000 (16:31 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 15 Jan 2010 06:54:34 +0000 (23:54 -0700)
There is two ways Horde applications can be initialized: through a
Horde_Registry API call and by directly loading the application (i.e.
loading a script in an application).  Both methods (may) require base
initialization of the application (things like setting up paths to the
template files, creating app-specific objects) but the latter also
requires that the app initially be pushed on the stack. Since this
latter behavior needs to be done in all applications, and is essentially
the same in all apps, move it to the globally accessible function
Horde_Registry::appInit().

Other benefits: initiation of compression can now be done in a single
place

Test out this new framework by converting Turba.
Add new syntax to Skeleton.

134 files changed:
framework/Core/lib/Horde/Registry.php
framework/Core/lib/Horde/Registry/Application.php
horde/admin/alarms.php
horde/admin/cmdshell.php
horde/admin/datatree.php
horde/admin/groups.php
horde/admin/perms/addchild.php
horde/admin/perms/delete.php
horde/admin/perms/edit.php
horde/admin/perms/index.php
horde/admin/phpshell.php
horde/admin/sessions.php
horde/admin/setup/config.php
horde/admin/setup/diff.php
horde/admin/setup/index.php
horde/admin/setup/scripts.php
horde/admin/signup_confirm.php
horde/admin/sqlshell.php
horde/admin/user.php
horde/bin/alarms
horde/bin/db_migrate
horde/index.php
horde/lib/Application.php
horde/login.php
horde/rampage.php
horde/rpc.php
horde/scripts/cookie_login.php
horde/scripts/get_login.php
horde/scripts/http_login_refer.php
horde/scripts/import_squirrelmail_file_prefs.php
horde/scripts/import_squirrelmail_sql_prefs.php
horde/scripts/upgrades/2008-04-09_horde_syncml_map.php
horde/scripts/upgrades/convert_datatree_groups_to_sql.php
horde/scripts/upgrades/convert_datatree_perms_to_sql.php
horde/scripts/upgrades/migrate_user_categories.php
horde/scripts/upgrades/move_history_out_of_datatree.php
horde/services/cache.php
horde/services/cacheview.php
horde/services/changepassword.php
horde/services/confirm.php
horde/services/facebook.php
horde/services/go.php
horde/services/help/index.php
horde/services/images/view.php
horde/services/imple.php
horde/services/javascript.php
horde/services/keyboard.php
horde/services/language.php
horde/services/logintasks.php
horde/services/obrowser/index.php
horde/services/portal/cloud_search.php
horde/services/portal/edit.php
horde/services/portal/index.php
horde/services/portal/mobile.php
horde/services/portal/rpcsum.php
horde/services/portal/sidebar.php
horde/services/portal/syncml.php
horde/services/problem.php
horde/services/resetpassword.php
horde/services/shares/edit.php
horde/services/snooze.php
horde/services/twitter.php
horde/services/twitterapi.php
horde/signup.php
horde/test.php
imp/acl.php
imp/ajax.php
imp/attachment.php
imp/compose-dimp.php
imp/compose-mimp.php
imp/compose.php
imp/contacts.php
imp/filterprefs.php
imp/folders-mimp.php
imp/folders.php
imp/index-dimp.php
imp/index.php
imp/lib/Application.php
imp/lib/Auth.php
imp/lib/Block/Foldersummary.php
imp/lib/Block/Newmail.php
imp/lib/Block/summary.php
imp/lib/Block/tree_folders.php
imp/mailbox-mimp.php
imp/mailbox.php
imp/message-dimp.php
imp/message-mimp.php
imp/message.php
imp/pgp.php
imp/rss.php
imp/saveimage.php
imp/search-basic.php
imp/search.php
imp/smime.php
imp/stationery.php
imp/thread.php
imp/view.php
skeleton/config/horde.local.php.dist [new file with mode: 0644]
skeleton/lib/Application.php
skeleton/lib/base.load.php [deleted file]
skeleton/lib/base.php [deleted file]
skeleton/list.php
turba/add.php
turba/addressbooks/create.php
turba/addressbooks/delete.php
turba/addressbooks/edit.php
turba/addressbooks/index.php
turba/browse.php
turba/contact.php
turba/data.php
turba/delete.php
turba/deletefile.php
turba/edit.php
turba/index.php
turba/lib/Api.php
turba/lib/Application.php
turba/lib/Block/minisearch.php
turba/lib/Block/tree_menu.php
turba/lib/base.load.php [deleted file]
turba/lib/base.php [deleted file]
turba/lib/tests/ApiTest.php
turba/lib/tests/KolabTestBase.php
turba/minisearch.php
turba/scripts/import_squirrelmail_file_abook.php
turba/scripts/import_squirrelmail_sql_abook.php
turba/scripts/upgrades/2.1_to_2.2_sql_schema.php
turba/scripts/upgrades/2005-09-23_flat_comments.php
turba/scripts/upgrades/2007-06-17_delete_old_vbooks.php
turba/scripts/upgrades/2007-06-17_flatten_shares.php
turba/scripts/upgrades/convert_datatree_shares_to_sql.php
turba/scripts/upgrades/public_to_horde_share.php
turba/search.php
turba/vcard.php
turba/view.php

index 9c114cf..f399047 100644 (file)
@@ -84,6 +84,95 @@ class Horde_Registry
     public $applications = array();
 
     /**
+     * Application initialization (called from within an application).
+     * Solves chicken-and-egg problem - need a way to init Horde environment
+     * from application without an active Horde_Registry object.
+     *
+     * Page compression will be started (if configured) via this function.
+     *
+     * Global variables defined:
+     *   $registry - Registry object
+     *
+     * @param string $app  The application to initialize.
+     * @param array $args  Optional arguments:
+     * <pre>
+     * 'admin' - (boolean) Require authenticated user to be an admin?
+     * 'authentication' - (string) The type of authentication to use:
+     *   'none'  - Do not authenticate
+     *   'throw' - Authenticate; on no auth, throw a Horde_Exception
+     *   [DEFAULT] - Authenticate; on no auth redirect to login screen
+     * 'nocompress' - (boolean) Controls whether the page should be
+     *                compressed.
+     * 'nologintasks' - (boolean) If set, don't perform logintasks (never
+     *                  performed if authentication is 'none').
+     * 'session_control' - (string) Sets special session control limitations:
+     *   'netscape' - TODO; start read/write session
+     *   'none' - Do not start a session
+     *   'readonly' - Start session readonly
+     *   [DEFAULT] - Start read/write session
+     * </pre>
+     *
+     * @return Horde_Registry_Application  The application object.
+     * @throws Horde_Exception
+     */
+    static public function appInit($app, $args = array())
+    {
+        $args = array_merge(array(
+            'admin' => false,
+            'authentication' => null,
+            'nocompress' => false,
+            'nologintasks' => false,
+            'session_control' => null
+        ), $args);
+
+        // Registry.
+        $s_ctrl = 0;
+        switch ($args['session_control']) {
+        case 'netscape':
+            if ($GLOBALS['browser']->isBrowser('mozilla')) {
+                session_cache_limiter('private, must-revalidate');
+            }
+            break;
+
+        case 'none':
+            $s_ctrl = self::SESSION_NONE;
+            break;
+
+        case 'readonly':
+            $s_ctrl = self::SESSION_READONLY;
+            break;
+        }
+
+        $GLOBALS['registry'] = self::singleton($s_ctrl);
+        $appob = $GLOBALS['registry']->getApiInstance($app, 'application');
+        $appob->initParams = $args;
+
+        try {
+            $GLOBALS['registry']->pushApp($app, array('check_perms' => ($args['authentication'] != 'none'), 'logintasks' => !$args['nologintasks']));
+
+            if ($args['admin'] && !Horde_Auth::isAdmin()) {
+                throw new Horde_Exception('Not an admin');
+            }
+        } catch (Horde_Exception $e) {
+            $appob->appInitFailure($e);
+
+            if ($args['authentication'] == 'throw') {
+                throw $e;
+            }
+
+            Horde_Auth::authenticateFailure($app, $e);
+        }
+
+        if (!$args['nocompress']) {
+            Horde::compressOutput();
+        }
+
+        $appob->init();
+
+        return $appob;
+    }
+
+    /**
      * Returns a reference to the global Horde_Registry object, only creating
      * it if it doesn't already exist.
      *
@@ -357,7 +446,7 @@ class Horde_Registry
         foreach (array_keys($this->applications) as $app) {
             if (in_array($this->applications[$app]['status'], $status)) {
                 try {
-                    $api = $this->_getApiInstance($app, 'api');
+                    $api = $this->getApiInstance($app, 'api');
                     $this->_cache['api'][$app] = array(
                         'api' => array_diff(get_class_methods($api), array('__construct'), $api->disabled),
                         'links' => $api->links,
@@ -381,7 +470,7 @@ class Horde_Registry
      * @return Horde_Registry_Api|Horde_Registry_Application  The API object.
      * @throws Horde_Exception
      */
-    protected function _getApiInstance($app, $type)
+    public function getApiInstance($app, $type)
     {
         if (isset($this->_cache['ob'][$app][$type])) {
             return $this->_cache['ob'][$app][$type];
@@ -403,7 +492,7 @@ class Horde_Registry
             throw new Horde_Exception("$app does not have an API");
         }
 
-        $this->_cache['ob'][$app][$type] = new $classname;
+        $this->_cache['ob'][$app][$type] = new $classname();
         return $this->_cache['ob'][$app][$type];
     }
 
@@ -551,7 +640,7 @@ class Horde_Registry
     public function hasAppMethod($app, $method)
     {
         try {
-            $appob = $this->_getApiInstance($app, 'application');
+            $appob = $this->getApiInstance($app, 'application');
         } catch (Horde_Exception $e) {
             return false;
         }
@@ -605,7 +694,7 @@ class Horde_Registry
         }
 
         /* Load the API now. */
-        $api = $this->_getApiInstance($app, 'api');
+        $api = $this->getApiInstance($app, 'api');
 
         /* Make sure that the function actually exists. */
         if (!method_exists($api, $call)) {
@@ -662,7 +751,7 @@ class Horde_Registry
         }
 
         /* Load the API now. */
-        $api = $this->_getApiInstance($app, 'application');
+        $api = $this->getApiInstance($app, 'application');
 
         /* Switch application contexts now, if necessary, before
          * including any files which might do it for us. Return an
@@ -1122,7 +1211,7 @@ class Horde_Registry
         }
 
         try {
-            $api = $this->_getApiInstance($app, 'application');
+            $api = $this->getApiInstance($app, 'application');
             return $api->version;
         } catch (Horde_Exception $e) {
             return 'unknown';
@@ -1143,7 +1232,7 @@ class Horde_Registry
         }
 
         try {
-            $api = $this->_getApiInstance($app, 'application');
+            $api = $this->getApiInstance($app, 'application');
             return $api->mobileView;
         } catch (Horde_Exception $e) {
             return false;
index b9689ce..f76574d 100644 (file)
@@ -34,11 +34,47 @@ class Horde_Registry_Application
     public $disabled = array();
 
     /**
+     * The init params used.
+     *
+     * @var array
+     */
+    public $initParams = array();
+
+    /**
+     * Has init() previously been called?
+     *
+     * @var boolean
+     */
+    protected $_initDone = false;
+
+    /**
+     * Application-specific code to run if application auth fails.
+     * Called from Horde_Registry::appInit().
+     *
+     * @param Horde_Exception $e  The exception object.
+     */
+    public function appInitFailure($e)
+    {
+    }
+
+    /**
      * Initialization. Does any necessary init needed to setup the full
      * environment for the application.
      */
     public function init()
     {
+        if (!$this->_initDone) {
+            $this->_initDone = true;
+            $this->_init();
+        }
+    }
+
+    /**
+     * Initialization code for an application should be defined in this
+     * function.
+     */
+    protected function _init()
+    {
     }
 
 }
index b9daa51..76aef3c 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 $horde_alarm = Horde_Alarm::factory();
 $methods = array();
index 094aa88..d95bcf9 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 $title = _("Command Shell");
 require HORDE_TEMPLATES . '/common-header.inc';
index ddf8eb5..070e3e1 100644 (file)
@@ -27,7 +27,7 @@ function addTree($parent, $parent_id, $indent = 1)
 }
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 require_once 'Horde/DataTree.php';
 $tree = Horde_Tree::factory('datatree', 'Html');
index f90d48b..4d5a70f 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 require_once 'Horde/Group.php';
 $groups = Group::singleton();
index 271ad6b..e4b2a36 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 /* Set up the form variables. */
 $vars = Horde_Variables::getDefaultVariables();
index d9c70f1..faa3000 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 /* Set up the form variables. */
 $vars = Horde_Variables::getDefaultVariables();
index 9bb063c..7931f22 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 /* Set up the form variables. */
 $vars = &Horde_Variables::getDefaultVariables();
index 2374ef2..a03a7f3 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 $perm_id = Horde_Util::getFormData('perm_id');
 
index deff4ec..11398e5 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 $title = _("PHP Shell");
 Horde::addScriptFile('stripe.js', 'horde');
index a95e8e3..c3a05c1 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 $type = !empty($conf['sessionhandler']['type']) ? $conf['sessionhandler']['type'] : 'none';
 if ($type == 'external') {
index a8ea974..18699d7 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 if (!Horde_Util::extensionExists('domxml') &&
     !Horde_Util::extensionExists('dom')) {
index 18f2fdc..6a235ee 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 /* Set up the diff renderer. */
 $render_type = Horde_Util::getFormData('render', 'inline');
index 1f9066c..e129696 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 /**
  * Does an FTP upload to save the configuration.
index b268fbc..d50fc89 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 /* Get form data. */
 $setup = Horde_Util::getFormData('setup');
index e5d721d..83a0eba 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/base.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 // Make sure signups are enabled before proceeding
 $auth = Horde_Auth::singleton($conf['auth']['driver']);
index 01516a0..47c97d6 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 $title = _("SQL Shell");
 Horde::addScriptFile('stripe.js', 'horde');
index ac9b422..1dcaf0d 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('admin' => true));
+Horde_Registry::appInit('horde', array('admin' => true));
 
 $auth = Horde_Auth::singleton($conf['auth']['driver']);
 
index 7a6e769..23ee796 100755 (executable)
@@ -22,7 +22,7 @@ if (!Horde_Cli::runningFromCLI()) {
 Horde_Cli::init();
 
 // Include needed libraries.
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 // Authenticate as administrator.
 if (!count($conf['auth']['admins'])) {
index 9a74743..4742353 100755 (executable)
@@ -23,7 +23,7 @@ Horde_Cli::init();
 $cli = Horde_Cli::singleton();
 
 // Include needed libraries.
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 // Get a database connection
 $db = $GLOBALS['injector']->getInstance('db-manager');
index aa98d2e..fbb74f7 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new Horde_Application(array('authentication' => 'none', 'nologintasks' => true));
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'nologintasks' => true));
 
 $main_page = Horde_Util::nonInputVar('horde_login_url', Horde_Util::getFormData('url'));
 
index b2bbdd1..7f5ab31 100644 (file)
@@ -25,84 +25,28 @@ class Horde_Application extends Horde_Registry_Application
     public $version = '4.0-git';
 
     /**
-     * Constructor.
+     * Application initialization.
      *
      * Global variables defined:
      *   $notification - Notification object
-     *   $registry     - Registry object
      *
      * Global constants defined:
      *   HORDE_TEMPLATES - (string) Location of template files.
-     *
-     * @param array $args  Optional arguments:
-     * <pre>
-     * 'admin' - (boolean) Require authenticated user to be and admin?
-     * 'authentication' - (string) The type of authentication to use:
-     *   'none'  - Do not authenticate
-     *   'throw' - Authenticate; on no auth, throw a Horde_Exception
-     *   [DEFAULT] - Authenticate; on no auth redirect to login screen
-     * 'nocompress' - (boolean) Controls whether the page should be
-     *                compressed.
-     * 'nologintasks' - (boolean) If set, don't perform logintasks (never
-     *                  performed if authentication is 'none').
-     * 'session_control' - (string) Sets special session control limitations:
-     *   'none' - Do not start a session
-     *   'readonly' - Start session readonly
-     *   [DEFAULT] - Start read/write session
-     * </pre>
      */
-    public function __construct($args = array())
+    protected function _init()
     {
-        $args = array_merge(array(
-            'admin' => false,
-            'authentication' => null,
-            'nocompress' => false,
-            'nologintasks' => false,
-            'session_control' => null
-        ), $args);
-
-        // Registry.
-        $s_ctrl = 0;
-        switch ($args['session_control']) {
-        case 'none':
-            $s_ctrl = Horde_Registry::SESSION_NONE;
-            break;
-
-        case 'readonly':
-            $s_ctrl = Horde_Registry::SESSION_READONLY;
-            break;
-        }
-        $GLOBALS['registry'] = Horde_Registry::singleton($s_ctrl);
-
-        try {
-            $GLOBALS['registry']->pushApp('horde', array('check_perms' => ($args['authentication'] != 'none'), 'logintasks' => !$args['nologintasks']));
-
-            if ($args['admin'] && !Horde_Auth::isAdmin()) {
-                throw new Horde_Exception('Not an admin');
-            }
-        } catch (Horde_Exception $e) {
-            if ($args['authentication'] == 'throw') {
-                throw $e;
-            }
-
-            Horde_Auth::authenticateFailure('horde', $e);
-        }
-
         if (!defined('HORDE_TEMPLATES')) {
             define('HORDE_TEMPLATES', $GLOBALS['registry']->get('templates'));
         }
 
         $GLOBALS['notification'] = Horde_Notification::singleton();
         $GLOBALS['notification']->attach('status');
-
-        // Start compression.
-        if (!$args['nocompress']) {
-            Horde::compressOutput();
-        }
     }
 
     /**
      * Returns a list of available permissions.
+     *
+     * @return array  TODO
      */
     public function perms()
     {
index eecc58c..7eef8cd 100644 (file)
@@ -77,7 +77,7 @@ function _getLogoutReasonString($code)
  * constructor. */
 require_once dirname(__FILE__) . '/lib/Application.php';
 try {
-    new Horde_Application(array('authentication' => 'throw', 'nologintasks' => true));
+    Horde_Registry::appInit('horde', array('authentication' => 'throw', 'nologintasks' => true));
 } catch (Horde_Exception $e) {}
 
 $app = Horde_Util::getFormData('app');
index 84a086b..ab71eb8 100644 (file)
@@ -24,7 +24,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 // Set up our request and routing objects
 $request = new Horde_Controller_Request_Http();
index 0ba1e43..cc12b37 100644 (file)
@@ -78,7 +78,7 @@ if (($ra = Horde_Util::getGet('requestMissingAuthorization')) !== null) {
 }
 
 /* Load base libraries. */
-new Horde_Application(array('authentication' => 'none', 'nocompress' => $nocompress, 'session_control' => $session_control));
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'nocompress' => $nocompress, 'session_control' => $session_control));
 
 /* Load the RPC backend based on $serverType. */
 $server = Horde_Rpc::factory($serverType, $params);
index 2e5d21d..61371be 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 $auth = Horde_Auth::singleton($conf['auth']['driver']);
 
index 98a4ad9..73360ed 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 $auth = Horde_Auth::singleton($conf['auth']['driver']);
 
index 1586f2a..c1e3d88 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 $auth = Horde_Auth::singleton($conf['auth']['driver']);
 
index dbfed1e..6e34610 100755 (executable)
@@ -39,7 +39,7 @@ $data = $argv[1];
 
 // Make sure we load Horde base to get the auth config
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 require_once dirname(__FILE__) . '/import_squirrelmail_prefs.php';
 
index 3438b52..7f1f3c2 100755 (executable)
@@ -37,7 +37,7 @@ if ($argc != 2) {
 $dsn = $argv[1];
 
 // Make sure we load Horde base to get the auth config
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 require_once dirname(__FILE__) . '/import_squirrelmail_prefs.php';
 
index 19b8be2..711edd8 100755 (executable)
@@ -18,7 +18,7 @@ if (!Horde_Cli::runningFromCLI()) {
 Horde_Cli::init();
 $cli = Horde_Cli::singleton();
 
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 require_once 'Horde/DataTree.php';
 $datatree = DataTree::factory('sql',
index 9c5bd77..9ad3cde 100755 (executable)
@@ -17,7 +17,7 @@ if (!Horde_Cli::runningFromCLI()) {
 // some variables, etc.
 Horde_Cli::init();
 
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 require_once 'Horde/Group.php';
 $g = Group::factory();
index 177cc22..145562e 100755 (executable)
@@ -17,7 +17,7 @@ if (!Horde_Cli::runningFromCLI()) {
 // some variables, etc.
 Horde_Cli::init();
 
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 $p = Perms::factory('datatree');
 
index a118b85..21e60ef 100755 (executable)
@@ -20,7 +20,7 @@ if (!Horde_Cli::runningFromCLI()) {
 // some variables, etc.
 Horde_Cli::init();
 
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 $cli = Horde_Cli::singleton();
 $cManager = new Horde_Prefs_CategoryManager();
index 0209fab..7ef41f1 100755 (executable)
@@ -21,7 +21,7 @@ $cli = Horde_Cli::singleton();
 $cli->writeln($cli->yellow("Beginning migration. This may take a very long time to complete."));
 $cli->writeln();
 
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 require_once 'Horde/DataTree.php';
 $datatree = DataTree::factory('sql', array_merge(Horde::getDriverConfig('datatree', 'sql'),
index a4151af..58efda2 100644 (file)
@@ -41,7 +41,7 @@ if (empty($args['nocache'])) {
     $session_cache_limiter = 'nocache';
 }
 
-new Horde_Application(array('authentication' => 'none', 'session_control' => 'readonly'));
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'session_control' => 'readonly'));
 
 switch ($type) {
 case 'app':
index eb13ea8..82278cb 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
 
 $cid = Horde_Util::getFormData('cid');
 if (empty($cid)) {
index 882c4a4..3291292 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
 
 // Make sure auth backend allows passwords to be reset.
 $auth = Horde_Auth::singleton($conf['auth']['driver']);
index 63e5c5a..182e455 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
 
 $identity = Horde_Prefs_Identity::singleton();
 list($message, $type) = $identity->confirmIdentity(Horde_Util::getFormData('h'));
index 0da4985..544f963 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 if (empty($GLOBALS['conf']['facebook']['enabled']) ||
     empty($GLOBALS['conf']['facebook']['key']) ||
index cc9fd53..f82ede2 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none', 'session_control' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none', 'session_control' => 'none'));
 
 if (empty($_GET['url'])) {
     exit;
index 25d9e80..b8bf1c5 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 $rtl = isset(Horde_Nls::$config['rtl'][$language]);
 $title = _("Help");
index e3ac9b6..3b2a4b7 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
 
 /* Get file info. The following parameters are available:
  *  'f' - the filename.
index 9bd059e..f6412a5 100644 (file)
@@ -58,7 +58,7 @@ if (!empty($args['post'])) {
     }
 }
 
-new Horde_Application(array('nologintasks' => true, 'session_control' => empty($args['sessionWrite']) ? 'readonly' : null));
+Horde_Registry::appInit('horde', array('nologintasks' => true, 'session_control' => empty($args['sessionWrite']) ? 'readonly' : null));
 
 $impleargs = $impleName;
 if (isset($args['impleApp'])) {
index 421fd7c..0b998fd 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('session_control' => 'readonly'));
+Horde_Registry::appInit('horde', array('session_control' => 'readonly'));
 
 // Figure out if we've been inlined, or called directly.
 $send_headers = strstr($_SERVER['PHP_SELF'], 'javascript.php');
index 6c7cb4f..ad8361d 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
 
 $title = _("Special Character Input");
 require HORDE_TEMPLATES . '/common-header.inc';
index f26192b..fd24ada 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 /* Set the language. */
 $_SESSION['horde_language'] = Horde_Nls::select();
index 4b784f2..5bbb2a4 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
 
 /* If no 'module' parameter passed in, die with an error. */
 if (!($app = basename(Horde_Util::getFormData('app')))) {
index 1f0574c..b1e3958 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 $path = Horde_Util::getFormData('path');
 
index 8692c9e..fdc73c4 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('nologintaks' => true));
+Horde_Registry::appInit('horde', array('nologintaks' => true));
 
 // If/when more apps support the searchTags api calls, we should probably
 // find a better solution to putting the apps hardcoded like this.
index d892318..d135d60 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 // Instantiate the blocks objects.
 $blocks = Horde_Block_Collection::singleton('portal');
index 0d32d6d..0c97597 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 // Get full name.
 $identity = Horde_Prefs_Identity::singleton();
index ddb1a0d..af7d808 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 $identity = Horde_Prefs_Identity::singleton();
 $fullname = $identity->getValue('fullname');
index 194efb9..dedd79d 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 $rpc_servers = @unserialize($prefs->getValue('remote_summaries'));
 if (!is_array($rpc_servers)) {
index 6bfee80..db1728a 100644 (file)
@@ -203,7 +203,7 @@ function buildMenu()
 }
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 if (!Horde_Auth::getAuth() && !$conf['menu']['always']) {
     Horde_Auth::authenticateFailure();
index 8c96690..cb79aee 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 $backend = SyncML_Backend::factory('Horde');
 
index 3f1fad6..ad1355e 100644 (file)
@@ -17,7 +17,7 @@ function _returnToPage()
 }
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 if (!Horde::showService('problem')) {
     _returnToPage();
index 72e43d5..a90d555 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 // Make sure auth backend allows passwords to be reset.
 $auth = Horde_Auth::singleton($conf['auth']['driver']);
index bcc639f..b493c97 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 // Exit if the user shouldn't be able to change share permissions.
 if (!empty($conf['share']['no_sharing'])) {
index 15f0ab5..1471629 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
 
 $alarm = Horde_Alarm::factory();
 $id = Horde_Util::getPost('alarm');
index e31b626..b7d27a5 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application();
+Horde_Registry::appInit('horde');
 
 if (empty($GLOBALS['conf']['twitter']['enabled'])) {
     $horde_url = Horde::url($registry->get('webroot', 'horde') . '/index.php');
index 31a43f3..f9f55e1 100644 (file)
@@ -14,7 +14,7 @@
  */
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-new Horde_Application(array('nologintasks' => true));
+Horde_Registry::appInit('horde', array('nologintasks' => true));
 
 $twitter = new Services_Twitter($_SESSION['horde']['twitterblock']['username'],
                                 $_SESSION['horde']['twitterblock']['password']);
index 595f2f8..8bf0ebd 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 $auth = Horde_Auth::singleton($conf['auth']['driver']);
 
index f765b97..e365f8d 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-$api = new Horde_Application(array('authentication' => 'none'));
+Horde_Registry::appInit('horde', array('authentication' => 'none'));
 
 if (!empty($conf['testdisable'])) {
     echo '<h2 style="color:red">Horde test scripts have been disabled in the local configuration.</h2>';
@@ -49,8 +49,7 @@ $app_version = $registry->getVersion($app);
 /* If we've gotten this far, we should have found enough of Horde to run
  * tests. Create the testing object. */
 if ($app != 'horde') {
-    $registry->pushApp($app, array('check_perms' => false));
-    print "C";
+    $registry->pushApp($app, array('check_perms' => false, 'init' => true));
 }
 $classname = ucfirst($app) . '_Test';
 if (!class_exists($classname)) {
index 2b4e6d3..26ec521 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 /* Redirect back to the options screen if ACL is not enabled. */
 $prefs_url = Horde::getServiceLink('options', 'imp');
index 51f7460..920bba6 100644 (file)
@@ -159,7 +159,7 @@ if (in_array($action, array('chunkContent', 'Html2Text', 'Text2Html', 'GetReplyD
 }
 
 try {
-    new IMP_Application(array('init' => array('authentication' => 'throw', 'session_control' => $session_control)));
+    Horde_Registry::appInit('imp', array('authentication' => 'throw', 'session_control' => $session_control));
 } catch (Horde_Exception $e) {
     /* Handle session timeouts when they come from an AJAX request. */
     if (($e->getCode() == Horde_Registry::AUTH_FAILURE) &&
index 921ae58..4e92a10 100644 (file)
@@ -17,7 +17,7 @@
 // We do not need to be authenticated to get the file. Most users won't send
 // linked attachments just to other IMP users.
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => array('authentication' => 'none', 'session_control' => 'none')));
+Horde_Registry::appInit('imp', array('authentication' => 'none', 'session_control' => 'none'));
 
 // Lets see if we are even able to send the user an attachment.
 if (!$conf['compose']['link_attachments']) {
index e27d473..a25b574 100644 (file)
@@ -18,7 +18,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
 
 /* Determine if compose mode is disabled. */
 $compose_disable = !IMP::canCompose();
index 797a7db..2e61e68 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
 
 /* The message text and headers. */
 $expand = array();
index 3c7bd6e..e46376b 100644 (file)
@@ -42,7 +42,7 @@ function _popupSuccess()
 
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => array('session_control' => 'netscape'), 'tz' => true));
+Horde_Registry::appInit('imp', array('session_control' => 'netscape', 'tz' => true));
 
 /* The message headers and text. */
 $header = array();
index 245d33e..f65c2fb 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => array('authentication' => 'horde')));
+Horde_Registry::appInit('imp', array('authentication' => 'horde'));
 
 /* Get the lists of address books through the API. */
 $source_list = $registry->call('contacts/sources');
index e588a16..a2137fb 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 /* Are preferences locked? */
 $login_locked = $prefs->isLocked('filter_on_login') || empty($_SESSION['imp']['filteravail']);
index 95bc833..62d1db5 100644 (file)
@@ -17,7 +17,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 /* Redirect back to the mailbox if folder use is not allowed. */
 if (empty($conf['user']['allow_folders'])) {
index e32e49c..85fa93f 100644 (file)
@@ -14,7 +14,8 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
+
 Horde::addScriptFile('folders.js', 'imp');
 
 /* Redirect back to the mailbox if folder use is not allowed. */
index 1d17fed..2905c49 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 $scripts = array(
     array('ContextSensitive.js', 'imp'),
index 5495e57..30fec51 100644 (file)
@@ -11,7 +11,7 @@
 
 // Will redirect to login page if not authenticated.
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 // Load initial page as defined by view mode & preferences.
 require IMP_Auth::getInitialPage();
index 2656a51..a8bd8e2 100644 (file)
@@ -47,20 +47,6 @@ class IMP_Application extends Horde_Registry_Application
     public $version = 'H4 (5.0-git)';
 
     /**
-     * Disable compression of pages?
-     *
-     * @var boolean
-     */
-    protected $_noCompress = false;
-
-    /**
-     * The auth type to use.
-     *
-     * @var string
-     */
-    static public $authType = null;
-
-    /**
      * Cached data for prefs pages.
      *
      * @var array
@@ -68,41 +54,33 @@ class IMP_Application extends Horde_Registry_Application
     static public $prefsCache = array();
 
     /**
-     * Has init previously been called?
-     *
-     * @var boolean
+     * Constructor.
      */
-    static protected $_init = false;
+    public function __construct()
+    {
+        /* Methods only available if admin config is set for this
+         * server/login. */
+        if (empty($_SESSION['imp']['admin'])) {
+            $this->disabled = array_merge($this->disabled, array('authAddUser', 'authRemoveUser', 'authUserList'));
+        }
+    }
 
     /**
-     * Constructor.
+     * Application-specific code to run if application auth fails.
      *
-     * @param array $args  The following entries:
-     * <pre>
-     * 'init' - (boolean|array) If true, perform application init. If an
-     *          array, perform application init and pass the array to
-     *          self::_impInit().
-     * 'tz' - (boolean) If true, sets the current time zone on the server.
-     * </pre>
+     * @param Horde_Exception $e  The exception object.
      */
-    public function __construct($args = array())
+    public function appInitFailure($e)
     {
-        if (!empty($args['init'])) {
-            $this->_impInit(is_array($args['init']) ? $args['init'] : array());
-        }
-
-        if (!empty($args['tz'])) {
-            Horde_Nls::setTimeZone();
-        }
-
-        /* Only available if admin config is set for this server/login. */
-        if (empty($_SESSION['imp']['admin'])) {
-            $this->disabled = array_merge($this->disabled, array('authAddUser', 'authRemoveUser', 'authUserList'));
+        if (($e->getCode() == Horde_Registry::AUTH_FAILURE) &&
+            Horde_Util::getFormData('composeCache')) {
+            $imp_compose = IMP_Compose::singleton();
+            $imp_compose->sessionExpireDraft();
         }
     }
 
     /**
-     * IMP base initialization.
+     * Initialization function.
      *
      * Global variables defined:
      *   $imp_imap     - An IMP_Imap object
@@ -110,86 +88,20 @@ class IMP_Application extends Horde_Registry_Application
      *   $imp_notify   - A Horde_Notification_Listener object
      *   $imp_search   - An IMP_Search object
      *   $notification - Notification object
-     *   $registry     - Registry object
      *
      * Global constants defined:
      *   IMP_TEMPLATES - (string) Location of template files.
      *
-     * @param array $args  Optional arguments:
+     * When calling Horde_Registry::appInit(), the following parameters are
+     * also supported:
      * <pre>
-     * 'authentication' - (string) The type of authentication to use:
-     *   'horde' - Only use horde authentication
-     *   'none'  - Do not authenticate
-     *   'throw' - Authenticate to IMAP/POP server; on no auth, throw a
-     *             Horde_Exception
-     *   [DEFAULT] - Authenticate to IMAP/POP server; on no auth redirect to
-     *               login screen
-     * 'nocompress' - (boolean) Controls whether the page should be
-     *                 compressed.
-     * 'session_control' - (string) Sets special session control limitations:
-     *   'netscape' - TODO; start read/write session
-     *   'none' - Do not start a session
-     *   'readonly' - Start session readonly
-     *   [DEFAULT] - Start read/write session
+     * 'tz' - (boolean) If true, sets the current time zone on the server.
      * </pre>
      */
-    protected function _impInit($args = array())
+    protected function _init()
     {
-        $args = array_merge(array(
-            'authentication' => null,
-            'nocompress' => false,
-            'session_control' => null
-        ), $args);
-
-        self::$authType = $args['authentication'];
-        $this->_noCompress = $args['nocompress'];
-
-        // Registry.
-        $s_ctrl = 0;
-        switch ($args['session_control']) {
-        case 'netscape':
-            if ($GLOBALS['browser']->isBrowser('mozilla')) {
-                session_cache_limiter('private, must-revalidate');
-            }
-            break;
-
-        case 'none':
-            $s_ctrl = Horde_Registry::SESSION_NONE;
-            break;
-
-        case 'readonly':
-            $s_ctrl = Horde_Registry::SESSION_READONLY;
-            break;
-        }
-        $GLOBALS['registry'] = Horde_Registry::singleton($s_ctrl);
-
-        try {
-            $GLOBALS['registry']->pushApp('imp', array('check_perms' => ($args['authentication'] != 'none'), 'logintasks' => true));
-        } catch (Horde_Exception $e) {
-            if ($e->getCode() == Horde_Registry::AUTH_FAILURE) {
-                if (Horde_Util::getFormData('composeCache')) {
-                    $imp_compose = IMP_Compose::singleton();
-                    $imp_compose->sessionExpireDraft();
-                }
-
-                if ($args['authentication'] == 'throw') {
-                    throw $e;
-                }
-            }
-
-            Horde_Auth::authenticateFailure('imp', $e);
-        }
-
-        $this->init();
-    }
-
-    /**
-     * Initialization function.
-     */
-    public function init()
-    {
-        if (self::$_init) {
-            return;
+        if (!empty($this->initParams['tz'])) {
+            Horde_Nls::setTimeZone();
         }
 
         if (!defined('IMP_TEMPLATES')) {
@@ -197,11 +109,6 @@ class IMP_Application extends Horde_Registry_Application
             define('IMP_TEMPLATES', $registry->get('templates'));
         }
 
-        // Start compression.
-        if (!$this->_noCompress) {
-            Horde::compressOutput();
-        }
-
         // Initialize global $imp_imap object.
         if (!isset($GLOBALS['imp_imap'])) {
             $GLOBALS['imp_imap'] = new IMP_Imap();
@@ -231,8 +138,6 @@ class IMP_Application extends Horde_Registry_Application
         // Initialize global $imp_mbox array. This call also initializes the
         // IMP_Search object.
         IMP::setCurrentMailboxInfo();
-
-        self::$_init = true;
     }
 
     /* Horde permissions. */
@@ -390,7 +295,7 @@ class IMP_Application extends Horde_Registry_Application
      */
     public function authAuthenticate($userId, $credentials)
     {
-        $this->_impInit(array('authentication' => 'none'));
+        $this->init();
 
         $new_session = IMP_Auth::authenticate(array(
             'password' => $credentials['password'],
@@ -416,7 +321,7 @@ class IMP_Application extends Horde_Registry_Application
      */
     public function authTransparent($auth_ob)
     {
-        $this->_impInit(array('authentication' => 'none'));
+        $this->init();
         return IMP_Auth::transparent($auth_ob);
     }
 
@@ -428,7 +333,7 @@ class IMP_Application extends Horde_Registry_Application
     public function authAuthenticateCallback()
     {
         if (Horde_Auth::getAuth()) {
-            $this->_impInit();
+            $this->init();
             IMP_Auth::authenticateCallback();
         }
     }
@@ -742,9 +647,6 @@ class IMP_Application extends Horde_Registry_Application
      */
     public function prefsStatus()
     {
-        require_once dirname(__FILE__) . '/Application.php';
-        new IMP_Application(array('init' => array('authentication' => 'none')));
-
         $notification = Horde_Notification::singleton();
         $notification->replace('status', array('prefs' => true, 'viewmode' => 'dimp'), 'IMP_Notification_Listener_Status');
     }
@@ -1075,12 +977,7 @@ class IMP_Application extends Horde_Registry_Application
      */
     public function changeLanguage()
     {
-        try {
-            $this->_impInit(array('authentication' => 'throw'));
-        } catch (Horde_Exception $e) {
-            return;
-        }
-
+        $this->init();
         $this->_mailboxesChanged();
         $GLOBALS['imp_search']->initialize(true);
     }
index 124296e..8f7b8a5 100644 (file)
@@ -32,7 +32,8 @@ class IMP_Auth
     static public function authenticate($credentials = array())
     {
         // Do 'horde' authentication.
-        if (IMP_Application::$authType == 'horde') {
+        $imp_app = $GLOBALS['registry']->getApiInstance('imp', 'application');
+        if ($imp_app->initParams['authentication'] == 'horde') {
             if (Horde_Auth::getAuth()) {
                 return false;
             }
index 0623985..352d2bf 100644 (file)
@@ -14,12 +14,6 @@ class IMP_Block_Foldersummary extends Horde_Block
 
     protected function _content()
     {
-        try {
-            new IMP_Application(array('init' => array('authentication' => 'throw')));
-        } catch (Horde_Exception $e) {
-            return;
-        }
-
         /* Filter on INBOX display, if requested. */
         if ($GLOBALS['prefs']->getValue('filter_on_display')) {
             $imp_filter = new IMP_Filter();
index 22fdaea..5643629 100644 (file)
@@ -14,12 +14,6 @@ class IMP_Block_Newmail extends Horde_Block
 
     protected function _content()
     {
-        try {
-            new IMP_Application(array('init' => array('authentication' => 'throw')));
-        } catch (Horde_Exception $e) {
-            return;
-        }
-
         /* Filter on INBOX display, if requested. */
         if ($GLOBALS['prefs']->getValue('filter_on_display')) {
             $imp_filter = new IMP_Filter();
index e4f9c2a..2cefa9a 100644 (file)
@@ -35,12 +35,6 @@ class Horde_Block_imp_summary extends Horde_Block
     {
         global $notification, $prefs, $registry;
 
-        try {
-            new IMP_Application(array('init' => array('authentication' => 'throw')));
-        } catch (Horde_Exception $e) {
-            return;
-        }
-
         $html = '<table cellspacing="0" width="100%">';
 
         /* Filter on INBOX display, if requested. */
index 2d69754..edd2ac2 100644 (file)
@@ -17,12 +17,6 @@ class Horde_Block_imp_tree_folders extends Horde_Block
 
     protected function _buildTree(&$tree, $indent = 0, $parent = null)
     {
-        try {
-            new IMP_Application(array('init' => array('authentication' => 'throw')));
-        } catch (Horde_Exception $e) {
-            return;
-        }
-
         /* Run filters now */
         if ($GLOBALS['prefs']->getValue('filter_on_sidebar')) {
             $imp_filter = new IMP_Filter();
index 6a5f786..b14cd71 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
 
 /* Determine if mailbox is readonly. */
 $readonly = $imp_imap->isReadOnly($imp_mbox['mailbox']);
index 27a79c9..ff120f3 100644 (file)
@@ -39,7 +39,7 @@ function _outputSummaries($msgs)
 
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
 
 /* Call the mailbox redirection hook, if requested. */
 try {
index d8f7131..019dbcf 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 $folder = Horde_Util::getFormData('folder');
 $uid = Horde_Util::getFormData('uid');
index 81d2fbb..1ac7677 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
 
 /* Make sure we have a valid index. */
 $imp_mailbox = IMP_Mailbox::singleton($imp_mbox['mailbox'], $imp_mbox['uid'] . IMP::IDX_SEP . $imp_mbox['thismailbox']);
index 35e8895..5c6fc3c 100644 (file)
@@ -20,7 +20,7 @@ function _returnToMailbox($startIndex = null, $actID = null)
 }
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
 
 /* We know we are going to be exclusively dealing with this mailbox, so
  * select it on the IMAP server (saves some STATUS calls). Open R/W to clear
index 3ef42ea..9f9c9c4 100644 (file)
@@ -78,7 +78,7 @@ function _reloadWindow()
 }
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 $imp_pgp = Horde_Crypt::singleton(array('IMP', 'Pgp'));
 $secure_check = Horde::isConnectionSecure();
index c648059..e229ce4 100644 (file)
@@ -11,7 +11,7 @@
 
 require_once dirname(__FILE__) . '/lib/Application.php';
 try {
-    new IMP_Application(array('init' => array('authentication' => 'throw')));
+    Horde_Registry::appInit('imp', array('authentication' => 'throw'));
 } catch (Horde_Exception $e) {
     //!$auth->authenticate($_SERVER['PHP_AUTH_USER'], array('password' => isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null)))) {
     header('WWW-Authenticate: Basic realm="IMP RSS Interface"');
index 54b1ac6..8f87575 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 $id = Horde_Util::getFormData('id');
 $muid = Horde_Util::getFormData('muid');
index 3fd8863..5103ed9 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 if ($_SESSION['imp']['protocol'] == 'pop') {
     if ($_SESSION['imp']['view'] == 'imp') {
index 578cb53..daea04c 100644 (file)
@@ -29,7 +29,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 /* Load basic search if javascript is not enabled or searching is not
  * allowed (basic page will do the required redirection in the latter case). */
index 334e050..47e6f99 100644 (file)
@@ -88,7 +88,7 @@ function _printKeyInfo($cert)
 
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true));
+Horde_Registry::appInit('imp');
 
 $imp_smime = Horde_Crypt::singleton(array('IMP', 'Smime'));
 $secure_check = Horde::isConnectionSecure();
index 9a82016..4375536 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => array('authentication' => 'horde')));
+Horde_Registry::appInit('imp', array('authentication' => 'horde'));
 
 $compose_url = Horde::getServiceLink('options', 'imp');
 
index 0197300..bf72f1d 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 require_once dirname(__FILE__) . '/lib/Application.php';
-new IMP_Application(array('init' => true, 'tz' => true));
+Horde_Registry::appInit('imp', array('tz' => true));
 
 /* What mode are we in?
  * DEFAULT/'thread' - Thread mode
index 4f138a7..606581b 100644 (file)
@@ -43,10 +43,10 @@ require_once dirname(__FILE__) . '/lib/Application.php';
 
 /* Don't compress if we are already sending in compressed format. */
 $actionID = Horde_Util::getFormData('actionID');
-new IMP_Application(array('init' => array(
+Horde_Registry::appInit('imp', array(
     'nocompress' => (($actionID == 'download_all') || Horde_Util::getFormData('zip')),
     'session_control' => 'readonly'
-)));
+));
 
 $ctype = Horde_Util::getFormData('ctype');
 $id = Horde_Util::getFormData('id');
diff --git a/skeleton/config/horde.local.php.dist b/skeleton/config/horde.local.php.dist
new file mode 100644 (file)
index 0000000..9793ac3
--- /dev/null
@@ -0,0 +1,4 @@
+<?php
+/* Defines the location of the Horde base directory, if it is not in its
+ * default location (TODO: where is default). */
+define('HORDE_BASE', '/path/to/horde');
index 594eb9d..da356e1 100644 (file)
@@ -1,9 +1,65 @@
 <?php
+/**
+ * Skeleton application API.
+ *
+ * This file defines Horde's core API interface. Other core Horde libraries
+ * can interact with Horde through this API.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @package IMP
+ */
+
+/* Determine the base directories. */
+if (!defined('SKELETON_BASE')) {
+    define('SKELETON_BASE', dirname(__FILE__) . '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+    /* If Horde does not live directly under the app directory, the HORDE_BASE
+     * constant should be defined in config/horde.local.php. */
+    if (file_exists(SKELETON_BASE . '/config/horde.local.php')) {
+        include SKELETON_BASE . '/config/horde.local.php';
+    } else {
+        define('HORDE_BASE', SKELETON_BASE . '/..');
+    }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
 class Skeleton_Application extends Horde_Registry_Application
 {
+    /**
+     * The application's version.
+     *
+     * @var string
+     */
     public $version = 'H4 (0.1-git)';
 
     /**
+     * Initialization function.
+     *
+     * Global variables defined:
+     *   $notification - Notification object
+     *
+     * Global constants defined:
+     *   SKELETON_TEMPLATES - (string) Location of template files.
+     */
+    protected function _init()
+    {
+        if (!defined('SKELETON_TEMPLATES')) {
+            define('SKELETON_TEMPLATES', $GLOBALS['registry']->get('templates'));
+        }
+
+        // Notification system.
+        $notification = Horde_Notification::singleton();
+        $notification->attach('status');
+    }
+
+    /**
      * Generate the menu to use on the prefs page.
      *
      * @return Horde_Menu  A Horde_Menu object.
diff --git a/skeleton/lib/base.load.php b/skeleton/lib/base.load.php
deleted file mode 100644 (file)
index 4ec90e3..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-/**
- * Script to determine the correct *_BASE values.
- *
- * Copyright 2009-2010 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.
- *
- * @package Skeleton
- */
-
-if (!defined('SKELETON_BASE')) {
-    define('SKELETON_BASE', dirname(__FILE__). '/..');
-}
-
-if (!defined('HORDE_BASE')) {
-    /* If horde does not live directly under the app directory, the HORDE_BASE
-     * constant should be defined in config/horde.local.php. */
-    if (file_exists(SKELETON_BASE. '/config/horde.local.php')) {
-        include SKELETON_BASE . '/config/horde.local.php';
-    } else {
-        define('HORDE_BASE', SKELETON_BASE . '/..');
-    }
-}
diff --git a/skeleton/lib/base.php b/skeleton/lib/base.php
deleted file mode 100644 (file)
index 6b563aa..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-/**
- * Skeleton base application file.
- *
- * This file brings in all of the dependencies that every Skeleton script will
- * need, and sets up objects that all scripts use.
- */
-
-// Determine BASE directories.
-require_once dirname(__FILE__) . '/base.load.php';
-
-// // Load the Horde Framework core.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-$registry = Horde_Registry::singleton();
-try {
-    $registry->pushApp('skeleton', array('check_perms' => true, 'logintasks' => true));
-} catch (Horde_Exception $e) {
-    Horde_Auth::authenticateFailure('skeleton', $e);
-}
-
-$conf = &$GLOBALS['conf'];
-@define('SKELETON_TEMPLATES', $registry->get('templates'));
-
-// Notification system.
-$notification = Horde_Notification::singleton();
-$notification->attach('status');
-
-// Start output compression.
-Horde::compressOutput();
index 82fd49f..518cea4 100644 (file)
@@ -10,7 +10,8 @@
  * @author Your Name <you@example.com>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('skeleton');
 
 $title = _("List");
 
index 652b865..82562fd 100644 (file)
@@ -10,7 +10,9 @@
  * @author Chuck Hagenbuch <chuck@horde.org>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
+
 require_once TURBA_BASE . '/lib/Forms/AddContact.php';
 
 /* Setup some variables. */
index d59a4f9..aac8467 100644 (file)
@@ -8,7 +8,9 @@
  * did not receive this file, see http://www.horde.org/licenses/asl.php.
  */
 
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('turba');
+
 require_once TURBA_BASE . '/lib/Forms/CreateAddressBook.php';
 
 // Exit if this isn't an authenticated user, or if there's no source
index 34cd621..44546d8 100644 (file)
@@ -8,7 +8,9 @@
  * did not receive this file, see http://www.horde.org/licenses/asl.php.
  */
 
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('turba');
+
 require_once TURBA_BASE . '/lib/Forms/DeleteAddressBook.php';
 
 // Exit if this isn't an authenticated user, or if there's no source
index fe19c42..b28a5e6 100644 (file)
@@ -8,7 +8,9 @@
  * did not receive this file, see http://www.horde.org/licenses/asl.php.
  */
 
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('turba');
+
 require_once TURBA_BASE . '/lib/Forms/EditAddressBook.php';
 
 // Exit if this isn't an authenticated user, or if there's no source
index da4f92c..adc9290 100644 (file)
@@ -8,7 +8,8 @@
  * did not receive this file, see http://www.horde.org/licenses/asl.php.
  */
 
-require_once dirname(__FILE__) . '/../lib/base.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('turba');
 
 // Exit if this isn't an authenticated user, or if there's no source
 // configured for shares.
index 62a65e1..504deba 100644 (file)
@@ -11,7 +11,8 @@
  * @package Turba
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
 
 $params = array(
     'vars' => Horde_Variables::getDefaultVariables(),
index b1cc1ca..2cf6232 100644 (file)
@@ -10,7 +10,8 @@
  * @author Chuck Hagenbuch <chuck@horde.org>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
 
 $vars = Horde_Variables::getDefaultVariables();
 $source = $vars->get('source');
index ca423d7..7607a72 100644 (file)
@@ -78,7 +78,8 @@ function _getBareEmail($address, $allow_multi = false)
     return implode(', ', $result);
 }
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
 
 if (!$conf['menu']['import_export']) {
     require TURBA_BASE . '/index.php';
index 2e78a78..0ccca96 100644 (file)
@@ -10,7 +10,8 @@
  * @author Chuck Hagenbuch <chuck@horde.org>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
 
 $source = Horde_Util::getFormData('source');
 $key = Horde_Util::getFormData('key');
index ad30be0..9eeafbb 100644 (file)
@@ -10,7 +10,8 @@
  * @author Chuck Hagenbuch <chuck@horde.org>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
 
 if ($conf['documents']['type'] == 'none') {
     exit;
index 3e9e11d..67538da 100644 (file)
@@ -10,7 +10,9 @@
  * @author Chuck Hagenbuch <chuck@horde.org>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
+
 require_once TURBA_BASE . '/lib/Forms/EditContact.php';
 
 $listView = null;
index 6d3b6b9..52ef65e 100644 (file)
@@ -10,7 +10,9 @@
  * @author Chuck Hagenbuch <chuck@horde.org>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
+
 require TURBA_BASE . '/' . ($browse_source_count
                             ? basename($prefs->getValue('initial_page'))
                             : 'search.php');
index 43819d4..ef1c7c8 100644 (file)
@@ -40,11 +40,8 @@ class Turba_Api extends Horde_Registry_Api
             return false;
         }
 
-        require_once dirname(__FILE__) . '/base.php';
-        global $cfgSources;
-
         @list($source, $key) = explode('.', $id, 2);
-        if (isset($cfgSources[$source]) && $key) {
+        if (isset($GLOBALS['cfgSources'][$source]) && $key) {
             $driver = Turba_Driver::singleton($source);
             if (!is_a($driver, 'PEAR_Error')) {
                 $object = $driver->getObject($key);
@@ -76,8 +73,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function sources($writeable = false)
     {
-        require_once dirname(__FILE__) . '/base.php';
-
         $addressbooks = Turba::getAddressBooks($writeable ? Horde_Perms::EDIT : Horde_Perms::READ);
         foreach ($addressbooks as $addressbook => $config) {
             $addressbooks[$addressbook] = $config['title'];
@@ -95,7 +90,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function fields($source = null)
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources, $attributes;
 
         if (empty($source) || !isset($cfgSources[$source])) {
@@ -122,8 +116,7 @@ class Turba_Api extends Horde_Registry_Api
     {
         global $prefs;
 
-        // Bring in turba's base and a clean copy of sources.
-        require_once dirname(__FILE__) . '/base.php';
+        // Bring in a clean copy of sources.
         require TURBA_BASE . '/config/sources.php';
 
         if (!empty($_SESSION['turba']['has_share'])) {
@@ -170,7 +163,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function browse($path = '', $properties = array())
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $registry, $cfgSources;
 
         // Default properties.
@@ -395,7 +387,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function path_delete($path)
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $registry, $cfgSources;
 
         // Strip off the application name if present
@@ -442,8 +433,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function listContacts($sources = null)
     {
-        require_once dirname(__FILE__) . '/base.php';
-
         global $cfgSources, $prefs;
 
         /* Get default address book from user preferences. */
@@ -499,7 +488,6 @@ class Turba_Api extends Horde_Registry_Api
     public function listBy($action, $timestamp, $sources = null)
     {
         global $prefs, $cfgSources;
-        require_once dirname(__FILE__) . '/base.php';
 
         /* Get default address book from user preferences. */
         if (empty($sources)) {
@@ -559,7 +547,6 @@ class Turba_Api extends Horde_Registry_Api
     public function getActionTimestamp($uid, $action, $sources = null)
     {
         global $prefs, $cfgSources;
-        require_once dirname(__FILE__) . '/base.php';
 
         /* Get default address book from user preferences. */
         if (empty($sources)) {
@@ -612,7 +599,6 @@ class Turba_Api extends Horde_Registry_Api
     public function import($content, $contentType = 'array',
                            $import_source = null)
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources, $prefs;
 
         /* Get default address book from user preferences. */
@@ -743,7 +729,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function export($uid, $contentType, $sources = null, $fields = null)
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources, $prefs;
 
         /* Get default address book from user preferences. */
@@ -855,7 +840,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function getOwnContactObject()
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources;
 
         $own_contact = $GLOBALS['prefs']->getValue('own_contact');
@@ -913,7 +897,6 @@ class Turba_Api extends Horde_Registry_Api
             return true;
         }
 
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources, $prefs;
 
         /* Get default address book from user preferences. */
@@ -979,7 +962,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function replace($uid, $content, $contentType, $sources = null)
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources, $prefs;
 
         /* Get default address book from user preferences. */
@@ -1082,7 +1064,6 @@ class Turba_Api extends Horde_Registry_Api
                            $fields = array(), $matchBegin = false,
                            $forceSource = false)
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources, $attributes, $prefs;
 
         if (!isset($cfgSources) || !is_array($cfgSources) || !count($cfgSources)) {
@@ -1273,7 +1254,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function getContact($source = null, $objectId = '')
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources;
 
         if (!isset($cfgSources) || !is_array($cfgSources) || !count($cfgSources)) {
@@ -1311,7 +1291,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function getContacts($source = '', $objectIds = array())
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources;
         $results = array();
         if (!is_array($objectIds)) {
@@ -1355,7 +1334,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function getAllAttributeValues($field = '', $sources = array())
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources;
 
         if (!isset($cfgSources) || !is_array($cfgSources) || !count($cfgSources)) {
@@ -1400,8 +1378,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function listTimeObjectCategories()
     {
-        require_once dirname(__FILE__) . '/base.php';
-
         $categories = array();
         foreach ($GLOBALS['attributes'] as $key => $attribute) {
             if ($attribute['type'] == 'monthdayyear' &&
@@ -1429,7 +1405,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function listTimeObjects($time_categories, $start, $end)
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources;
 
         $start = new Horde_Date($start);
@@ -1571,7 +1546,6 @@ class Turba_Api extends Horde_Registry_Api
                              $value = '',
         $source = '')
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources;
 
         if (empty($source) || !isset($cfgSources[$source])) {
@@ -1661,7 +1635,6 @@ class Turba_Api extends Horde_Registry_Api
     public function getField($address = '', $field = '', $sources = array(),
                              $strict = false, $multiple = false)
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources;
 
         if (empty($address)) {
@@ -1722,7 +1695,6 @@ class Turba_Api extends Horde_Registry_Api
      */
     public function deleteField($address = '', $field = '', $sources = array())
     {
-        require_once dirname(__FILE__) . '/base.php';
         global $cfgSources;
 
         if (empty($address)) {
index b12219d..16f5c27 100644 (file)
@@ -2,8 +2,34 @@
 /**
  * Turba application API.
  *
+ * This file defines Horde's core API interface. Other core Horde libraries
+ * can interact with Horde through this API.
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
  * @package Turba
  */
+
+/* Determine the base directories. */
+if (!defined('TURBA_BASE')) {
+    define('TURBA_BASE', dirname(__FILE__) . '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+    /* If Horde does not live directly under the app directory, the HORDE_BASE
+     * constant should be defined in config/horde.local.php. */
+    if (file_exists(TURBA_BASE . '/config/horde.local.php')) {
+        include TURBA_BASE . '/config/horde.local.php';
+    } else {
+        define('HORDE_BASE', TURBA_BASE . '/..');
+    }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
 class Turba_Application extends Horde_Registry_Application
 {
     /**
@@ -14,6 +40,114 @@ class Turba_Application extends Horde_Registry_Application
     public $version = 'H4 (3.0-git)';
 
     /**
+     * Initialization.
+     *
+     * Global variables defined:
+     *   $addSources   - TODO
+     *   $attributes   - TODO
+     *   $browse_source_count - TODO
+     *   $browse_source_options - TODO
+     *   $cfgSources   - TODO
+     *   $copymove_source_options - TODO
+     *   $copymoveSources - TODO
+     *   $notification - Notification object
+     *   $turba_shares - TODO
+     *
+     * Global constants defined:
+     *   TURBA_TEMPLATES - (string) Location of template files.
+     *
+     * 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());
+        }
+
+        if (!defined('TURBA_TEMPLATES')) {
+            define('TURBA_TEMPLATES', $GLOBALS['registry']->get('templates'));
+        }
+
+        $GLOBALS['notification'] = Horde_Notification::singleton();
+        $GLOBALS['notification']->attach('status');
+
+        // Turba source and attribute configuration.
+        include TURBA_BASE . '/config/attributes.php';
+        include TURBA_BASE . '/config/sources.php';
+
+        /* UGLY UGLY UGLY - we should NOT be using this as a global
+         * variable all over the place. */
+        $GLOBALS['cfgSources'] = &$cfgSources;
+
+        // See if any of our sources are configured to use Horde_Share.
+        foreach ($cfgSources as $key => $cfg) {
+            if (!empty($cfg['use_shares'])) {
+                // Create a share instance.
+                $_SESSION['turba']['has_share'] = true;
+                $GLOBALS['turba_shares'] = Horde_Share::singleton('turba');
+                $cfgSources = Turba::getConfigFromShares($cfgSources);
+                break;
+            }
+        }
+
+        $GLOBALS['attributes'] = $attributes;
+        $cfgSources = Turba::permissionsFilter($cfgSources);
+
+        // Build the directory sources select widget.
+        $default_source = Horde_Util::nonInputVar('source');
+        if (empty($default_source)) {
+            $default_source = empty($_SESSION['turba']['source'])
+                ? Turba::getDefaultAddressBook()
+                : $_SESSION['turba']['source'];
+            $default_source = Horde_Util::getFormData('source', $default_source);
+        }
+
+        $GLOBALS['browse_source_count'] = 0;
+        $GLOBALS['browse_source_options'] = '';
+
+        foreach (Turba::getAddressBooks() as $key => $curSource) {
+            if (!empty($curSource['browse'])) {
+                $selected = ($key == $default_source) ? ' selected="selected"' : '';
+                $GLOBALS['browse_source_options'] .= '<option value="' . htmlspecialchars($key) . '" ' . $selected . '>' .
+                    htmlspecialchars($curSource['title']) . '</option>';
+
+                ++$GLOBALS['browse_source_count'];
+
+                if (empty($default_source)) {
+                    $default_source = $key;
+                }
+            }
+        }
+
+        if (empty($cfgSources[$default_source]['browse'])) {
+            $default_source = Turba::getDefaultAddressBook();
+        }
+        $_SESSION['turba']['source'] = $default_source;
+        $GLOBALS['default_source'] = $default_source;
+
+        /* Only set $add_source_options if there is at least one editable
+         * address book that is not the current address book. */
+        $addSources = Turba::getAddressBooks(Horde_Perms::EDIT, array('require_add' => true));
+        $copymove_source_options = '';
+        $copymoveSources = $addSources;
+        unset($copymoveSources[$default_source]);
+        foreach ($copymoveSources as $key => $curSource) {
+            if ($key != $default_source) {
+                $copymove_source_options .= '<option value="' . htmlspecialchars($key) . '">' .
+                    htmlspecialchars($curSource['title']) . '</option>';
+            }
+        }
+
+        $GLOBALS['addSources'] = $addSources;
+        $GLOBALS['copymove_source_options'] = $copymove_source_options;
+        $GLOBALS['copymoveSources'] = $copymoveSources;
+    }
+
+    /**
      * Returns a list of available permissions.
      *
      * @return array  An array describing all available permissions.
@@ -25,7 +159,6 @@ class Turba_Application extends Horde_Registry_Application
             return $perms;
         }
 
-        require_once dirname(__FILE__) . '/base.php';
         require TURBA_BASE . '/config/sources.php';
 
         $perms['tree']['turba']['sources'] = false;
@@ -126,8 +259,6 @@ class Turba_Application extends Horde_Registry_Application
      */
     public function removeUserData($user)
     {
-        require_once dirname(__FILE__) . '/base.php';
-
         if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
             return PEAR::raiseError(_("You are not allowed to remove user data."));
         }
index fa04a19..192855f 100644 (file)
@@ -31,8 +31,6 @@ class Horde_Block_turba_minisearch extends Horde_Block {
      */
     function _content()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-
         if ($GLOBALS['browser']->hasFeature('iframes')) {
             Horde::addScriptFile('prototype.js', 'horde');
             return Horde_Util::bufferOutput(
index 1bb8afc..d4b2314 100644 (file)
@@ -14,8 +14,6 @@ class Horde_Block_turba_tree_menu extends Horde_Block {
     {
         global $registry;
 
-        require_once dirname(__FILE__) . '/../base.php';
-
         $browse = Horde::applicationUrl('browse.php');
         $add = Horde::applicationUrl('add.php');
         $icondir = $registry->getImageDir() . '/menu';
diff --git a/turba/lib/base.load.php b/turba/lib/base.load.php
deleted file mode 100644 (file)
index 507789b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-/**
- * Script to determine the correct *_BASE values.
- *
- * Copyright 2009-2010 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.
- *
- * @package Turba
- */
-
-if (!defined('TURBA_BASE')) {
-    define('TURBA_BASE', dirname(__FILE__) . '/..');
-}
-
-if (!defined('HORDE_BASE')) {
-    /* If horde does not live directly under the app directory, the HORDE_BASE
-     * constant should be defined in config/horde.local.php. */
-    if (file_exists(TURBA_BASE . '/config/horde.local.php')) {
-        include TURBA_BASE . '/config/horde.local.php';
-    } else {
-        define('HORDE_BASE', TURBA_BASE . '/..');
-    }
-}
diff --git a/turba/lib/base.php b/turba/lib/base.php
deleted file mode 100644 (file)
index d4df718..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * Turba base inclusion file.
- *
- * This file brings in all of the dependencies that every Turba script will
- * need, and sets up objects that all scripts use.
- *
- * The following global variables are used:
- * <pre>
- * $ingo_authentication - The type of authentication to use:
- *   'none'  - Do not authenticate
- *   [DEFAULT] - Authenticate; on failed auth redirect to login screen
- * $no_compress - Controls whether the page should be compressed
- * </pre>
- */
-
-// Determine BASE directories.
-require_once dirname(__FILE__) . '/base.load.php';
-
-// Load the Horde Framework core, and set up inclusion paths.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-$registry = Horde_Registry::singleton();
-try {
-    $registry->pushApp('turba', array('check_perms' => (Horde_Util::nonInputVar('turba_authentication') != 'none'), 'logintasks' => true));
-} catch (Horde_Exception $e) {
-    Horde_Auth::authenticateFailure('turba', $e);
-}
-$conf = $GLOBALS['conf'];
-define('TURBA_TEMPLATES', $registry->get('templates'));
-
-// Notification system.
-$notification = Horde_Notification::singleton();
-$notification->attach('status');
-
-// Turba source and attribute configuration.
-include TURBA_BASE . '/config/attributes.php';
-include TURBA_BASE . '/config/sources.php';
-
-// Ensure we have cfgSources in global scope since base.php might be loaded
-// within a function scope and the share hooks require access to cfgSources.
-$GLOBALS['cfgSources'] = $cfgSources;
-
-// See if any of our sources are configured to use Horde_Share.
-foreach ($cfgSources as $key => $cfg) {
-    if (!empty($cfg['use_shares'])) {
-        $_SESSION['turba']['has_share'] = true;
-        break;
-    }
-}
-if (!empty($_SESSION['turba']['has_share'])) {
-    // Create a share instance.
-    $GLOBALS['turba_shares'] = Horde_Share::singleton($registry->getApp());
-    $GLOBALS['cfgSources'] = Turba::getConfigFromShares($cfgSources);
-}
-$GLOBALS['cfgSources'] = Turba::permissionsFilter($GLOBALS['cfgSources']);
-$GLOBALS['attributes'] = $attributes;
-
-// Build the directory sources select widget.
-$default_source = Horde_Util::nonInputVar('source');
-if (empty($default_source)) {
-    $default_source = empty($_SESSION['turba']['source']) ? Turba::getDefaultAddressBook() : $_SESSION['turba']['source'];
-    $default_source = Horde_Util::getFormData('source', $default_source);
-}
-$GLOBALS['browse_source_options'] = '';
-$GLOBALS['browse_source_count'] = 0;
-foreach (Turba::getAddressBooks() as $key => $curSource) {
-    if (!empty($curSource['browse'])) {
-        $selected = ($key == $default_source) ? ' selected="selected"' : '';
-        $GLOBALS['browse_source_options'] .= '<option value="' . htmlspecialchars($key) . '" ' . $selected . '>' .
-            htmlspecialchars($curSource['title']) . '</option>';
-
-        $GLOBALS['browse_source_count']++;
-
-        if (empty($default_source)) {
-            $default_source = $key;
-        }
-    }
-}
-if (empty($cfgSources[$default_source]['browse'])) {
-    $default_source = Turba::getDefaultAddressBook();
-}
-$_SESSION['turba']['source'] = $default_source;
-
-// Only set $add_source_options if there is at least one editable address book
-// that is not the current address book.
-$addSources = Turba::getAddressBooks(Horde_Perms::EDIT, array('require_add' => true));
-$copymove_source_options = '';
-$copymoveSources = $addSources;
-unset($copymoveSources[$default_source]);
-foreach ($copymoveSources as $key => $curSource) {
-    if ($key != $default_source) {
-        $copymove_source_options .= '<option value="' . htmlspecialchars($key) . '">' .
-            htmlspecialchars($curSource['title']) . '</option>';
-    }
-}
-$GLOBALS['addSources'] = $addSources;
-
-// Start compression, if requested.
-if (!Horde_Util::nonInputVar('no_compress')) {
-    Horde::compressOutput();
-}
index 144ff7e..fecb4cf 100644 (file)
@@ -28,7 +28,6 @@ class Turba_ApiTest extends Turba_TestBase {
             return;
         }
 
-        require_once TURBA_BASE . '/lib/base.php';
         $GLOBALS['source'] = '_test_sql';
         $GLOBALS['cfgSources'] = array('_test_sql' => $this->getDriverConfig());
 
index ea7821c..5675602 100644 (file)
@@ -143,7 +143,6 @@ class Turba_KolabTestBase extends Horde_Kolab_Test_Storage
         $GLOBALS['registry']->pushApp('turba', array('check_perms' => false));
 
         // Turba base libraries.
-        require_once dirname(__FILE__) . '/../../lib/base.load.php';
         require_once TURBA_BASE . '/lib/Turba.php';
         require_once TURBA_BASE . '/lib/Driver.php';
         require_once TURBA_BASE . '/lib/Object.php';
@@ -162,12 +161,14 @@ class Turba_KolabTestBase extends Horde_Kolab_Test_Storage
         $GLOBALS['cfgSources'] = Turba::getConfigFromShares($cfgSources);
     }
 
-    function provideServerName() {
+    function provideServerName()
+    {
         return 'localhost.localdomain';
     }
 
-    function provideHordeBase() {
-        require_once dirname(__FILE__) . '/../../lib/base.load.php';
+    function provideHordeBase()
+    {
+        require_once dirname(__FILE__) . '/../Application.php';
         return HORDE_BASE;
     }
 }
index 78770a1..542a482 100644 (file)
@@ -10,7 +10,8 @@
  * @author Chuck Hagenbuch <chuck@horde.org>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
 
 $search = Horde_Util::getFormData('search');
 $results = array();
index 7a770e6..7cfe548 100755 (executable)
@@ -17,8 +17,7 @@
  */
 
 // Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
 
 // Makre sure no one runs this from the web.
 if (!Horde_Cli::runningFromCli()) {
@@ -39,16 +38,8 @@ if ($argc != 2) {
 $data = $argv[1];
 
 // Make sure we load Horde base to get the auth config
-$horde_authentication = 'none';
-require_once HORDE_BASE . '/lib/base.php';
-if ($conf['auth']['admins']) {
-    Horde_Auth::setAuth($conf['auth']['admins'][0], array());
-}
+Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null));
 
-// Now that we are authenticated, we can load Turba's base. Otherwise, the
-// share code breaks, causing a new, completely empty share to be created on
-// the DataTree with no owner.
-require_once TURBA_BASE . '/lib/base.php';
 require_once TURBA_BASE . '/lib/Object/Group.php';
 
 // Get list of SquirrelMail address book files
index ae8f2f6..298d744 100755 (executable)
@@ -16,8 +16,7 @@
  */
 
 // Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
 
 // Makre sure no one runs this from the web.
 if (!Horde_Cli::runningFromCli()) {
@@ -37,19 +36,9 @@ if ($argc != 2) {
 }
 $dsn = $argv[1];
 
-// Make sure we load Horde base to get the auth config
-$horde_authentication = 'none';
-require_once HORDE_BASE . '/lib/base.php';
-if ($conf['auth']['admins']) {
-    Horde_Auth::setAuth($conf['auth']['admins'][0], array());
-}
+Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null));
 
-// Now that we are authenticated, we can load Turba's base. Otherwise, the
-// share code breaks, causing a new, completely empty share to be created on
-// the DataTree with no owner.
-require_once TURBA_BASE . '/lib/base.php';
 require_once TURBA_BASE . '/lib/Object/Group.php';
-require_once 'Horde/Mime/Address.php';
 
 // Connect to database.
 $db = DB::connect($dsn);
index aafba78..edfc05c 100755 (executable)
@@ -33,8 +33,7 @@ $do_email = true;
 
 /* YOU SHOULD NOT HAVE TO TOUCH ANYTHING BELOW THIS LINE */
 /* Set up the CLI environment */
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../../lib/Application.php';
 if (!Horde_Cli::runningFromCli()) {
     exit("Must be run from the command line\n");
 }
index 6ca31ea..8c9c832 100755 (executable)
@@ -10,8 +10,7 @@
  */
 
 // Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.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()) {
@@ -22,15 +21,14 @@ if (!Horde_Cli::runningFromCLI()) {
 // variables, etc.
 Horde_Cli::init();
 
-$turba_authentication = 'none';
-require_once TURBA_BASE . '/lib/base.php';
+Horde_Registry::appInit('turba', array('authentication' => 'none'));
 
 // Instantiate DataTree.
 require_once 'Horde/DataTree.php';
 $driver = $conf['datatree']['driver'];
 $params = array_merge(Horde::getDriverConfig('datatree', $driver),
                       array('group' => 'agora.forums.turba'));
-$datatree = &DataTree::singleton($driver, $params);
+$datatree = DataTree::singleton($driver, $params);
 
 // Load comments.
 $forums = $datatree->get(DATATREE_FORMAT_TREE, DATATREE_ROOT);
index 81bb823..edcd838 100755 (executable)
@@ -6,8 +6,7 @@
  */
 
 // Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.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()) {
@@ -18,8 +17,7 @@ if (!Horde_Cli::runningFromCLI()) {
 // some variables, etc.
 Horde_Cli::init();
 
-$turba_authentication = 'none';
-require_once TURBA_BASE . '/lib/base.php';
+Horde_Registry::appInit('turba', array('authentication' => 'none'));
 
 // Re-load source config.
 // require TURBA_BASE . '/config/sources.php';
index 22be23a..4612623 100755 (executable)
@@ -6,8 +6,7 @@
  */
 
 // Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/base.load.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()) {
@@ -18,8 +17,7 @@ if (!Horde_Cli::runningFromCLI()) {
 // some variables, etc.
 Horde_Cli::init();
 
-$turba_authentication = 'none';
-require_once TURBA_BASE . '/lib/base.php';
+Horde_Registry::appInit('turba', array('authentication' => 'none'));
 
 // Re-load source config.
 require TURBA_BASE . '/config/sources.php';
index 4393a7e..0aefe9f 100755 (executable)
@@ -8,8 +8,7 @@
  */
 
 /* Set up the CLI environment */
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../../lib/Application.php';
 if (!Horde_Cli::runningFromCli()) {
     exit("Must be run from the command line\n");
 }
index 6bc62c3..9374efc 100755 (executable)
@@ -19,8 +19,7 @@
  */
 
 // Load Horde and Turba enviroments
-require_once dirname(__FILE__) . '/../lib/base.load.php';
-require_once HORDE_BASE . '/lib/core.php';
+require_once dirname(__FILE__) . '/../lib/Application.php';
 
 // Set up the CLI enviroment.
 if (!Horde_Cli::runningFromCLI()) {
@@ -30,16 +29,7 @@ Horde_Cli::init();
 $CLI = Horde_Cli::singleton();
 
 // Make sure we load Horde base to get the auth config
-$horde_authentication = 'none';
-require_once HORDE_BASE . '/lib/base.php';
-if ($conf['auth']['admins']) {
-    Horde_Auth::setAuth($conf['auth']['admins'][0], array());
-}
-
-// Now that we are authenticated, we can load Turba's base. Otherwise,
-// the share code breaks, causing a new, completely empty share to be
-// created on the DataTree with no owner.
-require_once TURBA_BASE . '/lib/base.php';
+Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null));
 
 $CLI->writeln('This script will turn all entries in the SQL address book into a globally shared address book.');
 $CLI->writeln('Make sure you read the script comments and be sure you know what you are doing.');
index 3970d2a..a039d1b 100644 (file)
@@ -67,7 +67,8 @@ function updateSortOrderFromVars()
     }
 }
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
 
 /* Verify if the search mode variable is passed in form or is
  * registered in the session. Always use basic search by default. */
index 83a410c..22d1d17 100644 (file)
@@ -10,7 +10,8 @@
  * @author Chuck Hagenbuch <chuck@horde.org>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
 
 $source = Horde_Util::getFormData('source');
 if (!isset($cfgSources[$source])) {
index 954e459..0b26104 100644 (file)
@@ -10,7 +10,8 @@
  * @author Jan Schneider <jan@horde.org>
  */
 
-require_once dirname(__FILE__) . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/Application.php';
+Horde_Registry::appInit('turba');
 
 if ($conf['documents']['type'] == 'none') {
     throw new Turba_Exception(_("The VFS backend needs to be configured to enable attachment uploads."));