Fix 'load_base' registry application loading.
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Nov 2009 23:33:59 +0000 (16:33 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 30 Nov 2009 23:38:15 +0000 (16:38 -0700)
Rename load_base -> init
Now can init an app from the registry if it doesn't have a base.php file
Login Tasks should now be able to be run in that application's
environment, without need to set up the environment in the tasks.

framework/Core/lib/Horde/Registry.php
framework/Core/lib/Horde/Registry/Application.php

index 569fd37..7e6f9b6 100644 (file)
@@ -823,8 +823,10 @@ class Horde_Registry
      *                 ONLY be disabled by system scripts (cron jobs, etc.)
      *                 and scripts that handle login.
      *                 DEFAULT: true
-     * 'load_base' - (boolean) Load the application's base.php file?
-     *               DEFAULT: false
+     * 'init' - (boolean) Init the application (by either loading the
+     *          application's base.php file (deprecated) or calling init()
+     *          on the Application object)?
+     *          DEFAULT: false
      * 'logintasks' - (boolean) Perform login tasks? Only performed if
      *                'check_perms' is also true. System tasks are always
      *                peformed if the user is authorized.
@@ -912,6 +914,17 @@ class Horde_Registry
             throw $e;
         } catch (Horde_Exception_HookNotSet $e) {}
 
+        /* Initialize application. */
+        if (!empty($options['init']) ||
+            ($checkPerms && !empty($options['logintasks']))) {
+            if (file_exists($app_lib . '/base.php')) {
+                // TODO: Remove once there is no more base.php files
+                require_once $app_lib . '/base.php';
+            } else {
+                $this->callAppMethod($app, 'init');
+            }
+        }
+
         /* Do login tasks. */
         if ($checkPerms) {
             $tasks = Horde_LoginTasks::singleton($app);
@@ -920,14 +933,6 @@ class Horde_Registry
             }
         }
 
-        /* Include base.php file. */
-        // TODO: Remove once there is no more base.php files
-        if (!empty($options['load_base'])) {
-            if (file_exists($app_lib . '/base.php')) {
-                require_once $app_lib . '/base.php';
-            }
-        }
-
         return true;
     }
 
index 32fd226..89c79c9 100644 (file)
@@ -33,4 +33,12 @@ class Horde_Registry_Application
      */
     public $disabled = array();
 
+    /**
+     * Initialization. Does any necessary init needed to setup the full
+     * environment for the application.
+     */
+    public function init()
+    {
+    }
+
 }