1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14: class Shout
15: {
16: 17: 18:
19: const MAIN_MENU = 'Main Menu';
20:
21: 22: 23: 24:
25: const MAIN_RECORDING = 'main_menu';
26:
27: var $applist = array();
28: var $_applist_curapp = '';
29: var $_applist_curfield = '';
30:
31: 32: 33: 34: 35:
36: static public function ($returnType = 'object')
37: {
38: $mask = Horde_Menu::MASK_PROBLEM | Horde_Menu::MASK_LOGIN;
39: $menu = new Horde_Menu($mask);
40:
41: $menu->add(Horde::url('dialplan.php'), _("Call Menus"), "dialplan.png");
42: $menu->add(Horde::url('recordings.php'), _("Recordings"), "recordings.png");
43: $menu->add(Horde::url('extensions.php'), _("Extensions"), "extension.png");
44: $menu->add(Horde::url('devices.php'), _("Devices"), "shout.png");
45: $menu->add(Horde::url('conferences.php'), _("Conferences"), "conference.png");
46:
47:
48: if ($GLOBALS['registry']->isAdmin(array('permission' => 'shout:admin'))) {
49: $menu->add(Horde::url('admin.php'), _("_Admin"), 'admin.png');
50: }
51:
52: if ($returnType == 'object') {
53: return $menu;
54: } else {
55: return $menu->render();
56: }
57: }
58:
59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72:
73: static public function checkRights($permname, $permmask = null, $numparents = 0)
74: {
75: if ($GLOBALS['registry']->isAdmin()) {
76: return true;
77: }
78:
79: if ($permmask === null) {
80: $permmask = Horde_Perms::SHOW | Horde_Perms::READ;
81: }
82:
83:
84: $user = 0;
85: $superadmin = 0;
86:
87: $perms = $GLOBALS['injector']->getInstance('Horde_Perms');
88: $superadmin = $perms->hasPermission('shout:superadmin',
89: $GLOBALS['registry']->getAuth(), $permmask);
90:
91: while ($numparents >= 0) {
92: $tmpuser = $perms->hasPermission($permname,
93: $GLOBALS['registry']->getAuth(), $permmask);
94:
95: $user = $user | $tmpuser;
96: if ($numparents > 0) {
97: $pos = strrpos($permname, ':');
98: if ($pos) {
99: $permname = substr($permname, 0, $pos);
100: }
101: }
102: $numparents--;
103: }
104: $test = $superadmin | $user;
105:
106: return ($test & $permmask) == $permmask;
107: }
108:
109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128:
129: static public function genDeviceAuth($account)
130: {
131: $devid = $account . substr(uniqid(), 6);
132:
133:
134:
135:
136:
137:
138: $possible = "0123456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ";
139:
140: $password = "";
141: $i = 0;
142: while ($i < 12) {
143:
144: $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
145:
146:
147: if (!strstr($password, $char)) {
148: $password .= $char;
149: $i++;
150: }
151: }
152:
153: return array($devid, $password);
154: }
155:
156: static public function ()
157: {
158: $shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
159: $account = $GLOBALS['session']->get('shout', 'curaccount_code');
160:
161: return array(
162: 'jump' => array(
163: 'description' => _("Jump to menu"),
164: 'args' => array (
165: 'menuName' => array(
166: 'name' => _("Menu"),
167: 'type' => 'enum',
168: 'required' => true,
169: 'params' => array(self::getNames($shout->dialplan->getMenus($account)))
170: )
171: )
172: ),
173: 'ringexten' => array(
174: 'description' => _("Ring extension"),
175: 'args' => array(
176: 'exten' => array(
177: 'name' => _("Extension"),
178: 'type' => 'enum',
179: 'required' => true,
180: 'params' => array(self::getNames($shout->extensions->getExtensions($account)))
181: )
182: )
183: ),
184: 'leave_message' => array(
185: 'description' => _("Go to voicemail"),
186: 'args' => array(
187: 'exten' => array(
188: 'name' => _("Mailbox"),
189: 'type' => 'enum',
190: 'required' => true,
191: 'params' => array(self::getNames($shout->extensions->getExtensions($account)))
192: )
193: )
194: ),
195: 'conference' => array(
196: 'description' => _("Enter conference"),
197: 'args' => array(
198: 'roomno' => array(
199: 'name' => _("Room Number (optional)"),
200: 'type' => 'number',
201: 'required' => false
202: )
203: )
204: ),
205: 'directory' => array(
206: 'description' => _("Company directory"),
207: 'args' => array()
208: ),
209: 'dial' => array(
210: 'description' => _("Call out"),
211: 'args' => array(
212: 'numbers' => array(
213: 'name' => _("Phone Number"),
214: 'type' => 'phone',
215: 'required' => true
216: )
217: )
218: ),
219: 'rewind' => array(
220: 'description' => _("Restart menu"),
221: 'args' => array()
222: ),
223: 'admin_login' => array(
224: 'description' => _("Login to Admin Functions"),
225: 'args' => array()
226: ),
227: 'none' => array(
228: 'description' => _("No action"),
229: 'args' => array()
230: )
231:
232:
233: );
234: }
235:
236: static public function getNames($array)
237: {
238: $res = array();
239: foreach ($array as $id => $info) {
240: $res[$id] = $info['name'];
241: }
242: return $res;
243: }
244:
245: static public function getAdminTabs()
246: {
247: $tabname = Horde_Util::getFormData('view');
248: $tabs = new Horde_Core_Ui_Tabs('view', Horde_Variables::getDefaultVariables());
249: $tabs->addTab(_("Telephone Numbers"),
250: Horde::url('admin/numbers.php'),
251: array('view' => 'numbers', id => 'tabnumbers'));
252: $tabs->addTab(_("Accounts"),
253: Horde::url('admin/accounts.php'),
254: array('view' => 'accounts', id => 'tabaccounts'));
255: if ($view === null) {
256: $view = 'numbers';
257: }
258:
259: echo $tabs->render($view);
260: }
261:
262: }
263: