Overview

Packages

  • Hermes
  • Horde
    • Data
  • Kronolith
  • None

Classes

  • Hermes_Application
  • Hermes_Exception
  • Hermes_Form_JobType_Add
  • Hermes_Slice
  • Hermes_Table
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Hermes application interface.
  4:  *
  5:  * This file is responsible for initializing the Hermes application.
  6:  *
  7:  * Copyright 2001-2007 Robert E. Coyle <robertecoyle@hotmail.com>
  8:  * Copyright 2010 Alkaloid Networks (http://projects.alkaloid.net/)
  9:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
 10:  *
 11:  * See the enclosed file LICENSE for license information (BSD). If you
 12:  * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
 13:  *
 14:  * @author Robert E. Coyle <robertecoyle@hotmail.com>
 15:  * @author  Ben Klang <ben@alkaloid.net>
 16:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
 17:  * @package Hermes
 18:  */
 19: 
 20: if (!defined('HERMES_BASE')) {
 21:     define('HERMES_BASE', dirname(__FILE__). '/..');
 22: }
 23: 
 24: if (!defined('HORDE_BASE')) {
 25:     /* If horde does not live directly under the app directory, the HORDE_BASE
 26:      * constant should be defined in config/horde.local.php. */
 27:     if (file_exists(HERMES_BASE. '/config/horde.local.php')) {
 28:         include HERMES_BASE . '/config/horde.local.php';
 29:     } else {
 30:         define('HORDE_BASE', HERMES_BASE . '/..');
 31:     }
 32: }
 33: 
 34: /* Load the Horde Framework core (needed to autoload
 35:  * Horde_Registry_Application::). */
 36: require_once HORDE_BASE . '/lib/core.php';
 37: 
 38: class Hermes_Application extends Horde_Registry_Application
 39: {
 40:     /**
 41:      */
 42:     public $version = 'H4 (2.0-git)';
 43: 
 44:     /**
 45:      */
 46:     protected function _init()
 47:     {
 48:         $GLOBALS['injector']->bindFactory('Hermes_Driver', 'Hermes_Factory_Driver', 'create');
 49:     }
 50: 
 51:     /**
 52:      */
 53:     public function perms()
 54:     {
 55:         return array(
 56:             'review' => array(
 57:                 'title' => _("Time Review Screen")
 58:             ),
 59:             'deliverables' => array(
 60:                 'title' => _("Deliverables")
 61:             ),
 62:             'invoicing' => array(
 63:                 'title' => _("Invoicing")
 64:             )
 65:         );
 66:     }
 67: 
 68:     /**
 69:      */
 70:     public function menu($menu)
 71:     {
 72:         $menu->add(Horde::url('time.php'), _("My _Time"), 'hermes.png', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
 73:         $menu->add(Horde::url('entry.php'), _("_New Time"), 'hermes.png', null, null, null, Horde_Util::getFormData('id') ? '__noselection' : null);
 74:         $menu->add(Horde::url('search.php'), _("_Search"), 'search.png');
 75: 
 76:         if ($GLOBALS['conf']['time']['deliverables'] &&
 77:             $GLOBALS['registry']->isAdmin(array('permission' => 'hermes:deliverables'))) {
 78:             $menu->add(Horde::url('deliverables.php'), _("_Deliverables"), 'hermes.png');
 79:         }
 80: 
 81:         if ($GLOBALS['conf']['invoices']['driver'] &&
 82:             $GLOBALS['registry']->isAdmin(array('permission' => 'hermes:invoicing'))) {
 83:             $menu->add(Horde::url('invoicing.php'), _("_Invoicing"), 'invoices.png');
 84:         }
 85: 
 86:         /* Administration. */
 87:         if ($GLOBALS['registry']->isAdmin()) {
 88:             $menu->add(Horde::url('admin.php'), _("_Admin"), 'hermes.png');
 89:         }
 90:     }
 91: 
 92:     /* Sidebar method. */
 93: 
 94:     /**
 95:      */
 96:     public function sidebarCreate(Horde_Tree_Base $tree, $parent = null,
 97:                                   array $params = array())
 98:     {
 99:         switch ($params['id']) {
100:         case 'menu':
101:             $tree->addNode(
102:                 $parent . '__add',
103:                 $parent,
104:                 _("Enter Time"),
105:                 1,
106:                 false,
107:                 array(
108:                     'icon' => Horde_Themes::img('hermes.png'),
109:                     'url' => Horde::url('entry.php')
110:                 )
111:             );
112: 
113:             $tree->addNode(
114:                 $parent . '__search',
115:                 $parent,
116:                 _("Search Time"),
117:                 1,
118:                 false,
119:                 array(
120:                     'icon' => Horde_Themes::img('search.png'),
121:                     'url' => Horde::url('search.php')
122:                 )
123:             );
124:             break;
125: 
126:         case 'stopwatch':
127:             $tree->addNode(
128:                 $parent . '__start',
129:                 $parent,
130:                 _("Start Watch"),
131:                 1,
132:                 false,
133:                 array(
134:                     'icon' => Horde_Themes::img('timer-start.png'),
135:                     'url' => 'javascript:' . Horde::popupJs(Horde::url('start.php'), array('height' => 200, 'width' => 400))
136:                 )
137:             );
138: 
139:             if ($timers = @unserialize($GLOBALS['prefs']->getValue('running_timers'))) {
140:                 $entry = Horde::url('entry.php');
141:                 foreach ($timers as $i => $timer) {
142:                     $hours = round((float)(time() - $i) / 3600, 2);
143:                     $tree->addNode(
144:                         $parent . '__timer_' . $i,
145:                         $parent,
146:                         $timer['name'] . sprintf(" (%s)", $hours),
147:                         1,
148:                         false,
149:                         array(
150:                             'icon' => Horde_Themes::img('timer-stop.png'),
151:                             'url' => $entry->add('timer', $i)
152:                         )
153:                     );
154:                 }
155:             }
156:             break;
157:         }
158:     }
159: 
160: }
161: 
API documentation generated by ApiGen