-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfunctions.inc.php
More file actions
107 lines (82 loc) · 3.02 KB
/
functions.inc.php
File metadata and controls
107 lines (82 loc) · 3.02 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
<?php /* $Id */
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
function queuemetrics_hookGet_config($engine) {
global $ext;
global $db;
switch($engine) {
case "asterisk":
$ivr_logging = queuemetrics_get_details('ivr_logging');
if ($ivr_logging['value'] == 'true') {
//get all ivrs
$ivrlist = ivr_get_details();
if(is_array($ivrlist)) {
foreach($ivrlist as $item) {
//splice into ivr to set the ivr selection var and append if already defined
$context = 'ivr-'.$item['id'];
//get ivr selection
$ivrentrieslist = ivr_get_entries($item['id']);
if (is_array($ivrentrieslist)) {
foreach($ivrentrieslist as $selection) {
//splice into ivr selection
$ext->splice($context, $selection['selection'], 'ivrsel-'.$selection['selection'], new ext_setvar("IVRSELECTION", '${EXTEN}|${IVR_CONTEXT}'));
$ext->splice($context, $selection['selection'], 'ivrsel-'.$selection['selection'], new ext_queuelog('NONE','${UNIQUEID}','NONE','INFO', 'IVRAPPEND|${IVRSELECTION}'));
}
}
}
}
}
break;
}
}
function queuemetrics_configpageinit($pagename) {
global $currentcomponent;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : '';
if($pagename == 'queuemetrics'){
$currentcomponent->addprocessfunc('queuemetrics_configprocess');
return true;
}
}
//process received arguments
function queuemetrics_configprocess(){
if (isset($_REQUEST['display']) && $_REQUEST['display'] == 'queuemetrics'){
//get variables
$get_var = array('ivr_logging');
foreach($get_var as $var){
$vars[$var] = isset($_REQUEST[$var]) ? $_REQUEST[$var] : '';
}
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
switch ($action) {
case 'save':
queuemetrics_put_details($vars);
needreload();
redirect_standard_continue();
break;
}
}
}
function queuemetrics_put_details($options) {
global $db;
foreach ($options as $key => $item) {
$data[] = array($key, $item);
}
$sql = $db->prepare('REPLACE INTO queuemetrics_options (`keyword`, `value`) VALUES (?, ?)');
$ret = $db->executeMultiple($sql, $data);
if($db->IsError($ret)) {
die_freepbx($ret->getDebugInfo()."\n".$ret->getUserInfo()."\n".$db->last_query);
}
return TRUE;
}
function queuemetrics_get_details($keyword = '') {
global $db;
$sql = "SELECT * FROM queuemetrics_options";
if (!empty($keyword)) {
$sql .= " WHERE `keyword` = '" . $keyword . "'";
}
$res = $db->getAll($sql, DB_FETCHMODE_ASSOC);
if($db->IsError($res)) {
die_freepbx($res->getDebugInfo());
}
return (isset($keyword) && $keyword != '') ? $res[0] : $res;
}
?>