From: Michael M Slusarz Date: Wed, 20 Jan 2010 06:17:18 +0000 (-0700) Subject: Convert Operator to updated Horde_Registry_Application usage X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=9d216e8a698beb16f92da477e6356b53c520b83f;p=horde.git Convert Operator to updated Horde_Registry_Application usage --- diff --git a/operator/export.php b/operator/export.php index e64137efe..7ea3e8339 100644 --- a/operator/export.php +++ b/operator/export.php @@ -9,12 +9,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; - -$operator = new Operator_Application(array('init' => true)); -$cache = &$GLOBALS['cache']; +Horde_Registry::appInit('operator'); require_once OPERATOR_BASE . '/lib/Form/SearchCDR.php'; +$cache = $GLOBALS['cache']; $renderer = new Horde_Form_Renderer(); $vars = Horde_Variables::getDefaultVariables(); $data = array(); diff --git a/operator/graphgen.php b/operator/graphgen.php index d7da100cd..870f88fec 100644 --- a/operator/graphgen.php +++ b/operator/graphgen.php @@ -9,8 +9,8 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; +Horde_Registry::appInit('operator'); -$operator = new Operator_Application(array('init' => true)); $cache = &$GLOBALS['cache']; // Work around warnings in Image_Graph diff --git a/operator/lib/Application.php b/operator/lib/Application.php index 1e9b232ed..58ba65a74 100644 --- a/operator/lib/Application.php +++ b/operator/lib/Application.php @@ -2,7 +2,8 @@ /** * Shout application interface. * - * This file defines Shout's application interface. + * This file defines Horde's core API interface. Other core Horde libraries + * can interact with Operator through this API. * * Copyright 2006-2010 Alkaloid Networks (http://projects.alkaloid.net/) * @@ -11,8 +12,9 @@ * http://www.opensource.org/licenses/bsd-license.html. * * @author Ben Klang - * @package Shout + * @package Operator */ + if (!defined('OPERATOR_BASE')) { define('OPERATOR_BASE', dirname(__FILE__). '/..'); } @@ -33,69 +35,57 @@ require_once HORDE_BASE . '/lib/core.php'; class Operator_Application extends Horde_Registry_Application { + /** + * The application's version. + * + * @var string + */ public $version = 'H4 (1.0-git)'; + + /** + * TODO + */ public $driver = null; - public function __construct($args = array()) + /** + * TODO + */ + static protected $_perms = array(); + + /** + * Initialization function. + * + * Global variables defined: + * $cache - TODO + */ + protected function _init() { - if (!empty($args['init'])) { - - // Registry. - $GLOBALS['registry'] = Horde_Registry::singleton(); - $registry = &$GLOBALS['registry']; - - try { - $registry->pushApp('operator'); - } catch (Horde_Exception $e) { - if ($e->getCode() == 'permission_denied') { - Horde::authenticationFailureRedirect(); - } - Horde::fatal($e, __FILE__, __LINE__, false); - } - $conf = &$GLOBALS['conf']; - @define('OPERATOR_TEMPLATES', $registry->get('templates')); - - // Notification system. - $GLOBALS['notification'] = &Horde_Notification::singleton(); - $notification = &$GLOBALS['notification']; - $notification->attach('status'); - - // Define the base file path of Operator. - @define('OPERATOR_BASE', dirname(__FILE__) . '/..'); + // Operator backend. + $this->driver = Operator_Driver::factory(); - // Operator base library - require_once OPERATOR_BASE . '/lib/Operator.php'; - - // Operator backend. - require_once OPERATOR_BASE . '/lib/Driver.php'; - $this->driver = Operator_Driver::factory(); - - // Caching system for storing DB results - $GLOBALS['cache'] = &Horde_Cache::singleton($conf['cache']['driver'], - Horde::getDriverConfig('cache', $conf['cache']['driver'])); - - // Start output compression. - Horde::compressOutput(); - } + // Caching system for storing DB results + $GLOBALS['cache'] = Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver'])); } + /** + * TODO + */ public function perms() { - static $perms = array(); - - if (!empty($perms)) { - return $perms; + if (!empty(self::$_perms)) { + return self::$_perms; } - $perms['tree']['operator']['accountcodes'] = false; - $perms['title']['operator:accountcodes'] = _("Account Codes"); + self::$_perms['tree']['operator']['accountcodes'] = false; + self::$_perms['title']['operator:accountcodes'] = _("Account Codes"); $accountcodes = Operator::getAccountCodes(); foreach ($accountcodes as $accountcode) { - $perms['tree']['operator']['accountcodes'][$accountcode] = false; - $perms['title']['operator:accountcodes:' . $accountcode] = $accountcode; + self::$_perms['tree']['operator']['accountcodes'][$accountcode] = false; + self::$_perms['title']['operator:accountcodes:' . $accountcode] = $accountcode; } - return $perms; + return self::$_perms; } + } diff --git a/operator/lib/Form/SearchCDR.php b/operator/lib/Form/SearchCDR.php index 52b61a342..f886f0d9b 100644 --- a/operator/lib/Form/SearchCDR.php +++ b/operator/lib/Form/SearchCDR.php @@ -110,9 +110,6 @@ class ExportCDRForm extends SearchCDRForm public function execute() { global $operator; - if (empty($operator) || empty($operator->driver)) { - $operator = new Operator_Application(array('init' => true)); - } $start = new Horde_Date($this->_vars->get('startdate')); $end = new Horde_Date($this->_vars->get('enddate')); diff --git a/operator/lib/Operator.php b/operator/lib/Operator.php index c707be908..6d6963f13 100644 --- a/operator/lib/Operator.php +++ b/operator/lib/Operator.php @@ -96,9 +96,6 @@ class Operator { public static function getAccountCodes($permfilter = false) { global $operator; - if (empty($operator) || empty($operator->driver)) { - $operator = new Operator_Application(array('init' => true)); - } // Set up arrays for filtering $keys = $values = $operator->driver->getAccountCodes(); diff --git a/operator/search.php b/operator/search.php index 987890d4a..00d47cdfc 100644 --- a/operator/search.php +++ b/operator/search.php @@ -9,12 +9,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; - -$operator = new Operator_Application(array('init' => true)); -$cache = &$GLOBALS['cache']; +Horde_Registry::appInit('operator'); require_once OPERATOR_BASE . '/lib/Form/SearchCDR.php'; +$cache = $GLOBALS['cache']; $renderer = new Horde_Form_Renderer(); $vars = Horde_Variables::getDefaultVariables(); $data = array(); diff --git a/operator/viewgraph.php b/operator/viewgraph.php index 71a4b2ded..b8787e4a4 100644 --- a/operator/viewgraph.php +++ b/operator/viewgraph.php @@ -9,12 +9,11 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; - -$operator = new Operator_Application(array('init' => true)); -$cache = &$GLOBALS['cache']; +Horde_Registry::appInit('operator'); require_once OPERATOR_BASE . '/lib/Form/SearchCDR.php'; +$cache = $GLOBALS['cache']; $renderer = new Horde_Form_Renderer(); $vars = Horde_Variables::getDefaultVariables();