From 2554550bbb07e1bb2d2c37221b164f97a379c409 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Wed, 29 Apr 2009 07:40:55 +0200 Subject: [PATCH] Fixes to make the PEAR based installation work (at least partially). --- koward/lib/Koward.php | 42 +++++++++++++++++------ koward/lib/Koward/Controller/Application.php | 12 ++++++- koward/lib/Koward/Controller/ObjectController.php | 9 ++--- koward/lib/Koward/Form/Actions.php | 2 +- koward/lib/Koward/Form/Object.php | 2 +- koward/lib/Koward/Form/Search.php | 2 +- 6 files changed, 48 insertions(+), 21 deletions(-) diff --git a/koward/lib/Koward.php b/koward/lib/Koward.php index 12043ffae..ad3116e3a 100644 --- a/koward/lib/Koward.php +++ b/koward/lib/Koward.php @@ -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; diff --git a/koward/lib/Koward/Controller/Application.php b/koward/lib/Koward/Controller/Application.php index e28fb3d0d..f3488357b 100644 --- a/koward/lib/Koward/Controller/Application.php +++ b/koward/lib/Koward/Controller/Application.php @@ -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'; } /** diff --git a/koward/lib/Koward/Controller/ObjectController.php b/koward/lib/Koward/Controller/ObjectController.php index e93f5e623..04f9eff1e 100644 --- a/koward/lib/Koward/Controller/ObjectController.php +++ b/koward/lib/Koward/Controller/ObjectController.php @@ -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', diff --git a/koward/lib/Koward/Form/Actions.php b/koward/lib/Koward/Form/Actions.php index 73cd95203..2dadc8b42 100644 --- a/koward/lib/Koward/Form/Actions.php +++ b/koward/lib/Koward/Form/Actions.php @@ -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; diff --git a/koward/lib/Koward/Form/Object.php b/koward/lib/Koward/Form/Object.php index dd6544261..e81e9383b 100644 --- a/koward/lib/Koward/Form/Object.php +++ b/koward/lib/Koward/Form/Object.php @@ -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; diff --git a/koward/lib/Koward/Form/Search.php b/koward/lib/Koward/Form/Search.php index 7e8a8a70d..b7f1c560f 100644 --- a/koward/lib/Koward/Form/Search.php +++ b/koward/lib/Koward/Form/Search.php @@ -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; -- 2.11.0