1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: class Sesha_Api extends Horde_Registry_Api
15: {
16:
17: 18: 19: 20:
21: public function listQueues()
22: {
23: $queues = array();
24: $categories = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create()->getCategories();
25: foreach ($categories as $category) {
26: $queues[$category['category_id']] = $category['category'];
27: }
28: asort($queues);
29:
30: return $queues;
31: }
32:
33: 34: 35: 36: 37: 38: 39:
40: public function getQueueDetails($queue_id)
41: {
42: global $registry;
43:
44: $category = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create()->getCategory($queue_id);
45:
46: return array('id' => $queue_id,
47: 'name' => $category['category'],
48: 'description' => $category['description'],
49: 'link' => Horde_Util::addParameter(Horde::url('list.php', true), 'display_category', $queue_id - 1, false),
50: 'subjectlist' => $GLOBALS['conf']['tickets']['subjects'],
51: 'versioned' => $registry->hasMethod('tickets/listVersions') == $registry->getApp(),
52: 'readonly' => true);
53: }
54:
55: 56: 57: 58: 59: 60: 61:
62: public function listVersions($queue_id)
63: {
64: $inventory = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create()->listStock($queue_id);
65: $versions = array();
66: foreach ($inventory as $item) {
67: $versions[] = array('id' => $item['stock_id'],
68: 'name' => $item['stock_name'],
69: 'description' => $item['note'],
70: 'readonly' => true);
71: }
72: Horde_Array::arraySort($versions, 'name', 0, false);
73:
74: return $versions;
75: }
76:
77: 78: 79: 80: 81: 82: 83: 84:
85: public function getVersionDetails($version_id)
86: {
87: global $registry;
88:
89: try {
90: $item = $GLOBALS['injector']->getInstance('Sesha_Factory_Driver')->create()->fetch($version_id);
91: } catch (Sesha_Exception $e) {
92: return array();
93: }
94: return array('id' => $version_id,
95: 'name' => $item['stock_name'],
96: 'description' => $item['note'],
97: 'link' => Horde_Util::addParameter(Horde::url('stock.php', true), array('stock_id' => $version_id, 'actionId' => 'view_stock'), null, false),
98: 'readonly' => true);
99: }
100: }
101: