1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13: class Operator {
14:
15: 16: 17:
18: public static function ($returnType = 'object')
19: {
20: global $conf, $registry, $browser, $print_link;
21:
22: $menu = new Horde_Menu(Horde_Menu::MASK_ALL);
23: $menu->add(Horde::url('viewgraph.php'), _("_View Graphs"), 'graphs.png', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
24: $menu->add(Horde::url('search.php'), _("_Search"), 'search.png');
25:
26:
27: if ($GLOBALS['conf']['menu']['export']) {
28: $menu->add(Horde::url('export.php'), _("_Export"), 'data.png');
29: }
30:
31: if ($returnType == 'object') {
32: return $menu;
33: } else {
34: return $menu->render();
35: }
36: }
37:
38: public static function getColumns()
39: {
40: static $columns = array();
41: if (!empty($columns)) {
42: return $columns;
43: }
44:
45: $columns = array(
46: 'accountcode' => _("Account Code"),
47: 'src' => _("Source"),
48: 'dst' => _("Destination"),
49: 'dcontext' => _("Destination Context"),
50: 'clid' => _("Caller ID"),
51: 'channel' => _("Channel"),
52: 'dstchannel' => _("Destination Channel"),
53: 'lastapp' => _("Last Application"),
54: 'lastdata' => _("Last Application Data"),
55: 'start' => _("Start Time"),
56: 'answer' => _("Answer Time"),
57: 'end' => _("End Time"),
58: 'duration' => _("Duration (sec)"),
59: 'billsec' => _("Billable Duration (sec)"),
60: 'disposition' => _("Disposition"),
61: 'amaflags' => _("AMA Flag"),
62: 'userfield' => _("User Defined Field"),
63: 'uniqueid' => _("Unique ID"));
64:
65: return $columns;
66: }
67:
68:
69: public static function getColumnName($column)
70: {
71: $columns = Operator::getColumns();
72: return $columns[$column];
73: }
74:
75: public static function getAMAFlagName($flagid)
76: {
77:
78: switch($flagid) {
79: case 1:
80: return _("OMIT");
81: break;
82: case 2:
83: return _("BILLING");
84: break;
85: case 3:
86: return _("DOCUMENTATION");
87: break;
88: }
89: }
90:
91: 92: 93: 94: 95:
96: public static function getAccountCodes($permfilter = false)
97: {
98: $operator = $GLOBALS['registry']->getApiInstance('operator', 'application');;
99:
100:
101: $keys = $values = $operator->driver->getAccountCodes();
102: $perms = $GLOBALS['injector']->getInstance('Horde_Perms');
103:
104: if ($GLOBALS['registry']->isAdmin() ||
105: $perms->hasPermission('operator:accountcodes',
106: $GLOBALS['registry']->getAuth(),
107: Horde_Perms::READ)) {
108: $permfilter = false;
109: }
110:
111: if (!$permfilter ||
112: $perms->hasPermission('operator:accountcodes:%',
113: $GLOBALS['registry']->getAuth(),
114: Horde_Perms::READ)) {
115:
116:
117: array_unshift($keys, '%');
118: array_unshift($values, _("-- All Accounts Combined --"));
119: }
120:
121:
122: if ($index = array_search('', $values)) {
123: $values[$index] = _("-- Empty Accountcode --");
124: }
125:
126: if ($permfilter) {
127:
128:
129: $accountcodes = array();
130: foreach ($keys as $index => $accountcode) {
131: if (empty($accountcode)) {
132: $permitem = 'operator:accountcodes';
133: } else {
134: $permitem = 'operator:accountcodes:' . $accountcode;
135: }
136:
137: if ($GLOBALS['registry']->isAdmin() ||
138: $perms->hasPermission($permitem, $GLOBALS['registry']->getAuth(), Horde_Perms::SHOW)) {
139: $accountcodes[$accountcode] = $values[$index];
140: }
141: }
142:
143: if (empty($accountcodes)) {
144: throw new Operator_Exception(_("You do not have permission to view any accounts."));
145: }
146: } else {
147: $accountcodes = array_combine($keys, $values);
148: }
149: return $accountcodes;
150: }
151:
152: public static function getGraphInfo($graphid = null)
153: {
154: static $graphs;
155:
156: if (empty($graphs)) {
157: $graphs = array(
158: 'numcalls' => array(
159: 'title' => _("Number of Calls by Month"),
160: 'axisX' => _("Month"),
161: 'axisY' => _("Number of Calls"),
162: ),
163: 'minutes' => array(
164: 'title' => _("Total Minutes Used by Month"),
165: 'axisX' => _("Month"),
166: 'axisY' => _("Minute"),
167: 'numberformat' => '%0.1f',
168: ),
169:
170:
171:
172:
173:
174:
175: );
176: }
177:
178: if ($graphid === null) {
179: return $graphs;
180: }
181:
182: if (isset($graphs[$graphid])) {
183: return $graphs[$graphid];
184: } else {
185: throw new Operator_Exception(_("Invalid graph type."));
186: }
187: }
188:
189: }
190: