Initial add of feature mobility user table:
- Add extra user fields and sccp_config entries - Create new buttonconfig table
This commit is contained in:
parent
96c9a82819
commit
713d588d98
|
@ -10,11 +10,11 @@
|
|||
// http://chan-sccp-b.sourceforge.net/doc/_howto.xhtml#nf_adhoc_plar
|
||||
// https://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cuipph/all_models/xsi/9-1-1/CUIP_BK_P82B3B16_00_phones-services-application-development-notes/CUIP_BK_P82B3B16_00_phones-services-application-development-notes_chapter_011.html
|
||||
// https://www.cisco.com/c/en/us/td/docs/voice_ip_comm/cuipph/7960g_7940g/sip/4_4/english/administration/guide/ver4_4/sipins44.html
|
||||
// http://usecallmanager.nz/
|
||||
/* !TODO!:
|
||||
* + Cisco Format Mac
|
||||
* + Model Information
|
||||
* + Device Right Menu
|
||||
|
||||
* + Device Right Menu
|
||||
<!-- Dial Templates are not really needed for skinny, skinny get's direct feed back from asterisk per digit -->
|
||||
<!-- If your dialplan is finite (completely fixed length (depends on your country dialplan) dialplan, then dial templates are not required) -->
|
||||
<!-- As far as i know FreePBX does also attempt to build a finite dialplan -->
|
||||
|
@ -38,14 +38,15 @@
|
|||
* + Make Var elements from separate class
|
||||
* + To make creating XML files in a separate class
|
||||
* + Add Switch to select XML schema (display)
|
||||
* - Bootstrap encodeURI(row['type']) ???????
|
||||
* - Check Time zone ....
|
||||
* + SRST Config
|
||||
* + secondary_dialtone_digits = "" line config
|
||||
* + secondary_dialtone_tone = 0x22 line config
|
||||
* - deviceSecurityMode http://usecallmanager.nz//itl-file-tlv.html
|
||||
* - transportLayerProtocol http://usecallmanager.nz//itl-file-tlv.html
|
||||
* - Check Time zone ....
|
||||
* - Failover config
|
||||
* + Auto Addons!
|
||||
* + DND Mode
|
||||
* + secondary_dialtone_digits = "" line config
|
||||
* + secondary_dialtone_tone = 0x22 line config
|
||||
* - support kv-store ?????
|
||||
* + Shared Line
|
||||
* - bug Soft key set (empty keysets )
|
||||
|
@ -98,7 +99,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
private $hint_context = array('default' => '@ext-local'); /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!!
|
||||
private $val_null = 'NONE'; /// REPLACE to null Field
|
||||
public $sccp_model_list = array();
|
||||
public $sccp_metainfo = array();
|
||||
public $sccp_metainfo = array();
|
||||
private $cnf_wr = null;
|
||||
public $sccppath = array();
|
||||
public $sccpvalues = array();
|
||||
|
@ -238,7 +239,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
// $this->sccpvalues[] = array('keyword' => (string)$child->name, 'data' =>(string)$child-> default,'type'=>'0');
|
||||
}
|
||||
}
|
||||
if ($child['type'] == 'SLD' || $child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SL' || $child['type'] == 'SLM' || $child['type'] == 'SLZ' || $child['type'] == 'SLZN' || $child['type'] == 'SLA') {
|
||||
// if ($child['type'] == 'SLD' || $child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SL' || $child['type'] == 'SLM' || $child['type'] == 'SLZ' || $child['type'] == 'SLZN' || $child['type'] == 'SLA') {
|
||||
if (in_array($child['type'], array('SLD','SLS','SLT','SL','SLM','SLZ','SLZN','SLA') )) {
|
||||
if (empty($child->value)) {
|
||||
$datav = (string) $child->default;
|
||||
} else {
|
||||
|
@ -366,7 +368,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$request = $_REQUEST;
|
||||
$action = !empty($request['action']) ? $request['action'] : '';
|
||||
if ($this->sccpvalues['sccp_compatible']['data'] >= '433') {
|
||||
$this->sccp_metainfo = $this->srvinterface->getеtestChanSCCP_GlablsInfo('general');
|
||||
// $this->sccp_metainfo = $this->srvinterface->getеtestChanSCCP_GlablsInfo('general');
|
||||
}
|
||||
|
||||
if (!empty($this->sccpvalues['displayconfig'])) {
|
||||
|
@ -497,7 +499,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$action = !empty($request['action']) ? $request['action'] : '';
|
||||
$inputform = !empty($request['tech_hardware']) ? $request['tech_hardware'] : '';
|
||||
if ($this->sccpvalues['sccp_compatible']['data'] >= '433') {
|
||||
$this->sccp_metainfo = $this->srvinterface->getеtestChanSCCP_GlablsInfo('device');
|
||||
// $this->sccp_metainfo = $this->srvinterface->getеtestChanSCCP_GlablsInfo('device');
|
||||
}
|
||||
|
||||
// print_r($inputform);
|
||||
|
@ -524,6 +526,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
|
||||
break;
|
||||
|
||||
case r_user:
|
||||
$this->pagedata = array(
|
||||
"general" => array(
|
||||
"name" => _("Rouming User configuration"),
|
||||
"page" => 'views/form.addruser.php'
|
||||
),
|
||||
"buttons" => array(
|
||||
"name" => _("Device Buttons"),
|
||||
"page" => 'views/form.buttons.php'
|
||||
),
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->pagedata = array(
|
||||
"general" => array(
|
||||
|
@ -590,6 +606,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
case 'backupsettings':
|
||||
case 'savesettings':
|
||||
case 'save_hardware':
|
||||
case 'save_ruser':
|
||||
case 'save_dialplan_template':
|
||||
case 'delete_hardware':
|
||||
case 'getPhoneGrid':
|
||||
|
@ -644,6 +661,12 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
return $this->save_hw_phone($request);
|
||||
|
||||
break;
|
||||
case 'save_ruser':
|
||||
// $res = $request;
|
||||
$res = $this->save_rouming_users($request);
|
||||
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'general');
|
||||
return array('status' => false, 'message' => print_r($res));
|
||||
break;
|
||||
/* !TODO!: -TODO-: dialplan templates should be removed (only required for very old devices (like ATA) */
|
||||
// ------------------------------- Old deviece suport - In the development---
|
||||
case 'save_dialplan_template':
|
||||
|
@ -844,8 +867,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
case 'getExtensionGrid':
|
||||
$result = $this->dbinterface->get_db_SccpTableData('SccpExtension');
|
||||
if (empty($result)) {
|
||||
$result = array();
|
||||
return array();
|
||||
}
|
||||
/* $res_info = $this->aminterface->core_list_all_exten('exten');
|
||||
if (!empty($res_info)) {
|
||||
foreach ($result as $key => $value) {
|
||||
$tpm_info = $res_info[$value['name']];
|
||||
if (!empty($tpm_info)) {
|
||||
$result[$key]['line_status'] = $tpm_info['status'];
|
||||
$result[$key]['line_statustext'] = $tpm_info['statustext'];
|
||||
} else {
|
||||
$result[$key]['line_status'] = '';
|
||||
$result[$key]['line_statustext'] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
*
|
||||
*/
|
||||
return $result;
|
||||
break;
|
||||
case 'getPhoneGrid':
|
||||
|
@ -911,7 +949,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
|
||||
readfile($filename);
|
||||
unlink($filename);
|
||||
|
||||
|
||||
// return array('status' => false, 'message' => $result);
|
||||
// return $result;
|
||||
break;
|
||||
|
@ -929,6 +967,111 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
* * Save Hardware Device Information to Db + ???? Create / update XML Profile
|
||||
*
|
||||
*/
|
||||
function get_buttons_phone($get_settings, $ref_id = '', $ref_type = 'sccpdevice') {
|
||||
// Get Model Buttons info
|
||||
$res = array();
|
||||
|
||||
$lines_list = $this->dbinterface->get_db_SccpTableData('SccpExtension');
|
||||
$max_btn = ((!empty($get_settings['buttonscount']) ? $get_settings['buttonscount'] : 100));
|
||||
$last_btn = $max_btn;
|
||||
for ($it = $max_btn; $it >= 0; $it--) {
|
||||
if (!empty($get_settings['button' . $it . '_type'])) {
|
||||
$last_btn = $it;
|
||||
$btn_t = $get_settings['button' . $it . '_type'];
|
||||
if ($btn_t != 'empty') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($it = 0; $it <= $last_btn; $it++) {
|
||||
if (!empty($get_settings['button' . $it . '_type'])) {
|
||||
$btn_t = $get_settings['button' . $it . '_type'];
|
||||
|
||||
$btn_n = '';
|
||||
$btn_opt = '';
|
||||
if ($it == 0) {
|
||||
$btn_opt = 'default';
|
||||
}
|
||||
switch ($btn_t) {
|
||||
case 'feature':
|
||||
$btn_f = $get_settings['button' . $it . '_feature'];
|
||||
// $btn_opt = (empty($get_settings['button' . $it . '_fvalue'])) ? '' : $get_settings['button' . $it . '_fvalue'];
|
||||
$btn_n = (empty($get_settings['button' . $it . '_flabel'])) ? $def_feature[$btn_f]['name'] : $get_settings['button' . $it . '_flabel'];
|
||||
$btn_opt = $btn_f;
|
||||
if (!empty($def_feature[$btn_f]['value'])) {
|
||||
if (empty($get_settings['button' . $it . '_fvalue'])) {
|
||||
$btn_opt .= ',' . $def_feature[$btn_f]['value'];
|
||||
} else {
|
||||
$btn_opt .= ',' . $get_settings['button' . $it . '_fvalue'];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'monitor':
|
||||
$btn_t = 'speeddial';
|
||||
$btn_opt = (string) $get_settings['button' . $it . '_line'];
|
||||
$db_res = $this->dbinterface->get_db_SccpTableData('SccpExtension', array('name' => $btn_opt));
|
||||
$btn_n = $db_res[0]['label'];
|
||||
$btn_opt .= ',' . $btn_opt . $this->hint_context['default'];
|
||||
break;
|
||||
case 'speeddial':
|
||||
if (!empty($get_settings['button' . $it . '_input'])) {
|
||||
$btn_n = $get_settings['button' . $it . '_input'];
|
||||
}
|
||||
if (!empty($get_settings['button' . $it . '_phone'])) {
|
||||
$btn_opt = $get_settings['button' . $it . '_phone'];
|
||||
if (empty($btn_n)) {
|
||||
$btn_n = $btn_opt;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($get_settings['button' . $it . '_hint'])) {
|
||||
if ($get_settings['button' . $it . '_hint'] == "hint") {
|
||||
if (empty($btn_n)) {
|
||||
$btn_t = 'line';
|
||||
$btn_n = $get_settings['button' . $it . '_hline'] . '!silent';
|
||||
$btn_opt = '';
|
||||
} else {
|
||||
// $btn_opt .= ',' . $get_settings['button' . $it . '_hline'] . $this->hint_context['default'];
|
||||
$btn_opt .= ',' . $get_settings['button' . $it . '_hline'];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'adv.line':
|
||||
$btn_t = 'line';
|
||||
$btn_n = (string) $get_settings['button' . $it . '_line'];
|
||||
$btn_n .= '@' . (string) $get_settings['button' . $it . '_advline'];
|
||||
$btn_opt = (string) $get_settings['button' . $it . '_advopt'];
|
||||
|
||||
break;
|
||||
case 'line':
|
||||
case 'silent':
|
||||
if (isset($get_settings['button' . $it . '_line'])) {
|
||||
$btn_n = (string) $get_settings['button' . $it . '_line'];
|
||||
if ($it > 0) {
|
||||
if ($btn_t == 'silent') {
|
||||
$btn_n .= '!silent';
|
||||
$btn_t = 'line';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$btn_t = 'empty';
|
||||
$btn_n = '';
|
||||
}
|
||||
break;
|
||||
case 'empty':
|
||||
$btn_t = 'empty';
|
||||
break;
|
||||
}
|
||||
if (!empty($btn_t)) {
|
||||
$res[] = array('ref' => $ref_id, 'reftype' => $ref_type, 'instance' => (string) ($it + 1), 'type' => $btn_t, 'name' => $btn_n, 'options' => $btn_opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
function save_hw_phone($get_settings, $validateonly = false) {
|
||||
$hdr_prefix = 'sccp_hw_';
|
||||
|
@ -1055,105 +1198,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$this->dbinterface->sccp_save_db("sccpdevice", $save_settings, 'replace');
|
||||
|
||||
// Get Model Buttons info
|
||||
$lines_list = $this->dbinterface->get_db_SccpTableData('SccpExtension');
|
||||
$max_btn = ((!empty($get_settings['buttonscount']) ? $get_settings['buttonscount'] : 100));
|
||||
$last_btn = $max_btn;
|
||||
for ($it = $max_btn; $it >= 0; $it--) {
|
||||
if (!empty($get_settings['button' . $it . '_type'])) {
|
||||
$last_btn = $it;
|
||||
$btn_t = $get_settings['button' . $it . '_type'];
|
||||
if ($btn_t != 'empty') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($it = 0; $it <= $last_btn; $it++) {
|
||||
if (!empty($get_settings['button' . $it . '_type'])) {
|
||||
$btn_t = $get_settings['button' . $it . '_type'];
|
||||
|
||||
$btn_n = '';
|
||||
$btn_opt = '';
|
||||
if ($it == 0) {
|
||||
$btn_opt = 'default';
|
||||
}
|
||||
switch ($btn_t) {
|
||||
case 'feature':
|
||||
$btn_f = $get_settings['button' . $it . '_feature'];
|
||||
// $btn_opt = (empty($get_settings['button' . $it . '_fvalue'])) ? '' : $get_settings['button' . $it . '_fvalue'];
|
||||
$btn_n = (empty($get_settings['button' . $it . '_flabel'])) ? $def_feature[$btn_f]['name'] : $get_settings['button' . $it . '_flabel'];
|
||||
$btn_opt = $btn_f;
|
||||
if (!empty($def_feature[$btn_f]['value'])) {
|
||||
if (empty($get_settings['button' . $it . '_fvalue'])) {
|
||||
$btn_opt .= ',' . $def_feature[$btn_f]['value'];
|
||||
} else {
|
||||
$btn_opt .= ',' . $get_settings['button' . $it . '_fvalue'];
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'monitor':
|
||||
$btn_t = 'speeddial';
|
||||
$btn_opt = (string) $get_settings['button' . $it . '_line'];
|
||||
$db_res = $this->dbinterface->get_db_SccpTableData('SccpExtension', array('name' => $btn_opt));
|
||||
$btn_n = $db_res[0]['label'];
|
||||
$btn_opt .= ',' . $btn_opt . $this->hint_context['default'];
|
||||
break;
|
||||
case 'speeddial':
|
||||
if (!empty($get_settings['button' . $it . '_input'])) {
|
||||
$btn_n = $get_settings['button' . $it . '_input'];
|
||||
}
|
||||
if (!empty($get_settings['button' . $it . '_phone'])) {
|
||||
$btn_opt = $get_settings['button' . $it . '_phone'];
|
||||
if (empty($btn_n)) {
|
||||
$btn_n = $btn_opt;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($get_settings['button' . $it . '_hint'])) {
|
||||
if ($get_settings['button' . $it . '_hint'] == "hint") {
|
||||
if (empty($btn_n)) {
|
||||
$btn_t = 'line';
|
||||
$btn_n = $get_settings['button' . $it . '_hline'] . '!silent';
|
||||
$btn_opt = '';
|
||||
} else {
|
||||
// $btn_opt .= ',' . $get_settings['button' . $it . '_hline'] . $this->hint_context['default'];
|
||||
$btn_opt .= ',' . $get_settings['button' . $it . '_hline'];
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'adv.line':
|
||||
$btn_t = 'line';
|
||||
$btn_n = (string) $get_settings['button' . $it . '_line'];
|
||||
$btn_n .= '@' . (string) $get_settings['button' . $it . '_advline'];
|
||||
$btn_opt = (string) $get_settings['button' . $it . '_advopt'];
|
||||
|
||||
break;
|
||||
case 'line':
|
||||
case 'silent':
|
||||
if (isset($get_settings['button' . $it . '_line'])) {
|
||||
$btn_n = (string) $get_settings['button' . $it . '_line'];
|
||||
if ($it > 0) {
|
||||
if ($btn_t == 'silent') {
|
||||
$btn_n .= '!silent';
|
||||
$btn_t = 'line';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$btn_t = 'empty';
|
||||
$btn_n = '';
|
||||
}
|
||||
break;
|
||||
case 'empty':
|
||||
$btn_t = 'empty';
|
||||
break;
|
||||
}
|
||||
if (!empty($btn_t)) {
|
||||
$save_buttons[] = array('device' => $name_dev, 'instance' => (string) ($it + 1), 'type' => $btn_t, 'name' => $btn_n, 'options' => $btn_opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$save_buttons = $this-> get_buttons_phone($get_settings,$name_dev, 'sccpdevice');
|
||||
|
||||
// Sace Buttons config
|
||||
$this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons, $update_hw, '', $name_dev);
|
||||
|
||||
|
@ -1259,6 +1305,111 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
return $save_settings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function save_rouming_users($get_settings, $validateonly = false) {
|
||||
$hdr_prefix = 'sccp_ru_';
|
||||
$hdr_arprefix = 'sccp_ru-ar_';
|
||||
|
||||
$save_buttons = array();
|
||||
$save_settings = array();
|
||||
/*
|
||||
$def_feature = array('parkinglot' => array('name' => 'P.slot', 'value' => 'default'),
|
||||
'devstate' => array('name' => 'Coffee', 'value' => 'coffee'),
|
||||
'monitor' => array('name' => 'Record Calls', 'value' => '')
|
||||
);
|
||||
*
|
||||
*/
|
||||
$name_dev = '';
|
||||
$db_field = $this->dbinterface->get_db_SccpTableData("get_colums_sccpusers");
|
||||
// $hw_id = (empty($get_settings['sccp_deviceid'])) ? 'new' : $get_settings['sccp_deviceid'];
|
||||
// $update_hw = ($hw_id == 'new') ? 'update' : 'clear';
|
||||
$hw_prefix = 'SEP';
|
||||
$name_dev = $get_settings[$hdr_prefix . 'id'];
|
||||
|
||||
foreach ($db_field as $data) {
|
||||
$key = (string) $data['Field'];
|
||||
$value = "";
|
||||
switch ($key) {
|
||||
case 'name':
|
||||
$value = $name_dev;
|
||||
break;
|
||||
case '_hwlang':
|
||||
if (empty($get_settings[$hdr_prefix . 'netlang']) || empty($get_settings[$hdr_prefix . 'devlang'])) {
|
||||
$value = 'null';
|
||||
} else {
|
||||
$value = $get_settings[$hdr_prefix . 'netlang'] . ':' . $get_settings[$hdr_prefix . 'devlang'];
|
||||
}
|
||||
break;
|
||||
default :
|
||||
if (!empty($get_settings[$hdr_prefix . $key])) {
|
||||
$value = $get_settings[$hdr_prefix . $key];
|
||||
}
|
||||
if (!empty($get_settings[$hdr_arprefix . $key])) {
|
||||
$arr_data = '';
|
||||
$arr_clear = FALSE;
|
||||
foreach ($get_settings[$hdr_arprefix . $key] as $vkey => $vval) {
|
||||
$tmp_data = '';
|
||||
foreach ($vval as $vkey => $vval) {
|
||||
switch ($vkey) {
|
||||
case 'inherit':
|
||||
if ($vval == 'on') {
|
||||
$arr_clear = TRUE;
|
||||
// Злобный ХАК
|
||||
if ($key == 'permit') {
|
||||
$save_settings['deny'] = 'NONE';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'internal':
|
||||
if ($vval == 'on') {
|
||||
$tmp_data .= 'internal;';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$tmp_data .= $vval . '/';
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (strlen($tmp_data) > 2) {
|
||||
while (substr($tmp_data, -1) == '/') {
|
||||
$tmp_data = substr($tmp_data, 0, -1);
|
||||
}
|
||||
$arr_data .= $tmp_data . ';';
|
||||
}
|
||||
}
|
||||
while (substr($arr_data, -1) == ';') {
|
||||
$arr_data = substr($arr_data, 0, -1);
|
||||
}
|
||||
if ($arr_clear) {
|
||||
$value = 'NONE';
|
||||
} else {
|
||||
$value = $arr_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($value)) {
|
||||
$save_settings[$key] = $value;
|
||||
}
|
||||
}
|
||||
// Save / Updade Base
|
||||
// return $save_settings;
|
||||
// $update_hw = ($hw_id == 'new') ? 'update' : 'clear';
|
||||
|
||||
$this->dbinterface->sccp_save_db("sccpusers", $save_settings, 'replace', 'name');
|
||||
|
||||
$save_buttons = $this-> get_buttons_phone($get_settings,$name_dev, 'sccpline');
|
||||
// Sace Buttons config
|
||||
$this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons,'clear', '', $name_dev);
|
||||
return $save_buttons;
|
||||
|
||||
return $save_settings;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function getSccpSettingFromDB() {
|
||||
$raw_data = $this->dbinterface->get_db_SccpSetting();
|
||||
foreach ($raw_data as $var) {
|
||||
|
@ -1767,11 +1918,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$backup_files = array($amp_conf['ASTETCDIR'] . '/sccp', $amp_conf['ASTETCDIR'] . '/extensions', $amp_conf['ASTETCDIR'] . '/extconfig',
|
||||
$amp_conf['ASTETCDIR'] . '/res_config_mysql', $amp_conf['ASTETCDIR'] . '/res_mysql');
|
||||
$backup_ext = array('.conf', '_additional.conf', '_custom.conf');
|
||||
$backup_info = $this->sccppath["tftp_path"].'/sccp_dir.info';
|
||||
$backup_info = $this->sccppath["tftp_path"] . '/sccp_dir.info';
|
||||
|
||||
$result = $this->dbinterface->dump_sccp_tables($this->sccppath["tftp_path"], $amp_conf['AMPDBNAME'], $amp_conf['AMPDBUSER'], $amp_conf['AMPDBPASS']);
|
||||
$dir_info['asterisk'] = $this->find_all_files($amp_conf['ASTETCDIR']);
|
||||
$dir_info['tftpdir'] = $this-> find_all_files($this->sccppath["tftp_path"]);
|
||||
$dir_info['asterisk'] = $this->find_all_files($amp_conf['ASTETCDIR']);
|
||||
$dir_info['tftpdir'] = $this->find_all_files($this->sccppath["tftp_path"]);
|
||||
$dir_info['driver'] = $this->FreePBX->Core->getAllDriversInfo();
|
||||
$dir_info['core'] = $this->srvinterface->getSCCPVersion();
|
||||
$dir_info['realtime'] = $this->srvinterface->sccp_realtime_status();
|
||||
|
@ -1780,23 +1931,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
$dir_info['dbinterface'] = $this->dbinterface->info();
|
||||
$dir_info['XML'] = $this->xmlinterface->info();
|
||||
|
||||
|
||||
|
||||
$fh = fopen($backup_info, 'w');
|
||||
$dir_str = "Begin JSON data ------------\r\n";
|
||||
fwrite($fh,$dir_str);
|
||||
fwrite($fh,json_encode($dir_info));
|
||||
fwrite($fh, $dir_str);
|
||||
fwrite($fh, json_encode($dir_info));
|
||||
$dir_str = "\r\n\r\nBegin TEXT data ------------\r\n";
|
||||
foreach ($dir_info['asterisk'] as $data) {
|
||||
$dir_str .= $data."\r\n";
|
||||
$dir_str .= $data . "\r\n";
|
||||
}
|
||||
foreach ($dir_info['tftpdir'] as $data) {
|
||||
$dir_str .= $data."\r\n";
|
||||
$dir_str .= $data . "\r\n";
|
||||
}
|
||||
fputs($fh, $dir_str);
|
||||
fclose($fh);
|
||||
|
||||
|
||||
$zip = new \ZipArchive();
|
||||
$filename = $result .".". gethostname().".zip";
|
||||
$filename = $result . "." . gethostname() . ".zip";
|
||||
if ($zip->open($filename, \ZIPARCHIVE::CREATE)) {
|
||||
$zip->addFile($result);
|
||||
$zip->addFile($backup_info);
|
||||
|
@ -1937,34 +2088,51 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
return $raw_settings;
|
||||
}
|
||||
|
||||
function get_hint_info($get = "all", $format_list = "all", $filter = array()) {
|
||||
function get_hint_info($sort = true, $filter = array()) {
|
||||
$res = array();
|
||||
$default_hint = '@ext-local';
|
||||
// get all hints [101@ext-local] => 101@ext-local
|
||||
$tmp_data = $this->srvinterface->sccp_list_all_hints();
|
||||
foreach ($tmp_data as $value) {
|
||||
/* !TODO!: Add Hint Filtred List */
|
||||
$res[$value] = array('hint' => $value, 'name' => before('@', $value), 'label' => $value);
|
||||
|
||||
// get all extension
|
||||
$res = $this->aminterface->core_list_all_exten('hint', $filter);
|
||||
if (empty($res)) {
|
||||
// Old Req get all hints
|
||||
$tmp_data = $this->srvinterface->sccp_list_all_hints();
|
||||
foreach ($tmp_data as $value) {
|
||||
$res[$value] = array('key' => $value, 'exten' => before('@', $value), 'label' => $value);
|
||||
}
|
||||
}
|
||||
|
||||
// Update info from sccp_db
|
||||
$tmp_data = $this->dbinterface->get_db_SccpTableData('SccpExtension');
|
||||
foreach ($tmp_data as $value) {
|
||||
$name_l = $value['name'];
|
||||
if (!empty($res[$name_l . $default_hint])) {
|
||||
$res[$name_l . $default_hint]['name'] = $name_l;
|
||||
$res[$name_l . $default_hint]['exten'] = $name_l;
|
||||
$res[$name_l . $default_hint]['label'] = $value['label'];
|
||||
} else { // if not exist in system hints ..... ???????
|
||||
$res[$name_l . $default_hint] = array('hint' => $name_l . $default_hint, 'name' => $name_l, 'label' => $value['label']);
|
||||
$res[$name_l . $default_hint] = array('key' => $name_l . $default_hint, 'exten' => $name_l, 'label' => $value['label']);
|
||||
}
|
||||
}
|
||||
if (!$sort) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
foreach ($res as $key => $value) {
|
||||
$data_sort[$value['exten']] = $key;
|
||||
}
|
||||
ksort($data_sort);
|
||||
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;
|
||||
return $res_sort;
|
||||
}
|
||||
|
||||
function getIP_information2($type = '') {
|
||||
$interfaces= array();
|
||||
$interfaces = array();
|
||||
switch ($type) {
|
||||
case 'ip4':
|
||||
exec("/sbin/ip -4 -o addr", $result, $ret);
|
||||
|
@ -1983,18 +2151,16 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
continue;
|
||||
if ($vals[2] != "inet" && $vals[2] != "inet6")
|
||||
continue;
|
||||
if (preg_match("/(.+?)(?:@.+)?:$/", $vals[1], $res)) {
|
||||
if (preg_match("/(.+?)(?:@.+)?:$/", $vals[1], $res)) {
|
||||
continue;
|
||||
}
|
||||
$ret = preg_match("/(\d*+.\d*+.\d*+.\d*+)[\/(\d*+)]*/", $vals[3], $ip);
|
||||
|
||||
$interfaces[$vals[1].':'.$vals[2]] = Array('name' => $vals[1],'type' => $vals[2], 'ip' => ((empty($ip[1]) ? '' : $ip[1])));
|
||||
$ret = preg_match("/(\d*+.\d*+.\d*+.\d*+)[\/(\d*+)]*/", $vals[3], $ip);
|
||||
|
||||
$interfaces[$vals[1] . ':' . $vals[2]] = Array('name' => $vals[1], 'type' => $vals[2], 'ip' => ((empty($ip[1]) ? '' : $ip[1])));
|
||||
}
|
||||
return $interfaces;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getIP_information_old() {
|
||||
$interfaces['auto'] = array('0.0.0.0', 'All', '0');
|
||||
|
||||
|
@ -2122,5 +2288,4 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
|||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
792
Sccp_manager.inc/aminterface.class.php
Normal file
792
Sccp_manager.inc/aminterface.class.php
Normal file
|
@ -0,0 +1,792 @@
|
|||
<?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;
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface;
|
||||
|
||||
abstract class Message {
|
||||
|
||||
const EOL = "\r\n";
|
||||
const EOM = "\r\n\r\n";
|
||||
|
||||
protected $lines;
|
||||
protected $variables;
|
||||
protected $keys;
|
||||
protected $createdDate;
|
||||
private $_responseHandler;
|
||||
|
||||
public function getResponseHandler() {
|
||||
if (strlen($this->_responseHandler) > 0) {
|
||||
//throw new PAMIException('Hier:' . $this->_responseHandler);
|
||||
return (string) $this->_responseHandler;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public function setResponseHandler($responseHandler) {
|
||||
if (0 == strlen($responseHandler)) {
|
||||
return ;
|
||||
}
|
||||
$className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\Message\\Response\\' . $responseHandler . 'Response';
|
||||
if (class_exists($className, true)) {
|
||||
$this->_responseHandler = $responseHandler;
|
||||
} else {
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
public function setVariable($key, $value) {
|
||||
$key = strtolower($key);
|
||||
$this->variables[$key] = $value;
|
||||
}
|
||||
|
||||
public function getVariable($key) {
|
||||
$key = strtolower($key);
|
||||
if (!isset($this->variables[$key])) {
|
||||
return null;
|
||||
}
|
||||
return $this->variables[$key];
|
||||
}
|
||||
|
||||
protected function setKey($key, $value) {
|
||||
$key = strtolower((string) $key);
|
||||
$this->keys[$key] = (string) $value;
|
||||
}
|
||||
|
||||
public function getKey($key) {
|
||||
$key = strtolower($key);
|
||||
if (!isset($this->keys[$key])) {
|
||||
return null;
|
||||
}
|
||||
//return (string)$this->keys[$key];
|
||||
return $this->keys[$key];
|
||||
}
|
||||
|
||||
public function getVariables() {
|
||||
return $this->variables;
|
||||
}
|
||||
|
||||
public function getActionID() {
|
||||
return $this->getKey('ActionID');
|
||||
}
|
||||
|
||||
public function getKeys() {
|
||||
return $this->keys;
|
||||
}
|
||||
|
||||
private function serializeVariable($key, $value) {
|
||||
return "Variable: $key=$value";
|
||||
}
|
||||
|
||||
protected function finishMessage($message) {
|
||||
return $message . self::EOL . self::EOL;
|
||||
}
|
||||
|
||||
public function serialize() {
|
||||
$result = array();
|
||||
foreach ($this->getKeys() as $k => $v) {
|
||||
$result[] = $k . ': ' . $v;
|
||||
}
|
||||
foreach ($this->getVariables() as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
foreach ($v as $singleValue) {
|
||||
$result[] = $this->serializeVariable($k, $singleValue);
|
||||
}
|
||||
} else {
|
||||
$result[] = $this->serializeVariable($k, $v);
|
||||
}
|
||||
}
|
||||
$mStr = $this->finishMessage(implode(self::EOL, $result));
|
||||
return $mStr;
|
||||
}
|
||||
|
||||
public function setActionID($actionID) {
|
||||
if (0 == strlen($actionID)) {
|
||||
// throw new PAMIException('ActionID cannot be empty.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen($actionID) > 69) {
|
||||
// throw new PAMIException('ActionID can be at most 69 characters long.');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setKey('ActionID', $actionID);
|
||||
}
|
||||
|
||||
public function __construct() {
|
||||
$this->lines = array();
|
||||
$this->variables = array();
|
||||
$this->keys = array();
|
||||
$this->createdDate = time();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager\aminterface\Message;
|
||||
|
||||
abstract class Response {
|
||||
|
||||
protected $_events;
|
||||
protected $_completed;
|
||||
protected $keys;
|
||||
|
||||
public function isSuccess() {
|
||||
return stristr($this->getKey('Response'), 'Error') === false;
|
||||
}
|
||||
|
||||
public function isComplete() {
|
||||
return $this->_completed;
|
||||
}
|
||||
|
||||
public function isList() {
|
||||
return
|
||||
stristr($this->getKey('EventList'), 'start') !== false || stristr($this->getMessage(), 'follow') !== false
|
||||
;
|
||||
}
|
||||
|
||||
public function setActionId($actionId) {
|
||||
$this->setKey('ActionId', $actionId);
|
||||
}
|
||||
|
||||
public function getMessage() {
|
||||
return $this->getKey('Message');
|
||||
}
|
||||
|
||||
public function __construct($rawContent) {
|
||||
parent::__construct($rawContent);
|
||||
|
||||
$this->_events = array();
|
||||
$this->_eventsCount = 0;
|
||||
$this->_completed = !$this->isList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//namespace FreePBX\modules\Sccp_manager\aminterface\Message;
|
||||
|
||||
class LoginAction extends \FreePBX\modules\Sccp_manager\aminterface\Message {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $user AMI username.
|
||||
* @param string $password AMI password.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($user, $password) {
|
||||
parent::__construct('Login');
|
||||
$this->setKey('Action', $what);
|
||||
$this->setKey('ActionID', microtime(true));
|
||||
$this->setKey('Username', $user);
|
||||
$this->setKey('Secret', $password);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
class aminterface {
|
||||
|
||||
var $_socket;
|
||||
var $_error;
|
||||
var $_config;
|
||||
// var $ProcessingMessage;
|
||||
private $_lastActionClass;
|
||||
private $_lastActionId;
|
||||
private $_lastRequestedResponseHandler;
|
||||
private $_ProcessingMessage;
|
||||
private $_responseFactory;
|
||||
|
||||
public function __construct($parent_class = null) {
|
||||
global $amp_conf;
|
||||
$this->paren_class = $parent_class;
|
||||
$this->_socket = false;
|
||||
$this->_error = array();
|
||||
$this->_config = array('host' => 'localhost', 'user' => '', 'pass' => '', 'port' => '5038', 'tsoket' => 'tcp://', 'timeout' => 30, 'enabled' => false);
|
||||
$fld_conf = array('user' => 'AMPMGRUSER', 'pass' => 'AMPMGRPASS');
|
||||
if (isset($amp_conf['AMPMGRUSER'])) {
|
||||
foreach ($fld_conf as $key => $value) {
|
||||
if (isset($amp_conf[$value])) {
|
||||
$this->_config[$key] = $amp_conf[$value];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function info() {
|
||||
$Ver = '13.0.4';
|
||||
if ($this->_config['enabled']) {
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'AMI data ver: ' . $Ver);
|
||||
} else {
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'Disabled AMI ver: ' . $Ver);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a tcp connection to ami.
|
||||
*
|
||||
*/
|
||||
public function open() {
|
||||
$cString = $this->_config['tsoket'] . $this->_config['host'] . ':' . $this->_config['port'];
|
||||
$this->_context = stream_context_create();
|
||||
$errno = 0;
|
||||
$errstr = '';
|
||||
$this->_socket = @stream_socket_client(
|
||||
$cString, $errno, $errstr,
|
||||
$this->_config['timeout'], STREAM_CLIENT_CONNECT, $this->_context
|
||||
);
|
||||
if ($this->_socket === false) {
|
||||
$this->_errorException('Error connecting to ami: ' . $errstr . $cString);
|
||||
return false;
|
||||
}
|
||||
// FreePBX\modules\Sccp_manager\aminterface\Message\LoginAction::
|
||||
$msg = new aminerface\Message\LoginAction($this->_config['user'], $this->_config['pass']);
|
||||
|
||||
$response = $this->send($msg);
|
||||
return $response;
|
||||
/*
|
||||
$params = array('Action' => 'Login', 'UserName' => $this->_config['user'], 'Secret' => $this->_config['pass'], 'Events' => 'on');
|
||||
$id = @stream_get_line($this->_socket, 1024, aminterface\Message::EOL);
|
||||
|
||||
if (strstr($id, 'Asterisk') === false) {
|
||||
$this->_errorException('Unknown peer. Is this an ami?: ' . $id);
|
||||
return false;
|
||||
}
|
||||
$response = $this->send($params);
|
||||
if (!$response->isSuccess()) {
|
||||
$this->_errorException('Could not connect: ' . $response->getMessage());
|
||||
return false;
|
||||
}
|
||||
@stream_set_blocking($this->_socket, 0);
|
||||
$this->_ProcessingMessage = '';
|
||||
//register_tick_function(array($this, 'process'));
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the connection to ami.
|
||||
*/
|
||||
public function close() {
|
||||
@stream_socket_shutdown($this->_socket, STREAM_SHUT_RDWR);
|
||||
}
|
||||
|
||||
public function send($message) {
|
||||
$messageToSend = $message->serialize();
|
||||
/* foreach ($params as $key => $value) {
|
||||
$messageToSend .= $key . ': ' . $value . aminterface\Message::EOL;
|
||||
}
|
||||
$messageToSend .= aminterface\Message::EOL;
|
||||
*
|
||||
*/
|
||||
$length = strlen($messageToSend);
|
||||
|
||||
$this->_lastActionId = $message->getActionId();
|
||||
$this->_lastRequestedResponseHandler = $message->getResponseHandler();
|
||||
$this->_lastActionClass = $message;
|
||||
|
||||
if (@fwrite($this->_socket, $messageToSend) < $length) {
|
||||
$this->_errorException('Could not send message');
|
||||
return false;
|
||||
}
|
||||
while (1) {
|
||||
stream_set_timeout($this->_socket, 1);
|
||||
// stream_set_timeout($this->_socket, (isset($this->socket_param['timeout']) ? $this->socket_param['timeout'] : 1));
|
||||
$this->process();
|
||||
$info = stream_get_meta_data($this->_socket);
|
||||
if ($info['timed_out'] == false) {
|
||||
$response = $this->getRelated($message);
|
||||
if ($response != false) {
|
||||
$this->_lastActionId = false;
|
||||
return $response;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->_errorException("Read waittime: " . ($this->socket_param['timeout']) . " exceeded (timeout).\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getRelated($message) {
|
||||
$ret = false;
|
||||
$id = 0;
|
||||
// $id = $message->getActionID('ActionID');
|
||||
if (isset($this->_incomingQueue[$id])) {
|
||||
$response = $this->_incomingQueue[$id];
|
||||
if ($response->isComplete()) {
|
||||
unset($this->_incomingQueue[$id]);
|
||||
$ret = $response;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
protected function getMessages() {
|
||||
$msgs = array();
|
||||
// Read something.
|
||||
$read = @fread($this->_socket, 65535);
|
||||
if ($read === false || @feof($this->_socket)) {
|
||||
$this->_errorException('Error reading');
|
||||
}
|
||||
$this->_ProcessingMessage .= $read;
|
||||
// If we have a complete message, then return it. Save the rest for
|
||||
// later.
|
||||
return $msgs;
|
||||
while (($marker = strpos($this->_ProcessingMessage, Message::EOM))) {
|
||||
$msg = substr($this->_ProcessingMessage, 0, $marker);
|
||||
$this->_ProcessingMessage = substr(
|
||||
$this->_ProcessingMessage, $marker + strlen(Message::EOM)
|
||||
);
|
||||
$msgs[] = $msg;
|
||||
}
|
||||
return $msgs;
|
||||
}
|
||||
|
||||
public function process() {
|
||||
$msgs = $this->getMessages();
|
||||
foreach ($msgs as $aMsg) {
|
||||
$resPos = strpos($aMsg, 'Response:');
|
||||
$evePos = strpos($aMsg, 'Event:');
|
||||
if (($resPos !== false) && (($resPos < $evePos) || $evePos === false)) {
|
||||
$response = $this->_msgToResponse($aMsg);
|
||||
$this->_incomingQueue[$this->_lastActionId] = $response;
|
||||
} else if ($evePos !== false) {
|
||||
/* $event = $this->_messageToEvent($aMsg);
|
||||
$response = $this->findResponse($event);
|
||||
if ($response === false || $response->isComplete()) {
|
||||
$this->dispatch($event);
|
||||
} else {
|
||||
$response->addEvent($event);
|
||||
}
|
||||
*
|
||||
*/
|
||||
} else {
|
||||
// broken ami.. sending a response with events without
|
||||
// Event and ActionId
|
||||
$bMsg = 'Event: ResponseEvent' . "\r\n";
|
||||
$bMsg .= 'ActionId: ' . $this->_lastActionId . "\r\n" . $aMsg;
|
||||
$event = $this->_messageToEvent($bMsg);
|
||||
$response = $this->findResponse($event);
|
||||
$response->addEvent($event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function _msgToResponse($msg) {
|
||||
$response = $this->_msgFromRaw($msg, $this->_lastActionClass, $this->_lastRequestedResponseHandler);
|
||||
/* $actionId = $response->getActionId();
|
||||
if ($actionId === null) {
|
||||
$actionId = $this->_lastActionId;
|
||||
$response->setActionId($this->_lastActionId);
|
||||
}
|
||||
*
|
||||
*/
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function _msgFromRaw($message, $requestingaction = false, $responseHandler = false) {
|
||||
|
||||
$_className = false;
|
||||
if ($responseHandler != false) {
|
||||
$_className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\Response';
|
||||
// $_className = '\\FreePBX\\modules\\Sccp_manager\\aminterface\\' . $responseHandler . 'Response';
|
||||
} else if ($requestingaction != false) {
|
||||
switch ($requestingaction) {
|
||||
case 'login':
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// $_className = '\\FreePBX\\modules\\Sccp_manager\\Response\\' . substr(get_class($requestingaction), 20, -6) . 'Response';
|
||||
$_className = '\\FreePBX\\modules\\Sccp_manager\\Response';
|
||||
}
|
||||
if ($_className) {
|
||||
if (class_exists($_className, true)) {
|
||||
$responseclass = $_className;
|
||||
} else if ($responseHandler != false) {
|
||||
$this->_errorException('Response Class ' . $_className . ' requested via responseHandler, could not be found');
|
||||
}
|
||||
}
|
||||
// return new $responseclass($message);
|
||||
}
|
||||
|
||||
protected function _errorException($msg) {
|
||||
$this->_error[] = $msg;
|
||||
}
|
||||
|
||||
/*
|
||||
* Replace or dublicate to AMI interface
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
function core_list_all_exten($keyfld = '', $filter = array()) {
|
||||
$result = array();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
public function sccp_list_extnint() {
|
||||
$hint_key = array();
|
||||
$hint_all = $this->sccp_list_all_hints();
|
||||
foreach ($hint_all as $value) {
|
||||
$res = $this->loc_after('@', $value);
|
||||
// array_search($res, $hint_key)) != NULL)
|
||||
if (!isset($hint_key[$res])) {
|
||||
$hint_key[$res] = '@' . $res;
|
||||
}
|
||||
}
|
||||
return $hint_key;
|
||||
}
|
||||
|
||||
private function astman_retrieveJSFromMetaData($segment = "") {
|
||||
global $astman;
|
||||
$params = array();
|
||||
if ($segment != "") {
|
||||
$params["Segment"] = $segment;
|
||||
}
|
||||
$response = $astman->send_request('SCCPConfigMetaData', $params);
|
||||
if ($response["Response"] == "Success") {
|
||||
//outn(_("JSON-content:").$response["JSON"]);
|
||||
$decode = json_decode($response["JSON"], true);
|
||||
return $decode;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getеtestChanSCC() {
|
||||
global $astman;
|
||||
// $action = Array('SCCPShowGlobals',);
|
||||
$params = array();
|
||||
$action = 'SCCPShowSoftkeySets';
|
||||
// $params = array('Segment' => 'device', 'ResultFormat'=>'command' );
|
||||
// $params = array('Segment' => 'device');
|
||||
// $params = array();
|
||||
$metadata = $astman->send_request($action, $params);
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
|
||||
function core_list_all_exten($keyfld = '', $filter = array()) {
|
||||
$result = array();
|
||||
$fld_data = array('exten', 'context', 'statustext', 'status');
|
||||
$row_data = $this->astman_GetRaw('ExtensionStateList');
|
||||
if (empty($row_data) || empty($row_data['eventlist'])) {
|
||||
return $result;
|
||||
}
|
||||
if ($row_data['eventlist'] == 'Complete') {
|
||||
foreach ($row_data['list'] as $value) {
|
||||
$exten = $value['exten'];
|
||||
$context = $value['context'];
|
||||
$exclude = empty($exten);
|
||||
switch ($keyfld) {
|
||||
case 'exten':
|
||||
$store_key = $exten;
|
||||
break;
|
||||
case 'hint':
|
||||
default:
|
||||
$store_key = $exten . '@' . $context;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($filter)) {
|
||||
foreach ($filter as $fkey => $fvalue) {
|
||||
if (!empty($value[$fkey])) {
|
||||
if (strpos(';' . $fvalue . ';', ';' . $value[$fkey] . ';') !== false) {
|
||||
$exclude = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$exclude) {
|
||||
foreach ($fld_data as $key) {
|
||||
$result[$store_key][$key] = (empty($value[$key]) ? '' : $value[$key] );
|
||||
}
|
||||
$result[$store_key]['key'] = $exten . '@' . $context;
|
||||
$result[$store_key]['label'] = $exten . '@' . $context;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function astLogin($host = "", $username = "", $password = "") {
|
||||
if ($this->Sok_param['enabled'] != true) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (empty($host) || empty($username) || empty($password)) {
|
||||
if (empty($this->Sok_param['host']) || empty($this->Sok_param['user']) || empty($this->Sok_param['pass'])) {
|
||||
return FALSE;
|
||||
}
|
||||
$host = (empty($host) ? $this->Sok_param['host'] : $host);
|
||||
$username = (empty($username) ? $this->Sok_param['user'] : $username);
|
||||
$password = (empty($password) ? $this->Sok_param['pass'] : $password);
|
||||
}
|
||||
$this->socket = @fsockopen($host, "5038", $errno, $errstr, 1);
|
||||
|
||||
if (!$this->socket) {
|
||||
$this->error = "Could not connect - $errstr ($errno)";
|
||||
return FALSE;
|
||||
} else {
|
||||
stream_set_timeout($this->socket, 1);
|
||||
|
||||
// $wrets = $this->astQuery("Action: Login\r\nUserName: $username\r\nSecret: $password\r\nEvents: off\r\n\r\n");
|
||||
$wrets = $this->astQuery("Action: Login\r\nUserName: $username\r\nSecret: $password\r\nEvents: on\r\n\r\n");
|
||||
|
||||
if (strpos($wrets['raw'], "Message: Authentication accepted") != FALSE) {
|
||||
return TRUE;
|
||||
} else {
|
||||
$this->error = "Could not login - Authentication failed ";
|
||||
fclose($this->socket);
|
||||
$this->socket = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function astLogout() {
|
||||
if ($this->socket) {
|
||||
fputs($this->socket, "Action: Logoff\r\n\r\n");
|
||||
while (!feof($this->socket)) {
|
||||
$wrets .= fread($this->socket, 8192);
|
||||
}
|
||||
fclose($this->socket);
|
||||
$this->socket = "FALSE";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private function astQuery($query, $rawdata = false) {
|
||||
$wrets = "";
|
||||
// return $this->socket;
|
||||
if ($this->socket === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
$time_Query = microtime(true);
|
||||
$parameters = array();
|
||||
$parameters['raw'] = '';
|
||||
$data_store = 'data';
|
||||
$parameters[$data_store] = '';
|
||||
fputs($this->socket, $query);
|
||||
$parameters['raw_q'] = $query;
|
||||
$stop_data = false;
|
||||
$row_list = false;
|
||||
$row_list_arr = Array();
|
||||
$stop_data = false;
|
||||
$row_list = !$rawdata;
|
||||
do {
|
||||
$line = fgets($this->socket, 4096);
|
||||
$parameters['raw'] .= $line;
|
||||
if (!$rawdata) {
|
||||
// if (true) {
|
||||
$a = strpos($line, ':');
|
||||
if ($a) {
|
||||
$key = trim(strtolower(substr($line, 0, $a)));
|
||||
switch ($key) {
|
||||
case 'eventlist':
|
||||
if (strpos($line, 'start') !== false) {
|
||||
$row_list = true;
|
||||
} else {
|
||||
$row_list = false;
|
||||
}
|
||||
case 'response':
|
||||
case 'message':
|
||||
$parameters[$key] = trim(substr($line, $a + 2));
|
||||
if (!empty($parameters['response']) && !empty($parameters['message'])) {
|
||||
if ($parameters['response'] == 'Error') {
|
||||
$stop_data = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'json':
|
||||
$parameters[$key] = substr($line, $a + 2);
|
||||
$data_store = $key;
|
||||
break;
|
||||
default:
|
||||
if ($row_list) {
|
||||
$row_list_arr[$key] = trim(str_replace("\r\n", "", substr($line, $a + 2)));
|
||||
;
|
||||
}
|
||||
$parameters[$data_store] .= $line;
|
||||
break;
|
||||
}
|
||||
// store parameter in $parameters
|
||||
} else {
|
||||
if (!isset($parameters[$data_store])) {
|
||||
$parameters[$data_store] = '';
|
||||
}
|
||||
$parameters[$data_store] .= $line;
|
||||
}
|
||||
}
|
||||
if ($line == "\r\n") {
|
||||
if ($row_list == false) {
|
||||
$stop_data = true;
|
||||
} else {
|
||||
$parameters['list'][] = $row_list_arr;
|
||||
$row_list_arr = array();
|
||||
}
|
||||
}
|
||||
$info = stream_get_meta_data($this->socket);
|
||||
} while ($stop_data == false && $info['timed_out'] == false);
|
||||
|
||||
$parameters['time_Query'] = microtime(true) - $time_Query;
|
||||
$this->Sok_param['total'] = $this->Sok_param['total'] + $parameters['time_Query'];
|
||||
// $this->astLogout();
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
function GetError() {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
function astman_GetRaw($action = "", $parameters = array()) {
|
||||
$option = "";
|
||||
$result = array();
|
||||
|
||||
if ($this->_socket === FALSE) {
|
||||
if (!$this->astLogin()) {
|
||||
$result["Response"] = "Faild";
|
||||
$result["Error"] = $this->error;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$query = "Action: $action\r\n";
|
||||
|
||||
foreach ($parameters as $var => $val) {
|
||||
if (is_array($val)) {
|
||||
foreach ($val as $k => $v) {
|
||||
$query .= "$var: $k=$v\r\n";
|
||||
}
|
||||
} else {
|
||||
$query .= "$var: $val\r\n";
|
||||
}
|
||||
}
|
||||
$result = $this->astQuery($query . "\r\n", true);
|
||||
$result = $this->astQuery($query . "\r\n", false);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
private function astman_retrieveMeta($action = "", $parameters=array(), $rawdata = false) {
|
||||
// $parameters=array()
|
||||
global $amp_conf;
|
||||
|
||||
if (empty($action)) {
|
||||
$action = 'SCCPConfigMetaData';
|
||||
}
|
||||
$query = "Action: $action\r\n";
|
||||
|
||||
foreach($parameters as $var=>$val) {
|
||||
if (is_array($val)) {
|
||||
foreach($val as $k => $v) {
|
||||
$query .= "$var: $k=$v\r\n";
|
||||
}
|
||||
} else {
|
||||
$query .= "$var: $val\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->astQuery($query."\r\n",$rawdata);
|
||||
|
||||
if ($result["Response"] == "Success") {
|
||||
if ($rawdata) {
|
||||
return $result;
|
||||
} else {
|
||||
if (!empty($result["JSON"])) {
|
||||
$decode = json_decode($response["JSON"], true);
|
||||
return $decode;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $result;
|
||||
return array();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
function t_get_meta_data() {
|
||||
global $amp_conf;
|
||||
$fp = fsockopen("127.0.0.1", "5038", $errno, $errstr, 10);
|
||||
|
||||
if (!$fp) {
|
||||
echo "$errstr ($errno)<br />\n";
|
||||
} else {
|
||||
fputs($fp, "Action: login\r\n");
|
||||
fputs($fp, "Username: " . $amp_conf[AMPMGRUSER] . "\r\n");
|
||||
// fputs ($fp,"Secret: secret\r\n");
|
||||
fputs($fp, "Secret: " . $amp_conf[AMPMGRPASS] . "\r\n");
|
||||
fputs($fp, "Events: on\r\n\r\n");
|
||||
|
||||
// fputs ($fp,"Action: SCCPShowDevices\r\n");
|
||||
// fputs ($fp,"Action: DeviceStateList\r\n");
|
||||
fputs($fp, "Action: ExtensionStateList\r\n");
|
||||
fputs($fp, "Action: Status\r\n");
|
||||
|
||||
// fputs ($fp,"Segment: general\r\n");
|
||||
// "Segments":["general","device","line","softkey"]}
|
||||
// fputs ($fp,"Segment: device\r\n");
|
||||
// fputs ($fp,"ResultFormat: command\r\n");
|
||||
fputs($fp, "\r\n");
|
||||
|
||||
/*
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: general\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: general\r\n");
|
||||
fputs ($fp,"ListResult: yes\r\n");
|
||||
fputs ($fp,"Option: fallback\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: device\r\n");
|
||||
fputs ($fp,"ListResult: freepbx\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: device\r\n");
|
||||
fputs ($fp,"Option: dtmfmode\r\n");
|
||||
fputs ($fp,"ListResult: yes\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
*/
|
||||
|
||||
fputs($fp, "Action: logoff\r\n\r\n");
|
||||
// print_r(fgets($fp));
|
||||
$resp = '';
|
||||
while (!feof($fp)) {
|
||||
$resp .= fgets($fp);
|
||||
}
|
||||
// print_r(fgets($fp));
|
||||
// print_r('<br>');
|
||||
// echo fgets($fp, 128);
|
||||
}
|
||||
fclose($fp);
|
||||
return $resp;
|
||||
}
|
||||
|
||||
}
|
|
@ -43,7 +43,7 @@ class dbinterface {
|
|||
break;
|
||||
case "SccpDevice":
|
||||
// $sql = "SELECT * FROM `sccpdeviceconfig` ORDER BY `name`";
|
||||
$sql = "select `name`,`name` as `mac`, `type`, `button`, `addon` from `sccpdeviceconfig` ORDER BY `name`";
|
||||
$sql = "select `name`,`name` as `mac`, `type`, `button`, `addon`, `_description` as description from `sccpdeviceconfig` ORDER BY `name`";
|
||||
$raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC);
|
||||
break;
|
||||
case "HWDevice":
|
||||
|
@ -56,6 +56,10 @@ class dbinterface {
|
|||
$sql = "DESCRIBE sccpdevice";
|
||||
$raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC);
|
||||
break;
|
||||
case "get_colums_sccpusers":
|
||||
$sql = "DESCRIBE sccpusers";
|
||||
$raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC);
|
||||
break;
|
||||
case "get_sccpdevice_byid":
|
||||
$sql = 'SELECT t1.*, types.dns, types.buttons, types.loadimage, types.nametemplate as nametemplate, '
|
||||
. 'addon.buttons as addon_buttons FROM sccpdevice AS t1 '
|
||||
|
@ -63,8 +67,16 @@ class dbinterface {
|
|||
. 'LEFT JOIN sccpdevmodel as addon ON t1.addon=addon.model WHERE name="' . $data['id'] . '";';
|
||||
$raw_settings = sql($sql, "getRow", DB_FETCHMODE_ASSOC);
|
||||
break;
|
||||
case "get_sccpdusers":
|
||||
$sql = "SELECT * FROM `sccpusers` ";
|
||||
if (!empty($data['id'])) {
|
||||
$sql .= 'WHERE name="' . $data['id'] . '" ';
|
||||
}
|
||||
$sql .= "ORDER BY `name`;";
|
||||
$raw_settings = sql($sql, "getRow", DB_FETCHMODE_ASSOC);
|
||||
break;
|
||||
case "get_sccpdevice_buttons":
|
||||
$sql = 'SELECT * FROM buttonconfig WHERE device="' . $data['id'] . '";';
|
||||
$sql = 'SELECT * FROM sccpbuttonconfig WHERE ref="' . $data['id'] . '" ORDER BY `instance`;';
|
||||
$raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC);
|
||||
break;
|
||||
}
|
||||
|
@ -161,6 +173,7 @@ class dbinterface {
|
|||
break;
|
||||
case 'sccpdevmodel':
|
||||
case 'sccpdevice':
|
||||
case 'sccpusers':
|
||||
$sql_db = $db_name;
|
||||
$sql_key = "";
|
||||
$sql_var = "";
|
||||
|
@ -193,7 +206,7 @@ class dbinterface {
|
|||
break;
|
||||
case 'sccpbuttons':
|
||||
if (($mode == 'clear') || ($mode == 'delete')) {
|
||||
$sql = 'DELETE FROM `buttonconfig` WHERE device="' . $hwid . '";';
|
||||
$sql = 'DELETE FROM `sccpbuttonconfig` WHERE ref="' . $hwid . '";';
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
@ -201,7 +214,8 @@ class dbinterface {
|
|||
break;
|
||||
}
|
||||
if (!empty($save_value)) {
|
||||
$sql = 'INSERT INTO `buttonconfig` (`device`, `instance`, `type`, `name`, `options`) VALUES (?,?,?,?,?);';
|
||||
$sql = 'INSERT INTO `sccpbuttonconfig` (`ref`, `reftype`,`instance`, `buttontype`, `name`, `options`) VALUES (?,?,?,?,?,?);';
|
||||
// die(print_r($save_value,1));
|
||||
$stmt = $db->prepare($sql);
|
||||
$res = $db->executeMultiple($stmt, $save_value);
|
||||
}
|
||||
|
|
|
@ -100,7 +100,6 @@ class extconfigs {
|
|||
'holdconf' => 'resume,newcall,endcall,join',
|
||||
'uriaction' => 'default');
|
||||
// Cisco Language Code / Directory
|
||||
|
||||
private $cisco_language = array('ar_SA' => array('code' => 'ar', 'language' => 'Arabic', 'locale' => 'Arabic_Saudi_Arabia', 'codepage' => 'ISO8859-1'),
|
||||
'bg_BG' => array('code' => 'bg', 'language' => 'Bulgarian', 'locale' => 'Bulgarian_Bulgaria', 'codepage' => 'ISO8859-1'),
|
||||
'cz_CZ' => array('code' => 'cz', 'language' => 'Czech', 'locale' => 'Czech_Czech_Republic', 'codepage' => 'ISO8859-1'),
|
||||
|
@ -217,10 +216,22 @@ class extconfigs {
|
|||
// *** Setings for Provision Sccp
|
||||
$adv_config = Array('tftproot' => '', 'firmware' => 'firmware', 'settings' => 'settings',
|
||||
'locales' => 'locales', 'languages' => 'languages', 'templates' => 'templates');
|
||||
// 'pro' /tftpboot - root dir
|
||||
// /tftpboot/locales/locales/%Languge_name%
|
||||
// /tftpboot/settings/XMLdefault.cnf.xml
|
||||
// /tftpboot/settings/SEP[MAC].cnf.xml
|
||||
// /tftpboot/firmware/79xx/SCCPxxxx.loads
|
||||
$adv_tree['pro'] = Array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales');
|
||||
|
||||
// 'def' /tftpboot - root dir
|
||||
// /tftpboot/languages/%Languge_name%
|
||||
// /tftpboot/XMLdefault.cnf.xml
|
||||
// /tftpboot/SEP[MAC].cnf.xml
|
||||
// /tftpboot/SCCPxxxx.loads
|
||||
$adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => '', 'firmware' => '', 'languages' => 'tftproot');
|
||||
// $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => '');
|
||||
$adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'tftproot');
|
||||
// $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'tftproot');
|
||||
|
||||
//* **************------ ****
|
||||
$base_tree = Array('tftp_templates' => 'templates', 'tftp_path_store' => 'settings', 'tftp_lang_path' => 'languages', 'tftp_firmware_path' => 'firmware');
|
||||
|
||||
|
|
|
@ -11,24 +11,16 @@
|
|||
namespace FreePBX\modules\Sccp_manager;
|
||||
|
||||
class srvinterface {
|
||||
var $socket;
|
||||
|
||||
var $error;
|
||||
|
||||
|
||||
public function __construct($parent_class = null) {
|
||||
global $amp_conf;
|
||||
$this->paren_class = $parent_class;
|
||||
$this->socket = FALSE;
|
||||
$this->paren_class = $parent_class;
|
||||
$this->error = "";
|
||||
/*
|
||||
if (isset($amp_conf[AMPMGRUSER])) {
|
||||
$this->astLogin('localhost', $amp_conf[AMPMGRUSER],$amp_conf[AMPMGRPASS]);
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
public function info() {
|
||||
$Ver = '13.0.3';
|
||||
$Ver = '13.0.4';
|
||||
return Array('Version' => $Ver,
|
||||
'about' => 'Server interface data ver: ' . $Ver);
|
||||
}
|
||||
|
@ -37,10 +29,11 @@ class srvinterface {
|
|||
Core Access Function
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Replace or dublicate to AMI interface
|
||||
*/
|
||||
|
||||
/*
|
||||
* Replace or dublicate to AMI interface
|
||||
*/
|
||||
|
||||
public function sccp_core_commands($params = array()) {
|
||||
global $astman;
|
||||
$cmd_list = array('get_softkey' => array('cmd' => "sccp show softkeyssets", 'param' => ''),
|
||||
|
@ -134,19 +127,20 @@ class srvinterface {
|
|||
/*
|
||||
* A function should be used in the form of buttons for getting all hint. Not working. I don't know how to use properly.
|
||||
*/
|
||||
|
||||
public function sccp_list_hints() {
|
||||
$hint_key = array();
|
||||
$hint_all = $this->sccp_list_all_hints();
|
||||
foreach ($hint_all as $value) {
|
||||
$res = $this->loc_after('@', $value);
|
||||
$res = $this->loc_after('@', $value);
|
||||
// array_search($res, $hint_key)) != NULL)
|
||||
if (!isset($hint_key[$res])) {
|
||||
$hint_key[$res] = '@'.$res;
|
||||
}
|
||||
if (!isset($hint_key[$res])) {
|
||||
$hint_key[$res] = '@' . $res;
|
||||
}
|
||||
}
|
||||
return $hint_key;
|
||||
}
|
||||
|
||||
|
||||
public function sccp_list_all_hints() {
|
||||
$ast_out = $this->sccp_core_commands(array('cmd' => 'get_hints'));
|
||||
$ast_out = preg_split("/[\n]/", $ast_out['data']);
|
||||
|
@ -160,7 +154,7 @@ class srvinterface {
|
|||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
list ($line, $junk) = explode(' ', $line);
|
||||
if (!is_bool(strpos($line,':'))) {
|
||||
if (!is_bool(strpos($line, ':'))) {
|
||||
$line = trim(substr($line, 0, strpos($line, ':')));
|
||||
}
|
||||
if (isset($ast_key[$line])) {
|
||||
|
@ -177,15 +171,15 @@ class srvinterface {
|
|||
|
||||
public function sccp_realtime_status() {
|
||||
$ast_res = array();
|
||||
$ast_out = $this->sccp_core_commands(array('cmd'=>'get_realtime_status'));
|
||||
$ast_out = preg_split("/[\n]/", $ast_out['data']);
|
||||
if (strpos($ast_out[0], 'Privilege') !== false){
|
||||
$ast_out = $this->sccp_core_commands(array('cmd' => 'get_realtime_status'));
|
||||
$ast_out = preg_split("/[\n]/", $ast_out['data']);
|
||||
if (strpos($ast_out[0], 'Privilege') !== false) {
|
||||
$ast_out[0] = "";
|
||||
}
|
||||
foreach ($ast_out as $line) {
|
||||
if (strlen($line) > 3) {
|
||||
$ast_key = strstr(trim($line), ' ', true);
|
||||
$ast_res[$ast_key] = array('message' => $line, 'status'=> strpos($line, 'connected') ? 'OK' : 'ERROR');
|
||||
$ast_key = strstr(trim($line), ' ', true);
|
||||
$ast_res[$ast_key] = array('message' => $line, 'status' => strpos($line, 'connected') ? 'OK' : 'ERROR');
|
||||
}
|
||||
}
|
||||
return $ast_res;
|
||||
|
@ -211,16 +205,16 @@ class srvinterface {
|
|||
default:
|
||||
return 430;
|
||||
}
|
||||
/* if ($res["vCode"] >= 433) {
|
||||
|
||||
}
|
||||
if ($res["vCode"] >= 431) {
|
||||
return 431;
|
||||
} else {
|
||||
return 430;
|
||||
}
|
||||
*
|
||||
*/
|
||||
/* if ($res["vCode"] >= 433) {
|
||||
|
||||
}
|
||||
if ($res["vCode"] >= 431) {
|
||||
return 431;
|
||||
} else {
|
||||
return 430;
|
||||
}
|
||||
*
|
||||
*/
|
||||
// return $res["vCode"];
|
||||
}
|
||||
|
||||
|
@ -228,7 +222,7 @@ class srvinterface {
|
|||
$res = $this->getChanSCCPVersion();
|
||||
if (empty($res)) {
|
||||
$res = $this->getCoreSCCPVersion();
|
||||
}
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -246,7 +240,7 @@ class srvinterface {
|
|||
$result["develop"] = $ast_out[1];
|
||||
$res = 10;
|
||||
// !TODO!: This does not work as you might expect
|
||||
if (base_convert($ast_out[3], 16, 10) == base_convert('702487a', 16, 10)) {
|
||||
if (base_convert($ast_out[3], 16, 10) == base_convert('702487a', 16, 10)) {
|
||||
$result["vCode"] = 431;
|
||||
}
|
||||
if (base_convert($ast_out[3], 16, 10) >= "10403") { // new method, RevisionNum is incremental
|
||||
|
@ -437,26 +431,26 @@ class srvinterface {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function strpos_array($haystack, $needles) {
|
||||
if (is_array($needles)) {
|
||||
foreach ($needles as $str) {
|
||||
if (is_array($str)) {
|
||||
$pos = strpos_array($haystack, $str);
|
||||
} else {
|
||||
$pos = strpos($haystack, $str);
|
||||
}
|
||||
if ($pos !== FALSE) {
|
||||
return $pos;
|
||||
foreach ($needles as $str) {
|
||||
if (is_array($str)) {
|
||||
$pos = strpos_array($haystack, $str);
|
||||
} else {
|
||||
$pos = strpos($haystack, $str);
|
||||
}
|
||||
if ($pos !== FALSE) {
|
||||
return $pos;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return strpos($haystack, $needles);
|
||||
}
|
||||
} else {
|
||||
return strpos($haystack, $needles);
|
||||
}
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
private function loc_after($value, $inthat)
|
||||
{
|
||||
private function loc_after($value, $inthat) {
|
||||
if (!is_bool(strpos($inthat, $value)))
|
||||
return substr($inthat, strpos($inthat, $value) + strlen($value));
|
||||
}
|
||||
|
@ -472,234 +466,35 @@ class srvinterface {
|
|||
$metadata = $astman->send_request($action, $params);
|
||||
return $metadata;
|
||||
}
|
||||
/*
|
||||
* [Segments] => ( [0] => general [1] => device [2] => line [3] => softkey )
|
||||
*/
|
||||
function getеtestChanSCCP_GlablsInfo($Segment='') {
|
||||
|
||||
/*
|
||||
* [Segments] => ( [0] => general [1] => device [2] => line [3] => softkey )
|
||||
*/
|
||||
function getеtestChanSCCP_GlablsInfo($Segment = '') {
|
||||
global $astman;
|
||||
$params = array();
|
||||
$response = $astman->send_request('SCCPConfigMetaData', $params);
|
||||
|
||||
$action = 'SCCPConfigMetaData';
|
||||
if (empty($Segment)) {
|
||||
$Segment = 'general';
|
||||
}
|
||||
$params = array('Segment' => $Segment, 'ResultFormat'=>'command' );
|
||||
$params = array('Segment' => $Segment, 'ResultFormat' => 'command');
|
||||
$metadata = $astman->send_request($action, $params);
|
||||
if (!empty($metadata['data'])) {
|
||||
$tmp_data = $metadata['data'];
|
||||
if (strpos($tmp_data, 'JSON:')!==false ) {
|
||||
$decode = json_decode(substr ($tmp_data,strpos($tmp_data, 'JSON:') + 5), true);
|
||||
$tmp_data = $metadata['data'];
|
||||
if (strpos($tmp_data, 'JSON:') !== false) {
|
||||
$decode = json_decode(substr($tmp_data, strpos($tmp_data, 'JSON:') + 5), true);
|
||||
$result = array();
|
||||
if (!empty($decode['Options'])) {
|
||||
foreach ($decode['Options'] as $value) {
|
||||
$result[$value['Name']] = $value;
|
||||
$result[$value['Name']] = $value;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return $decode;
|
||||
}
|
||||
|
||||
}
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
/*
|
||||
private function astLogin($host="localhost", $username="admin", $password="amp111"){
|
||||
|
||||
$this->socket = @fsockopen("127.0.0.1","5038", $errno, $errstr, 1);
|
||||
|
||||
if (!$this->socket) {
|
||||
$this->error = "Could not connect - $errstr ($errno)";
|
||||
return FALSE;
|
||||
}else{
|
||||
stream_set_timeout($this->socket, 1);
|
||||
|
||||
$wrets = $this->astQuery("Action: Login\r\nUserName: $username\r\nSecret: $password\r\nEvents: off\r\n\r\n");
|
||||
|
||||
if (strpos($wrets['raw'], "Message: Authentication accepted") != FALSE) {
|
||||
return TRUE;
|
||||
}else{
|
||||
$this->error = "Could not login - Authentication failed ";
|
||||
fclose($this->socket);
|
||||
$this->socket = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function astLogout(){
|
||||
if ($this->socket){
|
||||
fputs($this->socket, "Action: Logoff\r\n\r\n");
|
||||
while (!feof($this->socket)) {
|
||||
$wrets .= fread($this->socket, 8192);
|
||||
}
|
||||
fclose($this->socket);
|
||||
$this->socket = "FALSE";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private function astQuery($query, $rawdata = false){
|
||||
$wrets = "";
|
||||
|
||||
if ($this->socket === FALSE)
|
||||
return FALSE;
|
||||
$parameters = array();
|
||||
$data_store = 'data';
|
||||
fputs($this->socket, $query);
|
||||
$parameters['raw_q'] = $query;
|
||||
do
|
||||
{
|
||||
$line = fgets($this->socket, 4096);
|
||||
$parameters['raw'] .= $line;
|
||||
if (!$rawdata) {
|
||||
$a = strpos($line, ':');
|
||||
if($a) {
|
||||
$key = substr($line, 0, $a);
|
||||
switch ($key) {
|
||||
case 'Response':
|
||||
case 'Message':
|
||||
case 'EventList':
|
||||
$parameters[$key] = trim(substr($line, $a + 2));
|
||||
break;
|
||||
case 'JSON':
|
||||
$parameters[$key] = substr($line, $a + 2);
|
||||
$data_store = $key;
|
||||
break;
|
||||
default:
|
||||
$parameters[$data_store] .= $line;
|
||||
break;
|
||||
}
|
||||
// store parameter in $parameters
|
||||
} else {
|
||||
$parameters[$data_store] .= $line;
|
||||
}
|
||||
}
|
||||
$info = stream_get_meta_data($this->socket);
|
||||
}while ($line != "\r\n" && $info['timed_out'] == false );
|
||||
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
function GetError(){
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
private function astman_retrieveMeta($action = "", $parameters=array(), $rawdata = false) {
|
||||
// $parameters=array()
|
||||
global $amp_conf;
|
||||
$option = "";
|
||||
$result = array();
|
||||
if ($this->socket === FALSE) {
|
||||
if (!$this->astLogin(localhost, $amp_conf[AMPMGRUSER],$amp_conf[AMPMGRPASS])) {
|
||||
$result["Response"] = "Faild";
|
||||
$result["Error"] = $this->error;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($action)) {
|
||||
$action = 'SCCPConfigMetaData';
|
||||
}
|
||||
$query = "Action: $action\r\n";
|
||||
|
||||
foreach($parameters as $var=>$val) {
|
||||
if (is_array($val)) {
|
||||
foreach($val as $k => $v) {
|
||||
$query .= "$var: $k=$v\r\n";
|
||||
}
|
||||
} else {
|
||||
$query .= "$var: $val\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->astQuery($query."\r\n",$rawdata);
|
||||
|
||||
if ($result["Response"] == "Success") {
|
||||
if ($rawdata) {
|
||||
return $result;
|
||||
} else {
|
||||
if (!empty($result["JSON"])) {
|
||||
$decode = json_decode($response["JSON"], true);
|
||||
return $decode;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return $result;
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
function t_get_meta_data() {
|
||||
global $amp_conf;
|
||||
$fp = fsockopen("127.0.0.1", "5038", $errno, $errstr, 10);
|
||||
|
||||
if (!$fp) {
|
||||
echo "$errstr ($errno)<br />\n";
|
||||
} else {
|
||||
fputs ($fp,"Action: login\r\n");
|
||||
fputs ($fp,"Username: ".$amp_conf[AMPMGRUSER]."\r\n");
|
||||
// fputs ($fp,"Secret: secret\r\n");
|
||||
fputs ($fp,"Secret: ".$amp_conf[AMPMGRPASS]."\r\n");
|
||||
fputs ($fp,"Events: on\r\n\r\n");
|
||||
|
||||
// fputs ($fp,"Action: SCCPShowDevices\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
// fputs ($fp,"Segment: general\r\n");
|
||||
// "Segments":["general","device","line","softkey"]}
|
||||
fputs ($fp,"Segment: device\r\n");
|
||||
fputs ($fp,"ResultFormat: command\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
/*
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: general\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: general\r\n");
|
||||
fputs ($fp,"ListResult: yes\r\n");
|
||||
fputs ($fp,"Option: fallback\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: device\r\n");
|
||||
fputs ($fp,"ListResult: freepbx\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
|
||||
fputs ($fp,"Action: SCCPConfigMetaData\r\n");
|
||||
fputs ($fp,"Segment: device\r\n");
|
||||
fputs ($fp,"Option: dtmfmode\r\n");
|
||||
fputs ($fp,"ListResult: yes\r\n");
|
||||
fputs ($fp,"\r\n");
|
||||
*/
|
||||
|
||||
fputs ($fp,"Action: logoff\r\n\r\n");
|
||||
// print_r(fgets($fp));
|
||||
$resp = '';
|
||||
while (!feof($fp)) {
|
||||
$resp .= fgets($fp);
|
||||
|
||||
}
|
||||
// print_r(fgets($fp));
|
||||
// print_r('<br>');
|
||||
|
||||
// echo fgets($fp, 128);
|
||||
}
|
||||
fclose($fp);
|
||||
return $resp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -199,7 +199,7 @@ class xmlinterface {
|
|||
}
|
||||
$xnode->name = $tz_id;
|
||||
$xnode->dateTemplate = $data_values['dateformat'];
|
||||
$xnode->timeZone = $TZdata['cisco_code'];
|
||||
$xnode->timeZone = $TZdata['cisco_code'];
|
||||
// $xnode->timeZone = $tz_id.' Standard'.((empty($TZdata['daylight']))? '': '/'.$TZdata['daylight']).' Time';
|
||||
|
||||
if ($data_values['ntp_config_enabled'] == 'yes') {
|
||||
|
|
|
@ -58,12 +58,16 @@ $(document).ready(function () {
|
|||
$('#ajaxsubmit2').on('click', function (e) {
|
||||
var vdata = '';
|
||||
var snd_command = 'savesettings';
|
||||
console.log($('.fpbx-submit').data('id'));
|
||||
$('.fpbx-submit').each(function () {
|
||||
vdata = vdata + $(this).serialize() + '&';
|
||||
});
|
||||
if ($('.fpbx-submit').data('id') == "hw_edit") {
|
||||
snd_command = 'save_hardware';
|
||||
}
|
||||
if ($('.fpbx-submit').data('id') == "ruser_edit") {
|
||||
snd_command = 'save_ruser';
|
||||
}
|
||||
if ($('.fpbx-submit').data('id') == "dial_template") {
|
||||
snd_command = 'save_dialplan_template';
|
||||
}
|
||||
|
@ -99,6 +103,9 @@ $(document).ready(function () {
|
|||
if ($('.fpbx-submit').data('id') == "hw_edit") {
|
||||
snd_command = 'save_hardware';
|
||||
}
|
||||
if ($('.fpbx-submit').data('id') == "ruser_edit") {
|
||||
snd_command = 'save_ruser';
|
||||
}
|
||||
if ($('.fpbx-submit').data('id') == "dial_template") {
|
||||
snd_command = 'save_dialplan_template';
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
* SLK - System KeySet
|
||||
* * Input element Select SLS - System Language
|
||||
* Input element Select SDM - Model List
|
||||
* SDE - Extension List
|
||||
* SDE - Extension List tftp_rewrite
|
||||
* Help elemen HLP - Help Element
|
||||
|
||||
-->
|
||||
|
@ -995,6 +995,15 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
<button value="no">No</button>
|
||||
<help>Say 'yes' if you need to create cisco default language directory in tftp path.</help>
|
||||
</item>
|
||||
|
||||
<item type="IS" id="4" seq="90">
|
||||
<name>system_rouminguser</name>
|
||||
<label>User Rouming</label>
|
||||
<default>no</default>
|
||||
<button value="yes">Yes</button>
|
||||
<button value="no">No</button>
|
||||
<help>Experemental Function Rouming Users</help>
|
||||
</item>
|
||||
|
||||
</page_group>
|
||||
<!-- Form add/ edit device -->
|
||||
|
@ -1078,7 +1087,7 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
<item type="IE" id="1" seq="99">
|
||||
<label>Device Label</label>
|
||||
<input>
|
||||
<name>description</name>
|
||||
<name>_description</name>
|
||||
<default>000000000</default>
|
||||
<class>sccp-custom</class>
|
||||
</input>
|
||||
|
@ -1540,4 +1549,106 @@ and open the template in the editor. Base Version before all crash :-)
|
|||
</item>
|
||||
|
||||
</page_group>
|
||||
<!--
|
||||
Rouming User Pages
|
||||
-->
|
||||
<page_group name="sccp_ruser">
|
||||
<label>Rouming User configuration</label>
|
||||
<item type="IE" id="1" seq="99">
|
||||
<label>User ID</label>
|
||||
<input>
|
||||
<name>id</name>
|
||||
<default>000000000</default>
|
||||
<class>sccp-custom</class>
|
||||
<options readonly="readonly"></options>
|
||||
</input>
|
||||
<help>Help!</help>
|
||||
</item>
|
||||
|
||||
<item type="IE" id="2" seq="99">
|
||||
<label>User Display Name</label>
|
||||
<input>
|
||||
<name>description</name>
|
||||
<default></default>
|
||||
</input>
|
||||
<help>Help!</help>
|
||||
</item>
|
||||
<item type="IE" id="2" seq="99">
|
||||
<label>User Pincode</label>
|
||||
<input>
|
||||
<name>pin</name>
|
||||
<default></default>
|
||||
</input>
|
||||
<help>Help!</help>
|
||||
</item>
|
||||
<item type="IE-D" id="2" seq="99">
|
||||
<label>User password</label>
|
||||
<input>
|
||||
<name>pin</name>
|
||||
<default></default>
|
||||
</input>
|
||||
<help>Help!</help>
|
||||
</item>
|
||||
<item type="IS" id="13" seq="99">
|
||||
<name>rouminglogin</name>
|
||||
<label>Rouming</label>
|
||||
<default>off</default>
|
||||
<button value="off">Disabled</button>
|
||||
<button value="on">Enable Single</button>
|
||||
<button value="multi">Multi Device</button>
|
||||
<help></help>
|
||||
</item>
|
||||
<item type="IS" id="13" seq="99">
|
||||
<name>auto_logout</name>
|
||||
<label>Auto Logout</label>
|
||||
<default>off</default>
|
||||
<button value="off">Ask User</button>
|
||||
<button value="on">Enable</button>
|
||||
<button value="block">User must Logoff</button>
|
||||
<help></help>
|
||||
</item>
|
||||
<item type="SDD" id="3" seq="99">
|
||||
<label>Link Buttons from Home Device</label>
|
||||
<name>homedevice</name>
|
||||
<default>NONE</default>
|
||||
<select name="name" addlabel='description'>name</select>
|
||||
<class>sccp-custom</class>
|
||||
<help>Help!</help>
|
||||
</item>
|
||||
</page_group>
|
||||
<!--
|
||||
Rouming User Pages
|
||||
-->
|
||||
<page_group name="sccp_ruser_time">
|
||||
<label>Time Work configuration</label>
|
||||
<item type="IS" id="13" seq="99">
|
||||
<name>work_time</name>
|
||||
<label>Logof after Work Time</label>
|
||||
<default>off</default>
|
||||
<button value="off">Disabled</button>
|
||||
<button value="on">Gneneral logoff</button>
|
||||
<button value="group">Time Group</button>
|
||||
<help></help>
|
||||
</item>
|
||||
<item type="IE" id="2" seq="99">
|
||||
<label>Time Group</label>
|
||||
<input>
|
||||
<name>work_group</name>
|
||||
<default></default>
|
||||
</input>
|
||||
<help>Help!</help>
|
||||
</item>
|
||||
<item type="IE" id="2" seq="99">
|
||||
<label>Out of time session length</label>
|
||||
<input>
|
||||
<name>time_extend</name>
|
||||
<default>30</default>
|
||||
</input>
|
||||
<help>Help!</help>
|
||||
</item>
|
||||
|
||||
</page_group>
|
||||
|
||||
|
||||
|
||||
</root>
|
||||
|
|
|
@ -106,10 +106,10 @@ ri ^(cmterm_7936.3-3-21-0.bin)$ firmware/7936/\1
|
|||
ri ^(apps37sccp.1-4-5-7.bin)$ firmware/7937/\1
|
||||
|
||||
# 7940_7960 firmware (ancient)
|
||||
ri ^(P0030801SR)(.+\.bin)$ firmware/7940/\1
|
||||
ri ^(P0030801SR)(.+\.loads)$ firmware/7940/\1
|
||||
ri ^(P0030801SR)(.+\.sb2)$ firmware/7940/\1
|
||||
ri ^(P0030801SR)(.+\.sbn)$ firmware/7940/\1
|
||||
ri ^(P0030801SR)(+\.bin)$ firmware/7940/\1
|
||||
ri ^(P0030801SR)(+\.loads)$ firmware/7940/\1
|
||||
ri ^(P0030801SR)(+\.sb2)$ firmware/7940/\1
|
||||
ri ^(P0030801SR)(+\.sbn)$ firmware/7940/\1
|
||||
|
||||
# 7941_7961 firmware (java-based)
|
||||
ri ^(apps41)(.+\.sbn)$ firmware/7941/\1\2
|
||||
|
|
197
install.php
197
install.php
|
@ -155,9 +155,13 @@ function Get_DB_config($sccp_compatible) {
|
|||
'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"),
|
||||
'pickupmodeanswer' => array('rename' => "directed_pickup_modeanswer"),
|
||||
'directed_pickup_modeanswer' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"),
|
||||
'description' => array('rename' => "_description"),
|
||||
'hwlang' => array('rename' => "_hwlang"),
|
||||
'_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'),
|
||||
'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"),
|
||||
'_loginname' => array('create' => 'varchar(20) NULL DEFAULT NULL AFTER `_hwlang`'),
|
||||
'_profileid' => array('create' => 'varchar(20) NULL DEFAULT NULL AFTER `_loginname`'),
|
||||
|
||||
'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_profileid`"),
|
||||
//'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'),
|
||||
'dtmfmode' => array('drop' => "yes"),
|
||||
// 'force_dtmfmode' => array('create' => "VARCHAR(10) default 'auto'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'auto'),
|
||||
|
@ -203,6 +207,7 @@ function Get_DB_config($sccp_compatible) {
|
|||
'audio_cos' => array('drop' => "yes"),
|
||||
'video_tos' => array('drop' => "yes"),
|
||||
'video_cos' => array('drop' => "yes"),
|
||||
'phonecodepage' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL', 'modify' => "VARCHAR(50)"),
|
||||
'incominglimit' => array('create' => "INT(11) DEFAULT '6'", 'modify' => 'INT(11)', 'def_modify' => "6"),
|
||||
'transfer' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"),
|
||||
'vmnum' => array('def_modify' => "*97"),
|
||||
|
@ -230,11 +235,17 @@ function Get_DB_config($sccp_compatible) {
|
|||
'disallow' => array('drop' => "yes"),
|
||||
'directed_pickup_modeanswer' => array('drop' => "yes"),
|
||||
'pickupmodeanswer' => array('drop' => "yes"),
|
||||
'disallow' => array('drop' => "yes"),
|
||||
'disallow' => array('drop' => "yes"),
|
||||
'callhistory_answered_elsewhere' => array('create' => "enum('Ignore','Missed Calls','Received Calls', 'Placed Calls') NULL default NULL", 'modify' => "enum('Ignore','Missed Calls','Received Calls','Placed Calls')"),
|
||||
|
||||
'description' => array('rename' => "_description"),
|
||||
'hwlang' => array('rename' => "_hwlang"),
|
||||
'_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'),
|
||||
'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"),
|
||||
'_loginname' => array('create' => 'varchar(20) NULL DEFAULT NULL AFTER `_hwlang`'),
|
||||
'_profileid' => array('create' => 'varchar(20) NULL DEFAULT NULL AFTER `_loginname`'),
|
||||
|
||||
'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_profileid`"),
|
||||
//'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'),
|
||||
'dtmfmode' => array('drop' => "yes"),
|
||||
// 'force_dtmfmode' => array('create' => "VARCHAR(10) default 'auto'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'auto'),
|
||||
|
@ -254,6 +265,7 @@ function Get_DB_config($sccp_compatible) {
|
|||
'video_tos' => array('def_modify' => "0x88"),
|
||||
'video_cos' => array('def_modify' => "5"),
|
||||
'trustphoneip' => array('drop' => "yes"),
|
||||
'phonecodepage' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL', 'modify' => "VARCHAR(50)"),
|
||||
'mwilamp' => array('create' => "enum('on','off','wink','flash','blink') NULL default 'on'", 'modify' => "enum('on','off','wink','flash','blink')"),
|
||||
'mwioncall' => array('create' => "enum('on','off') NULL default 'on'", 'modify' => "enum('on','off')"),
|
||||
'private' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), // Что-то лишенне
|
||||
|
@ -288,6 +300,8 @@ function Get_DB_config($sccp_compatible) {
|
|||
'transfer' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"),
|
||||
'vmnum' => array('def_modify' => "*97"),
|
||||
'musicclass' => array('def_modify' => "default"),
|
||||
'disallow' => array('create' => "VARCHAR(255) NULL DEFAULT NULL"),
|
||||
'allow' => array('create' => "VARCHAR(255) NULL DEFAULT NULL"),
|
||||
'id' => array('create' => 'MEDIUMINT(9) NOT NULL AUTO_INCREMENT, ADD UNIQUE(id);', 'modify' => "MEDIUMINT(9)", 'index' => 'id'),
|
||||
// 'id' =>array('create' => 'VARCHAR( 20 ) NULL DEFAULT NULL', 'modify' => "VARCHAR(20)", 'def_modify' =>"NULL"),
|
||||
'echocancel' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
|
||||
|
@ -308,7 +322,7 @@ function Get_DB_config($sccp_compatible) {
|
|||
|
||||
$autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT" : "AUTO_INCREMENT";
|
||||
|
||||
$table_req = array('sccpdevice', 'sccpline', 'buttonconfig');
|
||||
$table_req = array('sccpdevice', 'sccpline');
|
||||
$ss = FreePBX::create()->Sccp_manager;
|
||||
$astman = FreePBX::create()->astman;
|
||||
$sccp_compatible = 0;
|
||||
|
@ -384,6 +398,64 @@ function CheckChanSCCPCompatible() {
|
|||
return $sccp_compatible;
|
||||
}
|
||||
|
||||
function InstallDB_Buttons() {
|
||||
global $db;
|
||||
outn("<li>" . _("Creating buttons table...") . "</li>");
|
||||
// $check = $db->getRow("SELECT 1 FROM buttonconfig LIMIT 0", DB_FETCHMODE_ASSOC);
|
||||
// if (DB::IsError($check)) {
|
||||
$sql = "DROP TABLE IF EXISTS `buttonconfig`;
|
||||
CREATE TABLE IF NOT EXISTS `sccpbuttonconfig` (
|
||||
`ref` varchar(15) NOT NULL default '',
|
||||
`reftype` enum('sccpdevice', 'sccpuser') NOT NULL default 'sccpdevice',
|
||||
`instance` tinyint(4) NOT NULL default 0,
|
||||
`buttontype` enum('line','speeddial','service','feature','empty') NOT NULL default 'line',
|
||||
`name` varchar(36) default NULL,
|
||||
`options` varchar(100) default NULL,
|
||||
PRIMARY KEY (`ref`,`reftype`,`instance`,`buttontype`),
|
||||
KEY `ref` (`ref`,`reftype`)
|
||||
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
|
||||
$check = $db->query($sql);
|
||||
if (db::IsError($check)) {
|
||||
die_freepbx("Can not create sccpbuttonconfig table, error:$check\n");
|
||||
}
|
||||
/*
|
||||
} else {
|
||||
$db_result = $db->getAll("SELECT TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE "
|
||||
. "WHERE TABLE_SCHEMA = 'asterisk' AND TABLE_NAME = 'buttonconfig' AND REFERENCED_COLUMN_NAME IS NOT NULL;");
|
||||
|
||||
if (DB::IsError($db_result)) {
|
||||
die_freepbx("Can not get informations TABLE_SCHEMA\n");
|
||||
}
|
||||
|
||||
$sql = '';
|
||||
$sql = 'RENAME TABLE `buttonconfig` TO `sccpbuttonconfig`;';
|
||||
$sql .= "ALTER TABLE `sccpbuttonconfig` ADD COLUMN `user` VARCHAR(20) NOT NULL DEFAULT '' AFTER `device`;";
|
||||
$check = $db->query($sql);
|
||||
if (db::IsError($check)) {
|
||||
die_freepbx("Can not create sccpsettings table, error:$check\n");
|
||||
}
|
||||
$sql = '';
|
||||
foreach ($db_result as $tabl_data) {
|
||||
$fld_id = $tabl_data[2];
|
||||
if (!empty($fld_id)) {
|
||||
$sql .= "ALTER TABLE `sccpbuttonconfig` DROP FOREIGN KEY `".$fld_id."`\n";
|
||||
}
|
||||
}
|
||||
|
||||
$sql .= "ALTER TABLE `sccpbuttonconfig` CHANGE COLUMN `device` `device` varchar(15) NULL default NULL";
|
||||
$sql .= "ALTER TABLE `sccpbuttonconfig` ADD FOREIGN KEY (device) REFERENCES sccpdevice(name) ON DELETE CASCADE;";
|
||||
|
||||
$check = $db->query($sql);
|
||||
if (DB::IsError($db_result)) {
|
||||
die_freepbx("Can not get drop old FOREIGN KEY \n");
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function InstallDB_sccpsettings() {
|
||||
global $db;
|
||||
outn("<li>" . _("Creating sccpsettings table...") . "</li>");
|
||||
|
@ -423,6 +495,28 @@ function InstallDB_sccpdevmodel() {
|
|||
return true;
|
||||
}
|
||||
|
||||
function InstallDB_sccpusers() {
|
||||
global $db;
|
||||
outn("<li>" . _("Creating sccpusers table...") . "</li>");
|
||||
$sql = "CREATE TABLE IF NOT EXISTS `sccpusers` (
|
||||
`name` VARCHAR(20) NULL DEFAULT NULL,
|
||||
`pin` VARCHAR(7) NULL DEFAULT NULL,
|
||||
`password` VARCHAR(7) NULL DEFAULT NULL,
|
||||
`description` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`rouminglogin` ENUM('on','off','multi') NULL DEFAULT 'off',
|
||||
`devicegroup` VARCHAR(20) NULL DEFAULT 'all',
|
||||
`auto_logout` ENUM('on','off') NULL DEFAULT 'off',
|
||||
`homedevice` VARCHAR(20) NULL DEFAULT NULL,
|
||||
UNIQUE INDEX (`name`),
|
||||
PRIMARY KEY (`name`)
|
||||
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;";
|
||||
$check = $db->query($sql);
|
||||
if (db::IsError($check)) {
|
||||
die_freepbx("Can not create sccpdevmodel table, error:$check\n");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function InstallDB_updateSchema($db_config) {
|
||||
global $db;
|
||||
if (!$db_config) {
|
||||
|
@ -572,28 +666,55 @@ function InstallDB_updateSccpDevice() {
|
|||
function InstallDB_createButtonConfigTrigger() {
|
||||
global $db;
|
||||
outn("<li>" . _("(Re)Create buttonconfig trigger") . "</li>");
|
||||
$sql = "
|
||||
DROP TRIGGER IF EXISTS trg_buttonconfig;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER trg_buttonconfig BEFORE INSERT ON buttonconfig
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.`type` = 'line' THEN
|
||||
SET @line_x = SUBSTRING_INDEX(NEW.`name`,'!',1);
|
||||
SET @line_x = SUBSTRING_INDEX(@line_x,'@',1);
|
||||
IF (SELECT COUNT(*) FROM `sccpline` WHERE `sccpline`.`name` = @line_x ) = 0
|
||||
THEN
|
||||
UPDATE `Foreign key contraint violated: line does not exist in sccpline` SET x=1;
|
||||
$sql = "DROP TRIGGER IF EXISTS sccp_trg_buttonconfig;";
|
||||
/* $sql = "DELIMITER $$
|
||||
CREATE TRIGGER sccp_trg_buttonconfig BEFORE INSERT ON sccpbuttonconfig
|
||||
FOR EACH ROW
|
||||
BEGIN
|
||||
IF NEW.`reftype` = 'sccpdevice' THEN
|
||||
IF (SELECT COUNT(*) FROM `sccpdevice` WHERE `sccpdevice`.`name` = NEW.`ref` ) = 0 THEN
|
||||
UPDATE `Foreign key contraint violated: ref does not exist in sccpdevice` SET x=1;
|
||||
END IF;
|
||||
END IF;
|
||||
END $$
|
||||
DELIMITER ;";
|
||||
IF NEW.`reftype` = 'sccpline' THEN
|
||||
IF (SELECT COUNT(*) FROM `sccpline` WHERE `sccpline`.`name` = NEW.`ref`) = 0 THEN
|
||||
UPDATE `Foreign key contraint violated: ref does not exist in sccpline` SET x=1;
|
||||
END IF;
|
||||
END IF;
|
||||
IF NEW.`buttontype` = 'line' THEN
|
||||
SET @line_x = SUBSTRING_INDEX(NEW.`name`,'!',1);
|
||||
SET @line_x = SUBSTRING_INDEX(@line_x,'@',1);
|
||||
IF (SELECT COUNT(*) FROM `sccpline` WHERE `sccpline`.`name` = @line_x ) = 0 THEN
|
||||
UPDATE `Foreign key contraint violated: line does not exist in sccpline` SET x=1;
|
||||
END IF;
|
||||
END IF;
|
||||
END $$
|
||||
DELIMITER ;";*/
|
||||
$sql .= "
|
||||
CREATE TRIGGER `sccp_trg_buttonconfig` BEFORE INSERT ON `sccpbuttonconfig` FOR EACH ROW BEGIN
|
||||
IF NEW.`reftype` = 'sccpdevice' THEN
|
||||
IF (SELECT COUNT(*) FROM `sccpdevice` WHERE `sccpdevice`.`name` = NEW.`ref` ) = 0 THEN
|
||||
UPDATE `Foreign key contraint violated: ref does not exist in sccpdevice` SET x=1;
|
||||
END IF;
|
||||
END IF;
|
||||
IF NEW.`reftype` = 'sccpline' THEN
|
||||
IF (SELECT COUNT(*) FROM `sccpline` WHERE `sccpline`.`name` = NEW.`ref`) = 0 THEN
|
||||
UPDATE `Foreign key contraint violated: ref does not exist in sccpline` SET x=1;
|
||||
END IF;
|
||||
END IF;
|
||||
IF NEW.`buttontype` = 'line' THEN
|
||||
SET @line_x = SUBSTRING_INDEX(NEW.`name`,'!',1);
|
||||
SET @line_x = SUBSTRING_INDEX(@line_x,'@',1);
|
||||
IF (SELECT COUNT(*) FROM `sccpline` WHERE `sccpline`.`name` = @line_x ) = 0 THEN
|
||||
UPDATE `Foreign key contraint violated: line does not exist in sccpline` SET x=1;
|
||||
END IF;
|
||||
END IF;
|
||||
END";
|
||||
$check = $db->query($sql);
|
||||
if (DB::IsError($check)) {
|
||||
die_freepbx("Can not modify sccpdevice table\n");
|
||||
}
|
||||
outn("<li>" . _("(Re)Create trigger Ok") . "</li>");
|
||||
// outn("<li>" . $sql . "</li>");
|
||||
outn("<li>" . $sql . "</li>");
|
||||
return true;
|
||||
}
|
||||
function InstallDB_updateDBVer($sccp_compatible) {
|
||||
|
@ -632,18 +753,38 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) {
|
|||
`sccpdevice`.`conf_show_conflist` AS `conf_show_conflist`,`sccpdevice`.`setvar` AS `setvar`,`sccpdevice`.`disallow` AS `disallow`,
|
||||
`sccpdevice`.`allow` AS `allow`,`sccpdevice`.`backgroundImage` AS `backgroundImage`,`sccpdevice`.`ringtone` AS `ringtone`,`sccpdevice`.`name` AS `name`
|
||||
FROM sccpdevice
|
||||
LEFT JOIN buttonconfig ON ( buttonconfig.device = sccpdevice.name )
|
||||
LEFT JOIN sccpbuttonconfig buttonconfig ON ( buttonconfig.device = sccpdevice.name )
|
||||
GROUP BY sccpdevice.name;";
|
||||
} else {
|
||||
/* $sql = "
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = MERGE
|
||||
VIEW sccpdeviceconfig AS
|
||||
SELECT IF(sccpdevice._profileid = 0,
|
||||
GROUP_CONCAT(CONCAT_WS( ',', defbutton.buttontype, defbutton.name, defbutton.options ) ORDER BY defbutton.instance ASC SEPARATOR ';' ),
|
||||
GROUP_CONCAT( CONCAT_WS( ',', userbutton.buttontype, userbutton.name, userbutton.options ) ORDER BY userbutton.instance ASC SEPARATOR ';' )
|
||||
) AS button,
|
||||
sccpdevice.*
|
||||
FROM sccpdevice
|
||||
LEFT JOIN sccpbuttonconfig defbutton ON ( defbutton.ref = sccpdevice.name )
|
||||
LEFT JOIN sccpbuttonconfig userbutton ON ( userbutton.ref = sccpdevice._loginname )
|
||||
LEFT JOIN sccpline ON ( sccpline.name = sccpdevice._loginname)
|
||||
GROUP BY sccpdevice.name;";
|
||||
*/
|
||||
$sql = "
|
||||
CREATE OR REPLACE
|
||||
ALGORITHM = MERGE
|
||||
VIEW sccpdeviceconfig AS
|
||||
SELECT GROUP_CONCAT( CONCAT_WS( ',', buttonconfig.type, buttonconfig.name, buttonconfig.options )
|
||||
ORDER BY instance ASC
|
||||
SEPARATOR ';' ) AS button, sccpdevice.*
|
||||
SELECT case sccpdevice._profileid
|
||||
when 0 then
|
||||
(select GROUP_CONCAT(CONCAT_WS( ',', defbutton.buttontype, defbutton.name, defbutton.options ) SEPARATOR ';') from `sccpbuttonconfig` as defbutton where defbutton.ref = sccpdevice.name ORDER BY defbutton.instance )
|
||||
when 1 then
|
||||
(select GROUP_CONCAT(CONCAT_WS( ',', userbutton.buttontype, userbutton.name, userbutton.options ) SEPARATOR ';') from `sccpbuttonconfig` as userbutton where userbutton.ref = sccpdevice._loginname ORDER BY userbutton.instance )
|
||||
when 2 then
|
||||
(select GROUP_CONCAT(CONCAT_WS( ',', homebutton.buttontype, homebutton.name, homebutton.options ) SEPARATOR ';') from `sccpbuttonconfig` as homebutton where homebutton.ref = sccpusers.homedevice ORDER BY homebutton.instance )
|
||||
end as button, sccpdevice.*, if(sccpdevice._profileid = 0, sccpdevice._description, sccpusers.description) as description
|
||||
FROM sccpdevice
|
||||
LEFT JOIN buttonconfig ON ( buttonconfig.device = sccpdevice.name )
|
||||
LEFT JOIN sccpusers sccpusers ON ( sccpusers.name = sccpdevice._loginname )
|
||||
GROUP BY sccpdevice.name;";
|
||||
}
|
||||
$results = $db->query($sql);
|
||||
|
@ -788,9 +929,8 @@ if ($sccp_compatible == 0) {
|
|||
$db_config = Get_DB_config($sccp_compatible);
|
||||
$sccp_db_ver = CheckSCCPManagerDBVersion();
|
||||
|
||||
// BackUp Old config
|
||||
CreateBackUpConfig();
|
||||
RenameConfig();
|
||||
InstallDB_sccpusers();
|
||||
InstallDB_Buttons();
|
||||
InstallDB_sccpsettings();
|
||||
InstallDB_sccpdevmodel();
|
||||
InstallDB_updateSchema($db_config);
|
||||
|
@ -800,6 +940,7 @@ if (!$sccp_db_ver) {
|
|||
} else {
|
||||
outn("Skip update Device model");
|
||||
}
|
||||
|
||||
InstallDB_createButtonConfigTrigger();
|
||||
InstallDB_CreateSccpDeviceConfigView($sccp_compatible);
|
||||
InstallDB_updateDBVer($sccp_compatible);
|
||||
|
@ -817,4 +958,4 @@ outn("<br>");
|
|||
// $ss->sccp_create_sccp_init();
|
||||
// $ss->sccp_db_save_setting();
|
||||
//
|
||||
//}
|
||||
//}
|
||||
|
|
|
@ -10,13 +10,18 @@ if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
|
|||
global $db;
|
||||
$version = FreePBX::Config()->get('ASTVERSION');
|
||||
|
||||
echo "dropping table sccpdevmodel..";
|
||||
sql("DROP TABLE IF EXISTS `sccpdevmodel`");
|
||||
echo "dropping table sccpsettings..";
|
||||
sql("DROP TABLE IF EXISTS `sccpsettings`");
|
||||
out('Remove all SCCP tables');
|
||||
$tables = array('sccpdevmodel', 'sccpsettings');
|
||||
foreach ($tables as $table) {
|
||||
$sql = "DROP TABLE IF EXISTS {$table}";
|
||||
$result = $db->query($sql);
|
||||
if (DB::IsError($result)) {
|
||||
die_freepbx($result->getDebugInfo());
|
||||
}
|
||||
unset($result);
|
||||
}
|
||||
if (!empty($version)) {
|
||||
// Woo, we have a version
|
||||
|
||||
$check = $db->getRow("SELECT 1 FROM `kvstore` LIMIT 0", DB_FETCHMODE_ASSOC);
|
||||
if (!(DB::IsError($check))) {
|
||||
//print_r("none, creating table :". $value);
|
||||
|
@ -29,7 +34,7 @@ if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
|
|||
/* So that you know if it is save to drop/delete them */
|
||||
|
||||
/* DROP VIEW `sccpdeviceconfig`;
|
||||
DROP TABLE `buttonconfig`;
|
||||
DROP TABLE `sccpbuttonconfig`;
|
||||
DROP TABLE `sccpdevice`;
|
||||
DROP TABLE `sccpdevmodel`;
|
||||
DROP TABLE `sccpline`;
|
||||
|
|
34
views/form.addruser.php
Normal file
34
views/form.addruser.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
$def_val = null;
|
||||
$dev_id = null;
|
||||
$dev_new = null;
|
||||
|
||||
if (!empty($_REQUEST['ru_id'])) {
|
||||
$dev_id = $_REQUEST['ru_id'];
|
||||
$def_val['id'] = array("keyword" => 'id', "data" => $dev_id, "seq" => "99");
|
||||
$db_res = $this->dbinterface->get_db_SccpTableData('get_sccpdusers', array("id" => $dev_id));
|
||||
if (!empty($db_res) ) {
|
||||
foreach ($db_res as $key => $val) {
|
||||
if (!empty($val)) {
|
||||
$def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form autocomplete="off" name="frm_addruser" id="frm_addruser" class="fpbx-submit" action="" method="post" data-id="ruser_edit">
|
||||
<input type="hidden" name="category" value="addruser_form">
|
||||
<input type="hidden" name="Submit" value="Submit">
|
||||
|
||||
<?php
|
||||
echo $this->ShowGroup('sccp_ruser', 1, 'sccp_ru', $def_val);
|
||||
echo $this->ShowGroup('sccp_ruser_time', 1, 'sccp_ru', $def_val);
|
||||
?>
|
||||
</form>
|
|
@ -16,20 +16,9 @@ $feature_list= array('parkinglot'=>'Park Slots','monitor'=> "Record Calls",'dev
|
|||
|
||||
$lines_list = $this->dbinterface->get_db_SccpTableData('SccpExtension');
|
||||
//$hint_list = $this->dbinterface->get_db_SccpTableData('SccpExtension');
|
||||
$data_sort = Array();
|
||||
$hint_list1 = $this->get_hint_info();
|
||||
foreach ($hint_list1 as $key => $value) {
|
||||
$data_sort[$value['name']] = $key;
|
||||
}
|
||||
ksort($data_sort);
|
||||
//print_r(count($data_sort));
|
||||
//print_r(count($hint_list1));
|
||||
foreach ($data_sort as $key => $value) {
|
||||
$hint_list[$value] = $hint_list1[$value];
|
||||
}
|
||||
//print_r($hint_list);
|
||||
//ksort($hint_list);
|
||||
//natsort($hint_list);
|
||||
$hint_list = $this->get_hint_info(true,array('context'=>'park-hints')) ;
|
||||
|
||||
// print_r($hint_list);
|
||||
$line_id =0;
|
||||
$max_buttons =56;
|
||||
$show_buttons =1;
|
||||
|
@ -56,6 +45,11 @@ if (!empty($_REQUEST['new_id'])) {
|
|||
}
|
||||
$show_buttons = $max_buttons;
|
||||
}
|
||||
if (!empty($_REQUEST['ru_id'])) {
|
||||
$dev_id = $_REQUEST['ru_id'];
|
||||
$db_buttons = $this->dbinterface->get_db_SccpTableData('get_sccpdevice_buttons', array("id" => $dev_id));
|
||||
$show_buttons = $max_buttons;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
@ -94,7 +88,7 @@ if (!empty($_REQUEST['new_id'])) {
|
|||
for ($line_id = 0; $line_id <=$max_buttons; $line_id ++){
|
||||
// print_r($db_buttons[$line_id]);
|
||||
$show_form_mode = '';
|
||||
$defaul_tv = (empty($db_buttons[$line_id])) ? "empty": $db_buttons[$line_id]['type'];
|
||||
$defaul_tv = (empty($db_buttons[$line_id])) ? "empty": $db_buttons[$line_id]['buttontype'];
|
||||
$defaul_btn = (empty($db_buttons[$line_id])) ? "": $db_buttons[$line_id]['name'];
|
||||
$defaul_opt = (empty($db_buttons[$line_id])) ? array(''): explode(',',$db_buttons[$line_id]['options']);
|
||||
|
||||
|
@ -122,6 +116,7 @@ if (!empty($_REQUEST['new_id'])) {
|
|||
$defaul_fcod = (empty($defaul_opt[1])) ? '': $defaul_opt[1];
|
||||
// print_r($defaul_fcod);
|
||||
}
|
||||
|
||||
foreach ($defaul_opt as $data_i) {
|
||||
if (strpos($data_i,'@')>0) {
|
||||
$test_btn = strtok($data_i,'@');
|
||||
|
@ -140,7 +135,7 @@ if (!empty($_REQUEST['new_id'])) {
|
|||
}
|
||||
}
|
||||
}
|
||||
// print_r($defaul_btn);
|
||||
// print_r($def_hint_btn);
|
||||
// print_r($defaul_opt);
|
||||
|
||||
echo '<!-- Begin button :'.$line_id.' -->';
|
||||
|
@ -211,8 +206,8 @@ if (!empty($_REQUEST['new_id'])) {
|
|||
echo '<select class="form-control" name="'.$forminfo[1]['name'].$line_id.'_hline" >';
|
||||
|
||||
foreach ($hint_list as $data){
|
||||
$select = (($data['hint']==$def_hint_btn)?"selected":"");
|
||||
echo '<option value="'.$data['hint'].'" '.$select.' >'.$data['name'].' / '.$data['label'].'</option>';
|
||||
$select = (($data['key']==$def_hint_btn)?"selected":"");
|
||||
echo '<option value="'.$data['key'].'" '.$select.' >'.$data['exten'].' / '.$data['label'].'</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
echo '</div>';
|
||||
|
|
|
@ -56,8 +56,11 @@ if (!is_array($moh_list)){
|
|||
$sofkey_list = \FreePBX::Sccp_manager()-> srvinterface -> sccp_list_keysets();
|
||||
$model_list = \FreePBX::Sccp_manager()->dbinterface->get_db_SccpTableData("HWDevice");
|
||||
$extension_list = \FreePBX::Sccp_manager()->dbinterface->get_db_SccpTableData("HWextension");
|
||||
$device_list = \FreePBX::Sccp_manager()->dbinterface->get_db_SccpTableData("SccpDevice");
|
||||
|
||||
$extension_list[]=array(model=>'NONE', vendor=>'CISCO', dns=>'0');
|
||||
$device_list[]=array(name=>'NONE', description=>'No Device');
|
||||
|
||||
|
||||
$items = $itm -> children();
|
||||
|
||||
|
@ -619,7 +622,7 @@ foreach ($items as $child) {
|
|||
* SDE - Extension List
|
||||
*/
|
||||
|
||||
if ($child['type'] == 'SDM' || $child['type'] == 'SDE' ) {
|
||||
if ($child['type'] == 'SDM' || $child['type'] == 'SDE' || $child['type'] == 'SDD') {
|
||||
// $value = $child -> select;
|
||||
$res_n = (string)$child ->name;
|
||||
$res_id = $npref.$res_n;
|
||||
|
@ -639,6 +642,9 @@ foreach ($items as $child) {
|
|||
if ($child['type'] == 'SDE') {
|
||||
$select_opt= $extension_list;
|
||||
}
|
||||
if ($child['type'] == 'SDD') {
|
||||
$select_opt = $device_list;
|
||||
}
|
||||
|
||||
echo '<!-- Begin '.$child->label.' -->';
|
||||
|
||||
|
@ -659,11 +665,12 @@ foreach ($items as $child) {
|
|||
}
|
||||
echo '>';
|
||||
|
||||
$fld = (string)$child->select['name'];
|
||||
$flv = (string)$child->select;
|
||||
$flk = (string)$child->select['dataid'];
|
||||
$flkv= (string)$child->select['dataval'];
|
||||
$key = (string)$child->default;
|
||||
$fld = (string)$child->select['name'];
|
||||
$flv = (string)$child->select;
|
||||
$flv2 = (string)$child->select['addlabel'];
|
||||
$flk = (string)$child->select['dataid'];
|
||||
$flkv = (string)$child->select['dataval'];
|
||||
$key = (string)$child->default;
|
||||
if (!empty($fvalues[$res_n])) {
|
||||
if (!empty($fvalues[$res_n]['data'])) {
|
||||
$child->value = $fvalues[$res_n]['data'];
|
||||
|
@ -682,7 +689,11 @@ foreach ($items as $child) {
|
|||
if (!empty($flkv)){
|
||||
echo ' data-val="'.$data[$flkv].'"';
|
||||
}
|
||||
echo '>' . $data[$flv] . '</option>';
|
||||
echo '>' . $data[$flv];
|
||||
if (!empty($flv2)){
|
||||
echo ' / '.$data[$flv2];
|
||||
}
|
||||
echo '</option>';
|
||||
}
|
||||
|
||||
?> </select>
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
* and open the template in the editor.
|
||||
*/
|
||||
// vim: set ai ts=4 sw=4 ft=phtml:
|
||||
|
||||
$roming_enable = '';
|
||||
if (!empty($this->sccpvalues['system_rouminguser'])) {
|
||||
if ($this->sccpvalues['system_rouminguser']['data'] == 'yes'){
|
||||
$roming_enable = 'yes';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="fpbx-container container-fluid">
|
||||
<div class="row">
|
||||
|
@ -24,6 +29,7 @@
|
|||
<!-- <th data-checkbox="true"></th> -->
|
||||
<th data-sortable="true" data-field="name"><?php echo _('Extension') ?></th>
|
||||
<th data-sortable="true" data-field="label"><?php echo _('Display Name') ?></th>
|
||||
<th data-sortable="true" data-field="line_statustext"><?php echo _('Status') ?></th>
|
||||
<th data-field="actions" data-formatter="DispayPhoneActionsKeyFormatter"><?php echo _('Actions') ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -34,6 +40,14 @@
|
|||
</div>
|
||||
<script>
|
||||
function DispayPhoneActionsKeyFormatter(value, row, index) {
|
||||
var exp_dev = '';
|
||||
var rmn_dev = '<?php echo $roming_enable ?>';
|
||||
exp_dev += '<a href="config.php?display=extensions&extdisplay=' + row['name'] + '"><i class="fa fa-pencil"></i></a> ';
|
||||
exp_dev += '<a class="clickable delete" data-id="' + row['name'] + '"><i class="fa fa-trash"></i></a>';
|
||||
if (rmn_dev == 'yes') {
|
||||
exp_dev += '<a href="config.php?display=sccp_phone&tech_hardware=r_user&ru_id=' + row['name'] + '"><i class="fa fa-bicycle"></i></a> ';
|
||||
}
|
||||
return exp_dev;
|
||||
return '<a href="config.php?display=extensions&extdisplay=' + row['name'] + '"><i class="fa fa-pencil"></i></a> <a class="clickable delete" data-id="' + row['name'] + '"><i class="fa fa-trash"></i></a>';
|
||||
}
|
||||
</script>
|
|
@ -27,6 +27,7 @@ $info = array();
|
|||
$info['srvinterface'] = $this->srvinterface->info();
|
||||
$info['extconfigs'] = $this->extconfigs->info();
|
||||
$info['dbinterface'] = $this->dbinterface->info();
|
||||
$info['aminterface'] = $this->aminterface->info();
|
||||
$db_Schema = $this->dbinterface->validate();
|
||||
|
||||
$info['XML'] = $this->xmlinterface->info();
|
||||
|
@ -90,29 +91,49 @@ if (empty($conf_realtime)) {
|
|||
}
|
||||
}
|
||||
//global $amp_conf;
|
||||
/*
|
||||
// ************************************************************************************
|
||||
print_r("<br> Request:<br><pre>");
|
||||
$json = '';
|
||||
print_r("<br>");
|
||||
// print_r($conf_realtime);
|
||||
print_r("<br>");
|
||||
print_r("<br>");
|
||||
print_r($this->dbinterface->validate());
|
||||
// print_r("DIRECT START");
|
||||
// print_r($this->sccpvalues['ccm_address']);
|
||||
//print_r($this->get_php_classes('\\FreePBX\\modules\\'));
|
||||
/*
|
||||
print_r(get_declared_classes());
|
||||
print_r($this->aminterface->open());
|
||||
|
||||
|
||||
print_r($this->aminterface->_error);
|
||||
print_r("<br>");
|
||||
// print_r($this->getIP_information2());
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//print_r($this->dbinterface->get_db_SccpTableData('SccpExtension'));
|
||||
// print_r($this->srvinterface->getеtestChanSCCP_GlablsInfo());
|
||||
// $test_data = $this->srvinterface-> astman_GetRaw('ExtensionStateList');
|
||||
// print_r($test_data);
|
||||
// print_r($this->srvinterface-> core_list_all_exten());
|
||||
// print_r($this->get_hint_info());
|
||||
// print_r($this->aminterface-> core_list_all_exten('exten'));
|
||||
// print_r($this->aminterface->Sok_param['total']);
|
||||
// print_r($this->srvinterface->t_get_meta_data());
|
||||
// print_r($this->sccp_metainfo);
|
||||
print("</pre>");
|
||||
|
||||
// ************************************************************************************
|
||||
|
||||
// $lang_arr = $this->extconfigs->getextConfig('sccp_lang','sk_SK');
|
||||
// print_r('<br>');
|
||||
// print_r(timezone_identifiers_list());
|
||||
// print_r('<br>');
|
||||
|
||||
//print_r($this->dbinterface->info());
|
||||
*/
|
||||
|
||||
if (!empty($this->class_error)) {
|
||||
?>
|
||||
<div class="fpbx-container container-fluid">
|
||||
|
|
Loading…
Reference in a new issue