Hermes: More H4 changes. Application now at least loads the main screen
authorBen Klang <ben@alkaloid.net>
Wed, 2 Jun 2010 20:37:23 +0000 (16:37 -0400)
committerBen Klang <ben@alkaloid.net>
Wed, 2 Jun 2010 20:37:23 +0000 (16:37 -0400)
13 files changed:
hermes/entry.php
hermes/lib/Api.php
hermes/lib/Application.php
hermes/lib/Driver/sql.php
hermes/lib/Forms/Export.php
hermes/lib/Forms/Search.php
hermes/lib/Forms/Time.php
hermes/lib/Hermes.php
hermes/lib/Table.php
hermes/lib/base.php [deleted file]
hermes/search.php
hermes/templates/common-header.inc
hermes/time.php

index 4f622de..bb3e6fe 100644 (file)
@@ -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')) {
index fe53f9c..a302036 100644 (file)
@@ -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 {
index 8083a8c..989ec8c 100644 (file)
@@ -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
index aa9e6c0..582df1e 100644 (file)
@@ -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;
index b3fc12c..050fa96 100644 (file)
@@ -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"));
index cfb8631..d62fbe5 100644 (file)
@@ -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'];
index 5e50706..eab1138 100644 (file)
@@ -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;
index 7edb93d..e188566 100644 (file)
@@ -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());
         }
index 1b2cea0..e9abea1 100644 (file)
@@ -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 (file)
index c0f70a1..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
- * Copyright 2001-2007 Robert E. Coyle <robertecoyle@hotmail.com>
- *
- * 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();
index d42033e..358e8a6 100644 (file)
@@ -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);
                     }
index b64edd5..7713b4d 100644 (file)
@@ -22,8 +22,8 @@ Horde::includeScriptFiles();
 
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
-<link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php Horde::includeStylesheetFiles() ?>
+<link href="<?php echo Horde_Themes::img('favicon.ico', array('nohorde' => true)) ?>" rel="SHORTCUT ICON" />
+<?php Horde_Themes::includeStylesheetFiles() ?>
 </head>
 
 <body<?php if ($bc = Horde_Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Horde_Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>
index 7e53904..415125b 100644 (file)
@@ -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,