Update Response.class.php

Change to only modify certain returned fields from convertTable
Need to validate changes for softkeysets as now only return sets and not mode
This commit is contained in:
stevenA 2022-01-16 11:58:40 +01:00
parent 8961ebd5de
commit 6b5cd413d7

View file

@ -262,23 +262,17 @@ class SCCPGeneric_Response extends Response
// No need to test if $_fkey is array as array required // No need to test if $_fkey is array as array required
foreach ($_fkey as $_fid) { foreach ($_fkey as $_fid) {
if (empty($_row[$_fid])) { if (empty($_row[$_fid])) {
$all_key_ok = false; return array();
} else { } else {
$set_name[$_fid] = $_row[$_fid]; $result[$_row[$_fid]] = $_row;
} }
} }
$Data = &$result; // Change any key labels that require changing for db compatibility.
foreach ($_fields as $value_key => $value_id) {
if ($all_key_ok) { $result[$_row[$_fid]][$value_id] = $result[$_row[$_fid]][$value_key];
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];
}
} }
} }
dbug($result);
return $result; return $result;
} }
@ -341,11 +335,7 @@ class SCCPShowSoftkeySets_Response extends SCCPGeneric_Response
} }
public function getResult() public function getResult()
{ {
return $this->ConvertTableData( return $this->ConvertTableData('SoftKeySets', array('set'), array());
'SoftKeySets',
array('set','mode'),
array('description'=>'description','label'=>'label','lblid'=>'lblid')
);
} }
} }
@ -358,12 +348,7 @@ class SCCPShowDevices_Response extends SCCPGeneric_Response
} }
public function getResult() public function getResult()
{ {
return $this->ConvertTableData( return $this->ConvertTableData('Devices', array('mac'), array('mac'=>'name','regstate'=>'status'));
'Devices',
array('mac'),
array('mac'=>'name','address'=>'address','descr'=>'descr','regstate'=>'status',
'token'=>'token','act'=>'act', 'lines'=>'lines','nat'=>'nat','regtime'=>'regtime')
);
} }
} }
@ -383,26 +368,9 @@ class SCCPShowDevice_Response extends SCCPGeneric_Response
$result = array_merge($result, $trow->getKeys()); $result = array_merge($result, $trow->getKeys());
} }
// Now handle label changes so that keys from AMI correspond to db keys in _tables // Now handle label changes so that keys from AMI correspond to db keys in _tables
$result['Buttons'] = $this->ConvertTableData( $result['Buttons'] = $this->ConvertTableData('Buttons', array('id'), array());
'Buttons', $result['SpeeddialButtons'] = $this->ConvertTableData('SpeeddialButtons', array('id'), array());
array('id'), $result['CallStatistics'] = $this->ConvertTableData('CallStatistics', array('type'), array());
array('id'=>'id','channelobjecttype'=>'channelobjecttype','inst'=>'inst',
'typestr'=>'typestr', 'type'=>'type', 'pendupdt'=>'pendupdt', 'penddel'=>'penddel', 'default'=>'default'
)
);
$result['SpeeddialButtons'] = $this->ConvertTableData(
'SpeeddialButtons',
array('id'),
array('id'=>'id','channelobjecttype'=>'channelobjecttype','name'=>'name','number'=>'number','hint'=>'hint')
);
$result['CallStatistics'] = $this->ConvertTableData(
'CallStatistics',
array('type'),
array('type'=>'type','channelobjecttype'=>'channelobjecttype','calls'=>'calls','pcktsnt'=>'pcktsnt','pcktrcvd'=>'pcktrcvd',
'lost'=>'lost','jitter'=>'jitter','latency'=>'latency', 'quality'=>'quality','avgqual'=>'avgqual','meanqual'=>'meanqual',
'maxqual'=>'maxqual', 'rconceal'=>'rconceal', 'sconceal'=>'sconceal'
)
);
$result['SCCP_Vendor'] = array('vendor' => strtok($result['skinnyphonetype'], ' '), 'model' => strtok('('), $result['SCCP_Vendor'] = array('vendor' => strtok($result['skinnyphonetype'], ' '), 'model' => strtok('('),
'model_id' => strtok(')'), 'vendor_addon' => strtok($result['configphonetype'], ' '), 'model_id' => strtok(')'), 'vendor_addon' => strtok($result['configphonetype'], ' '),
'model_addon' => strtok(' ')); 'model_addon' => strtok(' '));