1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17:
18: if (!defined('SHOUT_BASE')) {
19: define('SHOUT_BASE', dirname(__FILE__). '/..');
20: }
21:
22: if (!defined('HORDE_BASE')) {
23: 24:
25: if (file_exists(SHOUT_BASE. '/config/horde.local.php')) {
26: include SHOUT_BASE . '/config/horde.local.php';
27: } else {
28: define('HORDE_BASE', SHOUT_BASE . '/..');
29: }
30: }
31:
32: 33:
34: require_once HORDE_BASE . '/lib/core.php';
35:
36: class Shout_Application extends Horde_Registry_Application
37: {
38: 39:
40: public $version = 'H4 (1.0-git)';
41:
42: 43: 44:
45: public $storage = null;
46:
47: 48: 49:
50: public $extensions = null;
51:
52: 53: 54:
55: public $devices = null;
56:
57: 58: 59:
60: public $dialplan = null;
61:
62: 63: 64:
65: public $vfs = null;
66:
67: 68:
69: protected function _init()
70: {
71: try {
72: $this->storage = Shout_Driver::factory('storage');
73: $this->extensions = Shout_Driver::factory('extensions');
74: $this->devices = Shout_Driver::factory('devices');
75: $this->dialplan = Shout_Driver::factory('dialplan');
76: $conf = $GLOBALS['conf'];
77: $this->vfs = Horde_Vfs::factory($conf['ivr']['driver'], $conf['ivr']['params']);
78:
79: $accounts = $this->storage->getAccounts();
80: } catch (Shout_Exception $e) {
81: $GLOBALS['notification']->push($e);
82: $accounts = false;
83: return false;
84: }
85:
86: $account = Horde_Util::getFormData('account');
87: if (empty($account)) {
88: $account = $GLOBALS['session']->get('shout', 'curaccount_code');
89: }
90:
91: if (!empty($account) && !in_array($account, array_keys($accounts))) {
92:
93: $GLOBALS['notification']->push(_("You do not have permission to access that account."), 'horde.error');
94: $account = false;
95: }
96:
97: if (empty($account)) {
98: if (count($accounts)) {
99:
100: $account = reset(array_keys($accounts));
101: } else {
102:
103: $GLOBALS['notification']->push("Please select a account to continue.", 'horde.info');
104: $account = false;
105: }
106: }
107:
108: $session->set('shout', 'curaccount_code', $accounts[$account]['code']);
109: $session->set('shout', 'curaccount_name', $accounts[$account]['name']);
110: }
111:
112: 113:
114: public function perms()
115: {
116: $perms = array(
117: 'accounts' => array(
118: 'title' => _("Accounts")
119: ),
120: 'superadmin' => array(
121: 'title' => _("Super Administrator")
122: )
123: );
124:
125: $accounts = $this->storage->getAccounts();
126:
127:
128: foreach ($accounts as $code => $info) {
129: $perms['account:' . $code] = array(
130: 'title' => $info['name']
131: );
132:
133: foreach(
134: array(
135: 'extensions' => 'Extensions',
136: 'devices' => 'Devices',
137: 'conferences' => 'Conference Rooms',
138: )
139: as $module => $modname) {
140: $perms['accounts:' . $code . ':' . $module] = array(
141: 'title' => $modname
142: );
143: }
144: }
145:
146: return $perms;
147: }
148:
149:
150: public function getRecordings()
151: {
152: $account = $GLOBALS['session']->get('shout', 'curaccount_code');
153: $rlist = $this->vfs->listFolder($account);
154:
155:
156:
157:
158:
159: $recordings = array();
160: foreach ($rlist as $name => $info) {
161: $name = substr($name, 0, strrpos($name, '.'));
162: $info['name'] = $name;
163: $recordings[$name] = $info;
164: }
165:
166: return $recordings;
167: }
168:
169: }
170: