From efdf2d04694a63127128521e05e4f6ac70e03187 Mon Sep 17 00:00:00 2001
From: steve-lad <72376554+steve-lad@users.noreply.github.com>
Date: Thu, 17 Jun 2021 18:39:32 +0200
Subject: [PATCH] Added sccpline fields
WIP Still have issue with def_modify in installer
---
install.php | 31 ++++++++++++++++++++--------
sccpManClasses/dbinterface.class.php | 3 +++
sccpManTraits/ajaxHelper.php | 4 ++--
sccpManTraits/helperFunctions.php | 7 ++++---
views/form.adddevice.php | 2 +-
views/server.advanced.php | 2 +-
views/server.device.php | 5 ++++-
views/server.setting.php | 15 +++++++-------
8 files changed, 44 insertions(+), 25 deletions(-)
diff --git a/install.php b/install.php
index 73c07a4..47a0386 100644
--- a/install.php
+++ b/install.php
@@ -116,10 +116,10 @@ function Get_DB_config($sccp_compatible)
'earlyrtp' => array('create' => "ENUM('immediate','offHook','dialing','ringout','progress','none') NOT NULL default 'none'",
'modify' => "ENUM('immediate','offHook','dialing','ringout','progress','none')"),
'monitor' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
- 'audio_tos' => array('def_modify' => "0xB8"),
- 'audio_cos' => array('def_modify' => "6"),
- 'video_tos' => array('def_modify' => "0x88"),
- 'video_cos' => array('def_modify' => "5"),
+ 'audio_tos' => array('create' => "VARCHAR(11) NOT NULL default '0xB8'",'modify' => "0xB8"),
+ 'audio_cos' => array('create' => "VARCHAR(11) NOT NULL default '0x6'",'modify' => "0x6"),
+ 'video_tos' => array('create' => "VARCHAR(11) NOT NULL default '0x88'",'modify' => "0x88"),
+ 'video_cos' => array('create' => "VARCHAR(11) NOT NULL default '0x5'",'modify' => "0x5"),
'trustphoneip' => array('drop' => "yes"),
'transfer_on_hangup' => array('create' => "enum('on','off') NOT NULL DEFAULT 'off'", 'modify' => "enum('on','off')"),
'phonecodepage' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL', 'modify' => "VARCHAR(50)"),
@@ -242,10 +242,22 @@ function Get_DB_config($sccp_compatible)
'_remotehangup_tone' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"),
'_transfer_tone' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"),
'_callwaiting_tone' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"),
- '_callanswerorder' => array('create' => 'create' => "enum('oldestfirst','latestfirst') NOT NULL default 'latestfirst'",
- 'modify' => "enum('oldestfirst','latestfirst')"),
+ '_callanswerorder' => array('create' => "enum('oldestfirst','latestfirst') NOT NULL default 'latestfirst'",
+ 'modify' => "enum('oldestfirst','latestfirst')"),
'_echocancel' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
- '_silencesuppression' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)")
+ '_silencesuppression' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"),
+ '_sccp_tos' => array('create' => "VARCHAR(11) NOT NULL default '0x68'", 'modify' => "VARCHAR(11)"),
+ '_sccp_cos' => array('create' => "VARCHAR(11) NOT NULL default '0x4'", 'modify' => "VARCHAR(11)")
+ ),
+ 'sccpline' => array (
+ '_regcontext' => array('create' => "VARCHAR(20) NULL default 'sccpregistration'", 'modify' => "VARCHAR(20)"),
+ '_pickupgroup' => array('create' => "VARCHAR(50) NULL default null", 'modify' => "VARCHAR(50)"),
+ '_transfer_on_hangup' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
+ '_autoselectline_enabled' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
+ '_autocall_select' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
+ '_backgroundImageAccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
+ '_phonePersonalization' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
+ '_callLogBlfEnabled' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')")
)
);
@@ -257,6 +269,7 @@ function Get_DB_config($sccp_compatible)
// If integrated into chan-sccp, the version number will change
if ($sccp_compatible >= 433) {
$db_config_v4['sccpdevice'] = array_merge($db_config_v4['sccpdevice'],$db_config_v5['sccpdevice']);
+ $db_config_v4['sccpline'] = array_merge($db_config_v4['sccpline'],$db_config_v5['sccpline']);
}
return $db_config_v4;
}
@@ -435,10 +448,10 @@ function InstallDB_updateSchema($db_config)
if (!empty($sql_create)) {
outn("
" . _("Adding new FILTER_VALIDATE_INT") . "");
- $sql_create = "ALTER TABLE `" . $tabl_name . "` " . substr($sql_create, 0, -2);
+ $sql_create = "ALTER TABLE {$tabl_name} " .substr($sql_create, 0, -2);
$check = $db->query($sql_create);
if (DB::IsError($check)) {
- die_freepbx("Can not create " . $tabl_name . " table sql: " . $sql_create . "n");
+ die_freepbx("Can not create {$tabl_name}. SQL: {$sql_create} \n");
}
}
if (!empty($sql_modify)) {
diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php
index a9aa47d..a899069 100644
--- a/sccpManClasses/dbinterface.class.php
+++ b/sccpManClasses/dbinterface.class.php
@@ -109,6 +109,9 @@ class dbinterface
case 'get_columns_sccpuser':
$stmts = $dbh->prepare('DESCRIBE sccpuser');
break;
+ case 'get_columns_sccpline':
+ $stmts = $dbh->prepare('DESCRIBE sccpuser');
+ break;
case 'get_sccpdevice_byid':
$stmt = $dbh->prepare('SELECT t1.*, types.dns, types.buttons, types.loadimage, types.nametemplate as nametemplate,
addon.buttons as addon_buttons FROM sccpdevice AS t1
diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php
index c54df57..b3ea822 100644
--- a/sccpManTraits/ajaxHelper.php
+++ b/sccpManTraits/ajaxHelper.php
@@ -67,7 +67,6 @@ trait ajaxHelper {
case 'save_device':
$this->saveSccpDevice($request);
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'sccpdevice');
-
break;
case 'save_ruser':
//$res = $request;
@@ -388,6 +387,7 @@ trait ajaxHelper {
}
}
+
function handleSubmit($get_settings, $validateonly = false) {
$hdr_prefix = 'sccp_';
$hdr_arprefix = 'sccp-ar_';
@@ -407,7 +407,7 @@ trait ajaxHelper {
// There will be some exceptions to be handled where there should be no underscore
// Handle at db write
// Have default to be saved to db sccpdevice
- $dev_def = $this->getDeviceDefaults();
+ $dev_def = $this->getTableDefaults('sccpdevice');
if (!array_key_exists($key, $dev_def)) {
// This key needs to be prefixed with underscore
$key = '_'.$key;
diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php
index 3e135d0..37fead7 100644
--- a/sccpManTraits/helperFunctions.php
+++ b/sccpManTraits/helperFunctions.php
@@ -69,11 +69,12 @@ trait helperfunctions {
}
return FALSE;
}
- private function getDeviceDefaults() {
+ private function getTableDefaults($table) {
$def_val = array();
- $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice');
+ // TODO: This is ugly and overkill - needs to be cleaned up in dbinterface
+ $sccpTableDesc = $this->dbinterface->HWextension_db_SccpTableData("get_columns_{$table}");
- foreach ($sccpDeviceDesc as $data) {
+ foreach ($sccpTableDesc as $data) {
$key = (string) $data['Field'];
$def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99");
}
diff --git a/views/form.adddevice.php b/views/form.adddevice.php
index e0cae98..27678f5 100644
--- a/views/form.adddevice.php
+++ b/views/form.adddevice.php
@@ -38,7 +38,7 @@ if (!empty($_REQUEST['new_id'])) {
}
if (empty($_REQUEST['id'])) {
// Adding new device to database. Get default values
- $def_val = $this->getDeviceDefaults();
+ $def_val = $this->getTableDefaults('sccpdevice');
} else {
// Editing an existing Device
$dev_id = $_REQUEST['id'];
diff --git a/views/server.advanced.php b/views/server.advanced.php
index d712320..17facb9 100644
--- a/views/server.advanced.php
+++ b/views/server.advanced.php
@@ -14,7 +14,7 @@
// originally, this was populated by sccpgeneral.xml but that should be static
// now will populate from the db defaults.
- $defaultVals = $this->getDeviceDefaults();
+ $defaultVals = $this->getTableDefaults('sccpdevice');
echo $this->showGroup('sccp_srst', 1);
echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVals,false);
diff --git a/views/server.device.php b/views/server.device.php
index 8eb50dc..3f84306 100644
--- a/views/server.device.php
+++ b/views/server.device.php
@@ -11,8 +11,11 @@
getTableDefaults('sccpline');
+ $def_val_device = $this->getTableDefaults('sccpdevice');
echo $this->showGroup('sccp_dev_config', 1, 'sccpdevice');
- echo $this->showGroup('sccp_dev_group_config', 1,);
+ echo $this->showGroup('sccp_dev_group_config', 1, 'sccpline');
echo $this->showGroup('sccp_dev_advconfig', 1, 'sccpdevice');
echo $this->showGroup('sccp_dev_softkey', 1, 'sccpdevice');
echo $this->showGroup('sccp_hotline_config', 1, 'sccpdevice');
diff --git a/views/server.setting.php b/views/server.setting.php
index d918fc7..c9da1a8 100644
--- a/views/server.setting.php
+++ b/views/server.setting.php
@@ -26,10 +26,10 @@
echo $this->showGroup('sccp_dev_time_s', 1);
echo $this->showGroup('sccp_net', 1);
echo $this->showGroup('sccp_lang', 1);
- echo $this->showGroup('sccp_qos_config', 1);
+ echo $this->showGroup('sccp_qos_config', 1, 'sccpdevice');
echo $this->showGroup('sccp_extpath_config', 1);
-
- ?>
+
+ ?>
@@ -45,15 +45,14 @@
showGroup('add_network_1',0);
- ?>
+ ?>
-
-
+
+
+
-