Update SoftKey Set Management
Prior versions relied on preestablished default softkeyset which was no longer correct, and data from sccp.conf. Data returned from chan-sccp was mishandled, and only returned a keyset name. Now process data from AMI and show actual data in use by chan-sccp
This commit is contained in:
parent
a58d397866
commit
fb7a7da60a
|
@ -252,33 +252,47 @@ class SCCPGeneric_Response extends Response
|
|||
|
||||
protected function ConvertTableData( $_tablename, array $_fkey, array $_fields)
|
||||
{
|
||||
//dbug(debug_backtrace(2));
|
||||
/* except for softkeysets, $_fkey is a single element array so the Returned
|
||||
array is a normal array. For softkey sets, need to return an associative
|
||||
array with a second level.
|
||||
*/
|
||||
$result = array();
|
||||
$_rawtable = $this->Table2Array($_tablename);
|
||||
// Check that there is actually data to be converted
|
||||
if (empty($_rawtable)) { return $result;}
|
||||
foreach ($_rawtable as $_row) {
|
||||
$all_key_ok = true;
|
||||
// No need to test if $_fkey is array as array required
|
||||
foreach ($_fkey as $_fid) {
|
||||
if (empty($_row[$_fid])) {
|
||||
$all_key_ok = false;
|
||||
} else {
|
||||
$set_name[$_fid] = $_row[$_fid];
|
||||
}
|
||||
}
|
||||
$Data = &$result;
|
||||
|
||||
if ($all_key_ok) {
|
||||
foreach ($set_name as $value_id) {
|
||||
$Data = &$Data[$value_id];
|
||||
}
|
||||
// Label converter in case labels and keys are different
|
||||
foreach ($_fields as $value_key => $value_id) {
|
||||
$Data[$value_id] = $_row[$value_key];
|
||||
}
|
||||
if (empty($_rawtable)) {
|
||||
return $result;
|
||||
}
|
||||
// Now check that fkey fields exist in the $_rawtable. If exists in
|
||||
// the first element, Assume that it exists in all elements.
|
||||
foreach ($_fkey as $_fid) {
|
||||
if (!isset($_rawtable[0][$_fid])) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
// could also use tablename here
|
||||
$complexArray = true;
|
||||
if (count($_fkey) === 1) {
|
||||
$complexArray = false;
|
||||
}
|
||||
foreach ($_rawtable as $_rowArr) {
|
||||
// $_row is a table element
|
||||
$outputArr = array();
|
||||
foreach ($_fields as $value_key => $value_id) {
|
||||
$outputArr[$value_id] = $_rowArr[$value_key];
|
||||
}
|
||||
if ($complexArray) {
|
||||
// We are returning softkey sets. Only looking for formatted value
|
||||
$result[$_rowArr[$_fkey[0]]]['softkeys'] = $_rowArr[$_fkey[0]];
|
||||
if (isset($result[$_rowArr[$_fkey[0]]][$_rowArr[$_fkey[1]]])) {
|
||||
$result[$_rowArr[$_fkey[0]]][$_rowArr[$_fkey[1]]] .= "{$outputArr['label']}<br>";
|
||||
} else {
|
||||
$result[$_rowArr[$_fkey[0]]][$_rowArr[$_fkey[1]]] = "{$outputArr['label']}<br>";
|
||||
}
|
||||
} else {
|
||||
$result[$_rowArr[$_fkey[0]]] = $outputArr;
|
||||
}
|
||||
}
|
||||
//dbug($result);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
|
@ -361,10 +361,7 @@ class aminterface
|
|||
$result = array();
|
||||
if ($this->_connect_state) {
|
||||
$_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowSoftkeySetsAction();
|
||||
$_res = $this->send($_action)->getResult();
|
||||
foreach ($_res as $key => $value) {
|
||||
$result[$key] = $key;
|
||||
}
|
||||
$result = $this->send($_action)->getResult();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -571,9 +571,12 @@ class formcreate
|
|||
<?php
|
||||
echo '<select name="'.$res_id.'" class="'. $child->class . '" id="' . $res_id . '">';
|
||||
foreach ($select_opt as $key => $val) {
|
||||
// TODO: Clean this up - its a bunch of fixes
|
||||
if (is_array($val)) {
|
||||
$opt_key = (isset($val['id'])) ? $val['id'] : $key;
|
||||
$opt_val = (isset($val['val'])) ? $val['val'] : $val;
|
||||
$opt_key = (isset($val['softkeys'])) ? $val['softkeys'] : $key;
|
||||
$opt_val = (isset($val['softkeys'])) ? $val['softkeys'] : $val;
|
||||
} else if (\FreePBX::Sccp_manager()->is_assoc($select_opt)){
|
||||
// have associative array
|
||||
$opt_key = $key;
|
||||
|
|
|
@ -234,8 +234,8 @@ trait ajaxHelper {
|
|||
//$id_name = $request['softkey'];
|
||||
unset($this->sccp_conf_init[$request['softkey']]);
|
||||
$this->createDefaultSccpConfig($this->sccpvalues, $this->sccppath["asterisk"]);
|
||||
$msg = print_r($this->aminterface->core_sccp_reload(), 1);
|
||||
return array('status' => true, 'table_reload' => true);
|
||||
$msg = $this->aminterface->core_sccp_reload();
|
||||
return array('status' => true, 'reload' => true, 'message' => $msg['Response'] .' - Softkey set deleted');
|
||||
}
|
||||
break;
|
||||
case 'updateSoftKey':
|
||||
|
@ -251,8 +251,8 @@ trait ajaxHelper {
|
|||
|
||||
// !TODO!: -TODO-: Check SIP Support Enabled
|
||||
$this->createSccpXmlSoftkey();
|
||||
$msg = print_r($this->aminterface->core_sccp_reload(), 1);
|
||||
return array('status' => true, 'table_reload' => true, 'msg' => $msg);
|
||||
$msg = $this->aminterface->core_sccp_reload();
|
||||
return array('status' => true, 'reload' => true, 'message' => $msg['Response'] .' - Softkey sets updated');
|
||||
}
|
||||
break;
|
||||
case 'backupsettings':
|
||||
|
|
|
@ -23,7 +23,7 @@ trait bmoFunctions {
|
|||
break;
|
||||
case 'sccp_adv':
|
||||
$this->dialTemplateData = json_encode($this->getDialTemplate());
|
||||
$this->softKeyData = json_encode($this->getSoftKey());
|
||||
$this->softKeyData = json_encode(array_values($this->aminterface->sccp_list_keysets()));
|
||||
$this->deviceModelData = json_encode($this->ajaxHandler($_REQUEST = array('command'=>'getDeviceModel', 'type'=>'enabled')));
|
||||
break;
|
||||
default:
|
||||
|
@ -125,47 +125,6 @@ trait bmoFunctions {
|
|||
return $result;
|
||||
}
|
||||
|
||||
function getSoftKey() {
|
||||
$result = array();
|
||||
$i = 0;
|
||||
$keyl = 'default';
|
||||
foreach ($this->aminterface->sccp_list_keysets() as $keyl => $vall) {
|
||||
$result[$i]['softkeys'] = $keyl;
|
||||
if ($keyl == 'default') {
|
||||
foreach ($this->extconfigs->getExtConfig('keyset') as $key => $value) {
|
||||
$result[$i][$key] = str_replace(',', '<br>', $value);
|
||||
}
|
||||
} else {
|
||||
foreach ($this->getMyConfig('softkeyset', $keyl) as $key => $value) {
|
||||
$result[$i][$key] = str_replace(',', '<br>', $value);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getMyConfig(string $var, $id = "noid") {
|
||||
$final = array();
|
||||
$i = 0;
|
||||
if ($id == "noid") {
|
||||
foreach ($this->sccp_conf_init as $key => $value) {
|
||||
if ($this->sccp_conf_init[$key]['type'] == 'softkeyset') {
|
||||
$final[$i] = $value;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!empty($this->sccp_conf_init[$id])) {
|
||||
if ($this->sccp_conf_init[$id]['type'] == 'softkeyset') {
|
||||
$final = $this->sccp_conf_init[$id];
|
||||
}
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
return $final;
|
||||
}
|
||||
/* unused but FPBX API requires it */
|
||||
|
||||
public function install() {
|
||||
|
|
|
@ -26,20 +26,19 @@ $keysetarray = $this->extconfigs->getExtConfig('keyset');
|
|||
'uriaction' => array('default'));
|
||||
*/
|
||||
// ------------------------------------- Key Set Display information ---------------------------------------------------------
|
||||
$keynamearray = array('onhook' => array('sname' => 'ONHOOK', 'name' =>'Display Onhook', 'help' =>'help.'),
|
||||
'connected' => array('sname' => 'CONNECTED', 'name' =>'Display Connected', 'help' =>'help.'),
|
||||
'onhold' => array('sname' => 'ONHOLD', 'name' =>'Display onhold', 'help' =>'help.'),
|
||||
'ringin' => array('sname' => 'RINGIN', 'name' =>'Display ringin', 'help' =>'help.'),
|
||||
'offhook' => array('sname' => 'OFFHOOK', 'name' =>'Display offhook', 'help' =>'help.'),
|
||||
'conntrans' => array('sname' => 'CONNTRANS', 'name' =>'Display conntrans', 'help' =>'help.'),
|
||||
'digitsfoll' => array('sname' => 'DIGITSFOLL', 'name' =>'Display digitsfoll', 'help' =>'help.'),
|
||||
'connconf' => array('sname' => 'CONNCONF', 'name' =>'Display connconf', 'help' =>'help.'),
|
||||
'ringout' => array('sname' => 'RINGOUT', 'name' =>'Display ringout', 'help' =>'help.'),
|
||||
'offhookfeat'=> array('sname' => 'OFFHOOKFEAT', 'name' =>'Display offhookfeat', 'help' =>'help.'),
|
||||
'onhint' => array('sname' => 'ONHINT', 'name' =>'Display onhint', 'help' =>'help.'),
|
||||
'onstealable'=> array('sname' => 'onstealable', 'name' =>'Display onstealable', 'help' =>'help.'),
|
||||
'holdconf' => array('sname' => 'HOLDCONF', 'name' =>'Display holdconf', 'help' =>'help.'),
|
||||
'uriaction' => array('sname' => '', 'name' =>'Display uriaction', 'help' =>'help.')
|
||||
$keynamearray = array('ONHOOK' => array('sname' => 'ONHOOK', 'name' =>'Display Onhook', 'help' =>'help.'),
|
||||
'CONNECTED' => array('sname' => 'CONNECTED', 'name' =>'Display Connected', 'help' =>'help.'),
|
||||
'ONHOLD' => array('sname' => 'ONHOLD', 'name' =>'Display onhold', 'help' =>'help.'),
|
||||
'RINGIN' => array('sname' => 'RINGIN', 'name' =>'Display ringin', 'help' =>'help.'),
|
||||
'OFFHOOK' => array('sname' => 'OFFHOOK', 'name' =>'Display offhook', 'help' =>'help.'),
|
||||
'CONNTRANS' => array('sname' => 'CONNTRANS', 'name' =>'Display conntrans', 'help' =>'help.'),
|
||||
'DIGITSFOLL' => array('sname' => 'DIGITSFOLL', 'name' =>'Display digitsfoll', 'help' =>'help.'),
|
||||
'CONNCONF' => array('sname' => 'CONNCONF', 'name' =>'Display connconf', 'help' =>'help.'),
|
||||
'RINGOUT' => array('sname' => 'RINGOUT', 'name' =>'Display ringout', 'help' =>'help.'),
|
||||
'OFFHOOKFEAT'=> array('sname' => 'OFFHOOKFEAT', 'name' =>'Display offhookfeat', 'help' =>'help.'),
|
||||
'INUSEHINT' => array('sname' => 'INUSEHINT', 'name' =>'Display inusehint', 'help' =>'help.'),
|
||||
'ONHOOKSTEALABLE'=> array('sname' => 'ONHOOKSTEALABLE', 'name' =>'Display onhookstealable', 'help' =>'help.'),
|
||||
'HOLDCONF' => array('sname' => 'HOLDCONF', 'name' =>'Display holdconf', 'help' =>'help.')
|
||||
);
|
||||
|
||||
?>
|
||||
|
@ -60,7 +59,7 @@ $keynamearray = array('onhook' => array('sname' => 'ONHOOK', 'name' =>'Displa
|
|||
<?php
|
||||
$i = 0;
|
||||
foreach ($keynamearray as $key => $value) {
|
||||
if ($i < 12) {
|
||||
if ($i < 13) {
|
||||
echo '<th data-sortable="false" data-field="'.$key.'">'._($value['sname']).'</th>';
|
||||
}
|
||||
$i ++;
|
||||
|
|
Loading…
Reference in a new issue