1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
19:
20: if (!defined('HERMES_BASE')) {
21: define('HERMES_BASE', dirname(__FILE__). '/..');
22: }
23:
24: if (!defined('HORDE_BASE')) {
25: 26:
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: 35:
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)
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:
87: if ($GLOBALS['registry']->isAdmin()) {
88: $menu->add(Horde::url('admin.php'), _("_Admin"), 'hermes.png');
89: }
90: }
91:
92:
93:
94: 95:
96: public function (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: