1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16:
17: if (!defined('WHUPS_BASE')) {
18: define('WHUPS_BASE', dirname(__FILE__) . '/..');
19: }
20:
21: if (!defined('HORDE_BASE')) {
22: 23:
24: if (file_exists(WHUPS_BASE . '/config/horde.local.php')) {
25: include WHUPS_BASE . '/config/horde.local.php';
26: } else {
27: define('HORDE_BASE', WHUPS_BASE . '/..');
28: }
29: }
30:
31: 32:
33: require_once HORDE_BASE . '/lib/core.php';
34:
35: class Whups_Application extends Horde_Registry_Application
36: {
37: 38:
39: public $version = 'H4 (2.0.3-git)';
40:
41: 42: 43: 44: 45:
46: protected function _init()
47: {
48: $GLOBALS['whups_driver'] = $GLOBALS['injector']->getInstance('Whups_Factory_Driver')->create();
49: $GLOBALS['linkTags'] = array('<link href="' . Horde::url('opensearch.php', true, -1) . '" rel="search" type="application/opensearchdescription+xml" title="' . $GLOBALS['registry']->get('name') . ' (' . Horde::url('', true) . ')" />');
50:
51:
52: $GLOBALS['registry']->setTimeZone();
53: }
54:
55: 56:
57: public function perms()
58: {
59:
60: $perms = array(
61: 'admin' => array(
62: 'title' => _("Administration")
63: ),
64: 'hiddenComments' => array(
65: 'title' => _("Hidden Comments")
66: ),
67: 'queues' => array(
68: 'title' => _("Queues")
69: ),
70: 'replies' => array(
71: 'title' => _("Form Replies")
72: )
73: );
74:
75:
76: $queues = $GLOBALS['whups_driver']->getQueues();
77: foreach ($queues as $id => $name) {
78: $perms['queues:' . $id] = array(
79: 'title' => $name
80: );
81:
82: $entries = array(
83: 'assign' => _("Assign"),
84: 'requester' => _("Set Requester"),
85: 'update' => _("Update")
86: );
87:
88: foreach ($entries as $key => $val) {
89: $perms['queues:' . $id . ':' . $key] = array(
90: 'title' => $val,
91: 'type' => 'boolean'
92: );
93: }
94: }
95:
96:
97: foreach ($GLOBALS['whups_driver']->getAllTypes() as $type_id => $type_name) {
98: foreach ($GLOBALS['whups_driver']->getReplies($type_id) as $reply_id => $reply) {
99: $perms['replies:' . $reply_id] = array(
100: 'title' => $type_name . ': ' . $reply['reply_name']
101: );
102: }
103: }
104:
105: return $perms;
106: }
107:
108: 109:
110: public function ($menu)
111: {
112: $menu->add(Horde::url('mybugs.php'), sprintf(_("_My %s"), $GLOBALS['registry']->get('name')), 'whups.png', null, null, null, $GLOBALS['prefs']->getValue('whups_default_view') == 'mybugs' && strpos($_SERVER['PHP_SELF'], $GLOBALS['registry']->get('webroot') . '/index.php') !== false ? 'current' : null);
113: $menu->add(Horde::url('search.php'), _("_Search"), 'search.png', null, null, null, $GLOBALS['prefs']->getValue('whups_default_view') == 'search' && strpos($_SERVER['PHP_SELF'], $GLOBALS['registry']->get('webroot') . '/index.php') !== false ? 'current' : null);
114: $menu->add(Horde::url('ticket/create.php'), _("_New Ticket"), 'create.png', null, null, null, $GLOBALS['prefs']->getValue('whups_default_view') == 'ticket/create' && basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
115: $menu->add(Horde::url('query/index.php'), _("_Query Builder"), 'query.png');
116: $menu->add(Horde::url('reports.php'), _("_Reports"), 'reports.png');
117:
118:
119: if ($GLOBALS['registry']->isAdmin(array('permission' => 'whups:admin'))) {
120: $menu->add(Horde::url('admin/'), _("_Admin"), 'admin.png');
121: }
122: }
123:
124: 125:
126: public function prefsInit($ui)
127: {
128: if (!$GLOBALS['registry']->hasMethod('contacts/sources')) {
129: $ui->suppressGroups[] = 'addressbooks';
130: }
131: }
132:
133: 134:
135: public function prefsGroup($ui)
136: {
137: foreach ($ui->getChangeablePrefs() as $val) {
138: switch ($val) {
139: case 'sourceselect':
140: Horde_Core_Prefs_Ui_Widgets::addressbooksInit();
141: break;
142: }
143: }
144: }
145:
146: 147:
148: public function prefsSpecial($ui, $item)
149: {
150: switch ($item) {
151: case 'sourceselect':
152: $search = Whups::getAddressbookSearchParams();
153: return Horde_Core_Prefs_Ui_Widgets::addressbooks(array(
154: 'fields' => $search['fields'],
155: 'sources' => $search['sources']
156: ));
157: }
158:
159: return '';
160: }
161:
162: 163:
164: public function prefsSpecialUpdate($ui, $item)
165: {
166: $updated = false;
167:
168: switch ($item) {
169: case 'sourceselect':
170: $data = Horde_Core_Prefs_Ui_Widgets::addressbooksUpdate($ui);
171:
172: if (isset($data['sources'])) {
173: $GLOBALS['prefs']->setValue('search_sources', $data['sources']);
174: $updated = true;
175: }
176:
177: if (isset($data['fields'])) {
178: $GLOBALS['prefs']->setValue('search_fields', $data['fields']);
179: $updated = true;
180: }
181: break;
182: }
183:
184: return $updated;
185: }
186:
187:
188:
189: 190:
191: public function (Horde_Tree_Base $tree, $parent = null,
192: array $params = array())
193: {
194: $tree->addNode(
195: $parent . '__new',
196: $parent,
197: _("New Ticket"),
198: 1,
199: false,
200: array(
201: 'icon' => Horde_Themes::img('create.png'),
202: 'url' => Horde::url('ticket/create.php')
203: )
204: );
205:
206: $tree->addNode(
207: $parent . '__search',
208: $parent,
209: _("Search"),
210: 1,
211: false,
212: array(
213: 'icon' => Horde_Themes::img('search.png'),
214: 'url' => Horde::url('search.php')
215: )
216: );
217: }
218:
219: }
220: