-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueueexit.class.php
More file actions
181 lines (169 loc) · 6.1 KB
/
Copy pathQueueexit.class.php
File metadata and controls
181 lines (169 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
namespace FreePBX\modules;
class Queueexit implements \BMO
{
public function install()
{
}
public function uninstall()
{
}
// The following two stubs are planned for implementation in FreePBX 15.
public function backup()
{
}
public function restore($backup)
{
}
// This handles any data passed to this module before the page is rendered.
public function doConfigPageInit($page) {
$id = $_REQUEST['id']?$_REQUEST['id']:'';
$action = $_REQUEST['action']?$_REQUEST['action']:'';
$exampleField = $_REQUEST['example-field']?$_REQUEST['example-field']:'';
//Handle form submissions
$dbh = \FreePBX::Database();
$destinations = array();
foreach (['timeout_destination','full_destination','joinempty_destination','leaveempty_destination','joinunavail_destination','leaveunavail_destination','continue_destination'] as $key) {
if (isset($_REQUEST['goto'.$key]) && isset($_REQUEST[$_REQUEST['goto'.$key].$key])) {
$destinations[$key] = $_REQUEST[$_REQUEST['goto'.$key].$key];
} else {
$destinations[$key] = '';
}
}
switch ($action) {
case 'add':
$sql = 'INSERT INTO `queueexit`
(displayname,timeout_destination,full_destination,joinempty_destination,leaveempty_destination,joinunavail_destination,leaveunavail_destination,continue_destination)
VALUES (?,?,?,?,?,?,?,?)';
$sth = $dbh->prepare($sql);
$sth->execute(array(
$_REQUEST['displayname'],
$destinations['timeout_destination'],
$destinations['full_destination'],
$destinations['joinempty_destination'],
$destinations['leaveempty_destination'],
$destinations['joinunavail_destination'],
$destinations['leaveunavail_destination'],
$destinations['continue_destination']
));
needreload();
break;
case 'edit':
$sql = 'REPLACE INTO `queueexit`
(`id`,`displayname`,`timeout_destination`,`full_destination`,`joinempty_destination`,`leaveempty_destination`,`joinunavail_destination`,`leaveunavail_destination`,`continue_destination`)
VALUES (?,?,?,?,?,?,?,?,?)';
$sth = $dbh->prepare($sql);
$sth->execute(array(
$_REQUEST['id'],
$_REQUEST['displayname'],
$destinations['timeout_destination'],
$destinations['full_destination'],
$destinations['joinempty_destination'],
$destinations['leaveempty_destination'],
$destinations['joinunavail_destination'],
$destinations['leaveunavail_destination'],
$destinations['continue_destination']
));
needreload();
break;
case 'delete':
$sql = 'DELETE FROM `queueexit` WHERE `id` = ?';
$sth = $dbh->prepare($sql);
$sth->execute(array($id));
unset($_REQUEST['action']);
unset($_REQUEST['id']);
needreload();
break;
}
}
public function getActionBar($request)
{
$buttons = array();
switch ($request['display']) {
case 'queueexit':
if (isset($request['view']) && $request['view'] == 'form'){
$buttons = array(
'delete' => array(
'name' => 'delete',
'id' => 'delete',
'value' => _('Delete')
),
'submit' => array(
'name' => 'submit',
'id' => 'submit',
'value' => _('Submit')
)
);
if (empty($request['extdisplay'])) {
unset($buttons['delete']);
}
}
break;
}
return $buttons;
}
// http://wiki.freepbx.org/display/FOP/BMO+Ajax+Calls
public function ajaxRequest($req, &$setting)
{
switch ($req) {
case 'getJSON':
return true;
break;
default:
return false;
break;
}
}
// This is also documented at http://wiki.freepbx.org/display/FOP/BMO+Ajax+Calls
public function ajaxHandler()
{
switch ($_REQUEST['command']) {
case 'getJSON':
switch ($_REQUEST['jdata']) {
case 'grid':
$ret = array();
foreach ( $this->queueexit_get() as $queueexit) {
$name = $queueexit['displayname'];
$ret[] = array('queueexit'=>$name, 'id'=>$queueexit['id']);
}
return $ret;
break;
default:
return false;
break;
}
break;
default:
return false;
break;
}
}
// http://wiki.freepbx.org/display/FOP/HTML+Output+from+BMO
public function showPage()
{
switch ($_REQUEST['view']) {
case 'form':
if(isset($_REQUEST['id']) && !empty($_REQUEST['id'])){
$subhead = _('Edit Queue Exit');
$content = load_view(__DIR__.'/views/form.php', array('config' => queueexit_get_details($id)));
}else{
$subhead = _('Add Queue Exit');
$content = load_view(__DIR__.'/views/form.php');
}
break;
default:
$subhead = _('Queue Exit List');
$content = load_view(__DIR__.'/views/grid.php');
break;
}
echo load_view(__DIR__.'/views/default.php', array('subhead' => $subhead, 'content' => $content));
}
public function queueexit_get(){
$dbh = \FreePBX::Database();
$sql = 'SELECT * FROM queueexit';
$sth = $dbh->prepare($sql);
$sth->execute();
$res = $sth->fetchAll();
return $res;
}
}