Fixes to make the PEAR based installation work (at least partially).
authorGunnar Wrobel <p@rdus.de>
Wed, 29 Apr 2009 05:40:55 +0000 (07:40 +0200)
committerGunnar Wrobel <p@rdus.de>
Wed, 29 Apr 2009 05:43:55 +0000 (07:43 +0200)
koward/lib/Koward.php
koward/lib/Koward/Controller/Application.php
koward/lib/Koward/Controller/ObjectController.php
koward/lib/Koward/Form/Actions.php
koward/lib/Koward/Form/Object.php
koward/lib/Koward/Form/Search.php

index 12043ff..ad3116e 100644 (file)
@@ -23,18 +23,14 @@ class Koward {
 
     public function __construct()
     {
-        require_once 'Horde/Notification.php';
-        require_once 'Horde/Registry.php';
+        global $registry, $notification, $browser, $conf;
 
-        $this->notification = Notification::singleton();
-        $this->registry     = Registry::singleton();
+        $this->registry     = &$registry;
+        $this->notification = &$notification;
 
-        $result = $this->registry->pushApp('koward', false);
-        if ($result instanceOf PEAR_Error) {
-            $this->notification->push($result);
-        }
+        $this->auth = &Auth::singleton($conf['auth']['driver']);
 
-        $this->conf       = Horde::loadConfiguration('conf.php', 'conf');
+        $this->conf       = Horde::loadConfiguration('koward.php', 'koward');
         $this->objects    = Horde::loadConfiguration('objects.php', 'objects');
         $this->attributes = Horde::loadConfiguration('attributes.php', 'attributes');
         $this->labels     = Horde::loadConfiguration('labels.php', 'labels');
@@ -45,6 +41,30 @@ class Koward {
 
     public static function dispatch($koward)
     {
+        global $registry, $notification, $browser;
+
+        /* Horde core classes that aren't autoloaded. */
+        include_once 'Horde/Util.php';
+        include_once 'Horde/String.php';
+        include_once 'Horde/NLS.php';
+        include_once 'Horde/Auth.php';
+        include_once 'Horde/Perms.php';
+        include_once 'Horde/Notification.php';
+        include_once 'Horde/Registry.php';
+
+        $notification = Notification::singleton();
+        $registry     = Registry::singleton();
+
+        /* Browser detection object. */
+        if (class_exists('Horde_Browser')) {
+            $browser = Horde_Browser::singleton();
+        }
+
+        $result = $registry->pushApp('koward', false);
+        if ($result instanceOf PEAR_Error) {
+            $notification->push($result);
+        }
+
         $webroot = Koward::_detectWebroot($koward);
 
         // Set up our request and routing objects
@@ -65,7 +85,7 @@ class Koward {
         }
 
         // Check for route definitions.
-        $routeFile = dirname($koward) . '/config/routes.php';
+        $routeFile = dirname($koward) . '/../config/routes.php';
         if (!file_exists($routeFile)) {
             throw new Horde_Controller_Exception('Not routable');
         }
@@ -167,7 +187,7 @@ class Koward {
     static public function singleton()
     {
         if (!isset(self::$instance)) {
-            self::$instance = new Koward_Koward();
+            self::$instance = new Koward();
         }
 
         return self::$instance;
index e28fb3d..f348835 100644 (file)
@@ -4,8 +4,18 @@ class Koward_Controller_Application extends Horde_Controller_Base
 {
     protected function _initializeApplication()
     {
+        global $registry;
+
         $this->koward = Koward::singleton();
 
+        if (is_a(($pushed = $registry->pushApp('horde', empty($this->auth_handler))), 'PEAR_Error')) {
+            if ($pushed->getCode() == 'permission_denied') {
+                header('Location: ' . $this->urlFor(array('controller' => 'login', 'action' => 'login')));
+                exit;
+            }
+        }
+
+
         $this->types = array_keys($this->koward->objects);
         if (empty($this->types)) {
             throw new Koward_Exception('No object types have been configured!');
@@ -13,7 +23,7 @@ class Koward_Controller_Application extends Horde_Controller_Base
 
         $this->menu = $this->getMenu();
 
-        $this->theme = isset($this->koward->conf['koward']['theme']) ? $this->koward->conf['koward']['theme'] : 'koward';
+        $this->theme = isset($this->koward->conf['theme']) ? $this->koward->conf['theme'] : 'koward';
     }
 
     /**
index e93f5e6..04f9eff 100644 (file)
@@ -3,13 +3,10 @@
  * @package Koward
  */
 
-// @TODO Clean up
-require_once dirname(__FILE__) . '/ApplicationController.php';
-
 /**
  * @package Koward
  */
-class ObjectController extends Koward_ApplicationController
+class ObjectController extends Koward_Controller_Application
 {
 
     var $object_type;
@@ -40,8 +37,8 @@ class ObjectController extends Koward_ApplicationController
             && isset($this->koward->objects[$this->object_type])) {
             $params = array('attributes' => array_keys($this->attributes));
             $class = $this->koward->objects[$this->object_type]['class'];
-            $this->objectlist = $this->koward->server->listHash($class,
-                                                                $params);
+            $this->objectlist = $this->koward->getServer()->listHash($class,
+                                                                     $params);
             foreach ($this->objectlist as $uid => $info) {
                 $this->objectlist[$uid]['edit_url'] = Horde::link(
                     $this->urlFor(array('controller' => 'object', 
index 73cd952..2dadc8b 100644 (file)
@@ -17,7 +17,7 @@ class Koward_Form_Actions extends Horde_Form {
 
     public function __construct(&$object)
     {
-        $this->koward = &Koward_Koward::singleton();
+        $this->koward = &Koward::singleton();
 
         $this->object = &$object;
 
index dd65442..e81e938 100644 (file)
@@ -17,7 +17,7 @@ class Koward_Form_Object extends Horde_Form {
 
     public function __construct(&$vars, &$object, $params = array())
     {
-        $this->koward = &Koward_Koward::singleton();
+        $this->koward = &Koward::singleton();
 
         $this->object = &$object;
 
index 7e8a8a7..b7f1c56 100644 (file)
@@ -17,7 +17,7 @@ class Koward_Form_Search extends Horde_Form {
 
     public function __construct(&$vars, &$object, $params = array())
     {
-        $this->koward = &Koward_Koward::singleton();
+        $this->koward = &Koward::singleton();
 
         $this->object = &$object;