Optimise Hint processing
Remove hint processing from __Construct and place in getbuttons, only place where used Return hint information in correct format from ami, to avoid second formatting Optimise db calls for hints to speed loading of add/edit device.
This commit is contained in:
parent
ce383089b8
commit
2229eef432
|
@ -429,6 +429,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
|
||||
break;
|
||||
case 'monitor':
|
||||
$hint = $this->aminterface->core_list_hints();
|
||||
foreach ($hint as $key => $value) {
|
||||
if ($this->hint_context['default'] != $value) {
|
||||
$this->hint_context[$key] = $value;
|
||||
}
|
||||
}
|
||||
$btn_t = 'speeddial';
|
||||
$btn_opt = (string) $get_settings["button${it}_line"];
|
||||
$db_res = $this->dbinterface->getSccpDeviceTableData('SccpExtension', array('name' => $btn_opt));
|
||||
|
@ -711,13 +717,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
$hint = $this->aminterface->core_list_hints();
|
||||
foreach ($hint as $key => $value) {
|
||||
if ($this->hint_context['default'] != $value) {
|
||||
$this->hint_context[$key] = $value;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1055,34 +1062,35 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
return $modelList;
|
||||
}
|
||||
|
||||
function getHintInformation($sort = true, $filter = array()) {
|
||||
function getHintInformation($filter = array()) {
|
||||
$res = array();
|
||||
$default_hint = '@ext-local';
|
||||
|
||||
if (empty($res)) {
|
||||
//if (empty($res)) {
|
||||
// Old Req get all hints
|
||||
$tmp_data = $this->aminterface->core_list_all_hints();
|
||||
foreach ($tmp_data as $value) {
|
||||
$res[$value] = array('key' => $value, 'exten' => $this->before('@', $value), 'label' => $value);
|
||||
}
|
||||
}
|
||||
// Avoid post processing - return dat in required format.
|
||||
$res = $this->aminterface->core_list_all_hints();
|
||||
//foreach ($tmp_data as $value) {
|
||||
//$res[$value] = array('key' => $value, 'exten' => $this->before('@', $value), 'label' => $value);
|
||||
//}
|
||||
//dbug($res);
|
||||
//}
|
||||
|
||||
// Update info from sccp_db
|
||||
$tmp_data = $this->dbinterface->getSccpDeviceTableData('SccpExtension');
|
||||
foreach ($tmp_data as $value) {
|
||||
$name_l = $value['name'];
|
||||
if (!empty($res[$name_l . $default_hint])) {
|
||||
$res[$name_l . $default_hint]['exten'] = $name_l;
|
||||
$res[$name_l . $default_hint]['label'] = $value['label'];
|
||||
foreach ($this->dbinterface->getSccpDeviceTableData('sccpHints') as $key => $value) {
|
||||
if (!empty($res[$key . $default_hint])) {
|
||||
$res[$key . $default_hint]['exten'] = $key;
|
||||
$res[$key . $default_hint]['label'] = $value['label'];
|
||||
} else {
|
||||
// if not exist in system hints ..... ???????
|
||||
$res[$name_l . $default_hint] = array('key' => $name_l . $default_hint, 'exten' => $name_l, 'label' => $value['label']);
|
||||
$res[$key . $default_hint] = array('key' => $key . $default_hint, 'exten' => $key, 'label' => $value['label']);
|
||||
}
|
||||
}
|
||||
if (!$sort) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Hints returned from db are already sorted by name
|
||||
//if (!$sort) {
|
||||
return $res;
|
||||
//}
|
||||
/*
|
||||
foreach ($res as $key => $value) {
|
||||
$data_sort[$value['exten']] = $key;
|
||||
}
|
||||
|
@ -1090,10 +1098,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
foreach ($data_sort as $key => $value) {
|
||||
$res_sort[$value] = $res[$value];
|
||||
}
|
||||
|
||||
*/
|
||||
// Update info from sip DB
|
||||
/* !TODO!: Update Hint info from sip DB ??? */
|
||||
return $res_sort;
|
||||
//return $res_sort;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* Core Comsnd Interface
|
||||
*
|
||||
* https://www.voip-info.org/asterisk-manager-example-php/
|
||||
*/
|
||||
/* !TODO!: Re-Indent this file. -TODO-: What do you mean? coreaccessinterface ?? */
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface;
|
||||
|
||||
// ************************************************************************** Event *********************************************
|
||||
|
@ -94,7 +86,7 @@ class SCCPDeviceEntry_Event extends Event
|
|||
{
|
||||
// This is a list of tables, each table is an entry
|
||||
}
|
||||
|
||||
/*
|
||||
class SCCPShowDevice_Event extends Event
|
||||
{
|
||||
// This is a list of tables
|
||||
|
@ -109,7 +101,8 @@ class SCCPShowDevice_Event extends Event
|
|||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
public function getCodecsPreference()
|
||||
{
|
||||
// TODO unused method - to be deleted?
|
||||
|
@ -121,7 +114,8 @@ class SCCPShowDevice_Event extends Event
|
|||
}
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//}
|
||||
class SCCPDeviceButtonEntry_Event extends Event
|
||||
{
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ class AMIException extends \Exception
|
|||
|
||||
abstract class Message
|
||||
{
|
||||
|
||||
const EOL = "\r\n";
|
||||
const EOM = "\r\n\r\n";
|
||||
|
||||
|
@ -360,8 +359,8 @@ class ExtensionStateListAction extends ActionMessage
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct('ExtensionStateList');
|
||||
$this->setKey('Segment', 'general');
|
||||
$this->setKey('ResultFormat', 'command');
|
||||
//$this->setKey('Segment', 'general');
|
||||
//$this->setKey('ResultFormat', 'command');
|
||||
$this->setResponseHandler("ExtensionStateList");
|
||||
}
|
||||
}
|
||||
|
@ -379,8 +378,8 @@ class SCCPShowSoftkeySetsAction extends ActionMessage
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct('SCCPShowSoftkeySets');
|
||||
$this->setKey('Segment', 'general');
|
||||
$this->setKey('ResultFormat', 'command');
|
||||
//$this->setKey('Segment', 'general');
|
||||
//$this->setKey('ResultFormat', 'command');
|
||||
$this->setResponseHandler("SCCPShowSoftkeySets");
|
||||
}
|
||||
}
|
||||
|
@ -391,8 +390,8 @@ class SCCPShowDeviceAction extends ActionMessage
|
|||
public function __construct($devicename)
|
||||
{
|
||||
parent::__construct('SCCPShowDevice');
|
||||
$this->setKey('Segment', 'general');
|
||||
$this->setKey('ResultFormat', 'command');
|
||||
//$this->setKey('Segment', 'general');
|
||||
//$this->setKey('ResultFormat', 'command');
|
||||
$this->setKey('DeviceName', $devicename);
|
||||
$this->setResponseHandler("SCCPShowDevice");
|
||||
}
|
||||
|
@ -404,8 +403,8 @@ class SCCPShowDevicesAction extends ActionMessage
|
|||
public function __construct()
|
||||
{
|
||||
parent::__construct('SCCPShowDevices');
|
||||
$this->setKey('Segment', 'general');
|
||||
$this->setKey('ResultFormat', 'command');
|
||||
//$this->setKey('Segment', 'general');
|
||||
//$this->setKey('ResultFormat', 'command');
|
||||
$this->setResponseHandler("SCCPShowDevices");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -348,7 +348,8 @@ class aminterface
|
|||
$_res = $this->send($_action)->getResult();
|
||||
foreach ($_res as $key => $value) {
|
||||
foreach ($value as $key2 => $value2) {
|
||||
$result[$key.'@'.$key2] = $key.'@'.$key2;
|
||||
//$result[$key.'@'.$key2] = $key.'@'.$key2;
|
||||
$result[$key.'@'.$key2] = ['key' => $key.'@'.$key2, 'exten' => $key, 'label' => $key.'@'.$key2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,9 @@ class dbinterface
|
|||
$stmts->bindParam(':name', $data['name'],\PDO::PARAM_STR);
|
||||
}
|
||||
break;
|
||||
case 'sccpHints':
|
||||
$stmtU = $this->db->prepare('SELECT name, name, label FROM sccpline ORDER BY name');
|
||||
break;
|
||||
case 'phoneGrid':
|
||||
switch ($data['type']) {
|
||||
case "cisco-sip":
|
||||
|
|
|
@ -19,8 +19,8 @@ if ($_REQUEST['tech_hardware'] === 'cisco') {
|
|||
} else {
|
||||
$lines_list = $this->dbinterface->getSipTableData('extensionList');
|
||||
}
|
||||
|
||||
$hint_list = $this->getHintInformation(true, array('context'=>'park-hints'));
|
||||
// TODO: actually returning all hints - the filter is currently ignored.
|
||||
$hint_list = $this->getHintInformation(array('context'=>'park-hints'));
|
||||
|
||||
$line_id =0;
|
||||
$max_buttons =56; //Don't know hardware type so set a maximum. On save, this is set to actual max buttons
|
||||
|
|
Loading…
Reference in a new issue