diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index be1ac21..14cf855 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -106,6 +106,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public $sccp_conf_init = array(); public $xml_data; public $class_error; //error construct + public $info_warning; public function __construct($freepbx = null) { if ($freepbx == null) { @@ -621,6 +622,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case 'model_update': case 'model_add': case 'model_delete': + case 'update_button_label': case 'updateSoftKey': case 'deleteSoftKey': case 'delete_dialplan': @@ -646,6 +648,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->sccp_create_tftp_XML(); $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'sccp_reload')); +// $res = $this->srvinterface->sccp_core_commands(array('cmd' => 'restart_phone')); $msg = 'Config Saved: ' . $res['Response'] . '. Info :' . $res['data']; // needreload(); // !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) @@ -755,6 +758,24 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return array('status' => true, 'message' => 'Reset command send ' . $msg, 'reload' => true); // } break; + case 'update_button_label': + $msg = ''; + $hw_list = array(); +// return array('status' => false, 'message' => 'update_button_label send ' . $msg, 'reload' => false); + if (!empty($request['name'])) { + foreach ($request['name'] as $idv) { + if (!(strpos($idv, 'SEP') === false)) { + $hw_list[] = array('name' => $idv); + } + if ($idv == 'all') { + } + } + } + $res = $this->sccp_db_update_butons($hw_list); + $msg .= $res['Response'] . ' raw: ' . $res['data'] . ' '; +// !TODO!: It is necessary in the future to check, and replace all server responses on correct messages. Use _(msg) + return array('status' => true, 'message' => 'Update Butons Labels Complite ' . $msg, 'reload' => true); + case 'model_add': $save_settings = array(); $key_name = array('model', 'vendor', 'dns', 'buttons', 'loadimage', 'loadinformationid', 'nametemplate'); @@ -1792,6 +1813,52 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $errors; } + /* + * Update Butons Labels on mysql DB + * + */ + private function sccp_db_update_butons($hw_list = array()) { + + $save_buttons = array(); + if (!empty($hw_list)) { + $buton_list = array(); + foreach ($hw_list as $value) { + $buton_tmp =$this->dbinterface->get_db_SccpTableData("get_sccpdevice_buttons", array('buttontype'=>'speeddial','id'=>$value['name'])); +// die(print_r($buton_tmp,1)); + if (!empty($buton_tmp)) { + $buton_list = array_merge($buton_list, $buton_tmp); + } + } + } else { + $buton_list = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_buttons", array('buttontype'=>'speeddial')); + } +// die(print_r($buton_list,1)); + if (empty($buton_list)) { + return array('Response'=> ' Found 0 device ', 'data'=> ''); + } + $copy_fld = array('ref','reftype','instance','buttontype'); + $user_list = $user_list = $this->dbinterface->get_db_SccpTableByID("SccpExtension",Array(),'name'); + foreach ($buton_list as $value) { + $btn_opt = explode(',',$value['options']); + $btn_id = $btn_opt[0]; + if (!empty($user_list[$btn_id])){ + if ($user_list[$btn_id]['label'] != $value['name']) { + $btn_data['name'] = $user_list[$btn_id]['label']; + foreach ($copy_fld as $ckey) { + $btn_data[$ckey] = $value[$ckey]; + } + $save_buttons[] = $btn_data; + } + + } + } + if (empty($save_buttons)) { + return array('Response'=> 'No update required', 'data'=> ' 0 - records '); + } + $res = $this->dbinterface->sccp_save_db("sccpbuttons", $save_buttons, 'replace', '',''); + return array('Response'=> 'Update records :'.count($save_buttons),'data'=>$res); + } + /* * Save Config Value to mysql DB * sccp_db_save_setting(empty) - Save All settings from $sccpvalues diff --git a/Sccp_manager.inc/dbinterface.class.php b/Sccp_manager.inc/dbinterface.class.php index 5be7aa3..ee0bb0e 100644 --- a/Sccp_manager.inc/dbinterface.class.php +++ b/Sccp_manager.inc/dbinterface.class.php @@ -26,6 +26,18 @@ class dbinterface { /* * Core Access Function */ + public function get_db_SccpTableByID($dataid, $data = array(), $indexField = '') { + $resut = array(); + $raw = $this->get_db_SccpTableData($dataid, $data); + if ( empty($raw) || empty($indexField)) { + return $raw; + } + foreach ($raw as $value) { + $id = $value[$indexField]; + $resut[$id] = $value; + } + return $resut; + } public function get_db_SccpTableData($dataid, $data = array()) { if ($dataid == '') { @@ -76,8 +88,19 @@ class dbinterface { $raw_settings = sql($sql, "getRow", DB_FETCHMODE_ASSOC); break; case "get_sccpdevice_buttons": - $sql = 'SELECT * FROM sccpbuttonconfig WHERE ref="' . $data['id'] . '" ORDER BY `instance`;'; - $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); + $sql = ''; + if (!empty($data['buttontype'])) { + $sql .= 'buttontype="' . $data['buttontype'] . '" '; + } + if (!empty($data['id'])) { + $sql .= (empty($sql)) ? 'ref="' . $data['id'] . '" ' : 'and ref="' . $data['id'] . '" '; + } + if (!empty($sql)) { + $sql = 'SELECT * FROM sccpbuttonconfig WHERE ' .$sql. 'ORDER BY `instance`;'; + $raw_settings = sql($sql, "getAll", DB_FETCHMODE_ASSOC); + } else { + $raw_settings = Array(); + } break; } @@ -90,6 +113,12 @@ class dbinterface { return $raw_settings; } + public function get_db_sysvalues() { + $sql = "SHOW VARIABLES LIKE '%group_concat%'"; + $raw_settings = sql($sql, "getRow", DB_FETCHMODE_ASSOC); + return $raw_settings; + } + /* * Get Sccp Device Model information */ @@ -213,11 +242,20 @@ class dbinterface { if ($mode == 'delete') { break; } - if (!empty($save_value)) { + if (empty($save_value)) { + break; + } + if ($mode == 'replace') { + $sql = 'UPDATE `sccpbuttonconfig` SET `name`=? WHERE `ref`= ? AND `reftype`=? AND `instance`=? AND `buttontype`=?;'; +// $sql = 'INSERT INTO `sccpbuttonconfig` (`ref`, `reftype`,`instance`, `buttontype`, `name`, `options`) VALUES (?,?,?,?,?,?);'; +// die(print_r($save_value,1)); + $stmt = $db->prepare($sql); + $result= $db->executeMultiple($stmt, $save_value); + } else { $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); + $result = $db->executeMultiple($stmt, $save_value); } break; diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 36bec58..81640b4 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -601,16 +601,26 @@ $(document).ready(function () { } } - if ($(this).data('id') === 'reset_dev' || $(this).data('id') === 'reset_token') { + if ($(this).data('id') === 'reset_dev' || $(this).data('id') === 'reset_token' || $(this).data('id') === 'update_button_label' ) { var dev_cmd = $(this).data('id'); var datas = ''; var i = 0; + var conf_msg = '??????'; + if ($(this).data('id') === 'reset_dev') { + conf_msg = 'Reset All device ?'; + } + if ($(this).data('id') === 'reset_token') { + conf_msg = 'Reset Token on All device ?'; + } + if ($(this).data('id') === 'update_button_label') { + conf_msg = 'Update Butons Labels on All device ?'; + } $('table').bootstrapTable('getSelections').forEach(function (entry) { datas = datas + 'name[' + i + ']=' + entry['name'] + '&'; i++; }); if (datas === '') { - if (confirm('Resaet All device')) { + if (confirm(conf_msg)) { datas = 'name[0]=all'; } else { dev_cmd = ''; diff --git a/contrib/rewrite.rules b/contrib/rewrite.rules index 7e3bbed..d8edaf3 100644 --- a/contrib/rewrite.rules +++ b/contrib/rewrite.rules @@ -185,8 +185,8 @@ ri ^(ATA030204SCCP090202A.zup)$ firmware/ata186/\1 #ri ^(.+\.sbn)$ firmware/\1 # Keep locales in a separate directory (optional) -ri ^(.+)\/(.+-sccp.jar)$ locales/\1/\2 -ri ^(.+)\/(.+-dictionary.xml)$ locales/\1/\2 +ri ^(.+)\/(.+-sccp.jar)$ languages/\1/\2 +ri ^(.+)\/(.+-dictionary.xml)$ languages/\1/\2 ri ^(.+)\/(.+-dictionary-ext.xml)$ languages/\1/\2 ri ^(.+)\/(.+-tones.xml)$ languages/\1/\2 ri ^(.+)\/(.+-font.xml)$ languages/\1/\2 diff --git a/install.php b/install.php index 4d908ce..8d00870 100644 --- a/install.php +++ b/install.php @@ -266,6 +266,7 @@ function Get_DB_config($sccp_compatible) { 'video_tos' => array('def_modify' => "0x88"), 'video_cos' => array('def_modify' => "5"), 'trustphoneip' => array('drop' => "yes"), + 'transfer_on_hangup' => array('create' => "enum('on','off') NULL DEFAULT NULL", 'modify' => "enum('on','off')"), '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')"), @@ -330,7 +331,7 @@ function Get_DB_config($sccp_compatible) { '_description' => array('rename' => "description"), '_loginname' => array('drop' => "yes"), '_profileid' => array('drop' => "yes"), - + 'transfer_on_hangup' => array('create' => "enum('on','off') NULL DEFAULT NULL", 'modify' => "enum('on','off')"), ), 'sccpline' => array( 'directed_pickup' => array('create' => "enum('on','off') NULL default NULL", 'modify' => "enum('on','off')"), diff --git a/views/form.buttons.php b/views/form.buttons.php index 5cf70b7..acae18d 100644 --- a/views/form.buttons.php +++ b/views/form.buttons.php @@ -254,3 +254,6 @@ if (!empty($_REQUEST['ru_id'])) { +
+

+
diff --git a/views/hardware.phone.php b/views/hardware.phone.php index 38fee97..36eaade 100644 --- a/views/hardware.phone.php +++ b/views/hardware.phone.php @@ -21,6 +21,9 @@ + diff --git a/views/server.info.php b/views/server.info.php index abfec8c..bf64082 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -30,6 +30,9 @@ $info['dbinterface'] = $this->dbinterface->info(); $info['aminterface'] = $this->aminterface->info(); $db_Schema = $this->dbinterface->validate(); +$mysql_info = $this->dbinterface->get_db_sysvalues(); + + $info['XML'] = $this->xmlinterface->info(); $info['sccp_class'] = $driver['sccp']; $info['Core_sccp'] = array('Version' => $core['Version'], 'about'=> 'Sccp ver.'. $core['Version'].' r'.$core['vCode']. ' Revision :'. $core['RevisionNum']. ' Hash :'. $core['RevisionHash']); @@ -89,30 +92,27 @@ if (empty($conf_realtime)) { if (!empty($rt_info)) { $info['ConfigsRealTime'] = array('Version' => 'Error', 'about'=> $rt_info); } +} +// $mysql_info +if ($mysql_info['Value'] <= '2000') { + $this->info_warning['MySql'] = Array('Increase Mysql Group Concat Max. Length','Step 1: Go to mysql path
nano /etc/my.cnf', + 'Step 2: And add the following line below [mysqld] as shown below
[mysql]
group_concat_max_len = 4096 or more', + 'Step 3: Save and restart
systemctl restart mariadb.service
Or
service mysqld restart'); } //global $amp_conf; // ************************************************************************************ -print_r("
Request:
");
- $json = '';
+$buton_list = $this->dbinterface->get_db_SccpTableData("get_sccpdevice_buttons", array('buttontype'=>'speeddial'));
+$user_list = $this->dbinterface->get_db_SccpTableByID("SccpExtension",Array(),'name');
+
+print_r("
Help Info:
");
  print_r("
"); -// print_r($conf_realtime); + //print_r($buton_list); print_r("
"); + print_r($user_list); print_r("
"); // 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("
"); - - */ - - - //print_r($this->dbinterface->get_db_SccpTableData('SccpExtension')); // print_r($this->srvinterface->getеtestChanSCCP_GlablsInfo()); // $test_data = $this->srvinterface-> astman_GetRaw('ExtensionStateList'); @@ -134,6 +134,33 @@ print_r("
Request:
");
 
 //print_r($this->dbinterface->info());
 
+ if (!empty($this->info_warning)) {
+    ?>    
+    
+
+
+

Sccp Manager Warning

+
+
There are Warning in the SCCP Module:
+                        info_warning as $key => $value) {
+                                echo '

'.$key.'

'; + if (is_array($value)) { + echo '
  • '.implode('
  • ',$value).'
  • '; + } else { + echo '
  • '.$value.'
  • '; + } + } + ?> +
    +

    Check these problems before continuing to work.


    +
    +
    +
    +
    +
    +class_error)) { ?>