diff --git a/functions.inc.php b/functions.inc.php index 8dd2e7a..f4b0bc3 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -2,61 +2,66 @@ 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; - } + 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}|'.$context.'|'.$item['name'])); + $ext->splice($context, $selection['selection'], 'ivrsel-'.$selection['selection'], new ext_queuelog('NONE','${UNIQUEID}','NONE','INFO', 'IVRAPPEND|${IVRSELECTION}')); + } + $ext->splice($context, 'i','final', new ext_setvar("IVRSELECTION", 'i|'.$context.'|'.$item['name'])); + $ext->splice($context, 'i','final', new ext_queuelog('NONE','${UNIQUEID}','NONE','INFO', 'IVRAPPEND|${IVRSELECTION}')); + $ext->splice($context, 't','final', new ext_setvar("IVRSELECTION", 't|'.$context.'|'.$item['name'])); + $ext->splice($context, 't','final', new ext_queuelog('NONE','${UNIQUEID}','NONE','INFO', 'IVRAPPEND|${IVRSELECTION}')); + + } + } + } + } + break; + } } function queuemetrics_configpageinit($pagename) { global $currentcomponent; - $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; + $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : ''; - + if($pagename == 'queuemetrics'){ $currentcomponent->addprocessfunc('queuemetrics_configprocess'); - return true; + 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){ + + //get variables + $get_var = array('ivr_logging'); + + foreach($get_var as $var){ $vars[$var] = isset($_REQUEST[$var]) ? $_REQUEST[$var] : ''; } @@ -64,7 +69,7 @@ function queuemetrics_configprocess(){ switch ($action) { case 'save': - queuemetrics_put_details($vars); + queuemetrics_put_details($vars); needreload(); redirect_standard_continue(); break; @@ -73,35 +78,35 @@ function queuemetrics_configprocess(){ } function queuemetrics_put_details($options) { - global $db; - - foreach ($options as $key => $item) { - $data[] = array($key, $item); - } + global $db; + + foreach ($options as $key => $item) { + $data[] = array($key, $item); + } - $sql = $db->prepare('REPLACE INTO queuemetrics_options (`keyword`, `value`) VALUES (?, ?)'); + $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); + + if($db->IsError($ret)) { + die_freepbx($ret->getDebugInfo()."\n".$ret->getUserInfo()."\n".$db->last_query); } - return TRUE; + return TRUE; } function queuemetrics_get_details($keyword = '') { - global $db; + global $db; $sql = "SELECT * FROM queuemetrics_options"; - if (!empty($keyword)) { - $sql .= " WHERE `keyword` = '" . $keyword . "'"; - } + if (!empty($keyword)) { + $sql .= " WHERE `keyword` = '" . $keyword . "'"; + } - $res = $db->getAll($sql, DB_FETCHMODE_ASSOC); + $res = $db->getAll($sql, DB_FETCHMODE_ASSOC); if($db->IsError($res)) { die_freepbx($res->getDebugInfo()); } - return (isset($keyword) && $keyword != '') ? $res[0] : $res; + return (isset($keyword) && $keyword != '') ? $res[0] : $res; } ?> diff --git a/install.php b/install.php index 911a928..b22a9b4 100644 --- a/install.php +++ b/install.php @@ -6,24 +6,24 @@ $sql = "SELECT * FROM `queuemetrics_options` LIMIT 1"; $check = $db->query($sql); if(!DB::IsError($check)) { - out(_("queuemetrics table already exists, exiting")); + out(_("queuemetrics table already exists, exiting")); } else { - unset($sql); - $sql[] = "CREATE TABLE IF NOT EXISTS `queuemetrics_options` ( - `keyword` VARCHAR(25), - `value` TEXT, - UNIQUE KEY `keyword` (`keyword`) - )"; - - foreach ($sql as $q) { - $result = $db->query($q); - if($db->IsError($result)){ - die_freepbx($result->getDebugInfo()); - } - } + unset($sql); + $sql[] = "CREATE TABLE IF NOT EXISTS `queuemetrics_options` ( + `keyword` VARCHAR(25), + `value` TEXT, + UNIQUE KEY `keyword` (`keyword`) + )"; + + foreach ($sql as $q) { + $result = $db->query($q); + if($db->IsError($result)){ + die_freepbx($result->getDebugInfo()); + } + } - outn(_("creating queuemetrics...ok")); + outn(_("creating queuemetrics...ok")); } // sysadmin migration diff --git a/page.queuemetrics.php b/page.queuemetrics.php index ba3a594..21525b7 100644 --- a/page.queuemetrics.php +++ b/page.queuemetrics.php @@ -1,29 +1,29 @@ - $val) { - $var[$val['keyword']] = isset($_REQUEST[$val['keyword']]) ? $_REQUEST[$val['keyword']] : $val['value']; - $$val['keyword'] = $var[$val['keyword']]; + $var[$val['keyword']] = isset($_REQUEST[$val['keyword']]) ? $_REQUEST[$val['keyword']] : $val['value']; + $$val['keyword'] = $var[$val['keyword']]; } $checked = (isset($ivr_logging) && $ivr_logging == 'true')?'CHECKED':''; echo '

QueueMetrics

'; echo '
'; -echo ''; +echo ''; echo '

'; $table = new CI_Table(); $table->add_row( _('Settings')); $table->add_row('
'); -$table->add_row('Log IVR Selections ' . _('When checked, IVR selections will be reported by QueueMetrics') . '', ''); +$table->add_row('Log IVR Selections ' . _('When checked, IVR selections will be reported by QueueMetrics') . '', ''); $table->add_row(''); $table->add_row(''); $table->add_row(''); -echo $table->generate(); +echo $table->generate(); echo '














'; diff --git a/uninstall.php b/uninstall.php index 4e941f1..4496eb8 100644 --- a/uninstall.php +++ b/uninstall.php @@ -1,4 +1,4 @@ -