Fix Issue #59
Correct error in update mode selection Save all buttons, rather than to last empty - buttons do not need to be allocated sequentially Remove on duplicate case - add should always be new as either device is new, or have deleted device data before.
This commit is contained in:
parent
e08ad858f5
commit
381fe184bd
|
@ -390,21 +390,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
|
|
||||||
// $lines_list = $this->dbinterface->getSccpDeviceTableData('SccpExtension');
|
// $lines_list = $this->dbinterface->getSccpDeviceTableData('SccpExtension');
|
||||||
$max_btn = (!empty($get_settings['buttonscount']) ? $get_settings['buttonscount'] : 60);
|
$max_btn = (!empty($get_settings['buttonscount']) ? $get_settings['buttonscount'] : 60);
|
||||||
$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'];
|
|
||||||
|
|
||||||
|
for ($it = 0; $it < $max_btn; $it++) {
|
||||||
|
if (!empty($get_settings["button${it}_type"])) {
|
||||||
|
$btn_t = $get_settings["button${it}_type"];
|
||||||
$btn_n = '';
|
$btn_n = '';
|
||||||
$btn_opt = '';
|
$btn_opt = '';
|
||||||
if ($it == 0) {
|
if ($it == 0) {
|
||||||
|
@ -412,9 +401,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
}
|
}
|
||||||
switch ($btn_t) {
|
switch ($btn_t) {
|
||||||
case 'feature':
|
case 'feature':
|
||||||
$btn_f = $get_settings['button' . $it . '_feature'];
|
$btn_f = $get_settings["button${it}_feature"];
|
||||||
// $btn_opt = (empty($get_settings['button' . $it . '_fvalue'])) ? '' : $get_settings['button' . $it . '_fvalue'];
|
// $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_n = (empty($get_settings["button${it}_flabel"])) ? $def_feature[$btn_f]['name'] : $get_settings["button${it}_flabel"];
|
||||||
$btn_opt = $btn_f;
|
$btn_opt = $btn_f;
|
||||||
if (!empty($def_feature[$btn_f]['value'])) {
|
if (!empty($def_feature[$btn_f]['value'])) {
|
||||||
if (empty($get_settings['button' . $it . '_fvalue'])) {
|
if (empty($get_settings['button' . $it . '_fvalue'])) {
|
||||||
|
@ -432,46 +421,46 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
|
||||||
break;
|
break;
|
||||||
case 'monitor':
|
case 'monitor':
|
||||||
$btn_t = 'speeddial';
|
$btn_t = 'speeddial';
|
||||||
$btn_opt = (string) $get_settings['button' . $it . '_line'];
|
$btn_opt = (string) $get_settings["button${it}_line"];
|
||||||
$db_res = $this->dbinterface->getSccpDeviceTableData('SccpExtension', array('name' => $btn_opt));
|
$db_res = $this->dbinterface->getSccpDeviceTableData('SccpExtension', array('name' => $btn_opt));
|
||||||
$btn_n = $db_res[0]['label'];
|
$btn_n = $db_res[0]['label'];
|
||||||
$btn_opt .= ',' . $btn_opt . $this->hint_context['default'];
|
$btn_opt .= ',' . $btn_opt . $this->hint_context['default'];
|
||||||
break;
|
break;
|
||||||
case 'speeddial':
|
case 'speeddial':
|
||||||
if (!empty($get_settings['button' . $it . '_input'])) {
|
if (!empty($get_settings["button${it}_input"])) {
|
||||||
$btn_n = $get_settings['button' . $it . '_input'];
|
$btn_n = $get_settings["button${it}_input"];
|
||||||
}
|
}
|
||||||
if (!empty($get_settings['button' . $it . '_phone'])) {
|
if (!empty($get_settings["button${it}_phone"])) {
|
||||||
$btn_opt = $get_settings['button' . $it . '_phone'];
|
$btn_opt = $get_settings["button${it}_phone"];
|
||||||
if (empty($btn_n)) {
|
if (empty($btn_n)) {
|
||||||
$btn_n = $btn_opt;
|
$btn_n = $btn_opt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($get_settings['button' . $it . '_hint'])) {
|
if (!empty($get_settings["button${it}_hint"])) {
|
||||||
if ($get_settings['button' . $it . '_hint'] == "hint") {
|
if ($get_settings["button${it}_hint"] == "hint") {
|
||||||
if (empty($btn_n)) {
|
if (empty($btn_n)) {
|
||||||
$btn_t = 'line';
|
$btn_t = 'line';
|
||||||
$btn_n = $get_settings['button' . $it . '_hline'] . '!silent';
|
$btn_n = $get_settings["button${it}_hline"] . '!silent';
|
||||||
$btn_opt = '';
|
$btn_opt = '';
|
||||||
} else {
|
} else {
|
||||||
// $btn_opt .= ',' . $get_settings['button' . $it . '_hline'] . $this->hint_context['default'];
|
// $btn_opt .= ',' . $get_settings['button' . $it . '_hline'] . $this->hint_context['default'];
|
||||||
$btn_opt .= ',' . $get_settings['button' . $it . '_hline'];
|
$btn_opt .= ',' . $get_settings["button${it}_hline"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'adv.line':
|
case 'adv.line':
|
||||||
$btn_t = 'line';
|
$btn_t = 'line';
|
||||||
$btn_n = (string) $get_settings['button' . $it . '_line'];
|
$btn_n = (string) $get_settings["button${it}_line"];
|
||||||
$btn_n .= '@' . (string) $get_settings['button' . $it . '_advline'];
|
$btn_n .= '@' . (string) $get_settings["button${it}_advline"];
|
||||||
$btn_opt = (string) $get_settings['button' . $it . '_advopt'];
|
$btn_opt = (string) $get_settings["button${it}_advopt"];
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'line':
|
case 'line':
|
||||||
case 'silent':
|
case 'silent':
|
||||||
if (isset($get_settings['button' . $it . '_line'])) {
|
if (isset($get_settings["button${it}_line"])) {
|
||||||
$btn_n = (string) $get_settings['button' . $it . '_line'];
|
$btn_n = (string) $get_settings["button${it}_line"];
|
||||||
if ($it > 0) {
|
if ($it > 0) {
|
||||||
if ($btn_t == 'silent') {
|
if ($btn_t == 'silent') {
|
||||||
$btn_n .= '!silent';
|
$btn_n .= '!silent';
|
||||||
|
|
|
@ -334,27 +334,7 @@ class dbinterface
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
foreach ($save_value as $button_array) {
|
foreach ($save_value as $button_array) {
|
||||||
$stmt = $this->db->prepare("INSERT INTO sccpbuttonconfig SET ref = :ref, reftype = :reftype, instance = :instance, buttontype = :buttontype, name = :name, options = :options
|
$stmt = $this->db->prepare("INSERT INTO sccpbuttonconfig SET ref = :ref, reftype = :reftype, instance = :instance, buttontype = :buttontype, name = :name, options = :options");
|
||||||
ON DUPLICATE KEY UPDATE ref = :refU, reftype = :reftypeU, instance = :instanceU, buttontype = :buttontypeU, name = :nameU, options = :optionsU");
|
|
||||||
$stmt->bindParam(':ref', $button_array['ref'],\PDO::PARAM_STR);
|
|
||||||
$stmt->bindParam(':reftype', $button_array['reftype'],\PDO::PARAM_STR);
|
|
||||||
$stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT);
|
|
||||||
$stmt->bindParam(':buttontype', $button_array['buttontype'],\PDO::PARAM_STR);
|
|
||||||
$stmt->bindParam(':name', $button_array['name'],\PDO::PARAM_STR);
|
|
||||||
$stmt->bindParam(':options', $button_array['options'],\PDO::PARAM_STR);
|
|
||||||
$stmt->bindParam(':refU', $button_array['ref'],\PDO::PARAM_STR);
|
|
||||||
$stmt->bindParam(':reftypeU', $button_array['reftype'],\PDO::PARAM_STR);
|
|
||||||
$stmt->bindParam(':instanceU', $button_array['instance'],\PDO::PARAM_INT);
|
|
||||||
$stmt->bindParam(':buttontypeU', $button_array['buttontype'],\PDO::PARAM_STR);
|
|
||||||
$stmt->bindParam(':nameU', $button_array['name'],\PDO::PARAM_STR);
|
|
||||||
$stmt->bindParam(':optionsU', $button_array['options'],\PDO::PARAM_STR);
|
|
||||||
$result = $stmt->execute();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
/*
|
|
||||||
case 'add':
|
|
||||||
foreach ($save_value as $button_array) {
|
|
||||||
$stmt = $this->db->prepare('INSERT INTO sccpbuttonconfig (ref, reftype, instance, buttontype, name, options) VALUES (:ref, :reftype, :instance, :buttontype, :name, :options)');
|
|
||||||
$stmt->bindParam(':ref', $button_array['ref'],\PDO::PARAM_STR);
|
$stmt->bindParam(':ref', $button_array['ref'],\PDO::PARAM_STR);
|
||||||
$stmt->bindParam(':reftype', $button_array['reftype'],\PDO::PARAM_STR);
|
$stmt->bindParam(':reftype', $button_array['reftype'],\PDO::PARAM_STR);
|
||||||
$stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT);
|
$stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT);
|
||||||
|
@ -362,9 +342,9 @@ class dbinterface
|
||||||
$stmt->bindParam(':name', $button_array['name'],\PDO::PARAM_STR);
|
$stmt->bindParam(':name', $button_array['name'],\PDO::PARAM_STR);
|
||||||
$stmt->bindParam(':options', $button_array['options'],\PDO::PARAM_STR);
|
$stmt->bindParam(':options', $button_array['options'],\PDO::PARAM_STR);
|
||||||
$result = $stmt->execute();
|
$result = $stmt->execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
*/
|
|
||||||
case 'clear';
|
case 'clear';
|
||||||
// Clear is equivalent of delete + insert. Mode is used in order to activate trigger.
|
// Clear is equivalent of delete + insert. Mode is used in order to activate trigger.
|
||||||
$this->write('sccpbuttons', '', $mode = 'delete','', $hwid);
|
$this->write('sccpbuttons', '', $mode = 'delete','', $hwid);
|
||||||
|
|
|
@ -647,9 +647,9 @@ trait ajaxHelper {
|
||||||
$save_codec = array();
|
$save_codec = array();
|
||||||
$name_dev = '';
|
$name_dev = '';
|
||||||
$db_field = array_keys($this->dbinterface->getSccpDeviceTableData("get_columns_sccpdevice"));
|
$db_field = array_keys($this->dbinterface->getSccpDeviceTableData("get_columns_sccpdevice"));
|
||||||
$hw_id = (empty($get_settings['sccp_deviceid'])) ? 'new' : $get_settings['sccp_deviceid'];
|
$hw_id = (empty($get_settings['sccp_device_id'])) ? 'new' : $get_settings['sccp_device_id'];
|
||||||
$hw_type = (empty($get_settings['sccp_device_typeid'])) ? 'sccpdevice' : $get_settings['sccp_device_typeid'];
|
$hw_type = (empty($get_settings['sccp_device_typeid'])) ? 'sccpdevice' : $get_settings['sccp_device_typeid'];
|
||||||
$update_hw = ($hw_id == 'new') ? 'add' : 'clear'; // Clear is delete + add
|
$update_hw = ($hw_id == 'new') ? 'add' : 'clear'; // Clear is delete + add. Only used for buttons
|
||||||
$hw_prefix = 'SEP';
|
$hw_prefix = 'SEP';
|
||||||
if (!empty($get_settings[$hdr_prefix . 'type'])) {
|
if (!empty($get_settings[$hdr_prefix . 'type'])) {
|
||||||
$value = $get_settings[$hdr_prefix . 'type'];
|
$value = $get_settings[$hdr_prefix . 'type'];
|
||||||
|
|
Loading…
Reference in a new issue