Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fixes and optimisations as a result of issue 106 #108

Open
wants to merge 39 commits into
base: extension_mobility
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
14199fc
Switch to PDO model
steve-lad Feb 6, 2021
c1fb937
Test for chan_sccp_b version compatibility
steve-lad Feb 7, 2021
c104b0e
Switch to PDO model
steve-lad Feb 6, 2021
22e1939
Cleaning up
steve-lad Feb 7, 2021
1972e53
Merge branch 'Fix-dbinterface-class' of https://github.com/steve-lad/…
steve-lad Feb 8, 2021
6664ab9
Further clean ups and annotations
steve-lad Feb 8, 2021
89d4e45
Update Transactions and fix errors
steve-lad Feb 8, 2021
175346c
Use bindParam on db executes
steve-lad Feb 9, 2021
b3d31b6
Fix assignment sccp_compatible
steve-lad Feb 9, 2021
7993eec
Test for chan_sccp_b version compatibility
steve-lad Feb 7, 2021
5e5633e
Switch to PDO model
steve-lad Feb 6, 2021
22a4eb6
Cleaning up
steve-lad Feb 7, 2021
124f705
Further clean ups and annotations
steve-lad Feb 8, 2021
7d7b8cd
Update Transactions and fix errors
steve-lad Feb 8, 2021
73ea302
Use bindParam on db executes
steve-lad Feb 9, 2021
63e5be2
Merge branch 'Fix-dbinterface-class' of https://github.com/steve-lad/…
steve-lad Feb 11, 2021
6bfa311
Final version
steve-lad Feb 11, 2021
80923f5
Remove dbugs
steve-lad Feb 11, 2021
3362f5a
Update dbinterface.class.php
steve-lad Feb 11, 2021
c6c2134
Bug Fixes and optimisations as a result of issue 106
steve-lad Feb 24, 2021
6e2101d
Tidy up exception handling
steve-lad Feb 27, 2021
2b07718
Correct Field and add new event classes
steve-lad Feb 28, 2021
d5290f1
Tighten Ami controls
steve-lad Mar 12, 2021
0f9ebb8
Tidy up
steve-lad Mar 12, 2021
cc8eb54
Fix exception if sccpsettings table does not exist
steve-lad Mar 13, 2021
9ae3638
Correct type declarations
steve-lad Mar 13, 2021
7030ec2
Migrate from global db object
steve-lad Mar 13, 2021
da9517a
Apply PR 101
steve-lad Mar 13, 2021
fdf6c2a
Merge branch 'Fix-dbinterface-class' into Issue-106
steve-lad Mar 13, 2021
c24f6ad
Merge Fix-dbinterface-class
steve-lad Mar 13, 2021
815e569
Update install.php
steve-lad Mar 13, 2021
f560a1e
Remove tmp nfs files
steve-lad Mar 14, 2021
fe6ff74
Bug fixes
steve-lad Mar 17, 2021
118ff43
Update dbinterface.class.php
steve-lad Mar 18, 2021
03dd9be
Correct string quoting
steve-lad Mar 23, 2021
e3116d3
Update dbinterface.class.php
steve-lad Mar 24, 2021
b79498d
Fix Sccp Button Save
steve-lad Mar 29, 2021
4271742
Update dbinterface.class.php
steve-lad Mar 31, 2021
45db467
Remove PHP % incompatible code
steve-lad Apr 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 32 additions & 36 deletions Sccp_manager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ public function __construct($freepbx = null) {
$this->xml_data = simplexml_load_file($xml_vars);
$this->initVarfromXml(); // Overwrite Exist
}

if (get_class($freepbx) === 'FreePBX') {
// only save settings when building a new FreePBX object
$this->saveSccpSettings();
}
}

/*
Expand Down Expand Up @@ -269,25 +274,25 @@ public function doConfigPageInit($page) {
/* unused but FPBX API requires it */

public function install() {

}

/* unused but FPBX API requires it */

public function uninstall() {

}

/* unused but FPBX API requires it */

public function backup() {

}

/* unused but FPBX API requires it */

public function restore($backup) {

}

public function getActionBar($request) {
Expand Down Expand Up @@ -642,6 +647,8 @@ public function getRightNav($request) {
}

public function ajaxRequest($req, &$setting) {
// Called first by BMO. Must return true or request will be aborted.
// See https://wiki.freepbx.org/display/FOP/BMO+Ajax+Calls
switch ($req) {
case 'backupsettings':
case 'savesettings':
Expand Down Expand Up @@ -670,11 +677,13 @@ public function ajaxRequest($req, &$setting) {
case 'delete_dialplan':
return true;
break;
default:
return false;
}
return false;
}

// !TODO!: this should go into it's only ajam.html.php file (see: dahdiconfig)
// !TODO!: this should go into it's only ajax.html.php file (see: dahdiconfig)
// ajaxHandler is called after ajaxRequest returns true
public function ajaxHandler() {
$request = $_REQUEST;
$msg = array();
Expand Down Expand Up @@ -733,12 +742,12 @@ public function ajaxHandler() {
foreach ($request['idn'] as $idv) {
if ($this->strpos_array($idv, array('SEP', 'ATA', 'VG')) !== false) {
$this->dbinterface->write('sccpdevice', array('name' => $idv), 'delete', "name");
$this->dbinterface->write("sccpbuttons", array(), 'delete', '', $idv);
$this->dbinterface->write('sccpbuttons', array(), 'delete', '', $idv);
$this->deleteSccpDeviceXML($idv); // Концы в вводу !!
$this->srvinterface->sccpDeviceReset($idv);
}
}
return array('status' => true, 'table_reload' => true, 'message' => 'HW is Delete ! ');
return array('status' => true, 'table_reload' => true, 'message' => 'Hardware device has been deleted! ');
}
break;
case 'create_hw_tftp':
Expand Down Expand Up @@ -815,14 +824,13 @@ public function ajaxHandler() {
$hw_list[] = array('name' => $idv);
}
if ($idv == 'all') {

}
}
}
$res = $this->updateSccpButtons($hw_list);
$msg .= $res['Response'] . ' raw: ' . $res['data'] . ' ';
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');
Expand All @@ -846,7 +854,7 @@ public function ajaxHandler() {
return $save_settings;
break;
case 'model_enabled':
$model_set = '1';
$model_set = '1'; // fall through intentionally
case 'model_disabled':
if ($request['command'] == 'model_disabled') {
$model_set = '0';
Expand All @@ -859,7 +867,6 @@ public function ajaxHandler() {
}
}
return array('status' => true, 'table_reload' => true);

break;
case 'model_delete':
if (!empty($request['model'])) {
Expand Down Expand Up @@ -1161,7 +1168,7 @@ function saveSccpDevice($get_settings, $validateonly = false) {
$save_settings = array();
$save_codec = array();
$name_dev = '';
$db_field = $this->dbinterface->HWextension_db_SccpTableData("get_colums_sccpdevice");
$db_field = $this->dbinterface->HWextension_db_SccpTableData("get_columns_sccpdevice");
$hw_id = (empty($get_settings['sccp_deviceid'])) ? 'new' : $get_settings['sccp_deviceid'];
$hw_type = (empty($get_settings['sccp_device_typeid'])) ? 'sccpdevice' : $get_settings['sccp_device_typeid'];
$update_hw = ($hw_id == 'new') ? 'update' : 'clear';
Expand Down Expand Up @@ -1282,9 +1289,9 @@ function saveSccpDevice($get_settings, $validateonly = false) {
$save_settings[$key] = $value;
}
}
$this->dbinterface->write("sccpdevice", $save_settings, 'replace');
$this->dbinterface->write('sccpdevice', $save_settings, 'replace');
$save_buttons = $this->getPhoneButtons($get_settings, $name_dev, $hw_type);
$this->dbinterface->write("sccpbuttons", $save_buttons, $update_hw, '', $name_dev);
$this->dbinterface->write('sccpbuttons', $save_buttons, $update_hw, '', $name_dev);
$this->createSccpDeviceXML($name_dev);
if ($hw_id == 'new') {
$this->srvinterface->sccpDeviceReset($name_dev);
Expand Down Expand Up @@ -1403,7 +1410,7 @@ function handleRoamingUsers($get_settings, $validateonly = false) {
);
*/
$name_dev = '';
$db_field = $this->dbinterface->HWextension_db_SccpTableData("get_colums_sccpuser");
$db_field = $this->dbinterface->HWextension_db_SccpTableData("get_columns_sccpuser");
// $hw_id = (empty($get_settings['sccp_deviceid'])) ? 'new' : $get_settings['sccp_deviceid'];
// $update_hw = ($hw_id == 'new') ? 'update' : 'clear';
$hw_prefix = 'SEP';
Expand Down Expand Up @@ -1475,18 +1482,15 @@ function handleRoamingUsers($get_settings, $validateonly = false) {
$save_settings[$key] = $value;
}
}
$this->dbinterface->write("sccpuser", $save_settings, 'replace', 'name');
$this->dbinterface->write("sccpbuttons", $save_buttons, 'clear', '', $name_dev);
$this->dbinterface->write('sccpuser', $save_settings, 'replace', 'name');
$this->dbinterface->write('sccpbuttons', $save_buttons, 'delete', '', $name_dev); //standardise to delete
return $save_buttons;

// Why is there a second return here???????
return $save_settings;
}

public function getSccpSettingFromDB() {
$raw_data = $this->dbinterface->get_db_SccpSetting();
foreach ($raw_data as $var) {
$this->sccpvalues[$var['keyword']] = array('keyword' => $var['keyword'], 'data' => $var['data'], 'seq' => $var['seq'], 'type' => $var['type']);
}
$this->sccpvalues = $this->dbinterface->get_db_SccpSetting();
return;
}

Expand Down Expand Up @@ -1735,7 +1739,7 @@ function initializeSccpPath() {
}
}

$this->sccpvalues['sccp_compatible'] = array('keyword' => 'compatible', 'data' => $ver_id, 'type' => '1', 'seq' => '99');
$this->sccpvalues['sccp_compatible'] = array('keyword' => 'sccp_compatible', 'data' => $ver_id, 'type' => '1', 'seq' => '99');
$this->sccppath = $this->extconfigs->validate_init_path($confDir, $this->sccpvalues, $sccp_driver_replace);
$driver = $this->FreePBX->Core->getAllDriversInfo(); // ??????

Expand Down Expand Up @@ -1852,7 +1856,7 @@ private function updateSccpButtons($hw_list = array()) {
if (empty($save_buttons)) {
return array('Response' => 'No update required', 'data' => ' 0 - records ');
}
$res = $this->dbinterface->write("sccpbuttons", $save_buttons, 'replace', '', '');
$res = $this->dbinterface->write('sccpbuttons', $save_buttons, 'replace', '', '');
return array('Response' => 'Update records :' . count($save_buttons), 'data' => $res);
}

Expand All @@ -1864,17 +1868,11 @@ private function saveSccpSettings($save_value = array()) {
// global $db;
// global $amp_conf;

$save_settings = array();
// $save_settings = array();
if (empty($save_value)) {
foreach ($this->sccpvalues as $key => $val) {
if ((trim($val['data']) !== '') or ($val['data'] == '0')) {
$save_settings[] = array($key, $db->escapeSimple($val['data']), $val['seq'], $val['type']);
}
}
$this->dbinterface->write('sccpsettings', $save_settings, 'clear');
$this->dbinterface->write('sccpsettings', $this->sccpvalues, 'replace'); //Change to replace as clearer
} else {
$this->dbinterface->write('sccpsettings', $save_value, 'update');
return true;
}
return true;
}
Expand Down Expand Up @@ -2093,7 +2091,7 @@ function createDefaultSccpConfig() {
}
// [Namesoftkeyset]
// type=softkeyset
//
//
// ----- It is a very bad idea to add an external configuration file "sccp_custom.conf" !!!!
// This will add problems when solving problems caused by unexpected solutions from users.
//
Expand Down Expand Up @@ -2136,9 +2134,7 @@ function getSccpModelInformation($get = "all", $validate = false, $format_list =
} else {
$dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly');
}

$raw_settings = $this->dbinterface->getDb_model_info($get, $format_list, $filter);

if ($validate) {
for ($i = 0; $i < count($raw_settings); $i++) {
$raw_settings[$i]['validate'] = '-;-';
Expand Down
Loading