From 21e6ab16bb3435a787bf3596c0e3d42d7dbc9161 Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Wed, 2 Jun 2010 16:37:23 -0400 Subject: [PATCH] Hermes: More H4 changes. Application now at least loads the main screen --- hermes/entry.php | 2 +- hermes/lib/Api.php | 10 +++---- hermes/lib/Application.php | 2 +- hermes/lib/Driver/sql.php | 2 +- hermes/lib/Forms/Export.php | 2 +- hermes/lib/Forms/Search.php | 8 +++--- hermes/lib/Forms/Time.php | 2 +- hermes/lib/Hermes.php | 13 ++++----- hermes/lib/Table.php | 8 +++--- hermes/lib/base.php | 56 -------------------------------------- hermes/search.php | 2 +- hermes/templates/common-header.inc | 4 +-- hermes/time.php | 2 +- 13 files changed, 28 insertions(+), 85 deletions(-) delete mode 100644 hermes/lib/base.php diff --git a/hermes/entry.php b/hermes/entry.php index 4f622de85..bb3e6fe23 100644 --- a/hermes/entry.php +++ b/hermes/entry.php @@ -42,7 +42,7 @@ case 'timeentryform': $do_redirect = true; } else { $msg = _("Your time was successfully entered."); - $result = $hermes->driver->enterTime(Horde_Auth::getAuth(), $info); + $result = $hermes->driver->enterTime($GLOBALS['registry']->getAuth(), $info); $do_redirect = false; } if (is_a($result, 'PEAR_Error')) { diff --git a/hermes/lib/Api.php b/hermes/lib/Api.php index fe53f9c99..a3020366d 100644 --- a/hermes/lib/Api.php +++ b/hermes/lib/Api.php @@ -17,7 +17,7 @@ class Hermes_Api extends Horde_Registry_Api case 'hours': $emptype = Hermes::getEmployeesType('enum'); $clients = Hermes::listClients(); - $hours = $GLOBALS['hermes']->getHours($params); + $hours = $GLOBALS['hermes']->driver->getHours($params); $yesno = array(1 => _("Yes"), 0 => _("No")); @@ -106,7 +106,7 @@ class Hermes_Api extends Horde_Registry_Api { switch ($name) { case 'hours': - $time_data = $GLOBALS['hermes']->getHours($params); + $time_data = $GLOBALS['hermes']->driver->getHours($params); if (is_a($time_data, 'PEAR_Error')) { return $time_data; } @@ -277,7 +277,7 @@ class Hermes_Api extends Horde_Registry_Api return array(); } - $deliverables = $GLOBALS['hermes']->listDeliverables($criteria); + $deliverables = $GLOBALS['hermes']->driver->listDeliverables($criteria); if (is_a($deliverables, 'PEAR_Error')) { return PEAR::raiseError(sprintf(_("An error occurred retrieving deliverables: %s"), $deliverables->getMessage())); } @@ -349,7 +349,7 @@ class Hermes_Api extends Horde_Registry_Api */ function listJobTypes($criteria = array()) { - return $GLOBALS['hermes']->listJobTypes($criteria); + return $GLOBALS['hermes']->driver->listJobTypes($criteria); } function listClients() @@ -386,7 +386,7 @@ class Hermes_Api extends Horde_Registry_Api $form->useToken(false); if ($form->validate($vars)) { $form->getInfo($vars, $info); - $result = $GLOBALS['hermes']->enterTime(Horde_Auth::getAuth(), $info); + $result = $GLOBALS['hermes']->driver->enterTime($GLOBALS['registry']->getAuth(), $info); if (is_a($result, 'PEAR_Error')) { return $result; } else { diff --git a/hermes/lib/Application.php b/hermes/lib/Application.php index 8083a8cf9..989ec8ca0 100644 --- a/hermes/lib/Application.php +++ b/hermes/lib/Application.php @@ -45,7 +45,7 @@ class Hermes_Application extends Horde_Registry_Application /** * Driver object for reading/writing time entries */ - static protected $driver = null; + static public $driver = null; /** * TODO diff --git a/hermes/lib/Driver/sql.php b/hermes/lib/Driver/sql.php index aa9e6c07d..582df1e8d 100644 --- a/hermes/lib/Driver/sql.php +++ b/hermes/lib/Driver/sql.php @@ -279,7 +279,7 @@ class Hermes_Driver_sql extends Hermes_Driver { $sql .= ' ORDER BY timeslice_date DESC, clientjob_id'; - Horde::logMessage($sql, __FILE__, __LINE__, PEAR_LOG_DEBUG); + Horde::logMessage($sql, 'DEBUG'); $hours = $this->_db->getAll($sql, DB_FETCHMODE_ASSOC); if (is_a($hours, 'PEAR_Error')) { return $hours; diff --git a/hermes/lib/Forms/Export.php b/hermes/lib/Forms/Export.php index b3fc12c5b..050fa962e 100644 --- a/hermes/lib/Forms/Export.php +++ b/hermes/lib/Forms/Export.php @@ -41,7 +41,7 @@ class ExportForm extends Horde_Form { $this->addVariable(_("Select the export format"), 'format', 'enum', true, false, null, array($formats)); - if ($perms->hasPermission('hermes:review', Horde_Auth::getAuth(), + if ($perms->hasPermission('hermes:review', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $yesno = array('yes' => _("Yes"), 'no' => _("No")); diff --git a/hermes/lib/Forms/Search.php b/hermes/lib/Forms/Search.php index cfb86312c..d62fbe52f 100644 --- a/hermes/lib/Forms/Search.php +++ b/hermes/lib/Forms/Search.php @@ -29,7 +29,7 @@ class SearchForm extends Horde_Form { { parent::Horde_Form($vars, _("Search For Time")); - if ($GLOBALS['perms']->hasPermission('hermes:review', Horde_Auth::getAuth(), Horde_Perms::SHOW)) { + if ($GLOBALS['perms']->hasPermission('hermes:review', $GLOBALS['registry']->getAuth(), Horde_Perms::SHOW)) { $type = Hermes::getEmployeesType(); $this->addVariable(_("Employees"), 'employees', $type[0], false, false, null, $type[1]); @@ -115,7 +115,7 @@ class SearchForm extends Horde_Form { $costobjects = array(); foreach ($clients as $client) { - $criteria = array('user' => Horde_Auth::getAuth(), + $criteria = array('user' => $GLOBALS['registry']->getAuth(), 'active' => true, 'client_id' => $client); @@ -166,7 +166,7 @@ class SearchForm extends Horde_Form { $this->getInfo($vars, $info); $criteria = array(); - if ($GLOBALS['perms']->hasPermission('hermes:review', Horde_Auth::getAuth(), Horde_Perms::SHOW)) { + if ($GLOBALS['perms']->hasPermission('hermes:review', $GLOBALS['registry']->getAuth(), Horde_Perms::SHOW)) { if (!empty($info['employees'])) { $auth = Horde_Auth::singleton($GLOBALS['conf']['auth']['driver']); if (!$auth->capabilities['list']) { @@ -176,7 +176,7 @@ class SearchForm extends Horde_Form { } } } else { - $criteria['employee'] = Horde_Auth::getAuth(); + $criteria['employee'] = $GLOBALS['registry']->getAuth(); } if (!empty($info['clients'])) { $criteria['client'] = $info['clients']; diff --git a/hermes/lib/Forms/Time.php b/hermes/lib/Forms/Time.php index 5e50706b7..eab1138e8 100644 --- a/hermes/lib/Forms/Time.php +++ b/hermes/lib/Forms/Time.php @@ -72,7 +72,7 @@ class TimeForm extends Horde_Form { /* Check to see if any other active applications are exporting cost * objects to which we might want to bill our time. */ - $criteria = array('user' => Horde_Auth::getAuth(), + $criteria = array('user' => $GLOBALS['registry']->getAuth(), 'active' => true); if (!empty($clientID)) { $criteria['client_id'] = $clientID; diff --git a/hermes/lib/Hermes.php b/hermes/lib/Hermes.php index 7edb93d1b..e18856641 100644 --- a/hermes/lib/Hermes.php +++ b/hermes/lib/Hermes.php @@ -58,7 +58,7 @@ class Hermes { $menu = new Horde_Menu(); $menu->add(Horde::applicationUrl('time.php'), _("My _Time"), 'hermes.png', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null); $menu->add(Horde::applicationUrl('entry.php'), _("_New Time"), 'hermes.png', null, null, null, Horde_Util::getFormData('id') ? '__noselection' : null); - $menu->add(Horde::applicationUrl('search.php'), _("_Search"), 'search.png', $registry->getImageDir('horde')); + $menu->add(Horde::applicationUrl('search.php'), _("_Search"), Horde_Themes::img('search.png')); if ($conf['time']['deliverables'] && Horde_Auth::isAdmin('hermes:deliverables')) { $menu->add(Horde::applicationUrl('deliverables.php'), _("_Deliverables"), 'hermes.png'); @@ -70,11 +70,11 @@ class Hermes { /* Print. */ if ($conf['menu']['print'] && isset($print_link)) { - $menu->add($print_link, _("_Print"), 'print.png', $registry->getImageDir('horde'), '_blank', 'popup(this.href); return false;', '__noselection'); + $menu->add($print_link, _("_Print"), Horde_Themes::img('print.png'), '_blank', 'popup(this.href); return false;', '__noselection'); } /* Administration. */ - if (Horde_Auth::isAdmin()) { + if ($registry->isAdmin()) { $menu->add(Horde::applicationUrl('admin.php'), _("_Admin"), 'hermes.png'); } @@ -89,7 +89,7 @@ class Hermes { { global $hermes; - if ($GLOBALS['perms']->hasPermission('hermes:review', Horde_Auth::getAuth(), Horde_Perms::EDIT)) { + if ($GLOBALS['perms']->hasPermission('hermes:review', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { return true; } @@ -100,7 +100,7 @@ class Hermes { $slice = $hours[0]; // We can edit our own time if it hasn't been submitted. - if ($slice['employee'] == Horde_Auth::getAuth() && !$slice['submitted']) { + if ($slice['employee'] == $GLOBALS['registry']->getAuth() && !$slice['submitted']) { return true; } @@ -161,8 +161,7 @@ class Hermes { */ function getEmployeesType($enumtype = 'multienum') { - require_once 'Horde/Identity.php'; - $auth = Horde_Auth::singleton($GLOBALS['conf']['auth']['driver']); + $auth = $GLOBALS['injector']->getInstance('Horde_Auth'); if (!$auth->capabilities['list']) { return array('text', array()); } diff --git a/hermes/lib/Table.php b/hermes/lib/Table.php index 1b2cea03c..e9abea1f4 100644 --- a/hermes/lib/Table.php +++ b/hermes/lib/Table.php @@ -25,7 +25,7 @@ class Horde_Ui_Table extends Horde_Ui_Widget { */ var $_formVars = array(); - function getMetaData() + public function getMetaData() { if (is_null($this->_metaData)) { list($app, $name) = explode('/', $this->_config['name']); @@ -59,7 +59,7 @@ class Horde_Ui_Table extends Horde_Ui_Widget { return $this->_metaData; } - function _getData($range = null) + protected function _getData($range = null) { if (is_null($range)) { $range = array(); @@ -83,7 +83,7 @@ class Horde_Ui_Table extends Horde_Ui_Widget { * * @return mixed number of columns or PEAR_Error */ - function getColumnCount() + public function getColumnCount() { $res = $this->getMetaData(); if (is_a($res, 'PEAR_Error')) { @@ -110,7 +110,7 @@ class Horde_Ui_Table extends Horde_Ui_Widget { /** * Render the table. */ - function render() + public function render($data = null) { global $notification; diff --git a/hermes/lib/base.php b/hermes/lib/base.php deleted file mode 100644 index c0f70a1d7..000000000 --- a/hermes/lib/base.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * See the enclosed file LICENSE for license information (BSD). If you - * did not receive this file, see http://www.horde.org/licenses/bsdl.php. - * - * Hermes base inclusion file. - * - * This file brings in all of the dependencies that every Hermes script - * will need, and sets up objects that all scripts use. - */ - -// Check for a prior definition of HORDE_BASE (perhaps by an -// auto_prepend_file definition for site customization). -if (!defined('HORDE_BASE')) { - define('HORDE_BASE', dirname(__FILE__) . '/../..'); -} - -// 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('hermes', !defined('AUTH_HANDLER')); -} catch (Horde_Exception $e) { - if ($e->getCode() == 'permission_denied') { - Horde::authenticationFailureRedirect(); - } - Horde::fatal($e, __FILE__, __LINE__, false); -} -$conf = &$GLOBALS['conf']; -define('HERMES_TEMPLATES', $registry->get('templates')); -$print_link = null; - -// Notification system. -$notification = &Horde_Notification::singleton(); -$notification->attach('status'); - -// Find the base file path of Hermes. -if (!defined('HERMES_BASE')) { - define('HERMES_BASE', dirname(__FILE__) . '/..'); -} - -// Hermes base libraries. -require_once HERMES_BASE . '/lib/Hermes.php'; -$GLOBALS['hermes'] = &Hermes::getDriver(); - -// Horde libraries. -require_once 'Horde/Form.php'; -require_once 'Horde/Form/Renderer.php'; -require_once 'Horde/Template.php'; - -// Start compression. -Horde::compressOutput(); diff --git a/hermes/search.php b/hermes/search.php index d42033e8a..358e8a66c 100644 --- a/hermes/search.php +++ b/hermes/search.php @@ -74,7 +74,7 @@ case 'exportform': echo $filedata; if (!empty($info['mark_exported']) && $info['mark_exported'] == 'yes' && - $perms->hasPermission('hermes:review', Horde_Auth::getAuth(), + $perms->hasPermission('hermes:review', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { $hermes->driver->markAs('exported', $hours); } diff --git a/hermes/templates/common-header.inc b/hermes/templates/common-header.inc index b64edd578..7713b4d5d 100644 --- a/hermes/templates/common-header.inc +++ b/hermes/templates/common-header.inc @@ -22,8 +22,8 @@ Horde::includeScriptFiles(); ?> <?php echo htmlspecialchars($page_title) ?> - - + + > diff --git a/hermes/time.php b/hermes/time.php index 7e5390494..415125ba8 100644 --- a/hermes/time.php +++ b/hermes/time.php @@ -54,7 +54,7 @@ case 'submittimeform': // We are displaying all time. $tabs = Hermes::tabs(); -$criteria = array('employee' => Horde_Auth::getAuth(), +$criteria = array('employee' => $GLOBALS['registry']->getAuth(), 'submitted' => false, 'link_page' => 'time.php'); $table = new Horde_Ui_Table('week', $vars, -- 2.11.0