Added sccpline fields

WIP Still have issue with def_modify in installer
This commit is contained in:
steve-lad 2021-06-17 18:39:32 +02:00
parent afe3382aed
commit efdf2d0469
8 changed files with 44 additions and 25 deletions

View file

@ -116,10 +116,10 @@ function Get_DB_config($sccp_compatible)
'earlyrtp' => array('create' => "ENUM('immediate','offHook','dialing','ringout','progress','none') NOT NULL default 'none'", 'earlyrtp' => array('create' => "ENUM('immediate','offHook','dialing','ringout','progress','none') NOT NULL default 'none'",
'modify' => "ENUM('immediate','offHook','dialing','ringout','progress','none')"), 'modify' => "ENUM('immediate','offHook','dialing','ringout','progress','none')"),
'monitor' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), 'monitor' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"),
'audio_tos' => array('def_modify' => "0xB8"), 'audio_tos' => array('create' => "VARCHAR(11) NOT NULL default '0xB8'",'modify' => "0xB8"),
'audio_cos' => array('def_modify' => "6"), 'audio_cos' => array('create' => "VARCHAR(11) NOT NULL default '0x6'",'modify' => "0x6"),
'video_tos' => array('def_modify' => "0x88"), 'video_tos' => array('create' => "VARCHAR(11) NOT NULL default '0x88'",'modify' => "0x88"),
'video_cos' => array('def_modify' => "5"), 'video_cos' => array('create' => "VARCHAR(11) NOT NULL default '0x5'",'modify' => "0x5"),
'trustphoneip' => array('drop' => "yes"), 'trustphoneip' => array('drop' => "yes"),
'transfer_on_hangup' => array('create' => "enum('on','off') NOT NULL DEFAULT 'off'", 'modify' => "enum('on','off')"), '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)"), '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)"), '_remotehangup_tone' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"),
'_transfer_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)"), '_callwaiting_tone' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"),
'_callanswerorder' => array('create' => 'create' => "enum('oldestfirst','latestfirst') NOT NULL default 'latestfirst'", '_callanswerorder' => array('create' => "enum('oldestfirst','latestfirst') NOT NULL default 'latestfirst'",
'modify' => "enum('oldestfirst','latestfirst')"), 'modify' => "enum('oldestfirst','latestfirst')"),
'_echocancel' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), '_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 integrated into chan-sccp, the version number will change
if ($sccp_compatible >= 433) { if ($sccp_compatible >= 433) {
$db_config_v4['sccpdevice'] = array_merge($db_config_v4['sccpdevice'],$db_config_v5['sccpdevice']); $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; return $db_config_v4;
} }
@ -435,10 +448,10 @@ function InstallDB_updateSchema($db_config)
if (!empty($sql_create)) { if (!empty($sql_create)) {
outn("<li>" . _("Adding new FILTER_VALIDATE_INT") . "</li>"); outn("<li>" . _("Adding new FILTER_VALIDATE_INT") . "</li>");
$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); $check = $db->query($sql_create);
if (DB::IsError($check)) { 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)) { if (!empty($sql_modify)) {

View file

@ -109,6 +109,9 @@ class dbinterface
case 'get_columns_sccpuser': case 'get_columns_sccpuser':
$stmts = $dbh->prepare('DESCRIBE sccpuser'); $stmts = $dbh->prepare('DESCRIBE sccpuser');
break; break;
case 'get_columns_sccpline':
$stmts = $dbh->prepare('DESCRIBE sccpuser');
break;
case 'get_sccpdevice_byid': case 'get_sccpdevice_byid':
$stmt = $dbh->prepare('SELECT t1.*, types.dns, types.buttons, types.loadimage, types.nametemplate as nametemplate, $stmt = $dbh->prepare('SELECT t1.*, types.dns, types.buttons, types.loadimage, types.nametemplate as nametemplate,
addon.buttons as addon_buttons FROM sccpdevice AS t1 addon.buttons as addon_buttons FROM sccpdevice AS t1

View file

@ -67,7 +67,6 @@ trait ajaxHelper {
case 'save_device': case 'save_device':
$this->saveSccpDevice($request); $this->saveSccpDevice($request);
return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'sccpdevice'); return array('status' => true, 'search' => '?display=sccp_phone', 'hash' => 'sccpdevice');
break; break;
case 'save_ruser': case 'save_ruser':
//$res = $request; //$res = $request;
@ -388,6 +387,7 @@ trait ajaxHelper {
} }
} }
function handleSubmit($get_settings, $validateonly = false) { function handleSubmit($get_settings, $validateonly = false) {
$hdr_prefix = 'sccp_'; $hdr_prefix = 'sccp_';
$hdr_arprefix = 'sccp-ar_'; $hdr_arprefix = 'sccp-ar_';
@ -407,7 +407,7 @@ trait ajaxHelper {
// There will be some exceptions to be handled where there should be no underscore // There will be some exceptions to be handled where there should be no underscore
// Handle at db write // Handle at db write
// Have default to be saved to db sccpdevice // Have default to be saved to db sccpdevice
$dev_def = $this->getDeviceDefaults(); $dev_def = $this->getTableDefaults('sccpdevice');
if (!array_key_exists($key, $dev_def)) { if (!array_key_exists($key, $dev_def)) {
// This key needs to be prefixed with underscore // This key needs to be prefixed with underscore
$key = '_'.$key; $key = '_'.$key;

View file

@ -69,11 +69,12 @@ trait helperfunctions {
} }
return FALSE; return FALSE;
} }
private function getDeviceDefaults() { private function getTableDefaults($table) {
$def_val = array(); $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']; $key = (string) $data['Field'];
$def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); $def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99");
} }

View file

@ -38,7 +38,7 @@ if (!empty($_REQUEST['new_id'])) {
} }
if (empty($_REQUEST['id'])) { if (empty($_REQUEST['id'])) {
// Adding new device to database. Get default values // Adding new device to database. Get default values
$def_val = $this->getDeviceDefaults(); $def_val = $this->getTableDefaults('sccpdevice');
} else { } else {
// Editing an existing Device // Editing an existing Device
$dev_id = $_REQUEST['id']; $dev_id = $_REQUEST['id'];

View file

@ -14,7 +14,7 @@
// originally, this was populated by sccpgeneral.xml but that should be static // originally, this was populated by sccpgeneral.xml but that should be static
// now will populate from the db defaults. // now will populate from the db defaults.
$defaultVals = $this->getDeviceDefaults(); $defaultVals = $this->getTableDefaults('sccpdevice');
echo $this->showGroup('sccp_srst', 1); echo $this->showGroup('sccp_srst', 1);
echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVals,false); echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVals,false);

View file

@ -11,8 +11,11 @@
<input type="hidden" name="category" value="deviceform"> <input type="hidden" name="category" value="deviceform">
<input type="hidden" name="Submit" value="Submit"> <input type="hidden" name="Submit" value="Submit">
<?php <?php
$def_val_line = $this->getTableDefaults('sccpline');
$def_val_device = $this->getTableDefaults('sccpdevice');
echo $this->showGroup('sccp_dev_config', 1, '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_advconfig', 1, 'sccpdevice');
echo $this->showGroup('sccp_dev_softkey', 1, 'sccpdevice'); echo $this->showGroup('sccp_dev_softkey', 1, 'sccpdevice');
echo $this->showGroup('sccp_hotline_config', 1, 'sccpdevice'); echo $this->showGroup('sccp_hotline_config', 1, 'sccpdevice');

View file

@ -26,10 +26,10 @@
echo $this->showGroup('sccp_dev_time_s', 1); echo $this->showGroup('sccp_dev_time_s', 1);
echo $this->showGroup('sccp_net', 1); echo $this->showGroup('sccp_net', 1);
echo $this->showGroup('sccp_lang', 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); echo $this->showGroup('sccp_extpath_config', 1);
?> ?>
</form> </form>
@ -45,15 +45,14 @@
<ul class="nav nav-tabs" role="tablist"> <ul class="nav nav-tabs" role="tablist">
<?php <?php
// echo $this->showGroup('add_network_1',0); // echo $this->showGroup('add_network_1',0);
?> ?>
</ul> </ul>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary sccp_update" data-id="network_add" data-mode="new" id="network_add" data-dismiss="modal">Save</button> <button type="button" class="btn btn-primary sccp_update" data-id="network_add" data-mode="new" id="network_add" data-dismiss="modal">Save</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>