From 5e5cf3ffda374ca9564a5de93fd73695cd1d7735 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 16 Jun 2021 07:52:58 +0200 Subject: [PATCH 001/181] Remove unused cases in Save Device These Fields do not exist in sccpdevice --- Sccp_manager.class.php | 18 ++---------------- module.xml | 3 ++- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index cb57a78..87d38e8 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -565,8 +565,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function saveSccpDevice($get_settings, $validateonly = false) { + dbug('Settings', $get_settings); $hdr_prefix = 'sccp_hw_'; $hdr_arprefix = 'sccp_hw-ar_'; + $hdr_vendPrefix = 'sccp_hw_vendor'; $save_buttons = array(); $save_settings = array(); @@ -603,22 +605,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $name_dev = $value; } break; - case 'disallow': - $value = $get_settings['sccp_disallow']; - break; - - case 'allow': - $i = 0; - if (!empty($get_settings['voicecodecs'])) { - foreach ($get_settings['voicecodecs'] as $keycodeс => $valcodeс) { - $save_codec[$i] = $keycodeс; - $i++; - }; - $value = implode(";", $save_codec); - } else { - $value = 'all'; // Bug If not System Codecs - } - break; case 'phonecodepage': $value = 'null'; if (!empty($get_settings[$hdr_prefix . 'devlang'])) { diff --git a/module.xml b/module.xml index eca5e99..cd5c29f 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.2.0.10 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP @@ -23,6 +23,7 @@ * Version 14.2.0.8 * - Fix uninstaller and create backup * Version 14.2.0.9 * - Bug Fix - incorrect response class for Reset Token Device * Version 14.2.0.10 * - Bug Fix - line not assigned on device creation + * Version 14.3.0.0 * - New Minor Version - Change DB and add new settings https://github.com/chan-sccp/sccp_manager From 4c40809071cfabfe02ad6e7bb539731ae52f849b Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 16 Jun 2021 09:22:43 +0200 Subject: [PATCH 002/181] Update installer for new db version Define new sccpdevice fields Remove obsolete code Remove duplicate code --- install.php | 153 +++++++++++++++++++--------------------------------- 1 file changed, 56 insertions(+), 97 deletions(-) diff --git a/install.php b/install.php index 6f73ae7..341dacc 100644 --- a/install.php +++ b/install.php @@ -1,4 +1,4 @@ - array('drop' => "yes"), 'pickupmodeanswer' => array('drop' => "yes"), 'disallow' => array('drop' => "yes"), - 'disallow' => array('drop' => "yes"), 'callhistory_answered_elsewhere' => array('create' => "enum('Ignore','Missed Calls','Received Calls', 'Placed Calls') NOT NULL default 'Ignore'", 'modify' => "enum('Ignore','Missed Calls','Received Calls','Placed Calls')"), - 'description' => array('rename' => "_description"), 'hwlang' => array('rename' => "_hwlang"), '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'), @@ -214,13 +207,40 @@ function Get_DB_config($sccp_compatible) 'name' => array('create' => "varchar(45) NOT NULL", 'modify' => "VARCHAR(45)" ), ) ); + $db_config_V5 = array( + 'sccpdevice' => array( + 'logserver' => array('create' => "varchar(100) NULL default null", 'modify' => "VARCHAR(20)"), + 'daysdisplaynotactive' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'displayontime' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'displayonduration' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'displayidletimeout' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'settingsaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'videocapability' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'webaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'webadmin' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'pcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'spantopcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'voicevlanaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'enablecdpswport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), + 'enablecdppcport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), + 'enablelldpswport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), + 'enablelldppcport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')") + ) + ); if ($sccp_compatible >= 433) { if ($mobile_hw == '1') { return $db_config_v4M; } + if ($sccp_compatible > 433) { + $db_config_v4['sccpdevice'] = array_merge($db_config_v4['sccpdevice'],$db_config_v5['sccpdevice']); + } return $db_config_v4; } + + // New values to add (these are currently unused) + + } function CheckSCCPManagerDBTables($table_req) @@ -553,17 +573,6 @@ function InstallDB_fillsccpdevmodel() return true; } -function InstallDB_updateSccpDevice() -{ - global $db; - outn("
  • " . _("Update sccpdevice") . "
  • "); - $sql = "UPDATE `sccpdevice` set audio_tos='0xB8',audio_cos='6',video_tos='0x88',video_cos='5' where audio_tos=NULL or audio_tos='';"; - $check = $db->query($sql); - if (DB::IsError($check)) { - die_freepbx("Can not REPLACE defaults into sccpdevice table\n"); - } -} - function InstallDB_createButtonConfigTrigger() { global $db; @@ -596,7 +605,6 @@ function InstallDB_createButtonConfigTrigger() die_freepbx("Can not modify sccpdevice table\n"); } outn("
  • " . _("(Re)Create trigger Ok") . "
  • "); -// outn("
  • " . $sql . "
  • "); return true; } function InstallDB_updateDBVer($sccp_compatible) @@ -616,91 +624,42 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) global $db; outn("
  • " . _("(Re)Create sccpdeviceconfig view") . "
  • "); $sql = ""; - if ($sccp_compatible < 431) { - $sql = "CREATE OR REPLACE + $sql = "DROP VIEW IF EXISTS sccpdeviceconfig; + DROP VIEW IF EXISTS sccpuserconfig;"; + /// global $hw_mobil; + // From logserver to end only applies to db ver > 433 + + global $mobile_hw; + if ($mobile_hw == '1') { + $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpdeviceconfig AS - SELECT GROUP_CONCAT( CONCAT_WS( ',', buttonconfig.type, buttonconfig.name, buttonconfig.options ) - ORDER BY instance ASC - SEPARATOR ';' ) AS button, - sccpdevice.type AS type, - sccpdevice.addon AS addon, - sccpdevice.description AS description, - sccpdevice.tzoffset AS tzoffset, - sccpdevice.transfer AS transfer, - sccpdevice.cfwdall AS cfwdall, - sccpdevice.cfwdbusy AS cfwdbusy, - sccpdevice.imageversion AS imageversion, - sccpdevice.deny AS deny, - sccpdevice.permit AS permit, - sccpdevice.dndFeature AS dndFeature, - sccpdevice.directrtp AS directrtp, - sccpdevice.earlyrtp AS earlyrtp, - sccpdevice.mwilamp AS mwilamp, - sccpdevice.mwioncall AS mwioncall, - sccpdevice.pickupexten AS pickupexten, - sccpdevice.pickupcontext AS pickupcontext, - sccpdevice.pickupmodeanswer AS pickupmodeanswer, - sccpdevice.private AS private, - sccpdevice.privacy AS privacy, - sccpdevice.nat AS nat, - sccpdevice.softkeyset AS softkeyset, - sccpdevice.audio_tos AS audio_tos, - sccpdevice.audio_cos AS audio_cos, - sccpdevice.video_tos AS video_tos, - sccpdevice.video_cos AS video_cos, - sccpdevice.conf_allow AS conf_allow, - sccpdevice.conf_play_general_announce AS conf_play_general_announce, - sccpdevice.conf_play_part_announce AS conf_play_part_announce, - sccpdevice.conf_mute_on_entry AS conf_mute_on_entry, - sccpdevice.conf_music_on_hold_class AS conf_music_on_hold_class, - sccpdevice.conf_show_conflist AS conf_show_conflist, - sccpdevice.setvar AS setvar, - sccpdevice.disallow AS disallow, - sccpdevice.allow AS allow, - sccpdevice.backgroundImage AS backgroundImage, - sccpdevice.ringtone AS ringtone, - sccpdevice.name AS name + SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options ) + ORDER BY instance ASC SEPARATOR ';' ) AS sccpbutton, sccpdevice.* FROM sccpdevice - LEFT JOIN sccpbuttonconfig buttonconfig ON ( buttonconfig.device = sccpdevice.name ) - GROUP BY sccpdevice.name;"; + LEFT JOIN sccpbuttonconfig ON (sccpbuttonconfig.reftype = 'sccpdevice' AND sccpbuttonconfig.ref = sccpdevice.name ) + GROUP BY sccpdevice.name; "; + $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpuserconfig AS + SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options ) + ORDER BY instance ASC SEPARATOR ';' ) AS button, sccpuser.* + FROM sccpuser + LEFT JOIN sccpbuttonconfig ON ( sccpbuttonconfig.reftype = 'sccpuser' AND sccpbuttonconfig.ref = sccpuser.id) + GROUP BY sccpuser.name; "; } else { - $sql = "DROP VIEW IF EXISTS sccpdeviceconfig; - DROP VIEW IF EXISTS sccpuserconfig;"; - /// global $hw_mobil; - - global $mobile_hw; - if ($mobile_hw == '1') { - $sql .= "CREATE OR REPLACE - ALGORITHM = MERGE - VIEW sccpdeviceconfig AS - SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options ) - ORDER BY instance ASC SEPARATOR ';' ) AS sccpbutton, sccpdevice.* - FROM sccpdevice - LEFT JOIN sccpbuttonconfig ON (sccpbuttonconfig.reftype = 'sccpdevice' AND sccpbuttonconfig.ref = sccpdevice.name ) - GROUP BY sccpdevice.name; "; - $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpuserconfig AS - SELECT GROUP_CONCAT( CONCAT_WS( ',', sccpbuttonconfig.buttontype, sccpbuttonconfig.name, sccpbuttonconfig.options ) - ORDER BY instance ASC SEPARATOR ';' ) AS button, sccpuser.* - FROM sccpuser - LEFT JOIN sccpbuttonconfig ON ( sccpbuttonconfig.reftype = 'sccpuser' AND sccpbuttonconfig.ref = sccpuser.id) - GROUP BY sccpuser.name; "; - } else { - $sql .= "CREATE OR REPLACE - ALGORITHM = MERGE - VIEW sccpdeviceconfig AS + $sql .= "CREATE OR REPLACE + ALGORITHM = MERGE + VIEW sccpdeviceconfig AS SELECT case sccpdevice._profileid - when 0 then - (select GROUP_CONCAT(CONCAT_WS( ',', defbutton.buttontype, defbutton.name, defbutton.options ) SEPARATOR ';') from sccpbuttonconfig as defbutton where defbutton.ref = sccpdevice.name ORDER BY defbutton.instance ) - when 1 then - (select GROUP_CONCAT(CONCAT_WS( ',', userbutton.buttontype, userbutton.name, userbutton.options ) SEPARATOR ';') from sccpbuttonconfig as userbutton where userbutton.ref = sccpdevice._loginname ORDER BY userbutton.instance ) - when 2 then - (select GROUP_CONCAT(CONCAT_WS( ',', homebutton.buttontype, homebutton.name, homebutton.options ) SEPARATOR ';') from sccpbuttonconfig as homebutton where homebutton.ref = sccpuser.homedevice ORDER BY homebutton.instance ) - end as button, if(sccpdevice._profileid = 0, sccpdevice._description, sccpuser.description) as description, sccpdevice.* + when 0 then + (select GROUP_CONCAT(CONCAT_WS( ',', defbutton.buttontype, defbutton.name, defbutton.options ) SEPARATOR ';') from sccpbuttonconfig as defbutton where defbutton.ref = sccpdevice.name ORDER BY defbutton.instance ) + when 1 then + (select GROUP_CONCAT(CONCAT_WS( ',', userbutton.buttontype, userbutton.name, userbutton.options ) SEPARATOR ';') from sccpbuttonconfig as userbutton where userbutton.ref = sccpdevice._loginname ORDER BY userbutton.instance ) + when 2 then + (select GROUP_CONCAT(CONCAT_WS( ',', homebutton.buttontype, homebutton.name, homebutton.options ) SEPARATOR ';') from sccpbuttonconfig as homebutton where homebutton.ref = sccpuser.homedevice ORDER BY homebutton.instance ) + end as button, if(sccpdevice._profileid = 0, sccpdevice._description, sccpuser.description) as description, sccpdevice.* FROM sccpdevice LEFT JOIN sccpuser sccpuser ON ( sccpuser.name = sccpdevice._loginname ) GROUP BY sccpdevice.name;"; - } } $results = $db->query($sql); if (DB::IsError($results)) { From 922ae3eaf7059274dcfaf3e7f1822247d5ddd58c Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 16 Jun 2021 10:13:29 +0200 Subject: [PATCH 003/181] Update fields so that ignored by chan-sccp To avoid unnecessary changes to chan-sccp, these fields are prefixed with an underscore and should be ignored. They are used to create the SEPXXXX file --- install.php | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/install.php b/install.php index 341dacc..a2f9e8e 100644 --- a/install.php +++ b/install.php @@ -207,24 +207,28 @@ function Get_DB_config($sccp_compatible) 'name' => array('create' => "varchar(45) NOT NULL", 'modify' => "VARCHAR(45)" ), ) ); + // Below fields allow configuration of these settings on a per device basis + // whereas previously they were all global. + // By prefixing with an underscore, these fields are ignored by chan-sccp + // which is not an issue as they are not "runtime" $db_config_V5 = array( 'sccpdevice' => array( - 'logserver' => array('create' => "varchar(100) NULL default null", 'modify' => "VARCHAR(20)"), - 'daysdisplaynotactive' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), - 'displayontime' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), - 'displayonduration' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), - 'displayidletimeout' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), - 'settingsaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - 'videocapability' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - 'webaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - 'webadmin' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - 'pcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), - 'spantopcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), - 'voicevlanaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - 'enablecdpswport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), - 'enablecdppcport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), - 'enablelldpswport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), - 'enablelldppcport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')") + '_logserver' => array('create' => "varchar(100) NULL default null", 'modify' => "VARCHAR(20)"), + '_daysdisplaynotactive' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), + '_displayontime' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), + '_displayonduration' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), + '_displayidletimeout' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), + '_settingsaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + '_videocapability' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + '_webaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + '_webadmin' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + '_pcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + '_spantopcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + '_voicevlanaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + '_enablecdpswport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), + '_enablecdppcport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), + '_enablelldpswport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), + '_enablelldppcport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')") ) ); @@ -232,7 +236,9 @@ function Get_DB_config($sccp_compatible) if ($mobile_hw == '1') { return $db_config_v4M; } - if ($sccp_compatible > 433) { + // This looks extraneous, but is for future compatibility - do not delete + // 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']); } return $db_config_v4; From b2ee6ad853acb20da1b5099c143e7fc93f126998 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 16 Jun 2021 10:27:28 +0200 Subject: [PATCH 004/181] Correct NOT NULL fields Ensure all enums are NOT NULL Correct variable name to lowercase --- install.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/install.php b/install.php index a2f9e8e..3118f76 100644 --- a/install.php +++ b/install.php @@ -211,7 +211,7 @@ function Get_DB_config($sccp_compatible) // whereas previously they were all global. // By prefixing with an underscore, these fields are ignored by chan-sccp // which is not an issue as they are not "runtime" - $db_config_V5 = array( + $db_config_v5 = array( 'sccpdevice' => array( '_logserver' => array('create' => "varchar(100) NULL default null", 'modify' => "VARCHAR(20)"), '_daysdisplaynotactive' => array('create' => "varchar(20) NULL default null", 'modify' => "VARCHAR(20)"), @@ -225,10 +225,10 @@ function Get_DB_config($sccp_compatible) '_pcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), '_spantopcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), '_voicevlanaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_enablecdpswport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), - '_enablecdppcport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), - '_enablelldpswport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')"), - '_enablelldppcport' => array('create' => "enum('on','off') NULL default 'off'", 'modify' => "enum('on','off')") + '_enablecdpswport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + '_enablecdppcport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + '_enablelldpswport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + '_enablelldppcport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')") ) ); From 790b5f7949b5eae5cd13a9ec595be2bd1456fcb2 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 16 Jun 2021 12:42:07 +0200 Subject: [PATCH 005/181] Add vendorconfig data to Edit Device Translate DB fields to formshow fields These field translations need to be simplified --- Sccp_manager.class.php | 5 ++- conf/sccpgeneral.xml.v433 | 67 ++++++++++++++++++++------------------- views/form.adddevice.php | 25 +++++++++++++++ 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 87d38e8..5fd8c92 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -568,7 +568,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { dbug('Settings', $get_settings); $hdr_prefix = 'sccp_hw_'; $hdr_arprefix = 'sccp_hw-ar_'; - $hdr_vendPrefix = 'sccp_hw_vendor'; + $hdr_vendPrefix = 'sccp_hw_vendorconfig'; $save_buttons = array(); $save_settings = array(); @@ -625,6 +625,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (!empty($get_settings[$hdr_prefix . $key])) { $value = $get_settings[$hdr_prefix . $key]; } + if (!empty($get_settings[$hdr_vendPrefix . $key])) { + $value = $get_settings[$hdr_vendPrefix . $key]; + } if (!empty($get_settings[$hdr_arprefix . $key])) { $arr_data = ''; $arr_clear = false; diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 0d0bc08..4bfe55b 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -588,103 +588,104 @@ and open the template in the editor. Base Version before all crash :-) Timeout in HH:MM format to automatically turn off phone display if outside the time specified by "daysDisplayNotActive", "displayOnTime" and "displayOnTimeout". + vendorconfig_settingsaccess - + Inherit - - + + Whether a user can access the phone settings. vendorconfig_videocapability - + Inherit - - + + vendorconfig_webaccess - + Inherit - - + + Enable the phone's HTTP server. vendorconfig_webadmin - + Inherit - - + + Enable remote administration using the phone's HTTP server. 8821 model only. vendorconfig_pcport - + Inherit - - + + Disable the PC (computer) port vendorconfig_spantopcport - + Inherit - - + + Forward packets sent and received on the SW (network) port to the PC (computer) port. vendorconfig_voicevlanaccess - + Inherit - - + + Allow devices connected to the PC (computer) port to access the voice VLAN. vendorconfig_enablecdpswport - + Inherit - - + + Enable Cisco Discovery Protocol on the SW (network) port. vendorconfig_enablecdppcport - + Inherit - - + + Enable Cisco Discovery Protocol on the PC (computer) port. vendorconfig_enablelldpswport - + Inherit - - + + Enable Link Layer Discovery Protocol on the SW (network) port. vendorconfig_enablelldppcport - + Inherit - - + + Enable Link Layer Discovery Protocol on the PC (computer) port. diff --git a/views/form.adddevice.php b/views/form.adddevice.php index 09bb2dc..91b54dd 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -26,10 +26,12 @@ if (!empty($_REQUEST['new_id'])) { } } +// Editing an existing Device if (!empty($_REQUEST['id'])) { $dev_id = $_REQUEST['id']; $dev_new = $dev_id; $db_res = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array("id" => $dev_id)); + dbug('db_res', $db_res); foreach ($db_res as $key => $val) { if (!empty($val)) { switch ($key) { @@ -65,9 +67,32 @@ if (!empty($_REQUEST['id'])) { // $val = after('/', $val); // break; } + $translateFieldArray = array('_logserver' => 'vendorconfig_logserver', + '_daysdisplaynotactive' => 'vendorconfig_daysdisplaynotactive', + '_displayontime' => 'vendorconfig_displayontime', + '_displayonduration' => 'vendorconfig_displayonduration', + '_displayidletimeout' => 'vendorconfig_displayidletimeout', + '_settingsaccess' => 'vendorconfig_settingsaccess', + '_videocapability' => 'vendorconfig_videocapability', + '_webaccess' => 'vendorconfig_webaccess', + '_webadmin' => 'vendorconfig_webadmin', + '_pcport' => 'vendorconfig_pcport', + '_spantopcport' => 'vendorconfig_spantopcport', + '_voicevlanaccess' => 'vendorconfig_voicevlanaccess', + '_enablecdpswport' => 'vendorconfig_enablecdpswport', + '_enablecdppcport' => 'vendorconfig_enablecdppcport', + '_enablelldpswport' => 'vendorconfig_enablelldpswport', + '_enablelldppcport' => 'vendorconfig_enablelldppcport' + ); + if (array_key_exists($key,$translateFieldArray)) { + $def_val[$translateFieldArray[$key]] = array("keyword" => $translateFieldArray[$key], "data" => $val, "seq" => "99"); + continue; + } $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); } } + dbug('def_value', $def_val); + } //print_r($db_res); From 815b7dbd2a9ee68e0b1a693386ba3f1689cd2876 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 16 Jun 2021 13:21:44 +0200 Subject: [PATCH 006/181] Update Vendor defaults from db Use db default values instead of xml as these are dynamic. --- views/server.advanced.php | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/views/server.advanced.php b/views/server.advanced.php index 0bb48bd..67145ed 100644 --- a/views/server.advanced.php +++ b/views/server.advanced.php @@ -12,8 +12,38 @@ dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); + + $translateFieldArray = array('_logserver' => 'vendorconfig_logserver', + '_daysdisplaynotactive' => 'vendorconfig_daysdisplaynotactive', + '_displayontime' => 'vendorconfig_displayontime', + '_displayonduration' => 'vendorconfig_displayonduration', + '_displayidletimeout' => 'vendorconfig_displayidletimeout', + '_settingsaccess' => 'vendorconfig_settingsaccess', + '_videocapability' => 'vendorconfig_videocapability', + '_webaccess' => 'vendorconfig_webaccess', + '_webadmin' => 'vendorconfig_webadmin', + '_pcport' => 'vendorconfig_pcport', + '_spantopcport' => 'vendorconfig_spantopcport', + '_voicevlanaccess' => 'vendorconfig_voicevlanaccess', + '_enablecdpswport' => 'vendorconfig_enablecdpswport', + '_enablecdppcport' => 'vendorconfig_enablecdppcport', + '_enablelldpswport' => 'vendorconfig_enablelldpswport', + '_enablelldppcport' => 'vendorconfig_enablelldppcport' + ); + + foreach ($sccpDeviceDesc as $data) { + $key = (string) $data['Field']; + if (array_key_exists($key, $translateFieldArray)) { + $defaultVal[$translateFieldArray[$key]] = array("keyword" => $translateFieldArray[$key], "data" => $data['Default'], "seq" => "99"); + } + } + echo $this->showGroup('sccp_srst', 1); - echo $this->showGroup('sccp_dev_vendor_conf', 1,'sccp',null,false); + echo $this->showGroup('sccp_dev_vendor_conf', 1,'sccp',$defaultVal,false); // echo $this->showGroup('sccp_dev_time',1); ?> From b420f35ad2d6a10a8fe2f30b21eb48921fa1c918 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:58:04 +0200 Subject: [PATCH 007/181] WIP Fix formshow prefix logic for IS Currently only fixed for IS FormShow was adding the prefix to the full child name, making a useless result. Need to remove form_prefix from childname to return to db values --- Sccp_manager.class.php | 1 - views/form.adddevice.php | 29 ++++------------------------- views/formShow.php | 13 +++++++++---- views/server.advanced.php | 26 ++------------------------ 4 files changed, 15 insertions(+), 54 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 5fd8c92..9489bdf 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -565,7 +565,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function saveSccpDevice($get_settings, $validateonly = false) { - dbug('Settings', $get_settings); $hdr_prefix = 'sccp_hw_'; $hdr_arprefix = 'sccp_hw-ar_'; $hdr_vendPrefix = 'sccp_hw_vendorconfig'; diff --git a/views/form.adddevice.php b/views/form.adddevice.php index 91b54dd..47f046d 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -24,6 +24,9 @@ if (!empty($_REQUEST['new_id'])) { if (!empty($_REQUEST['addon'])) { $def_val['addon'] = array("keyword" => 'type', "data" => $_REQUEST['addon'], "seq" => "99"); } + // TODO Default values should be used to populate this device + // Currently these are read from sccpgeneral.xml + // Need to get these from the db as defaults may have changed. } // Editing an existing Device @@ -31,7 +34,6 @@ if (!empty($_REQUEST['id'])) { $dev_id = $_REQUEST['id']; $dev_new = $dev_id; $db_res = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array("id" => $dev_id)); - dbug('db_res', $db_res); foreach ($db_res as $key => $val) { if (!empty($val)) { switch ($key) { @@ -67,34 +69,11 @@ if (!empty($_REQUEST['id'])) { // $val = after('/', $val); // break; } - $translateFieldArray = array('_logserver' => 'vendorconfig_logserver', - '_daysdisplaynotactive' => 'vendorconfig_daysdisplaynotactive', - '_displayontime' => 'vendorconfig_displayontime', - '_displayonduration' => 'vendorconfig_displayonduration', - '_displayidletimeout' => 'vendorconfig_displayidletimeout', - '_settingsaccess' => 'vendorconfig_settingsaccess', - '_videocapability' => 'vendorconfig_videocapability', - '_webaccess' => 'vendorconfig_webaccess', - '_webadmin' => 'vendorconfig_webadmin', - '_pcport' => 'vendorconfig_pcport', - '_spantopcport' => 'vendorconfig_spantopcport', - '_voicevlanaccess' => 'vendorconfig_voicevlanaccess', - '_enablecdpswport' => 'vendorconfig_enablecdpswport', - '_enablecdppcport' => 'vendorconfig_enablecdppcport', - '_enablelldpswport' => 'vendorconfig_enablelldpswport', - '_enablelldppcport' => 'vendorconfig_enablelldppcport' - ); - if (array_key_exists($key,$translateFieldArray)) { - $def_val[$translateFieldArray[$key]] = array("keyword" => $translateFieldArray[$key], "data" => $val, "seq" => "99"); - continue; - } $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); } } - dbug('def_value', $def_val); } -//print_r($db_res); if (!empty($device_warning)) { ?> @@ -142,7 +121,7 @@ if (!empty($device_warning)) { echo $this->showGroup('sccp_hw_dev_softkey', 1, 'sccp_hw', $def_val); // echo $this->showGroup('sccp_hw_dev_pickup', 1, 'sccp_hw', $def_val); This are line properties and does not exist! echo $this->showGroup('sccp_hw_dev_conference', 1, 'sccp_hw', $def_val); - echo $this->showGroup('sccp_dev_vendor_conf', 1, 'sccp_hw', $def_val, true); + echo $this->showGroup('sccp_dev_vendor_conf', 1, 'vendorconfig', $def_val, true); echo $this->showGroup('sccp_hw_dev_network', 1, 'sccp_hw', $def_val); ?> diff --git a/views/formShow.php b/views/formShow.php index 9ed3fd8..63dffc9 100644 --- a/views/formShow.php +++ b/views/formShow.php @@ -18,11 +18,15 @@ * Help elemen HLP - Help Element */ +// This will not work if the field already has the underscore $npref = $form_prefix.'_'; $napref = $form_prefix.'-ar_'; if (empty($form_prefix)) { $npref = "sccp_"; $napref ="sccp-ar_"; +} elseif ($form_prefix == 'vendorconfig') { + $npref = 'vendorconfig'; + $napref = 'vendorconfig-ar'; } $day_format = array("D.M.Y", "D.M.YA", "Y.M.D", "YA.M.D", "M-D-Y", "M-D-YA", "D-M-Y", "D-M-YA", "Y-M-D", "YA-M-D", "M/D/Y", "M/D/YA", "D/M/Y", "D/M/YA", "Y/M/D", "YA/M/D", "M/D/Y", "M/D/YA"); @@ -328,7 +332,8 @@ foreach ($items as $child) { if ($child['type'] == 'IS') { $res_n = (string)$child->name; - $res_id = $npref.$child->name; + $res_id = $npref.$res_n; + $res_ext = str_replace($npref,'',$res_n); if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { $child->help = $metainfo[$res_n]['Description']; @@ -361,9 +366,9 @@ foreach ($items as $child) { if (!empty($child->value)) { $res_v = (string)$child->value; } - if (!empty($fvalues[$res_n])) { - if (($fvalues[$res_n]['data'] != '') ) { - $res_v = (string)$fvalues[$res_n]['data']; + if (!empty($fvalues[$res_ext])) { + if (($fvalues[$res_ext]['data'] != '') ) { + $res_v = (string)$fvalues[$res_ext]['data']; } } if (!empty($child->option_hide)) { diff --git a/views/server.advanced.php b/views/server.advanced.php index 67145ed..f592dff 100644 --- a/views/server.advanced.php +++ b/views/server.advanced.php @@ -17,34 +17,12 @@ $defaultVal = array(); $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); - $translateFieldArray = array('_logserver' => 'vendorconfig_logserver', - '_daysdisplaynotactive' => 'vendorconfig_daysdisplaynotactive', - '_displayontime' => 'vendorconfig_displayontime', - '_displayonduration' => 'vendorconfig_displayonduration', - '_displayidletimeout' => 'vendorconfig_displayidletimeout', - '_settingsaccess' => 'vendorconfig_settingsaccess', - '_videocapability' => 'vendorconfig_videocapability', - '_webaccess' => 'vendorconfig_webaccess', - '_webadmin' => 'vendorconfig_webadmin', - '_pcport' => 'vendorconfig_pcport', - '_spantopcport' => 'vendorconfig_spantopcport', - '_voicevlanaccess' => 'vendorconfig_voicevlanaccess', - '_enablecdpswport' => 'vendorconfig_enablecdpswport', - '_enablecdppcport' => 'vendorconfig_enablecdppcport', - '_enablelldpswport' => 'vendorconfig_enablelldpswport', - '_enablelldppcport' => 'vendorconfig_enablelldppcport' - ); - foreach ($sccpDeviceDesc as $data) { $key = (string) $data['Field']; - if (array_key_exists($key, $translateFieldArray)) { - $defaultVal[$translateFieldArray[$key]] = array("keyword" => $translateFieldArray[$key], "data" => $data['Default'], "seq" => "99"); - } + $defaultVal[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); } - echo $this->showGroup('sccp_srst', 1); - echo $this->showGroup('sccp_dev_vendor_conf', 1,'sccp',$defaultVal,false); -// echo $this->showGroup('sccp_dev_time',1); + echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVal,false); ?> From a146cd235437893f9106766ffe8f758aed2feb46 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 17 Jun 2021 09:40:24 +0200 Subject: [PATCH 008/181] Set defaults for Add Device Get default values from db for add new device Tidy up AjaxHelper get phone grid removing unnecessary tests and using clearer variable names Correct typos in sccpgeneral --- conf/sccpgeneral.xml.v433 | 6 +-- sccpManTraits/ajaxHelper.php | 94 +++++++++++++++++++----------------- views/form.adddevice.php | 30 +++++++++--- 3 files changed, 76 insertions(+), 54 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 4bfe55b..261de0c 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1119,7 +1119,7 @@ and open the template in the editor. Base Version before all crash :-) off - Enable/Disable conferencing via meetme (on/off), make sure you have one of the meetme apps mentioned below activated in module.conf + Enable/Disable conferencing via meetme (on/off), make sure you have one of the meetme apps mentioned below is activated in module.conf @@ -1534,7 +1534,7 @@ and open the template in the editor. Base Version before all crash :-) conf_play_general_announce - + on @@ -1542,7 +1542,7 @@ and open the template in the editor. Base Version before all crash :-) conf_play_part_announce - + on diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 33e2620..2e2fdc3 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -299,61 +299,67 @@ trait ajaxHelper { return $result; break; case 'getPhoneGrid': + $dbDevices = array(); $cmd_type = !empty($request['type']) ? $request['type'] : ''; - $result = $this->dbinterface->HWextension_db_SccpTableData('SccpDevice', array('type' => $cmd_type)); + // Find all devices defined in the database + $dbDevices = $this->dbinterface->HWextension_db_SccpTableData('SccpDevice', array('type' => $cmd_type)); + // Return if only interested in SIP devices if ($cmd_type == 'cisco-sip') { - return $result; + return $dbDevices; //this may be empty } - $staus = $this->aminterface->sccp_get_active_device(); - if (empty($result)) { - $result = array(); - } else { - foreach ($result as &$dev_id) { - $id_name = $dev_id['name']; - if (!empty($staus[$id_name])) { - $dev_id['description'] = $staus[$id_name]['descr']; - $dev_id['status'] = $staus[$id_name]['status']; - $dev_id['address'] = $staus[$id_name]['address']; - $dev_id['new_hw'] = 'N'; - $staus[$id_name]['news'] = 'N'; - } else { - $dev_id['description'] = '- -'; - $dev_id['status'] = 'not connected'; - $dev_id['address'] = '- -'; - } + // Find all devices currently connected + $activeDevices = $this->aminterface->sccp_get_active_device(); + + foreach ($dbDevices as &$dev_id) { + $id_name = $dev_id['name']; + if (!empty($activeDevices[$id_name])) { + // Device is in db and is connected + $dev_id['description'] = $activeDevices[$id_name]['descr']; + $dev_id['status'] = $activeDevices[$id_name]['status']; + $dev_id['address'] = $activeDevices[$id_name]['address']; + $dev_id['new_hw'] = 'N'; + // No further action required on this active device + unset($activeDevices[$id_name]); + } else { + // Device is in db but not connected + $dev_id['description'] = '- -'; + $dev_id['status'] = 'not connected'; + $dev_id['address'] = '- -'; } } - if (!empty($staus)) { - foreach ($staus as $dev_ids) { + + if (!empty($activeDevices)) { + // Have a device that is connected but is not currently in the database + // This device must have been configured by sccp.conf + // Pass parameters to addDevice so that can be added to db. + foreach ($activeDevices as $dev_ids) { $id_name = $dev_ids['name']; - if (empty($dev_ids['news'])) { - $dev_data = $this->aminterface->sccp_getdevice_info($id_name); - if (!empty($dev_data['SCCP_Vendor']['model_id'])) { - $dev_addon = $dev_data['SCCP_Vendor']['model_addon']; - if (empty($dev_addon)) { - $dev_addon = null; - } - $dev_schema = $this->getSccpModelInformation('byciscoid', false, "all", array('model' => $dev_data['SCCP_Vendor']['model_id'])); - if (empty($dev_schema)) { - $dev_schema[0]['model'] = "ERROR in Model Schema"; - } - $result[] = array( - 'name' => $id_name, - 'mac' => $id_name, - 'button' => '---', - 'type' => $dev_schema[0]['model'], - 'new_hw' => 'Y', - 'description' => '*NEW* ' . $dev_ids['descr'], - 'status' => '*NEW* ' . $dev_ids['status'], - 'address' => $dev_ids['address'], - 'addon' => $dev_addon - ); + $dev_data = $this->aminterface->sccp_getdevice_info($id_name); + if (!empty($dev_data['SCCP_Vendor']['model_id'])) { + $dev_addon = $dev_data['SCCP_Vendor']['model_addon']; + if (empty($dev_addon)) { + $dev_addon = null; } + $dev_schema = $this->getSccpModelInformation('byciscoid', false, "all", array('model' => $dev_data['SCCP_Vendor']['model_id'])); + if (empty($dev_schema)) { + $dev_schema[0]['model'] = "ERROR in Model Schema"; + } + $dbDevices[] = array( + 'name' => $id_name, + 'mac' => $id_name, + 'button' => '---', + 'type' => $dev_schema[0]['model'], + 'new_hw' => 'Y', + 'description' => '*NEW* ' . $dev_ids['descr'], + 'status' => '*NEW* ' . $dev_ids['status'], + 'address' => $dev_ids['address'], + 'addon' => $dev_addon + ); } } } - return $result; + return $dbDevices; break; case 'getDialTemplate': // ------------------------------- Old device support - In the development--- diff --git a/views/form.adddevice.php b/views/form.adddevice.php index 47f046d..f220a6e 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -4,7 +4,7 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -$def_val = null; +$def_val = array(); $dev_id = null; $dev_new = null; $device_warning= null; @@ -15,7 +15,18 @@ $def_val['devlang'] = array("keyword" => 'devlang', "data" => $this->sccpvalues $def_val['directed_pickup_context'] = array("keyword" => 'directed_pickup_context', "data" => $this->sccpvalues['directed_pickup_context']['data'], "seq" => "99"); if (!empty($_REQUEST['new_id'])) { + // Adding device that is connected but not in database $dev_id = $_REQUEST['new_id']; + + // Get device defaults from db + $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); + + foreach ($sccpDeviceDesc as $data) { + $key = (string) $data['Field']; + $def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); + } + + // Overwrite some specific defaults based on $_REQUEST $val = str_replace(array('SEP','ATA','VG'), '', $dev_id); $val = implode('.', sscanf($val, '%4s%4s%4s')); // Convert to Cisco display Format $def_val['mac'] = array("keyword" => 'mac', "data" => $val, "seq" => "99"); @@ -24,13 +35,17 @@ if (!empty($_REQUEST['new_id'])) { if (!empty($_REQUEST['addon'])) { $def_val['addon'] = array("keyword" => 'type', "data" => $_REQUEST['addon'], "seq" => "99"); } - // TODO Default values should be used to populate this device - // Currently these are read from sccpgeneral.xml - // Need to get these from the db as defaults may have changed. } +if (empty($_REQUEST['id'])) { + // Adding new device to database + $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); -// Editing an existing Device -if (!empty($_REQUEST['id'])) { + foreach ($sccpDeviceDesc as $data) { + $key = (string) $data['Field']; + $def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); + } +} else { + // Editing an existing Device $dev_id = $_REQUEST['id']; $dev_new = $dev_id; $db_res = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array("id" => $dev_id)); @@ -68,8 +83,9 @@ if (!empty($_REQUEST['id'])) { // $key = $key . '_mask'; // $val = after('/', $val); // break; + default: + $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); } - $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); } } From 416cedc42558472c53a6a150adb705eed14f49f3 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 17 Jun 2021 10:18:07 +0200 Subject: [PATCH 009/181] Create new function to get device defaults Add new function in helperFunctions and use --- sccpManTraits/helperFunctions.php | 10 ++++++++++ views/form.adddevice.php | 9 ++------- views/server.advanced.php | 9 ++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 4441e46..3e135d0 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -69,6 +69,16 @@ trait helperfunctions { } return FALSE; } + private function getDeviceDefaults() { + $def_val = array(); + $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); + + foreach ($sccpDeviceDesc as $data) { + $key = (string) $data['Field']; + $def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); + } + return $def_val; + } private function findAllFiles($dir, $file_mask = null, $mode = 'full') { $result = null; diff --git a/views/form.adddevice.php b/views/form.adddevice.php index f220a6e..e0cae98 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -37,13 +37,8 @@ if (!empty($_REQUEST['new_id'])) { } } if (empty($_REQUEST['id'])) { - // Adding new device to database - $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); - - foreach ($sccpDeviceDesc as $data) { - $key = (string) $data['Field']; - $def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); - } + // Adding new device to database. Get default values + $def_val = $this->getDeviceDefaults(); } else { // Editing an existing Device $dev_id = $_REQUEST['id']; diff --git a/views/server.advanced.php b/views/server.advanced.php index f592dff..d712320 100644 --- a/views/server.advanced.php +++ b/views/server.advanced.php @@ -14,15 +14,10 @@ // originally, this was populated by sccpgeneral.xml but that should be static // now will populate from the db defaults. - $defaultVal = array(); - $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); + $defaultVals = $this->getDeviceDefaults(); - foreach ($sccpDeviceDesc as $data) { - $key = (string) $data['Field']; - $defaultVal[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); - } echo $this->showGroup('sccp_srst', 1); - echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVal,false); + echo $this->showGroup('sccp_dev_vendor_conf', 1,'vendorconfig',$defaultVals,false); ?> From 5df918a04b684239a50f9d01bd24dccce594688c Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 17 Jun 2021 15:10:31 +0200 Subject: [PATCH 010/181] Save Defaults to Db Defaults Initial changes. Need to update other tables and fields Minor bugfix in dbinterface Correct XML version --- Sccp_manager.class.php | 29 ++++++++++++ conf/sccpgeneral.xml.v433 | 71 +++++++++------------------- install.php | 49 ++++++++++++------- module.xml | 2 +- sccpManClasses/dbinterface.class.php | 8 +++- sccpManTraits/ajaxHelper.php | 1 + views/server.device.php | 13 +++-- 7 files changed, 99 insertions(+), 74 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 9489bdf..0df07df 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -697,10 +697,34 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); $save_codec = array(); + $count_mods = 0; + $dbSaveArray = array(); $integer_msg = _("%s must be a non-negative integer"); $errors = array(); $i = 0; foreach ($get_settings as $key => $value) { + // Initallly saved all to sccpvalues. Now will save to db defaults if appropriate + // TODO: Need to verify the tables defined in showGroup - some options maybe + // device options, but if set by freePbx extensions, be in sccpline. + $key = (str_replace('sccpdevice_', '', $key, $count_mods)); + if (($count_mods) && (!empty($value))) { + // 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(); + if (!array_key_exists($key, $dev_def)) { + // This key needs to be prefixed with underscore + $key = '_'.$key; + } + if ((array_key_exists($key, $dev_def)) && ($dev_def[$key]['data'] == $value)) { + // Value unchanged so ignore and get next key. + continue; + } + $dbSaveArray[] = array('table' => 'sccpdevice', 'field' => $key, 'Default' => $value); + unset($get_settings[$key]); + continue; + } + $pos = strpos($key, $hdr_prefix); if ($pos !== false) { $key1 = substr_replace($key, '', 0, strlen($hdr_prefix)); @@ -780,6 +804,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->saveSccpSettings($save_settings); $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); } + + foreach ($dbSaveArray as $rowToSave) { + $this->dbinterface->updateTableDefaults($rowToSave['table'], $rowToSave['field'], $rowToSave['Default']); + } + $this->createDefaultSccpConfig(); // Rewrite Config. $save_settings[] = array('status' => true); return $save_settings; diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 261de0c..4223446 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -30,7 +30,6 @@ and open the template in the editor. Base Version before all crash :-) - @@ -63,11 +62,10 @@ and open the template in the editor. Base Version before all crash :-) sccp_xml_about - XML Base ver: 11.2, Sccp ver: 431 + XML Base ver: 11.2, Sccp ver: 433 Help. - @@ -116,7 +114,6 @@ and open the template in the editor. Base Version before all crash :-) / externhost - @@ -166,6 +163,7 @@ and open the template in the editor. Base Version before all crash :-) Help! + @@ -183,8 +181,6 @@ and open the template in the editor. Base Version before all crash :-) Add Allow Range Allow network settings. Blank fields will be ignored used Network 0.0.0.0/0.0.0.0 to resolve any existing connections. You can use the 'internal' connections only from the networks connected to the server. - - localnet @@ -218,7 +214,6 @@ and open the template in the editor. Base Version before all crash :-) Add Deny network All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'. - ccm_address @@ -236,9 +231,8 @@ and open the template in the editor. Base Version before all crash :-) Add Address This function is useful when the server has many interfaces, but devices must connect only to some interfaces. - - + @@ -262,8 +256,8 @@ and open the template in the editor. Base Version before all crash :-) The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. - + @@ -440,6 +434,7 @@ and open the template in the editor. Base Version before all crash :-) Use simulated enbloc dialing to speedup connection when dialing while onhook (older phones) + @@ -513,8 +508,8 @@ and open the template in the editor. Base Version before all crash :-) Configure NTP Server protocol time synchronization - + @@ -907,8 +902,8 @@ and open the template in the editor. Base Version before all crash :-) - + @@ -954,6 +949,7 @@ and open the template in the editor. Base Version before all crash :-) Video Type Of Service / Class Of Service: Video Type or Class of Service - this is modifiable, but don't. + @@ -1001,7 +997,6 @@ and open the template in the editor. Base Version before all crash :-) - hotline_enabled @@ -1079,7 +1074,6 @@ and open the template in the editor. Base Version before all crash :-) Context where direct pickup search for extensions. if not set current context will be use. - pickup_modeanswer @@ -1130,7 +1124,6 @@ and open the template in the editor. Base Version before all crash :-) Other options (app_meetme: A,a,b,c,C,d,D,E,e,F,i,I,l,L,m,M,o,p,P,q,r,s,S,t,T,w,x,X,1) see meetme specific documentation - autocall_select @@ -1145,7 +1138,7 @@ and open the template in the editor. Base Version before all crash :-) true - I'm guessing on this one, but on some devices, the background image on the display can be modified at the device. I think this is the thing that allows that to take. + I'm guessing on this one, but on some devices, the background image on the display can be modified at the device. I think this is the thing that allows that to happen. phonePersonalization @@ -1153,7 +1146,7 @@ and open the template in the editor. Base Version before all crash :-) 0 - Phone personalization needs to be set to allow the server to push background or ringtones to the phone in the SEPXXXXXXXXXX.cnf.xml of each phone: + This needs to be enabled to allow the server to push background or ringtones to the phone in the SEPXXXXXXXXXX.cnf.xml of each phone: callLogBlfEnabled @@ -1161,7 +1154,7 @@ and open the template in the editor. Base Version before all crash :-) 2 - Which does show numbers you can redial, but also include their current device state, so you know when they are currently busy. Note that the other phonebook entries will now also monitor the remove device state and show the current device state + Show numbers you can redial, but also include their current device state, so you know when they are currently busy. Note that the other phonebook entries will now also monitor the remove device state and show the current device state @@ -1171,7 +1164,6 @@ and open the template in the editor. Base Version before all crash :-) form-control Music Class: Available MOH Classes. These are the MOH classes listed in your current server. - @@ -1204,7 +1196,6 @@ and open the template in the editor. Base Version before all crash :-) Use path from provision index.cnf file. You must first make sure that you have properly configured the "Provision" - tftp_rewrite @@ -1217,7 +1208,6 @@ and open the template in the editor. Base Version before all crash :-) Support the use of regular-expression-based filename remapping - devicetable @@ -1227,7 +1217,6 @@ and open the template in the editor. Base Version before all crash :-) sccp-custom Device Table: This is the devicetable for your realtime configuration. Don't change this unless you know what you are doing and have made all the appropriate changes in the rest of your Asterisk config files. There are two reasonable settings for this - the sccpdevice table or the sccpdeviceconfig view. If you do not want to use the realtime database anymore, you can set this to blank. NOT RECOMMENDED. - @@ -1237,7 +1226,6 @@ and open the template in the editor. Base Version before all crash :-) Line Table: This is the linetable for your realtime configuration. Don't change this unless you know what you are doing and have made all the appropriate changes in the rest of your Asterisk config files. If you do not want to use the realtime database anymore, you can set this to blank. NOT RECOMMENDED. - createlangdir @@ -1246,7 +1234,6 @@ and open the template in the editor. Base Version before all crash :-) Say 'yes' if you need to create cisco default language directory in tftp path. - system_rouminguser @@ -1255,9 +1242,9 @@ and open the template in the editor. Base Version before all crash :-) Experemental Function Roaming Users - - + + @@ -1269,7 +1256,6 @@ and open the template in the editor. Base Version before all crash :-) The MAC address of the phone. You must specify 12 characters in the format XXXX.XXXX.XXXX or XX-XX-XX-XX-XX-XX or XXXXXXXXXXXX - type @@ -1332,7 +1318,6 @@ and open the template in the editor. Base Version before all crash :-) - @@ -1391,8 +1376,8 @@ and open the template in the editor. Base Version before all crash :-) The ringtone that the phone will default to. Can be overridden in the phone. The files RINGLIST.XML provice the basic phone ring tones, while DISTINCTIVERINGLIST.XML defines the list of possible ring tones for your other line types. They, along with the actual 'raw' ringtones, are stored in the /tftpboot/ringtones directory with the rest of the config files. - + @@ -1404,8 +1389,8 @@ and open the template in the editor. Base Version before all crash :-) - + @@ -1473,9 +1458,7 @@ and open the template in the editor. Base Version before all crash :-) - - useRedialMenu @@ -1524,9 +1507,8 @@ and open the template in the editor. Base Version before all crash :-) - + Do not update history for this Phonebook if answered by another extension - @@ -1572,8 +1554,10 @@ and open the template in the editor. Base Version before all crash :-) form-control Play music on hold of this class when no moderator is listening on the conference. If set to an empty string, no music on hold will be played. - + + + custom_network_acc @@ -1608,7 +1592,6 @@ and open the template in the editor. Base Version before all crash :-) Help. - @@ -1628,10 +1611,8 @@ and open the template in the editor. Base Version before all crash :-) Add Deny network All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'. - - permit NONE Inherit @@ -1650,7 +1631,6 @@ and open the template in the editor. Base Version before all crash :-) Add Allow network Allow network settings. Blank fields will be ignored used Network 0.0.0.0. - nat @@ -1661,7 +1641,6 @@ and open the template in the editor. Base Version before all crash :-) Device NAT support (default Auto) - directrtp @@ -1686,6 +1665,7 @@ and open the template in the editor. Base Version before all crash :-) The audio stream will be open in the progress and connected state. Valid options: none, progress, offhook, dial, ringout. Default may be Progress. + @@ -1696,8 +1676,8 @@ and open the template in the editor. Base Version before all crash :-) Help. - + @@ -1768,7 +1748,6 @@ and open the template in the editor. Base Version before all crash :-) - dialtemplate */10/* @@ -1815,9 +1794,7 @@ and open the template in the editor. Base Version before all crash :-) CallWaiting-4 Allow network settings. Blank fields will be ignored used Network 0.0.0.0. - - '; @@ -500,7 +498,7 @@ foreach ($items as $child) { $select_opt= $tftp_lang; } if ($child['type'] == 'SLZ') { - $select_opt= $time_zone; + $select_opt= $timeZoneOffsetList; // $child->value = ($system_time_zone[offset]/60); } diff --git a/views/server.codec.php b/views/server.codec.php index ff543f4..4c5ded5 100644 --- a/views/server.codec.php +++ b/views/server.codec.php @@ -11,7 +11,7 @@ $def_val = null; $dev_id = null; $sccp_codec = $this->getCodecs('audio', true); $video_codecs = $this->getCodecs('video', true); -$sccp_disalow_def = $this->extconfigs->getextConfig('sccpDefaults', 'disallow'); +$sccp_disalow_def = $this->extconfigs->getExtConfig('sccpDefaults', 'disallow'); $sccp_disalow = $sccp_disalow_def; if (!empty($_REQUEST['id'])) { diff --git a/views/server.info.php b/views/server.info.php index de80df4..c1a2e47 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -119,7 +119,7 @@ if ($mysql_info['Value'] <= '2000') { // Check Time Zone compatibility $conf_tz = $this->sccpvalues['ntp_timezone']['data']; -$cisco_tz = $this->extconfigs->getextConfig('sccp_timezone', $conf_tz); +$cisco_tz = $this->extconfigs->getExtConfig('sccp_timezone', $conf_tz); if ($cisco_tz['offset'] == 0) { if (!empty($conf_tz)) { $tmp_dt = new DateTime(null, new DateTimeZone($conf_tz)); From cb890aa264cc3e6155b85bc92e64c3f9294f0109 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 22 Jun 2021 17:18:01 +0200 Subject: [PATCH 026/181] Update installer to check TFTP server is running and usable Use dummy put to test and locate the TFTP server Move all TFTP tests from extconfigs to install (reduces module constructor) --- Sccp_manager.class.php | 3 +- install.php | 184 +++++++++++++++++++++++++--- module.xml | 2 +- sccpManClasses/extconfigs.class.php | 135 +------------------- 4 files changed, 174 insertions(+), 150 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 4c0d8dc..a18eade 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -956,7 +956,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Check file paths and permissions */ - // !TODO!: -TODO-: This function is getting a little big. Might be possible to sperate tftp work into it's own file/class. Initially, you need to remove the not working section and commented out section function initializeSccpPath() { global $db; global $amp_conf; @@ -978,7 +977,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $driver = $this->FreePBX->Core->getAllDriversInfo(); $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); + //$this->sccppath = $this->extconfigs->validate_init_path($confDir, $this->sccpvalues); $driver = $this->FreePBX->Core->getAllDriversInfo(); // Check that Sccp Driver has been updated by above $read_config = $this->cnf_read->getConfig('sccp.conf'); diff --git a/install.php b/install.php index d485969..305871a 100644 --- a/install.php +++ b/install.php @@ -10,6 +10,8 @@ global $version; global $aminterface; global $mobile_hw; global $useAmiForSoftKeys; +global $settingsFromDb; +global $cnf_int; $mobile_hw = '0'; $autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT" : "AUTO_INCREMENT"; $table_req = array('sccpdevice', 'sccpline', 'sccpsettings'); @@ -17,8 +19,14 @@ $sccp_compatible = 0; $chanSCCPWarning = true; $db_config = ''; $sccp_version = array(); +$cnf_int = \FreePBX::Config(); CheckSCCPManagerDBTables($table_req); + +$stmt = $db->prepare("SELECT * FROM sccpsettings"); +$stmt->execute(); +$settingsFromDb = $stmt->fetchAll(\PDO::FETCH_ASSOC); + CheckAsteriskVersion(); // Have essential tables so can create Sccp_manager object and verify have aminterface @@ -66,6 +74,7 @@ if ($chanSCCPWarning) { } Setup_RealTime(); addDriver($sccp_compatible); +checkTftpServer(); outn("
    "); outn("Install Complete !"); outn("
    "); @@ -283,7 +292,6 @@ function Get_DB_config($sccp_compatible) function CheckSCCPManagerDBTables($table_req) { // These tables should already exist having been created by FreePBX through module.xml - global $amp_conf; global $db; outn("
  • " . _("Checking for required Sccp_manager database tables..") . "
  • "); foreach ($table_req as $value) { @@ -300,17 +308,13 @@ function CheckSCCPManagerDBVersion() { global $db; outn("
  • " . _("Checking for previous version of Sccp_manager.") . "
  • "); - $check = $db->getRow("SELECT data FROM `sccpsettings` where keyword ='sccp_compatible'", DB_FETCHMODE_ASSOC); - if (DB::IsError($check)) { + + if (!isset($settingsFromDb['sccp_compatible']['data'])) { outn(_("No previous version found ")); return false; } - if (!empty($check['data'])) { - outn(_("Found DB Schema : " . $check['data'])); - return $check['data']; - } else { - return false; - } + outn(_("Found DB Schema : {$settingsFromDb['sccp_compatible']['data']}")); + return $settingsFromDb['sccp_compatible']['data']; } /* notused */ @@ -707,8 +711,8 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) function createBackUpConfig() { global $amp_conf; + global $cnf_int; outn("
  • " . _("Creating Config BackUp") . "
  • "); - $cnf_int = \FreePBX::Config(); $backup_files = array('extensions','extconfig','res_mysql', 'res_config_mysql','sccp','sccp_hardware','sccp_extensions'); $backup_ext = array('_custom.conf', '_additional.conf','.conf'); $dir = $cnf_int->get('ASTETCDIR'); @@ -745,9 +749,8 @@ function createBackUpConfig() function RenameConfig() { - global $amp_conf; outn("
  • " . _("Move Old Config") . "
  • "); - $cnf_int = \FreePBX::Config(); + global $cnf_int; $rename_files = array('sccp_hardware','sccp_extensions'); $rename_ext = array('_custom.conf', '_additional.conf','.conf'); $dir = $cnf_int->get('ASTETCDIR'); @@ -764,7 +767,7 @@ function Setup_RealTime() { outn("
  • " . _("Checking realtime configuration ...") . "
  • "); global $amp_conf; - $cnf_int = \FreePBX::Config(); + global $cnf_int; $cnf_wr = \FreePBX::WriteConfig(); $cnf_read = \FreePBX::LoadConfig(); @@ -858,7 +861,7 @@ function addDriver($sccp_compatible) { $contents = ""; file_put_contents($file, $contents); - $cnf_int = \FreePBX::Config(); + global $cnf_int; $dir = $cnf_int->get('ASTETCDIR'); if (!file_exists("{$dir}/sccp.conf")) { // System re Config outn("
  • " . _("Adding default configuration file ...") . "
  • "); @@ -866,5 +869,158 @@ function addDriver($sccp_compatible) { file_put_contents("{$dir}/sccp.conf", $sccpfile); } } +function checkTftpServer() { + global $db; + global $cnf_int; + $confDir = $cnf_int->get('ASTETCDIR'); + // TODO: add option to use external server + $remoteFile = "TestFileXXX111.txt"; // should not exist + tftp_put_test_file(); + + $possibleFtpDirs = array('/srv', '/srv/tftp','/var/lib/tftp', '/tftpboot'); + foreach ($possibleFtpDirs as $dirToTest) { + if (file_exists("{$dirToTest}/{$remoteFile}")) { + $tftpRootPath = $dirToTest; + unlink("{$dirToTest}/{$remoteFile}"); + outn("
  • " . _("Found ftp root dir at {$dirToTest}") . "
  • "); + + $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('tftp_path', '{$tftpRootPath}','0','0');"; + $results = $db->query($sql); + if (DB::IsError($results)) { + die_freepbx(sprintf(_("Error updating tftp_path in sccpsettings. Command was: %s; error was: %s "), $sql, $results->getMessage())); + } + break; + } + } + + if (empty($tftpRootPath)) { + die_freepbx(_("Either tftp server is down or TFTP root is non standard. Please fix, refresh, and try again")); + } + if (!is_writeable($tftpRootPath)) { + die_freepbx(_("{$tftpRootPath} is not writable by user asterisk. Please fix, refresh and try again")); + } + + $adv_config = array('tftproot' => '', + 'firmware' => 'firmware', + 'settings' => 'settings', + 'locales' => 'locales', + 'languages' => 'languages', + 'templates' => 'templates', + 'dialplan' => 'dialplan', + 'softkey' => 'softkey' + ); + + $adv_tree['pro'] = array('templates' => 'tftproot', + 'settings' => 'tftproot', + 'locales' => 'tftproot', + 'firmware' => 'tftproot', + 'languages' => 'locales', + 'dialplan' => 'tftproot', + 'softkey' => 'tftproot' + ); + + $adv_tree['def'] = array('templates' => 'tftproot', + 'settings' => '', + 'locales' => '', + 'firmware' => '', + 'languages' => 'tftproot', + 'dialplan' => '', + 'softkey' => '' + ); + + $base_tree = array('tftp_templates' => 'templates', + 'tftp_path_store' => 'settings', + 'tftp_lang_path' => 'languages', + 'tftp_firmware_path' => 'firmware', + 'tftp_dialplan' => 'dialplan', + 'tftp_softkey' => 'softkey' + ); + + $base_config = array('asterisk' => $confDir, + 'sccp_conf' => "$confDir/sccp.conf", + 'tftp_path' => $tftpRootPath); + + if (!empty($db_vars['tftp_rewrite_path'])) { + $adv_ini = $db_vars['tftp_rewrite_path']["data"]; + } + + $adv_tree_mode = 'def'; + if (empty($db_vars["tftp_rewrite"])) { + $db_vars["tftp_rewrite"]["data"] = "off"; + } + + $adv_config['tftproot'] = $base_config["tftp_path"]; + if ($settingsFromDb["tftp_rewrite"]["data"] == 'pro') { + $adv_tree_mode = 'pro'; + if (!empty($adv_ini)) { // something found in external conflicts + $adv_ini .= '/index.cnf'; + if (file_exists($adv_ini)) { + $adv_ini_array = parse_ini_file($adv_ini); + $adv_config = array_merge($adv_config, $adv_ini_array); + } + } + } + if ($settingsFromDb["tftp_rewrite"]["data"] == 'on') { + $adv_tree_mode = 'def'; + } + foreach ($adv_tree[$adv_tree_mode] as $key => $value) { + if (!empty($adv_config[$key])) { + if (!empty($value)) { + if (substr($adv_config[$key], 0, 1) != "/") { + $adv_config[$key] = $adv_config[$value] . '/' . $adv_config[$key]; + } + } else { + $adv_config[$key] = $adv_config['tftproot']; + } + } + } + foreach ($base_tree as $key => $value) { + $base_config[$key] = $adv_config[$value]; + if (!file_exists($base_config[$key])) { + if (!mkdir($base_config[$key], 0777, true)) { + die('Error creating dir : ' . $base_config[$key]); + } + } + } + + if (!file_exists($base_config["tftp_templates"] . '/XMLDefault.cnf.xml_template')) { + $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; + $dst_path = $base_config["tftp_templates"] . '/'; + foreach (glob($src_path . '*.*_template') as $filename) { + copy($filename, $dst_path . basename($filename)); + } + } + return $base_config; +} + +function tftp_put_test_file() +{ + // https://datatracker.ietf.org/doc/html/rfc1350 + $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + $host = "127.0.0.1"; // TODO: Should consider remote TFT Servers in future + + // create the WRQ request packet + $packet = chr(0) . chr(2) . "TestFileXXX111.txt" . chr(0) . 'netascii' . chr(0); + // UDP is connectionless, so we just send it. + socket_sendto($socket, $packet, strlen($packet), MSG_EOR, $host, 69); + + $buffer = ''; + $port = ''; + $ret = ''; + + // Should now receive an ack packet + socket_recvfrom($socket, $buffer, 4, MSG_PEEK, $host, $port); + + // Then should send our data packet + $packet = chr(0) . chr(3) . chr(0) . chr(1) . 'This is a test file'; + socket_sendto($socket, $packet, strlen($packet), MSG_EOR, $host, $port); + + // finally will recieve an ack packet + socket_recvfrom($socket, $buffer, 4, MSG_PEEK, $host, $port); + + socket_close($socket); + + return; +} ?> diff --git a/module.xml b/module.xml index 57723fe..cd5c29f 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 75cdd6d..e73df46 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -113,8 +113,7 @@ class extconfigs "hotline_extension" => '*60', # !TODO!: Is this a good default extension to dial for hotline ? "hotline_label" => 'hotline', "devicetable" => 'sccpdevice', - "linetable" => 'sccpline', - "tftp_path" => '/tftpboot' + "linetable" => 'sccpline' ); private $keysetdefault = array('onhook' => 'redial,newcall,cfwdall,cfwdbusy,cfwdnoanswer,pickup,gpickup,dnd,private', 'connected' => 'hold,endcall,park,vidmode,select,cfwdall,cfwdbusy,idivert,monitor', @@ -221,137 +220,7 @@ class extconfigs 'New Zealand' => array('offset' => '720', 'daylight' => true) ); - public function validate_init_path($confDir = '', $db_vars) { - $adv_config = array('tftproot' => '', - 'firmware' => 'firmware', - 'settings' => 'settings', - 'locales' => 'locales', - 'languages' => 'languages', - 'templates' => 'templates', - 'dialplan' => 'dialplan', - 'softkey' => 'softkey' - ); - - $adv_tree['pro'] = array('templates' => 'tftproot', - 'settings' => 'tftproot', - 'locales' => 'tftproot', - 'firmware' => 'tftproot', - 'languages' => 'locales', - 'dialplan' => 'tftproot', - 'softkey' => 'tftproot' - ); - - $adv_tree['def'] = array('templates' => 'tftproot', - 'settings' => '', - 'locales' => '', - 'firmware' => '', - 'languages' => 'tftproot', - 'dialplan' => '', - 'softkey' => '' - ); - - $base_tree = array('tftp_templates' => 'templates', - 'tftp_path_store' => 'settings', - 'tftp_lang_path' => 'languages', - 'tftp_firmware_path' => 'firmware', - 'tftp_dialplan' => 'dialplan', - 'tftp_softkey' => 'softkey' - ); - - if (empty($confDir)) { - return array('error' => 'empty СonfDir'); - } - - $base_config = array('asterisk' => $confDir, - 'sccp_conf' => "$confDir/sccp.conf", - 'tftp_path' => ''); - -// Test Base dir (/tftproot) - if (!empty($db_vars["tftp_path"])) { - if (file_exists($db_vars["tftp_path"]["data"])) { - $base_config["tftp_path"] = $db_vars["tftp_path"]["data"]; - } - } - if (empty($base_config["tftp_path"])) { - if (file_exists($this->getExtConfig('sccpDefaults', "tftp_path"))) { - $base_config["tftp_path"] = $this->getExtConfig('sccpDefaults', "tftp_path"); - } - } - if (empty($base_config["tftp_path"])) { - if (!empty($this->paren_class)) { - $this->paren_class->class_error['tftp_path'] = 'Tftp path not exist or not defined'; - } - return array('error' => 'empty tftp_path'); - } - if (!is_writeable($base_config["tftp_path"])) { - if (!empty($this->paren_class)) { - $this->paren_class->class_error['tftp_path'] = 'No write permission on tftp DIR'; - } - return array('error' => 'No write permission on tftp DIR'); - } -// END Test Base dir (/tftproot) - - if (!empty($db_vars['tftp_rewrite_path'])) { - $adv_ini = $db_vars['tftp_rewrite_path']["data"]; - } - - $adv_tree_mode = 'def'; - if (empty($db_vars["tftp_rewrite"])) { - $db_vars["tftp_rewrite"]["data"] = "off"; - } - - $adv_config['tftproot'] = $base_config["tftp_path"]; - if ($db_vars["tftp_rewrite"]["data"] == 'pro') { - $adv_tree_mode = 'pro'; - if (!empty($adv_ini)) { // something found in external conflicts - $adv_ini .= '/index.cnf'; - if (file_exists($adv_ini)) { - $adv_ini_array = parse_ini_file($adv_ini); - $adv_config = array_merge($adv_config, $adv_ini_array); - } - } - } - if ($db_vars["tftp_rewrite"]["data"] == 'on') { - $adv_tree_mode = 'def'; - } - foreach ($adv_tree[$adv_tree_mode] as $key => $value) { - if (!empty($adv_config[$key])) { - if (!empty($value)) { - if (substr($adv_config[$key], 0, 1) != "/") { - $adv_config[$key] = $adv_config[$value] . '/' . $adv_config[$key]; - } - } else { - $adv_config[$key] = $adv_config['tftproot']; - } - } - } - foreach ($base_tree as $key => $value) { - $base_config[$key] = $adv_config[$value]; - if (!file_exists($base_config[$key])) { - if (!mkdir($base_config[$key], 0777, true)) { - die('Error creating dir : ' . $base_config[$key]); - } - } - } - - // TFTP -REWrite double model - if (empty($_SERVER['DOCUMENT_ROOT'])) { - if (!empty($this->paren_class)) { - $this->paren_class->class_error['DOCUMENT_ROOT'] = 'Empty DOCUMENT_ROOT'; - } - $base_config['error'] = 'Empty DOCUMENT_ROOT'; - return $base_config; - } - - if (!file_exists($base_config["tftp_templates"] . '/XMLDefault.cnf.xml_template')) { - $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; - $dst_path = $base_config["tftp_templates"] . '/'; - foreach (glob($src_path . '*.*_template') as $filename) { - copy($filename, $dst_path . basename($filename)); - } - } - return $base_config; - } + public function validate_RealTime( $connector ) { From 4e153761811557288b9e3dbfe7f4bfdd2dfd2011 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 22 Jun 2021 20:53:41 +0200 Subject: [PATCH 027/181] Update install.php --- install.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index 305871a..60781e2 100644 --- a/install.php +++ b/install.php @@ -894,7 +894,7 @@ function checkTftpServer() { } if (empty($tftpRootPath)) { - die_freepbx(_("Either tftp server is down or TFTP root is non standard. Please fix, refresh, and try again")); + die_freepbx(_("Either TFTP server is down or TFTP root is non standard. Please fix, refresh, and try again")); } if (!is_writeable($tftpRootPath)) { die_freepbx(_("{$tftpRootPath} is not writable by user asterisk. Please fix, refresh and try again")); @@ -1012,7 +1012,7 @@ function tftp_put_test_file() socket_recvfrom($socket, $buffer, 4, MSG_PEEK, $host, $port); // Then should send our data packet - $packet = chr(0) . chr(3) . chr(0) . chr(1) . 'This is a test file'; + $packet = chr(0) . chr(3) . chr(0) . chr(1) . 'This is a test file created by Sccp_Manager. It can be deleted without any impact'; socket_sendto($socket, $packet, strlen($packet), MSG_EOR, $host, $port); // finally will recieve an ack packet From d422776ad614e4b59cca1502293b9a3af56e045f Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 23 Jun 2021 12:35:33 +0200 Subject: [PATCH 028/181] Create full TFTP Pro structure and save relevant settings Default structure now created is ready for pro use and settings have been moved to sccp settings and not stored in array sccppath --- conf/sccpgeneral.xml.v433 | 4 +-- install.php | 75 ++++++++++++++++++++++++++------------- 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 6fc466e..dc0a88d 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1179,7 +1179,7 @@ and open the template in the editor. Base Version before all crash :-) provision_show tftp_rewrite_path - /tftpboot + sccp-custom Use path from provision index.cnf file. You must first make sure that you have properly configured the "Provision" @@ -1228,7 +1228,7 @@ and open the template in the editor. Base Version before all crash :-) no - Experemental Function Roaming Users + Experimental Function Roaming Users diff --git a/install.php b/install.php index 60781e2..dbdd867 100644 --- a/install.php +++ b/install.php @@ -26,7 +26,10 @@ CheckSCCPManagerDBTables($table_req); $stmt = $db->prepare("SELECT * FROM sccpsettings"); $stmt->execute(); $settingsFromDb = $stmt->fetchAll(\PDO::FETCH_ASSOC); - +foreach ($settingsFromDb as $key => $rowArray) { + $settingsFromDb[$rowArray['keyword']] = $rowArray; + unset($settingsFromDb[$key]); +} CheckAsteriskVersion(); // Have essential tables so can create Sccp_manager object and verify have aminterface @@ -872,6 +875,7 @@ function addDriver($sccp_compatible) { function checkTftpServer() { global $db; global $cnf_int; + global $settingsFromDb; $confDir = $cnf_int->get('ASTETCDIR'); // TODO: add option to use external server $remoteFile = "TestFileXXX111.txt"; // should not exist @@ -883,11 +887,8 @@ function checkTftpServer() { $tftpRootPath = $dirToTest; unlink("{$dirToTest}/{$remoteFile}"); outn("
  • " . _("Found ftp root dir at {$dirToTest}") . "
  • "); - - $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('tftp_path', '{$tftpRootPath}','0','0');"; - $results = $db->query($sql); - if (DB::IsError($results)) { - die_freepbx(sprintf(_("Error updating tftp_path in sccpsettings. Command was: %s; error was: %s "), $sql, $results->getMessage())); + if ($settingsFromDb['tftp_path']['data'] != $tftpRootPath) { + $settingsToDb["tftp_path"] =array( 'keyword' => 'tftp_path', 'seq' => 2, 'type' => 0, 'data' => $tftpRootPath); } break; } @@ -900,7 +901,7 @@ function checkTftpServer() { die_freepbx(_("{$tftpRootPath} is not writable by user asterisk. Please fix, refresh and try again")); } - $adv_config = array('tftproot' => '', + $adv_config = array('tftproot' => $tftpRootPath, 'firmware' => 'firmware', 'settings' => 'settings', 'locales' => 'locales', @@ -940,29 +941,43 @@ function checkTftpServer() { 'sccp_conf' => "$confDir/sccp.conf", 'tftp_path' => $tftpRootPath); - if (!empty($db_vars['tftp_rewrite_path'])) { - $adv_ini = $db_vars['tftp_rewrite_path']["data"]; + if (!empty($settingsFromDb['tftp_rewrite_path']['data'])) { + // Have a setting in sccpsettings. It should start with $tftpRootPath + // If not we will replace it with $tftpRootPath. Avoids issues with legacy values + if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$tftpRootPath)) { + + $adv_ini = "{$tftpRootPath}/index.cnf"; + $settingsToDb['tftp_rewrite_path'] = $settingsFromDb['tftp_rewrite_path']; + $settingsToDb['tftp_rewrite_path']['data'] = $tftpRootPath; + } + $adv_ini = "{$settingsFromDb['tftp_rewrite_path']["data"]}/index.cnf"; } - $adv_tree_mode = 'def'; - if (empty($db_vars["tftp_rewrite"])) { - $db_vars["tftp_rewrite"]["data"] = "off"; - } + $adv_tree_mode = 'pro'; // Set to pro so that create full directory structure - $adv_config['tftproot'] = $base_config["tftp_path"]; - if ($settingsFromDb["tftp_rewrite"]["data"] == 'pro') { - $adv_tree_mode = 'pro'; - if (!empty($adv_ini)) { // something found in external conflicts - $adv_ini .= '/index.cnf'; - if (file_exists($adv_ini)) { +// TODO: Below can be simplified for the installer but leave as is until have +// modified in sccp_manager to account for changed settings. + + switch ($settingsFromDb["tftp_rewrite"]["data"]) { + case 'on': + break; + case 'pro': + $adv_tree_mode = 'pro'; + if (!empty($adv_ini) && file_exists($adv_ini)) { $adv_ini_array = parse_ini_file($adv_ini); $adv_config = array_merge($adv_config, $adv_ini_array); } - } - } - if ($settingsFromDb["tftp_rewrite"]["data"] == 'on') { - $adv_tree_mode = 'def'; + break; + case 'internal': + break; + case 'off': + break; + default: + // includes case where the value is undefined + $settingsToDb["tftp_rewrite"] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'off'); + // TODO: Need to write this back to sccpsettings } + foreach ($adv_tree[$adv_tree_mode] as $key => $value) { if (!empty($adv_config[$key])) { if (!empty($value)) { @@ -976,9 +991,11 @@ function checkTftpServer() { } foreach ($base_tree as $key => $value) { $base_config[$key] = $adv_config[$value]; + // Save to sccpsettings + $settingsToDb[$key] =array( 'keyword' => $key, 'seq' => 20, 'type' => 0, 'data' => $adv_config[$value]); if (!file_exists($base_config[$key])) { if (!mkdir($base_config[$key], 0777, true)) { - die('Error creating dir : ' . $base_config[$key]); + die_freepbx(_('Error creating dir : ' . $base_config[$key])); } } } @@ -990,7 +1007,15 @@ function checkTftpServer() { copy($filename, $dst_path . basename($filename)); } } - return $base_config; + + foreach ($settingsToDb as $settingToSave) { + $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']});"; + $results = $db->query($sql); + if (DB::IsError($results)) { + die_freepbx(_("Error updating sccpsettings. $sql")); + } + } + return; } function tftp_put_test_file() From ec799256611ff3fb396e59ba2a8584d01c3b8596 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 23 Jun 2021 13:21:19 +0200 Subject: [PATCH 029/181] add asterisk etc dir to sccp settings --- Sccp_manager.class.php | 1 + install.php | 1 + module.xml | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index a18eade..ca73889 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -140,6 +140,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); // Overwrite Exist + $this->initializeSccpPath(); $this->initVarfromDefs(); $this->initTftpLang(); diff --git a/install.php b/install.php index dbdd867..d19420f 100644 --- a/install.php +++ b/install.php @@ -1007,6 +1007,7 @@ function checkTftpServer() { copy($filename, $dst_path . basename($filename)); } } + $settingsToDb['asterisk_etc_path'] =array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir); foreach ($settingsToDb as $settingToSave) { $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']});"; diff --git a/module.xml b/module.xml index cd5c29f..57723fe 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.0 + 14.3.0.1 setup SCCP Connectivity Steve Lad, Alex GP From d7e196cf213c46c338eec245b9aa27e6f40a2bbd Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 23 Jun 2021 17:03:24 +0200 Subject: [PATCH 030/181] Clean up installer and partially revert externconfigs Remove ancillary function to traits Move tftp directory management back to extern configs Remove call to extern configs from InitialiseSccpPath and so from Construct Need to add call to updateTftpStructure when settings changed ---WIP --- --- Sccp_manager.class.php | 23 ++-- install.php | 195 ++++----------------------- module.xml | 2 +- sccpManClasses/dbinterface.class.php | 7 +- sccpManClasses/extconfigs.class.php | 108 ++++++++++++++- sccpManTraits/helperFunctions.php | 30 +++++ 6 files changed, 181 insertions(+), 184 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index ca73889..a9744fe 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -140,7 +140,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); // Overwrite Exist - $this->initializeSccpPath(); $this->initVarfromDefs(); $this->initTftpLang(); @@ -958,27 +957,25 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ function initializeSccpPath() { - global $db; - global $amp_conf; $driver_revision = array('0' => '', '430' => '.v431', '431' => '.v432', '432' => '.v432', '433' => '.v433' . $this->sccp_branch); - - $confDir = $amp_conf["ASTETCDIR"]; - if (empty($this->sccppath["asterisk"])) { - if (strlen($confDir) < 1) { - $this->sccppath["asterisk"] = "/etc/asterisk"; - } else { - $this->sccppath["asterisk"] = $confDir; - } - } $ver_id = $this->aminterface->get_compatible_sccp(); if (!empty($this->sccpvalues['SccpDBmodel'])) { $ver_id = $this->sccpvalues['SccpDBmodel']['data']; } + $sccppath = array( + 'asterisk' => $this->sccpvalues['asterisk_etc_path']['data'], + 'tftp_path' => $this->sccpvalues['tftp_path']['data'], + 'tftp_templates' => $this->sccpvalues['tftp_templates']['data'], + 'tftp_path_store' => $this->sccpvalues['tftp_path_store']['data'], + 'tftp_lang_path' => $this->sccpvalues['tftp_lang_path']['data'], + 'tftp_firmware_path' => $this->sccpvalues['tftp_firmware_path']['data'], + 'tftp_dialplan' => $this->sccpvalues['tftp_dialplan']['data'], + 'tftp_softkey' => $this->sccpvalues['tftp_softkey']['data'] + ); $driver = $this->FreePBX->Core->getAllDriversInfo(); $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); $driver = $this->FreePBX->Core->getAllDriversInfo(); // Check that Sccp Driver has been updated by above $read_config = $this->cnf_read->getConfig('sccp.conf'); diff --git a/install.php b/install.php index d19420f..d5d380a 100644 --- a/install.php +++ b/install.php @@ -8,9 +8,11 @@ global $db; global $amp_conf; global $version; global $aminterface; +global $extConfigs; global $mobile_hw; global $useAmiForSoftKeys; global $settingsFromDb; +global $thisInstaller; global $cnf_int; $mobile_hw = '0'; $autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT" : "AUTO_INCREMENT"; @@ -21,7 +23,20 @@ $db_config = ''; $sccp_version = array(); $cnf_int = \FreePBX::Config(); -CheckSCCPManagerDBTables($table_req); +$thisInstaller = new class{ + use \FreePBX\modules\Sccp_Manager\sccpManTraits\helperFunctions; +}; + +$requiredClasses = array('amiinterface', 'extconfigs'); +foreach ($requiredClasses as $className) { + $class = "\\FreePBX\\Modules\\Sccp_manager\\$className"; + if (!class_exists($class, false)) { + include(__DIR__ . "/sccpManClasses/$className.class.php"); + } + if (class_exists($class, false)) { + ${$className} = new $class(); + } +} $stmt = $db->prepare("SELECT * FROM sccpsettings"); $stmt->execute(); @@ -30,23 +45,17 @@ foreach ($settingsFromDb as $key => $rowArray) { $settingsFromDb[$rowArray['keyword']] = $rowArray; unset($settingsFromDb[$key]); } + +// Do not create Sccp_Manager object as not required. +// Only include required classes + + + CheckAsteriskVersion(); - -// Have essential tables so can create Sccp_manager object and verify have aminterface -$ss = FreePBX::create()->Sccp_manager; - -$class = "\\FreePBX\\Modules\\Sccp_manager\\aminterface"; -if (!class_exists($class, false)) { - include(__DIR__ . "/sccpManClasses/aminterface.class.php"); -} -if (class_exists($class, false)) { - $aminterface = new $class(); -} - $sccp_version = CheckChanSCCPCompatible(); $sccp_compatible = $sccp_version[0]; $chanSCCPWarning = $sccp_version[1] ^= 1; -outn("
  • " . _("Sccp model Compatible code : ") . $resultReturned[0] . "
  • "); +outn("
  • " . _("Sccp model Compatible code : ") . $sccp_compatible . "
  • "); if ($sccp_compatible == 0) { outn("
    "); outn("Chan Sccp not Found. Install it before continuing !"); @@ -292,24 +301,10 @@ function Get_DB_config($sccp_compatible) } -function CheckSCCPManagerDBTables($table_req) -{ - // These tables should already exist having been created by FreePBX through module.xml - global $db; - outn("
  • " . _("Checking for required Sccp_manager database tables..") . "
  • "); - foreach ($table_req as $value) { - $check = $db->getRow("SELECT 1 FROM `$value` LIMIT 0", DB_FETCHMODE_ASSOC); - if (DB::IsError($check)) { - outn(_("Can't find table: " . $value)); - outn(_("Please goto the chan-sccp/conf directory and create the DB schema manually (See wiki)")); - die_freepbx("!!!! Installation error: Can not find required " . $value . " table !!!!!!\n"); - } - } -} - function CheckSCCPManagerDBVersion() { global $db; + global $settingsFromDb; outn("
  • " . _("Checking for previous version of Sccp_manager.") . "
  • "); if (!isset($settingsFromDb['sccp_compatible']['data'])) { @@ -333,8 +328,8 @@ function CheckPermissions() function CheckAsteriskVersion() { - outn("
  • " . _("Checking Asterisk Version : ") . $version . "
  • "); $version = FreePBX::Config()->get('ASTVERSION'); + outn("
  • " . _("Checking Asterisk Version : ") . $version . "
  • "); if (!empty($version)) { // Woo, we have a version if (version_compare($version, "12.2.0", ">=")) { @@ -876,10 +871,12 @@ function checkTftpServer() { global $db; global $cnf_int; global $settingsFromDb; + global $extConfigs; + global $thisInstaller; $confDir = $cnf_int->get('ASTETCDIR'); // TODO: add option to use external server $remoteFile = "TestFileXXX111.txt"; // should not exist - tftp_put_test_file(); + $thisInstaller->tftp_put_test_file(); $possibleFtpDirs = array('/srv', '/srv/tftp','/var/lib/tftp', '/tftpboot'); foreach ($possibleFtpDirs as $dirToTest) { @@ -901,112 +898,8 @@ function checkTftpServer() { die_freepbx(_("{$tftpRootPath} is not writable by user asterisk. Please fix, refresh and try again")); } - $adv_config = array('tftproot' => $tftpRootPath, - 'firmware' => 'firmware', - 'settings' => 'settings', - 'locales' => 'locales', - 'languages' => 'languages', - 'templates' => 'templates', - 'dialplan' => 'dialplan', - 'softkey' => 'softkey' - ); + $extConfigs->updateTftpStructure($settingsFromDb); - $adv_tree['pro'] = array('templates' => 'tftproot', - 'settings' => 'tftproot', - 'locales' => 'tftproot', - 'firmware' => 'tftproot', - 'languages' => 'locales', - 'dialplan' => 'tftproot', - 'softkey' => 'tftproot' - ); - - $adv_tree['def'] = array('templates' => 'tftproot', - 'settings' => '', - 'locales' => '', - 'firmware' => '', - 'languages' => 'tftproot', - 'dialplan' => '', - 'softkey' => '' - ); - - $base_tree = array('tftp_templates' => 'templates', - 'tftp_path_store' => 'settings', - 'tftp_lang_path' => 'languages', - 'tftp_firmware_path' => 'firmware', - 'tftp_dialplan' => 'dialplan', - 'tftp_softkey' => 'softkey' - ); - - $base_config = array('asterisk' => $confDir, - 'sccp_conf' => "$confDir/sccp.conf", - 'tftp_path' => $tftpRootPath); - - if (!empty($settingsFromDb['tftp_rewrite_path']['data'])) { - // Have a setting in sccpsettings. It should start with $tftpRootPath - // If not we will replace it with $tftpRootPath. Avoids issues with legacy values - if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$tftpRootPath)) { - - $adv_ini = "{$tftpRootPath}/index.cnf"; - $settingsToDb['tftp_rewrite_path'] = $settingsFromDb['tftp_rewrite_path']; - $settingsToDb['tftp_rewrite_path']['data'] = $tftpRootPath; - } - $adv_ini = "{$settingsFromDb['tftp_rewrite_path']["data"]}/index.cnf"; - } - - $adv_tree_mode = 'pro'; // Set to pro so that create full directory structure - -// TODO: Below can be simplified for the installer but leave as is until have -// modified in sccp_manager to account for changed settings. - - switch ($settingsFromDb["tftp_rewrite"]["data"]) { - case 'on': - break; - case 'pro': - $adv_tree_mode = 'pro'; - if (!empty($adv_ini) && file_exists($adv_ini)) { - $adv_ini_array = parse_ini_file($adv_ini); - $adv_config = array_merge($adv_config, $adv_ini_array); - } - break; - case 'internal': - break; - case 'off': - break; - default: - // includes case where the value is undefined - $settingsToDb["tftp_rewrite"] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'off'); - // TODO: Need to write this back to sccpsettings - } - - foreach ($adv_tree[$adv_tree_mode] as $key => $value) { - if (!empty($adv_config[$key])) { - if (!empty($value)) { - if (substr($adv_config[$key], 0, 1) != "/") { - $adv_config[$key] = $adv_config[$value] . '/' . $adv_config[$key]; - } - } else { - $adv_config[$key] = $adv_config['tftproot']; - } - } - } - foreach ($base_tree as $key => $value) { - $base_config[$key] = $adv_config[$value]; - // Save to sccpsettings - $settingsToDb[$key] =array( 'keyword' => $key, 'seq' => 20, 'type' => 0, 'data' => $adv_config[$value]); - if (!file_exists($base_config[$key])) { - if (!mkdir($base_config[$key], 0777, true)) { - die_freepbx(_('Error creating dir : ' . $base_config[$key])); - } - } - } - - if (!file_exists($base_config["tftp_templates"] . '/XMLDefault.cnf.xml_template')) { - $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; - $dst_path = $base_config["tftp_templates"] . '/'; - foreach (glob($src_path . '*.*_template') as $filename) { - copy($filename, $dst_path . basename($filename)); - } - } $settingsToDb['asterisk_etc_path'] =array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir); foreach ($settingsToDb as $settingToSave) { @@ -1019,34 +912,4 @@ function checkTftpServer() { return; } -function tftp_put_test_file() -{ - // https://datatracker.ietf.org/doc/html/rfc1350 - $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - $host = "127.0.0.1"; // TODO: Should consider remote TFT Servers in future - - // create the WRQ request packet - $packet = chr(0) . chr(2) . "TestFileXXX111.txt" . chr(0) . 'netascii' . chr(0); - // UDP is connectionless, so we just send it. - socket_sendto($socket, $packet, strlen($packet), MSG_EOR, $host, 69); - - $buffer = ''; - $port = ''; - $ret = ''; - - // Should now receive an ack packet - socket_recvfrom($socket, $buffer, 4, MSG_PEEK, $host, $port); - - // Then should send our data packet - $packet = chr(0) . chr(3) . chr(0) . chr(1) . 'This is a test file created by Sccp_Manager. It can be deleted without any impact'; - socket_sendto($socket, $packet, strlen($packet), MSG_EOR, $host, $port); - - // finally will recieve an ack packet - socket_recvfrom($socket, $buffer, 4, MSG_PEEK, $host, $port); - - socket_close($socket); - - return; -} - ?> diff --git a/module.xml b/module.xml index 57723fe..cd5c29f 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 9a03a00..2427663 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -163,10 +163,11 @@ class dbinterface $dbh = \FreePBX::Database(); $stmt = $dbh->prepare('SELECT keyword, data, type, seq FROM sccpsettings ORDER BY type, seq'); $stmt->execute(); - foreach ($stmt->fetchAll() as $var) { - $mysccpvalues[$var['keyword']] = array('keyword' => $var['keyword'], 'data' => $var['data'], 'seq' => $var['seq'], 'type' => $var['type']); + foreach ($stmt->fetchAll() as $key => $rowArray) { + $settingsFromDb[$rowArray['keyword']] = $rowArray; + unset($settingsFromDb[$key]); } - return $mysccpvalues; + return $settingsFromDb; } public function get_db_sysvalues() diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index e73df46..4f42ade 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -220,7 +220,113 @@ class extconfigs 'New Zealand' => array('offset' => '720', 'daylight' => true) ); - + public function updateTftpStructure($settingsFromDb) { + $adv_config = array('tftproot' => $settingsFromDb['tftp_path']['data'], + 'firmware' => 'firmware', + 'settings' => 'settings', + 'locales' => 'locales', + 'languages' => 'languages', + 'templates' => 'templates', + 'dialplan' => 'dialplan', + 'softkey' => 'softkey' + ); + + $adv_tree['pro'] = array('templates' => 'tftproot', + 'settings' => 'tftproot', + 'locales' => 'tftproot', + 'firmware' => 'tftproot', + 'languages' => 'locales', + 'dialplan' => 'tftproot', + 'softkey' => 'tftproot' + ); + + $adv_tree['def'] = array('templates' => 'tftproot', + 'settings' => '', + 'locales' => '', + 'firmware' => '', + 'languages' => 'tftproot', + 'dialplan' => '', + 'softkey' => '' + ); + + $base_tree = array('tftp_templates' => 'templates', + 'tftp_path_store' => 'settings', + 'tftp_lang_path' => 'languages', + 'tftp_firmware_path' => 'firmware', + 'tftp_dialplan' => 'dialplan', + 'tftp_softkey' => 'softkey' + ); + + $base_config = array(); + + if (!empty($settingsFromDb['tftp_rewrite_path']['data'])) { + // Have a setting in sccpsettings. It should start with $tftpRootPath + // If not we will replace it with $tftpRootPath. Avoids issues with legacy values + if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$settingsFromDb['tftp_path']['data'])) { + + $adv_ini = "{$tftpRootPath}/index.cnf"; + $settingsToDb['tftp_rewrite_path'] = $settingsFromDb['tftp_rewrite_path']; + $settingsToDb['tftp_rewrite_path']['data'] = $tftpRootPath; + } + $adv_ini = "{$settingsFromDb['tftp_rewrite_path']["data"]}/index.cnf"; + } + + $adv_tree_mode = 'def'; + + switch ($settingsFromDb['tftp_rewrite']['data']) { + case 'pro': + $adv_tree_mode = 'pro'; + if (!empty($adv_ini) && file_exists($adv_ini)) { + $adv_ini_array = parse_ini_file($adv_ini); + $adv_config = array_merge($adv_config, $adv_ini_array); + } + break; + case 'on': + case 'internal': + case 'off': + break; + default: + // not defined so set here + $settingsToDb["tftp_rewrite"] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'off'); + } + + foreach ($adv_tree[$adv_tree_mode] as $key => $value) { + if (!empty($adv_config[$key])) { + if (!empty($value)) { + if (substr($adv_config[$key], 0, 1) != "/") { + $adv_config[$key] = $adv_config[$value] . '/' . $adv_config[$key]; + } + } else { + $adv_config[$key] = $adv_config['tftproot']; + } + } + } + foreach ($base_tree as $key => $value) { + $base_config[$key] = $adv_config[$value]; + // Save to sccpsettings + $settingsToDb[$key] =array( 'keyword' => $key, 'seq' => 20, 'type' => 0, 'data' => $adv_config[$value]); + if (!file_exists($base_config[$key])) { + if (!mkdir($base_config[$key], 0777, true)) { + die_freepbx(_('Error creating dir : ' . $base_config[$key])); + } + } + } + + if (!file_exists($base_config["tftp_templates"] . '/XMLDefault.cnf.xml_template')) { + $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; + $dst_path = $base_config["tftp_templates"] . '/'; + foreach (glob($src_path . '*.*_template') as $filename) { + copy($filename, $dst_path . basename($filename)); + } + } + + + + + + + return $base_config; + } public function validate_RealTime( $connector ) { diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 2aeb76e..3b36904 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -160,5 +160,35 @@ trait helperfunctions { } return $result; } + + public function tftp_put_test_file() + { + // https://datatracker.ietf.org/doc/html/rfc1350 + $socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); + $host = "127.0.0.1"; // TODO: Should consider remote TFT Servers in future + + // create the WRQ request packet + $packet = chr(0) . chr(2) . "TestFileXXX111.txt" . chr(0) . 'netascii' . chr(0); + // UDP is connectionless, so we just send it. + socket_sendto($socket, $packet, strlen($packet), MSG_EOR, $host, 69); + + $buffer = ''; + $port = ''; + $ret = ''; + + // Should now receive an ack packet + socket_recvfrom($socket, $buffer, 4, MSG_PEEK, $host, $port); + + // Then should send our data packet + $packet = chr(0) . chr(3) . chr(0) . chr(1) . 'This is a test file created by Sccp_Manager. It can be deleted without any impact'; + socket_sendto($socket, $packet, strlen($packet), MSG_EOR, $host, $port); + + // finally will recieve an ack packet + socket_recvfrom($socket, $buffer, 4, MSG_PEEK, $host, $port); + + socket_close($socket); + + return; + } } ?> From cdac0f02769a9795bd8f01ef39ef6c1a48eb1986 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 23 Jun 2021 17:43:58 +0200 Subject: [PATCH 031/181] Fix incorrect variable declaration --- Sccp_manager.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index a9744fe..e5d77ad 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -962,7 +962,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (!empty($this->sccpvalues['SccpDBmodel'])) { $ver_id = $this->sccpvalues['SccpDBmodel']['data']; } - $sccppath = array( + $this->sccppath = array( 'asterisk' => $this->sccpvalues['asterisk_etc_path']['data'], 'tftp_path' => $this->sccpvalues['tftp_path']['data'], 'tftp_templates' => $this->sccpvalues['tftp_templates']['data'], @@ -1352,8 +1352,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // $file_ext = array('.loads', '.LOADS', '.sbn', '.SBN', '.bin', '.BIN','.zup','.ZUP'); $file_ext = array('.loads', '.sbn', '.bin', '.zup'); // $dir = $this->sccppath["tftp_path"]; - $dir = $this->sccppath["tftp_firmware_path"]; - $dir_tepl = $this->sccppath["tftp_templates"]; + $dir = $this->sccppath['tftp_firmware_path']; + $dir_tepl = $this->sccppath['tftp_templates']; $search_mode = ''; if (!empty($this->sccpvalues['tftp_rewrite'])) { From 9daf307081be5e26b93795bb0edd51c38317521a Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 23 Jun 2021 19:46:32 +0200 Subject: [PATCH 032/181] Correct defaults --- conf/sccpgeneral.xml.v433 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index dc0a88d..578e812 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -594,7 +594,7 @@ and open the template in the editor. Base Version before all crash :-) videocapability - "off" + off @@ -602,7 +602,7 @@ and open the template in the editor. Base Version before all crash :-) webaccess - "off" + off Enable the phone's HTTP server. @@ -610,7 +610,7 @@ and open the template in the editor. Base Version before all crash :-) webadmin - "off" + off Enable remote administration using the phone's HTTP server. 8821 model only. @@ -618,7 +618,7 @@ and open the template in the editor. Base Version before all crash :-) pcport - "off" + off Disable the PC (computer) port @@ -626,7 +626,7 @@ and open the template in the editor. Base Version before all crash :-) spantopcport - "off" + off Forward packets sent and received on the SW (network) port to the PC (computer) port. @@ -634,7 +634,7 @@ and open the template in the editor. Base Version before all crash :-) voicevlanaccess - "off" + off Allow devices connected to the PC (computer) port to access the voice VLAN. @@ -642,7 +642,7 @@ and open the template in the editor. Base Version before all crash :-) enablecdpswport - "off" + off Enable Cisco Discovery Protocol on the SW (network) port. @@ -650,7 +650,7 @@ and open the template in the editor. Base Version before all crash :-) enablecdppcport - "off" + off Enable Cisco Discovery Protocol on the PC (computer) port. @@ -658,7 +658,7 @@ and open the template in the editor. Base Version before all crash :-) enablelldpswport - "off" + off Enable Link Layer Discovery Protocol on the SW (network) port. From 4d7463f341cf2fcb955bcf864f244a4cc5671e42 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 23 Jun 2021 19:52:00 +0200 Subject: [PATCH 033/181] Update sccpgeneral.xml.v433 --- conf/sccpgeneral.xml.v433 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 578e812..228972f 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -666,7 +666,7 @@ and open the template in the editor. Base Version before all crash :-) enablelldppcport - "off" + off Enable Link Layer Discovery Protocol on the PC (computer) port. From ff1c451fe1e703868c3ee97fb752d407e9686ed0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 24 Jun 2021 10:02:26 +0200 Subject: [PATCH 034/181] Update Installer and Sccp_manager Construct Move initial defaults reading from Construct to Install Move initVarFromXml to helper functions - no longer used as defaults should come from db Remove extraneous initialisations from Sccp_manager - these are now handled in Installer Save TFTP structure to sccpsettings in Installer Pass tftp_root to extconfigs ( if changed or uninitialised, was not written back to settingsFromDb before being passed to extconfigs --- Sccp_manager.class.php | 105 ++-------------------------- install.php | 41 ++++++++--- module.xml | 2 +- sccpManClasses/extconfigs.class.php | 36 +++++----- sccpManTraits/helperFunctions.php | 51 ++++++++++++++ 5 files changed, 106 insertions(+), 129 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index e5d77ad..26dc630 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -139,34 +139,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return; } - $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); // Overwrite Exist - $this->initializeSccpPath(); - $this->initVarfromDefs(); + $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); //Initialise core settings + $this->initializeSccpPath(); //Set required Paths + $this->updateTimeZone(); // Get timezone from FreePBX $this->initTftpLang(); - - if (!empty($this->sccpvalues['SccpDBmodel'])) { - if ($this->sccpvalues['sccp_compatible']['data'] > $this->sccpvalues['SccpDBmodel']['data']) { - $this->sccpvalues['sccp_compatible']['data'] = $this->sccpvalues['SccpDBmodel']['data']; - } - } - // Load Advanced Form Constructor Data - if (empty($this->sccpvalues['displayconfig'])) { - $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v' . $this->sccpvalues['sccp_compatible']['data']; - } else { - $xml_vars = __DIR__ . '/conf/' . $this->sccpvalues['displayconfig']['data'] . '.xml.v' . $this->sccpvalues['sccp_compatible']['data']; - } - if (!file_exists($xml_vars)) { - $xml_vars = __DIR__ . '/conf/sccpgeneral.xml'; - } - if (file_exists($xml_vars)) { - $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(); - //} } /* @@ -199,73 +175,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { * Load config vars from base array */ - public function initVarfromDefs() { - foreach ($this->extconfigs->getExtConfig('sccpDefaults') as $key => $value) { - if (empty($this->sccpvalues[$key])) { - $this->sccpvalues[$key] = array('keyword' => $key, 'data' => $value, 'type' => '0', 'seq' => '0'); - } - } + public function updateTimeZone() { // Check timezone has not been changed in FreePBX and update if has if ($this->sccpvalues['ntp_timezone'] != \date_default_timezone_get()) { $this->sccpvalues['ntp_timezone'] = array('keyword' => 'ntp_timezone', 'seq'=>95, 'type' => 2, 'data' => \date_default_timezone_get()); } } - /* - * Load config vars from xml - */ - - public function initVarfromXml() { - if ((array) $this->xml_data) { - foreach ($this->xml_data->xpath('//page_group') as $item) { - foreach ($item->children() as $child) { - $seq = 0; - if (!empty($child['seq'])) { - $seq = (string) $child['seq']; - } - if ($seq < 99) { - if ($child['type'] == 'IE') { - foreach ($child->xpath('input') as $value) { - $tp = 0; - if (empty($value->value)) { - $datav = (string) $value->default; - } else { - $datav = (string) $value->value; - } - if (strtolower($value->type) == 'number') { - $tp = 1; - } - if (empty($this->sccpvalues[(string) $value->name])) { - $this->sccpvalues[(string) $value->name] = array('keyword' => (string) $value->name, 'data' => $datav, 'type' => $tp, 'seq' => $seq); - } - } - } - if ($child['type'] == 'IS' || $child['type'] == 'IED') { - if (empty($child->value)) { - $datav = (string) $child->default; - } else { - $datav = (string) $child->value; - } - if (empty($this->sccpvalues[(string) $child->name])) { - $this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq); - } - } - if (in_array($child['type'], array('SLD', 'SLS', 'SLT', 'SL', 'SLM', 'SLZ', 'SLTZN', 'SLA'))) { - if (empty($child->value)) { - $datav = (string) $child->default; - } else { - $datav = (string) $child->value; - } - if (empty($this->sccpvalues[(string) $child->name])) { - $this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq); - } - } - } - } - } - } - } - /* * Show form information - General */ @@ -957,11 +873,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ function initializeSccpPath() { - $driver_revision = array('0' => '', '430' => '.v431', '431' => '.v432', '432' => '.v432', '433' => '.v433' . $this->sccp_branch); - $ver_id = $this->aminterface->get_compatible_sccp(); - if (!empty($this->sccpvalues['SccpDBmodel'])) { - $ver_id = $this->sccpvalues['SccpDBmodel']['data']; - } + $this->sccppath = array( 'asterisk' => $this->sccpvalues['asterisk_etc_path']['data'], 'tftp_path' => $this->sccpvalues['tftp_path']['data'], @@ -973,11 +885,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'tftp_softkey' => $this->sccpvalues['tftp_softkey']['data'] ); - $driver = $this->FreePBX->Core->getAllDriversInfo(); - - $this->sccpvalues['sccp_compatible'] = array('keyword' => 'sccp_compatible', 'data' => $ver_id, 'type' => '1', 'seq' => '99'); - $driver = $this->FreePBX->Core->getAllDriversInfo(); // Check that Sccp Driver has been updated by above - $read_config = $this->cnf_read->getConfig('sccp.conf'); $this->sccp_conf_init['general'] = $read_config['general']; foreach ($read_config as $key => $value) { @@ -1317,7 +1224,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { break; case "netlang": // Remove Key case "tftp_path": - case "sccp_compatible": + case "sccp_compatible": // This is equal to SccpDBmodel break; default: if (!empty($value['data'])) { diff --git a/install.php b/install.php index d5d380a..db9cff0 100644 --- a/install.php +++ b/install.php @@ -8,7 +8,7 @@ global $db; global $amp_conf; global $version; global $aminterface; -global $extConfigs; +global $extconfigs; global $mobile_hw; global $useAmiForSoftKeys; global $settingsFromDb; @@ -23,11 +23,14 @@ $db_config = ''; $sccp_version = array(); $cnf_int = \FreePBX::Config(); +// Do not create Sccp_Manager object as not required. +// Only include required classes and create anonymous class for thisInstaller + $thisInstaller = new class{ use \FreePBX\modules\Sccp_Manager\sccpManTraits\helperFunctions; }; -$requiredClasses = array('amiinterface', 'extconfigs'); +$requiredClasses = array('aminterface', 'extconfigs'); foreach ($requiredClasses as $className) { $class = "\\FreePBX\\Modules\\Sccp_manager\\$className"; if (!class_exists($class, false)) { @@ -38,6 +41,7 @@ foreach ($requiredClasses as $className) { } } +// Get current default settings from db $stmt = $db->prepare("SELECT * FROM sccpsettings"); $stmt->execute(); $settingsFromDb = $stmt->fetchAll(\PDO::FETCH_ASSOC); @@ -45,11 +49,18 @@ foreach ($settingsFromDb as $key => $rowArray) { $settingsFromDb[$rowArray['keyword']] = $rowArray; unset($settingsFromDb[$key]); } +// Check that required settings are initialised and update db and $settingsFromDb if not +foreach ($extconfigs->getExtConfig('sccpDefaults') as $key => $value) { + if (empty($settingsFromDb[$key])) { + $settingsFromDb[$key] = array('keyword' => $key, 'data' => $value, 'type' => 0, 'seq' => 0); -// Do not create Sccp_Manager object as not required. -// Only include required classes - - + $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$key}', '{$value}', 0, 0)"; + $results = $db->query($sql); + if (DB::IsError($results)) { + die_freepbx(_("Error updating sccpsettings: $key")); + } + } +} CheckAsteriskVersion(); $sccp_version = CheckChanSCCPCompatible(); @@ -871,7 +882,7 @@ function checkTftpServer() { global $db; global $cnf_int; global $settingsFromDb; - global $extConfigs; + global $extconfigs; global $thisInstaller; $confDir = $cnf_int->get('ASTETCDIR'); // TODO: add option to use external server @@ -886,6 +897,8 @@ function checkTftpServer() { outn("
  • " . _("Found ftp root dir at {$dirToTest}") . "
  • "); if ($settingsFromDb['tftp_path']['data'] != $tftpRootPath) { $settingsToDb["tftp_path"] =array( 'keyword' => 'tftp_path', 'seq' => 2, 'type' => 0, 'data' => $tftpRootPath); + // Need to set the new value here to pass to extconfigs below + $settingsFromDb['tftp_path']['data'] = $tftpRootPath; } break; } @@ -898,8 +911,6 @@ function checkTftpServer() { die_freepbx(_("{$tftpRootPath} is not writable by user asterisk. Please fix, refresh and try again")); } - $extConfigs->updateTftpStructure($settingsFromDb); - $settingsToDb['asterisk_etc_path'] =array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir); foreach ($settingsToDb as $settingToSave) { @@ -908,7 +919,19 @@ function checkTftpServer() { if (DB::IsError($results)) { die_freepbx(_("Error updating sccpsettings. $sql")); } + unset($settingsToDb[$settingToSave['keyword']]); } + + $settingsToDb = $extconfigs->updateTftpStructure($settingsFromDb); + + foreach ($settingsToDb as $settingKey => $settingVal) { + $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingKey}', '{$settingVal}', 20, 0)"; + $results = $db->query($sql); + if (DB::IsError($results)) { + die_freepbx(_("Error updating sccpsettings. $sql")); + } + } + return; } diff --git a/module.xml b/module.xml index cd5c29f..57723fe 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.0 + 14.3.0.1 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 4f42ade..7214302 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -101,19 +101,19 @@ class extconfigs } private $sccpDefaults = array( - "servername" => 'VPBXSCCP', - "bindaddr" => '0.0.0.0', "port" => '2000', # chan_sccp also supports ipv6 - "deny" => '0.0.0.0/0.0.0.0', - "permit" => '0.0.0.0/0.0.0.0', # !TODO!: please change this to 'internal' which would mean: - # permit:127.0.0.0/255.0.0.0,permit:10.0.0.0/255.0.0.0,permit:172.0.0.0/255.224.0.0,permit:192.168.0.0/255.255.0.0" - "dateformat" => 'D.M.Y', - "disallow" => 'all', "allow" => 'alaw;ulaw', - "hotline_enabled" => 'off', - "hotline_context" => 'default', # !TODO!: Should this not be from-internal on FreePBX ? - "hotline_extension" => '*60', # !TODO!: Is this a good default extension to dial for hotline ? - "hotline_label" => 'hotline', - "devicetable" => 'sccpdevice', - "linetable" => 'sccpline' + 'servername' => 'VPBXSCCP', + 'bindaddr' => '0.0.0.0', "port" => '2000', # chan_sccp also supports ipv6 + 'deny' => '0.0.0.0/0.0.0.0', + 'permit' => '0.0.0.0/0.0.0.0', # !TODO!: please change this to 'internal' which would mean: + 'dateformat' => 'D.M.Y', + 'disallow' => 'all', "allow" => 'alaw;ulaw', + 'hotline_enabled' => 'off', + 'hotline_context' => 'default', # !TODO!: Should this not be from-internal on FreePBX ? + 'hotline_extension' => '*60', # !TODO!: Is this a good default extension to dial for hotline ? + 'hotline_label' => 'hotline', + 'devicetable' => 'sccpdevice', + 'linetable' => 'sccpline', + 'displayconfig' => 'sccpgeneral' ); private $keysetdefault = array('onhook' => 'redial,newcall,cfwdall,cfwdbusy,cfwdnoanswer,pickup,gpickup,dnd,private', 'connected' => 'hold,endcall,park,vidmode,select,cfwdall,cfwdbusy,idivert,monitor', @@ -311,7 +311,7 @@ class extconfigs } } } - + // TODO: Need to add index.cnf, after setting defaults correctly if (!file_exists($base_config["tftp_templates"] . '/XMLDefault.cnf.xml_template')) { $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; $dst_path = $base_config["tftp_templates"] . '/'; @@ -319,12 +319,8 @@ class extconfigs copy($filename, $dst_path . basename($filename)); } } - - - - - - + // Remove keys that are not required before returning $base_config. + unset($base_config['asterisk'], $base_config['sccp_conf'], $base_config['tftp_path']); return $base_config; } diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 3b36904..a25e516 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -190,5 +190,56 @@ trait helperfunctions { return; } + + public function initVarfromXml() { + if ((array) $this->xml_data) { + foreach ($this->xml_data->xpath('//page_group') as $item) { + foreach ($item->children() as $child) { + $seq = 0; + if (!empty($child['seq'])) { + $seq = (string) $child['seq']; + } + if ($seq < 99) { + if ($child['type'] == 'IE') { + foreach ($child->xpath('input') as $value) { + $tp = 0; + if (empty($value->value)) { + $datav = (string) $value->default; + } else { + $datav = (string) $value->value; + } + if (strtolower($value->type) == 'number') { + $tp = 1; + } + if (empty($this->sccpvalues[(string) $value->name])) { + $this->sccpvalues[(string) $value->name] = array('keyword' => (string) $value->name, 'data' => $datav, 'type' => $tp, 'seq' => $seq); + } + } + } + if ($child['type'] == 'IS' || $child['type'] == 'IED') { + if (empty($child->value)) { + $datav = (string) $child->default; + } else { + $datav = (string) $child->value; + } + if (empty($this->sccpvalues[(string) $child->name])) { + $this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq); + } + } + if (in_array($child['type'], array('SLD', 'SLS', 'SLT', 'SL', 'SLM', 'SLZ', 'SLTZN', 'SLA'))) { + if (empty($child->value)) { + $datav = (string) $child->default; + } else { + $datav = (string) $child->value; + } + if (empty($this->sccpvalues[(string) $child->name])) { + $this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq); + } + } + } + } + } + } + } } ?> From e841c7cb402ea4d4d9d3574f2c1333cec4ac3e5e Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 24 Jun 2021 10:59:00 +0200 Subject: [PATCH 035/181] Reversions and corrections to previous commit Restore saveSccpSettings to Sccp_Manager construct (deleted in error) Initialise ntp_timezone without check (may have been changed externally) Load xml data in ShowGroup instead of construct. --- Sccp_manager.class.php | 16 ++++++++++++---- sccpManTraits/ajaxHelper.php | 2 +- views/formShowError.php | 5 ++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 26dc630..5007ea5 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -143,6 +143,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->initializeSccpPath(); //Set required Paths $this->updateTimeZone(); // Get timezone from FreePBX $this->initTftpLang(); + $this->saveSccpSettings(); } /* @@ -153,6 +154,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (empty($form_values)) { $form_values = $this->sccpvalues; } + // load xml data - moved from Construct to simplify Construct + $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v433'; + $this->xml_data = simplexml_load_file($xml_vars); + if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group[@name="' . $group_name . '"]') as $item) { $htmlret = load_view(__DIR__ . '/views/formShow.php', array( @@ -176,9 +181,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ public function updateTimeZone() { - // Check timezone has not been changed in FreePBX and update if has - if ($this->sccpvalues['ntp_timezone'] != \date_default_timezone_get()) { - $this->sccpvalues['ntp_timezone'] = array('keyword' => 'ntp_timezone', 'seq'=>95, 'type' => 2, 'data' => \date_default_timezone_get()); + // Get latest FreePBX time $timeZoneOffsetList + $freepbxTZ = \date_default_timezone_get(); + $this->sccpvalues['ntp_timezone'] = array('keyword' => 'ntp_timezone', 'seq'=>95, 'type' => 2, 'data' => $freepbxTZ); + $TZdata = $this->extconfigs->getExtConfig('sccp_timezone', $freepbxTZ); + if (!empty($TZdata)) { + $value = $TZdata['offset']/60; // TODO: Is this correct (storing in hours not minutes) + $this->sccpvalues['tzoffset'] = array('keyword' => 'tzoffset', 'seq'=>98, 'type' => 2, 'data' => $value); } } @@ -932,7 +941,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { function getDialPlan($get_file) { $file = $this->sccppath["tftp_dialplan"] . '/' . $get_file . '.xml'; if (file_exists($file)) { -// $load_xml_data = simplexml_load_file($file); $fileContents = file_get_contents($file); $fileContents = str_replace(array("\n", "\r", "\t"), '', $fileContents); diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index bd4898c..39ddbeb 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -448,7 +448,7 @@ trait ajaxHelper { 'keyword' => $this->sccpvalues[$key]['keyword'], 'data' => $value, 'seq' => $this->sccpvalues[$key]['seq'], - 'type' => $this->sccpvalues[$key1]['type'] + 'type' => $this->sccpvalues[$key]['type'] ); } } diff --git a/views/formShowError.php b/views/formShowError.php index 9b10fd1..91fc232 100644 --- a/views/formShowError.php +++ b/views/formShowError.php @@ -1,5 +1,4 @@ -
    -
    +
    +
    - From 9be50bab5ced7df2480d71a8b929862a05872609 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:25:26 +0200 Subject: [PATCH 036/181] Update Create_SEP_XML and defaults Merge data_values and dev_config so that device specific settings are written to the SEP file Add sccp general device defaults Allow saving empty sccpvalues Add new fields to sccpdevice move phonepersonalization to sccpdevice from sccpline Change advanced display block for personalisation to correctly pickup defaults --- Sccp_manager.class.php | 3 +- conf/sccpgeneral.xml.v433 | 16 +- install.php | 6 +- module.xml | 2 +- sccpManClasses/dbinterface.class.php | 6 +- sccpManClasses/extconfigs.class.php | 23 +- sccpManClasses/xmlinterface.class.php | 421 +++++++++++++------------- sccpManTraits/ajaxHelper.php | 14 +- 8 files changed, 254 insertions(+), 237 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 5007ea5..946691c 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1102,7 +1102,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } - foreach ($this->sccpvalues as $key => $value) { $data_value[$key] = $value['data']; } @@ -1126,7 +1125,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (!$sccp_native) { return $this->xmlinterface->create_SEP_SIP_XML($this->sccppath["tftp_path_store"], $data_value, $dev_config, $dev_id, $lang_data); } - return $this->xmlinterface->create_SEP_XML($this->sccppath["tftp_path_store"], $data_value, $dev_config, $dev_id, $lang_data); + return $this->xmlinterface->create_SEP_XML($this->sccppath["tftp_templates"], $data_value, $dev_config, $dev_id, $lang_data); } function deleteSccpDeviceXML($dev_id = '') { diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 228972f..2c871f5 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -433,6 +433,14 @@ and open the template in the editor. Base Version before all crash :-) Use simulated enbloc dialing to speedup connection when dialing while onhook (older phones) + + phonepersonalization + + 0 + + + This needs to be enabled to allow the server to push background or ringtones to the phone in the SEPXXXXXXXXXX.cnf.xml of each phone: + @@ -1128,14 +1136,6 @@ and open the template in the editor. Base Version before all crash :-) I'm guessing on this one, but on some devices, the background image on the display can be modified at the device. I think this is the thing that allows that to happen. - - phonePersonalization - - 0 - - - This needs to be enabled to allow the server to push background or ringtones to the phone in the SEPXXXXXXXXXX.cnf.xml of each phone: - callLogBlfEnabled diff --git a/install.php b/install.php index db9cff0..bc01f43 100644 --- a/install.php +++ b/install.php @@ -281,7 +281,10 @@ function Get_DB_config($sccp_compatible) '_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)"), '_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)") + '_sccp_cos' => array('create' => "VARCHAR(11) NOT NULL default '0x4'", 'modify' => "VARCHAR(11)"), + '_dev_sshPassword' => array('create' => "VARCHAR(25) NOT NULL default 'cisco'"), + '_dev_sshUserId' => array('create' => "VARCHAR(25) NOT NULL default 'cisco'"), + '_phonepersonalization' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')") ), 'sccpline' => array ( '_regcontext' => array('create' => "VARCHAR(20) NULL default 'sccpregistration'", 'modify' => "VARCHAR(20)"), @@ -289,7 +292,6 @@ function Get_DB_config($sccp_compatible) '_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('3','2') NOT NULL default '2'", 'modify' => "enum('3','2')") ) ); diff --git a/module.xml b/module.xml index 57723fe..cd5c29f 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 2427663..322115b 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -163,7 +163,7 @@ class dbinterface $dbh = \FreePBX::Database(); $stmt = $dbh->prepare('SELECT keyword, data, type, seq FROM sccpsettings ORDER BY type, seq'); $stmt->execute(); - foreach ($stmt->fetchAll() as $key => $rowArray) { + foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $key => $rowArray) { $settingsFromDb[$rowArray['keyword']] = $rowArray; unset($settingsFromDb[$key]); } @@ -254,10 +254,8 @@ class dbinterface $stmt = $dbh->prepare('REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES (:keyword,:data,:seq,:type)'); } foreach ($save_value as $key => $dataArr) { - if (!empty($dataArr) && isset($dataArr['data'])) { - if (empty($dataArr['data'])) { + if (empty($dataArr)) { continue; - } } $stmt->bindParam(':keyword',$dataArr['keyword'],\PDO::PARAM_STR); $stmt->bindParam(':data',$dataArr['data'],\PDO::PARAM_STR); diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 7214302..890619e 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -113,7 +113,28 @@ class extconfigs 'hotline_label' => 'hotline', 'devicetable' => 'sccpdevice', 'linetable' => 'sccpline', - 'displayconfig' => 'sccpgeneral' + 'displayconfig' => 'sccpgeneral', + '_dev_sshPassword' => 'cisco', + '_dev_sshUserId' => 'cisco', + 'dev_deviceProtocol' => 'SCCP', + 'dev_idleTimeout' => '60', + 'ntp_config_enabled' => 'off', + 'ntp_server' => 'pool.ntp.org', + 'ntp_server_mode' => 'unicast', + 'devlang' => 'English_United_States', + 'dev_authenticationURL' => '', + 'dev_informationURL' => '', + 'dev_messagesURL' => '', + 'dev_servicesURL' => '', + 'dev_directoryURL' => '', + 'dev_idleURL' => '', + 'dev_secureauthenticationURL' => '', + 'dev_secureinformationURL' => '', + 'dev_securemessagesURL' => '', + 'dev_secureservicesURL' => '', + 'dev_securedirectoryURL' => '', + 'dev_secureidleURL' => '', + 'dev_proxyServerURL' => '' ); private $keysetdefault = array('onhook' => 'redial,newcall,cfwdall,cfwdbusy,cfwdnoanswer,pickup,gpickup,dnd,private', 'connected' => 'hold,endcall,park,vidmode,select,cfwdall,cfwdbusy,idivert,monitor', diff --git a/sccpManClasses/xmlinterface.class.php b/sccpManClasses/xmlinterface.class.php index 0107c5e..d1ea593 100644 --- a/sccpManClasses/xmlinterface.class.php +++ b/sccpManClasses/xmlinterface.class.php @@ -116,235 +116,234 @@ class xmlinterface } } - function create_SEP_XML($store_path = '', $data_values = array(), $dev_config = array(), $dev_id = '', $lang_info = array()) + function create_SEP_XML($store_path, $data_values, $dev_config, $dev_id, $lang_info = array()) { + // TODO: $data_values are system wide defaults, $dev_config are specific defice values. + // Need to merge the two arrays so that device specific values override system values + // Values that cannot be sent to the device by chan-sccp are prefixed by an underscore + // so need to be sure that we apply the same convention to system wide defaults. + $data_values = array_merge($data_values, $dev_config); $var_xml_general_fields = array('authenticationurl' => 'dev_authenticationURL', 'informationurl' => 'dev_informationURL', 'messagesurl' => 'dev_messagesURL', 'servicesurl' => 'dev_servicesURL', 'directoryurl' => 'dev_directoryURL', 'idleurl' => 'dev_idleURL', 'secureauthenticationurl' => 'dev_secureauthenticationURL', 'secureinformationurl' => 'dev_secureinformationURL', 'securemessagesurl'=>'dev_securemessagesURL', 'secureservicesurl'=>'dev_secureservicesURL', 'securedirectoryurl'=>'dev_securedirectoryURL', 'secureidleurl' => 'dev_secureidleURL', 'proxyserverurl' => 'dev_proxyServerURL', 'idletimeout' => 'dev_idleTimeout', - 'sshuserid' => 'dev_sshUserId', 'sshpassword' => 'dev_sshPassword', 'deviceprotocol' => 'dev_deviceProtocol', - 'phonepersonalization' => 'phonePersonalization' + 'sshuserid' => '_dev_sshUserId', 'sshpassword' => '_dev_sshPassword', 'deviceprotocol' => 'dev_deviceProtocol', + 'phonepersonalization' => '_phonepersonalization' ); $var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList' => 'null', 'mobility' => 'null', 'phoneServices' => 'null', 'certHash' => 'null', 'deviceSecurityMode' => '1'); - if (empty($dev_config)) { - return false; + $data_path = $dev_config['tftp_templates']; + if (empty($data_path)) { + die('Create_SEP_XML data_path not defined'); } - $data_path = $dev_config['tftp_path']; - - if (empty($store_path) || empty($data_path) || empty($data_values) || empty($dev_id)) { - return; - } - if (!empty($dev_config['nametemplate'])) { - $xml_template = $data_path . '/templates/' . $dev_config['nametemplate']; + $xml_template = "{$data_path}/{$dev_config['nametemplate']}"; } else { - $xml_template = $data_path . '/templates/SEP0000000000.cnf.xml_79df_template'; + $xml_template = "{$data_path}/templates/SEP0000000000.cnf.xml_79df_template"; } - $xml_name = $store_path . '/' . $dev_id . '.cnf.xml'; - if (file_exists($xml_template)) { - $xml_work = simplexml_load_file($xml_template); - - foreach ($var_xml_general_vars as $key => $data) { - if (isset($xml_work->$key)) { - if ($data != 'null') { - $xml_work->$key = $data; - } else { - $node = $xml_work->$key; - unset($node[0][0]); - } - } - } - - foreach ($xml_work as $key => $data) { -// Set System global Values - $key_l = strtolower($key); - if (!empty($var_xml_general_fields[$key_l])) { - $xml_work->$key = $data_values[$var_xml_general_fields[$key_l]]; - } -// Set section Values - $xml_node = $xml_work->$key; - switch ($key_l) { - case 'devicepool': - $xml_node = $xml_work->$key; - foreach ($xml_work->$key->children() as $dkey => $ddata) { - switch (strtolower($dkey)) { - case 'datetimesetting': - $xnode = &$xml_node->$dkey; - $tz_id = $data_values['ntp_timezone']; - $TZdata = $data_values['ntp_timezone_id']; - if (empty($TZdata)) { - $TZdata = array('offset' => '0', 'daylight' => '', 'cisco_code' => 'Greenwich Standard Time'); - } - $xnode->name = $tz_id; - $xnode->dateTemplate = $data_values['dateformat']; - $xnode->timeZone = $TZdata['cisco_code']; -// $xnode->timeZone = $tz_id.' Standard'.((empty($TZdata['daylight']))? '': '/'.$TZdata['daylight']).' Time'; - - if ($data_values['ntp_config_enabled'] == 'on') { - $xnode->ntps->ntp->name = $data_values['ntp_server']; - $xnode->ntps->ntp->ntpMode = $data_values['ntp_server_mode']; - } else { - $xnode->ntps = null; - } - // Ntp Config - break; - case 'srstinfo': - if ($data_values['srst_Option'] == 'user') { - break; - } - $xnode = &$xml_node->$dkey; - $xnode->name = $data_values['srst_Name']; - $xnode->srstOption = $data_values['srst_Option']; - $xnode->userModifiable = $data_values['srst_userModifiable']; - $xnode->isSecure = $data_values['srst_isSecure']; - - $srst_fld = array('srst_ip' => array('ipAddr', 'port')); - foreach ($srst_fld as $srst_pro => $srs_put) { - if (empty($data_values[$srst_pro]) || ($data_values['srst_Option'] == 'disable') ) { - $srst_data =array(); - } else { - $srst_data = explode(';', $data_values[$srst_pro]); - } - $si = 1; - foreach ($srst_data as $value) { - $srs_val = explode('/', $value); - $nod = $srs_put[0] . $si; - $xnode->$nod = $srs_val[0]; - $nod = $srs_put[1] . $si; - $xnode->$nod = ((empty($srs_val[1])) ? "2000": $srs_val[1]); - $si++; - } - while ($si < 4) { - $nod = $srs_put[0] . $si; - $xnode->$nod = ''; - $nod = $srs_put[1] . $si; - $xnode->$nod = ''; - $si++; - } - } - break; - case 'connectionmonitorduration': - $xml_node->$dkey = strval(intval(intval($data_values['keepalive']) * 0.75)); - break; - case 'callmanagergroup': - $xnode = &$xml_node->$dkey->members; - $bind_tmp = $this->get_server_sccp_bind($data_values); - $ifc = 0; - foreach ($bind_tmp as $bind_value) { - $xnode_obj = clone $xnode->member; - $xnode_obj['priority'] = $ifc; - $xnode_obj->callManager->name = $data_values['servername']; - if (!is_null($xnode_obj->callManager->description)) { - $xnode_obj->callManager->description = $data_values['servername']; - } - $xnode_obj->callManager->ports->ethernetPhonePort = $bind_value['port']; - $xnode_obj->callManager->processNodeName = $bind_value['ip']; - if (!empty($xnode_obj->callManager->ports->mgcpPorts)) { - unset($xnode_obj->callManager->ports->mgcpPorts); - } - - if ($ifc === 0) { - $this->replaceSimpleXmlNode($xnode->member, $xnode_obj); - } else { - $this->appendSimpleXmlNode($xnode->member, $xnode_obj); - } - $ifc++; - } - } - } - $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); - break; - case 'vendorconfig': - $xml_node = $xml_work->$key; - foreach ($xml_work->$key->children() as $dkey => $ddata) { - $dkey_l = strtolower($dkey); - $vtmp_key = $key_l.'_'.$dkey_l; - if (isset($data_values[$vtmp_key])) { - $vtmp_data = $data_values[$vtmp_key]; - if ((!empty($vtmp_data)) || ($vtmp_data == "0")) { - $xml_node->$dkey = $vtmp_data; - } - } - } - $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); - break; - - case 'versionstamp': - $xml_work->$key = time(); - break; - case 'loadinformation': -// Set Path Image ???? - if (isset($dev_config["tftp_firmware"])) { - $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : ''; - } else { - $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["loadimage"] : ''; - } - if (!empty($dev_config['addon'])) { - $xnode = $xml_work->addChild('addOnModules'); - $ti = 1; - $hw_addon = explode(',', $dev_config['addon']); - foreach ($hw_addon as $add_key) { - if (!empty($dev_config['addon_info'][$add_key])) { - $add_val = $dev_config['addon_info'][$add_key]; - $xnode_obj = $xnode->addChild('addOnModule'); - $xnode_obj->addAttribute('idx', $ti); - $xnode_obj->addChild('loadInformation', $add_val); - $ti++; - } - } - } - break; - case 'commonprofile': - $xml_node->phonePassword = $data_values['dev_sshPassword']; - $xml_node->backgroundImageAccess = (($data_values['backgroundImageAccess'] == 'on') || ($data_values['backgroundImageAccess'] == 'true') ) ? 'true' : 'false'; - $xml_node->callLogBlfEnabled = $data_values['callLogBlfEnabled']; - break; - - case 'userlocale': - case 'networklocaleinfo': - case 'networklocale': - $hwlang = ''; - $lang = ''; - if (!empty($dev_config["_hwlang"])) { - $hwlang = explode(':', $dev_config["_hwlang"]); - } - if (($key_l == 'networklocaleinfo') || ($key_l == 'networklocale')) { - $lang = (empty($hwlang[0])) ? $data_values['netlang'] : $hwlang[0]; - } else { - $lang = (empty($hwlang[1])) ? $data_values['devlang'] : $hwlang[1]; - } - if (($lang != 'null') && (!empty($lang))) { - if ($key_l == 'networklocale') { - $xml_work->$key = $lang; - } else { - if (isset($lang_info[$lang])) { - $xml_node->name = $lang_info[$lang]['locale']; - $xml_node->langCode = $lang_info[$lang]['code']; - if ($key_l == 'userlocale') { - $xml_node->winCharSet = $lang_info[$lang]['codepage']; - } - $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); - } - } - } else { - $xml_work->$key = ''; - } - break; - default: - break; - } - } - -// print_r($xml_work); - $xml_work->asXml($xml_name); // Save - } else { + $xml_name = "{$store_path}/{$dev_id}.cnf.xml"; + if (!file_exists($xml_template)) { die('Error Hardware template :' . $xml_template . ' not found'); } + $xml_work = simplexml_load_file($xml_template); + + foreach ($var_xml_general_vars as $key => $data) { + if (isset($xml_work->$key)) { + if ($data != 'null') { + $xml_work->$key = $data; + } else { + $node = $xml_work->$key; + unset($node[0][0]); + } + } + } + + foreach ($xml_work as $key => $data) { +// Set System global Values + $key_l = strtolower($key); + if (!empty($var_xml_general_fields[$key_l])) { + $xml_work->$key = $data_values[$var_xml_general_fields[$key_l]]; + } +// Set section Values + $xml_node = $xml_work->$key; + switch ($key_l) { + case 'devicepool': + $xml_node = $xml_work->$key; + foreach ($xml_work->$key->children() as $dkey => $ddata) { + switch (strtolower($dkey)) { + case 'datetimesetting': + $xnode = &$xml_node->$dkey; + $tz_id = $data_values['ntp_timezone']; + $TZdata = $data_values['ntp_timezone_id']; + if (empty($TZdata)) { + $TZdata = array('offset' => '0', 'daylight' => '', 'cisco_code' => 'Greenwich Standard Time'); + } + $xnode->name = $tz_id; + $xnode->dateTemplate = $data_values['dateformat']; + $xnode->timeZone = $TZdata['cisco_code']; +// $xnode->timeZone = $tz_id.' Standard'.((empty($TZdata['daylight']))? '': '/'.$TZdata['daylight']).' Time'; + + if ($data_values['ntp_config_enabled'] == 'on') { + $xnode->ntps->ntp->name = $data_values['ntp_server']; + $xnode->ntps->ntp->ntpMode = $data_values['ntp_server_mode']; + } else { + $xnode->ntps = null; + } + // Ntp Config + break; + case 'srstinfo': + if ($data_values['srst_Option'] == 'user') { + break; + } + $xnode = &$xml_node->$dkey; + $xnode->name = $data_values['srst_Name']; + $xnode->srstOption = $data_values['srst_Option']; + $xnode->userModifiable = $data_values['srst_userModifiable']; + $xnode->isSecure = $data_values['srst_isSecure']; + + $srst_fld = array('srst_ip' => array('ipAddr', 'port')); + foreach ($srst_fld as $srst_pro => $srs_put) { + if (empty($data_values[$srst_pro]) || ($data_values['srst_Option'] == 'disable') ) { + $srst_data =array(); + } else { + $srst_data = explode(';', $data_values[$srst_pro]); + } + $si = 1; + foreach ($srst_data as $value) { + $srs_val = explode('/', $value); + $nod = $srs_put[0] . $si; + $xnode->$nod = $srs_val[0]; + $nod = $srs_put[1] . $si; + $xnode->$nod = ((empty($srs_val[1])) ? "2000": $srs_val[1]); + $si++; + } + while ($si < 4) { + $nod = $srs_put[0] . $si; + $xnode->$nod = ''; + $nod = $srs_put[1] . $si; + $xnode->$nod = ''; + $si++; + } + } + break; + case 'connectionmonitorduration': + $xml_node->$dkey = strval(intval(intval($data_values['keepalive']) * 0.75)); + break; + case 'callmanagergroup': + $xnode = &$xml_node->$dkey->members; + $bind_tmp = $this->get_server_sccp_bind($data_values); + $ifc = 0; + foreach ($bind_tmp as $bind_value) { + $xnode_obj = clone $xnode->member; + $xnode_obj['priority'] = $ifc; + $xnode_obj->callManager->name = $data_values['servername']; + if (!is_null($xnode_obj->callManager->description)) { + $xnode_obj->callManager->description = $data_values['servername']; + } + $xnode_obj->callManager->ports->ethernetPhonePort = $bind_value['port']; + $xnode_obj->callManager->processNodeName = $bind_value['ip']; + if (!empty($xnode_obj->callManager->ports->mgcpPorts)) { + unset($xnode_obj->callManager->ports->mgcpPorts); + } + + if ($ifc === 0) { + $this->replaceSimpleXmlNode($xnode->member, $xnode_obj); + } else { + $this->appendSimpleXmlNode($xnode->member, $xnode_obj); + } + $ifc++; + } + } + } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + break; + case 'vendorconfig': + $xml_node = $xml_work->$key; + foreach ($xml_work->$key->children() as $dkey => $ddata) { + $dkey_l = strtolower($dkey); + $vtmp_key = $key_l.'_'.$dkey_l; + if (isset($data_values[$vtmp_key])) { + $vtmp_data = $data_values[$vtmp_key]; + if ((!empty($vtmp_data)) || ($vtmp_data == "0")) { + $xml_node->$dkey = $vtmp_data; + } + } + } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + break; + + case 'versionstamp': + $xml_work->$key = time(); + break; + case 'loadinformation': +// Set Path Image ???? + if (isset($dev_config["tftp_firmware"])) { + $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : ''; + } else { + $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["loadimage"] : ''; + } + if (!empty($dev_config['addon'])) { + $xnode = $xml_work->addChild('addOnModules'); + $ti = 1; + $hw_addon = explode(',', $dev_config['addon']); + foreach ($hw_addon as $add_key) { + if (!empty($dev_config['addon_info'][$add_key])) { + $add_val = $dev_config['addon_info'][$add_key]; + $xnode_obj = $xnode->addChild('addOnModule'); + $xnode_obj->addAttribute('idx', $ti); + $xnode_obj->addChild('loadInformation', $add_val); + $ti++; + } + } + } + break; + case 'commonprofile': + $xml_node->phonePassword = $data_values['dev_sshPassword']; + $xml_node->backgroundImageAccess = (($data_values['backgroundImageAccess'] == 'on') || ($data_values['backgroundImageAccess'] == 'true') ) ? 'true' : 'false'; + $xml_node->callLogBlfEnabled = $data_values['callLogBlfEnabled']; + break; + + case 'userlocale': + case 'networklocaleinfo': + case 'networklocale': + $hwlang = ''; + $lang = ''; + if (!empty($dev_config["_hwlang"])) { + $hwlang = explode(':', $dev_config["_hwlang"]); + } + if (($key_l == 'networklocaleinfo') || ($key_l == 'networklocale')) { + $lang = (empty($hwlang[0])) ? $data_values['netlang'] : $hwlang[0]; + } else { + $lang = (empty($hwlang[1])) ? $data_values['devlang'] : $hwlang[1]; + } + if (($lang != 'null') && (!empty($lang))) { + if ($key_l == 'networklocale') { + $xml_work->$key = $lang; + } else { + if (isset($lang_info[$lang])) { + $xml_node->name = $lang_info[$lang]['locale']; + $xml_node->langCode = $lang_info[$lang]['code']; + if ($key_l == 'userlocale') { + $xml_node->winCharSet = $lang_info[$lang]['codepage']; + } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + } + } + } else { + $xml_work->$key = ''; + } + break; + default: + break; + } + } + + $xml_work->asXml($xml_name); // Save + return time(); } diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 39ddbeb..8e7befb 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -512,14 +512,12 @@ trait ajaxHelper { $TZdata = $this->extconfigs->getExtConfig('sccp_timezone', $tz_id); if (!empty($TZdata)) { $value = $TZdata['offset']/60; - if (!($this->sccpvalues['tzoffset']['data'] == $value)) { - $save_settings[] = array( - 'keyword' => 'tzoffset', - 'data' => $value, - 'seq' => '98', - 'type' => '2' - ); - } + $save_settings[] = array( + 'keyword' => 'tzoffset', + 'data' => $value, + 'seq' => '98', + 'type' => '2' + ); } break; } From 0e363360333a1495436646369c901a04113b17a2 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:32:07 +0200 Subject: [PATCH 037/181] Delete sccpsimple.xml.v433 Not required and complicates maintainability --- conf/sccpsimple.xml.v433 | 1578 -------------------------------------- 1 file changed, 1578 deletions(-) delete mode 100644 conf/sccpsimple.xml.v433 diff --git a/conf/sccpsimple.xml.v433 b/conf/sccpsimple.xml.v433 deleted file mode 100644 index 4fdb312..0000000 --- a/conf/sccpsimple.xml.v433 +++ /dev/null @@ -1,1578 +0,0 @@ - - - - - - XML_info - - NONE - - - - - - - - - - - - dev_sshUserId - cisco - - Help. - - - - - dev_sshPassword - cisco - - Help. - - - - - dev_deviceProtocol - SCCP - - Help. - - - - - sccp_xml_about - XML Base ver: 11.2, Sccp ver: 431 - - Help. - - - - - autoanswer_tone - 0x32 - sccp-custom - - Autoanswer Tone: The tone the phone plays back when it picks up the phone in autoanswer mode. Default is '0x32'. Silence is '0x00'. There are lots of tones, all expressed as '0XNN' where 'NN' is a hexadecimal number. - - - - - remotehangup_tone - 0x32 - sccp-custom - - Remote Hangup Tone: The tone played by the phone when it received a remote hang-up signal. Use '0' to disable the tone. - - - - - transfer_tone - 0x32 - sccp-custom - - Transfer Tone: The tone played when a call is transferred. Use '0' to disable the tone. - - - - - callwaiting_tone - 0x2D - sccp-custom - - Call Waiting Tone: The tone played when a call is waiting. If you set this one to '0', you will not get a tone in your current call if a new call comes in, so you might want to disable call waiting for this line instead. - - - - - - - sccp_tos - 0x68 - sccp-custom - - - sccp_cos - 0x4 - sccp-custom - - SCCP Type Of Service / Class Of Service: SCCP Type or Class of Service - this is modifiable, but don't. - - - - - audio_tos - 0xB8 - sccp-custom - - - audio_cos - 0x6 - sccp-custom - - Audio Type Of Service / Class Of Service: Audio Type or Class of Service - this is modifiable, but don't. - - - - - video_tos - 0x88 - sccp-custom - - - video_cos - 0x5 - sccp-custom - - Video Type Of Service / Class Of Service: Video Type or Class of Service - this is modifiable, but don't. - - - - - - linetable - sccpline - sccp-custom - - Line Table: This is the linetable for your realtime configuration. Don't change this unless you know what you are doing and have made all the appropriate changes in the rest of your Asterisk config files. If you do not want to use the realtime database anymore, you can set this to blank. NOT RECOMMENDED. - - - - devicetable - sccpdevice - - - sccp-custom - Device Table: This is the devicetable for your realtime configuration. Don't change this unless you know what you are doing and have made all the appropriate changes in the rest of your Asterisk config files. There are two reasonable settings for this - the sccpdevice table or the sccpdeviceconfig view. If you do not want to use the realtime database anymore, you can set this to blank. NOT RECOMMENDED. - - - callhistory_answered_elsewhere - - Missed Calls - - - - - - - - callLogBlfEnabled - - 2 - - - Which does show numbers you can redial, but also include their current device state, so you know when they are currently busy. Note that the other phonebook entries will now also monitor the remove device state and show the current device state - - - - - - - - - - - - - - servername - Vt - - Servername: This is the type of server - usually, it will be Asterisk. - - - - - bindaddr - 0.0.0.0 - sccp-custom - - - port - 2000 - sccp-custom - - Bind Address: The address to bind to for SCCP. In general, it should be set to '0.0.0.0'. If you find problems with one-way audio, you can set this to a specific address in the server. Note that '127.0.0.1' is always wrong here. Also note that placing in your external IP address will cause the chan_sccp module to not load. A manual edit of the /etc/asterisk/sccp.conf file will be needed to fix and reload the module. - : - - - - - externip - - sccp-custom - - - External IP Address of the firewall, required in case the PBX is running on a separate host behind it. IP Address that we're going to notify in RTP media stream as the pbx source address. - / - - - - - keepalive - 60 - sccp-custom - number - - - Time between Keep Alive checks. Valid range is 60-300 seconds. After much trial-and-error, the minimum (60) seems to work just fine. - - - nat - - auto - - - - Global NAT support (default Auto) - - - debug - - NONE - - - - - - Debug: Enable debugging level in SCCP module. - - - displayconfig - - sccpgeneral - - - Help! - - - - - - - permit - Internal - 0.0.0.0/0.0.0.0 - - - - - - - + - Add Allow Range - Allow network settings. Blank fields will be ignored used Network 0.0.0.0/0.0.0.0 to resolve any existing connections. You can use the 'internal' connections only from the networks connected to the server. - - - - - - localnet - Internal - 0.0.0.0/0.0.0.0 - - - - - - - - - + - Add Internal Range - Local network settings. Blank fields will be ignored used Network 0.0.0.0. - - - - deny - 0.0.0.0/0.0.0.0 - - - - - - - - - + - Add Deny network - All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'. - - - - - - - - - language - English - - SCCP Language: This is the language for your hints and other features of the phone. If you don't have any languages installed or are using a single language, you can leave this blank. - - - - netlang - English_United_States - - The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. - - - - devlang - English_United_States - - The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. - - - - - - - - - firstdigittimeout - 16 - sccp-custom - number - - - First Digit Timeout: The amount of time after your first digit to start dialing automatically. This can be over-ridden with settings in your dialplan.xml or by using the 'immediate dial' button. - - - - - digittimeout - 8 - sccp-custom - number - - - Digit Timeout: The amount of time to wait after the second (or subsequent) dialed digit. Override rules are the same as for firstdigittimeout. - - - - - autoanswer_ring_time - 0 - sccp-custom - number - - - Autoanswer Ring Time: The amount of time the phones will ring when being called as Intercom or Paging mode. - - - echocancel - - off - - - Echo Cancel: Echo Cancellation (On or Off). - - - silencesuppression - - off - - - Silence Suppression: Slience Suppression on the phone. - - - private - - on - - - Private Calling Enabled: Place a call with privacy Options (no Caller ID) turned on. Needs to be supported in Asterisk to work through SIP and DAHDI trunks. - - - callanswerorder - - oldestfirst - - - Call Answer Order: Which call should be answered first? The most common choice is "oldestfirst", but other orders are supported. - - - mwilamp - - On - - - - - - Set the MWI lamp style when MWI active to on, off, wink, flash or blink - - - mwioncall - - off - - - Set the MWI on call. - - - - - - - - context - from-internal - sccp-custom - - Context: This is the context in which your phones will operate. It should match the context you are using for the rest of your phones (if you have any). The FreePBX default is 'from-internal' - - - - - regcontext - sccpregistration - sccp-custom - - If regcontext is specified in sccp.conf chan-sccp-b will dynamically create and destroy a NoOp priority 1 extension for a given peer/line which registers with the server. If the context is not specified in extension.conf, then it will be dynamically created when an chan-sccp-b agent registers - - - - - directed_pickup_context - - - sccp-custom - - Context where direct pickup search for extensions. if not set current contect will be use. - - - - - pickupgroup - - - sccp-custom - - Context where direct pickup search for extensions. if not set current contect will be use. - - - - pickup_modeanswer - - off - - - Directed Pickup Mode (Answer): If a call is sent with the "directed pickup" flag, the phone will answer when set to "Yes". - - - transfer_on_hangup - - off - - - Complete transfer on hangup, without pressing transfer a second time. Will complete transfer, when the transferer puts the receiver on hook, after the destination has been reached. To cancel the transfer, either press resume on the transferred channel, press the 'endcall' softkey, or have the receiving party hangup first. - - - - - dial_template - NONE - - sccp-custom - Help. - - - autoselectline_enabled - - off - - - Enables and Disables auto line selection. - - - meetme - - off - - - Enable/Disable conferencing via meetme (on/off), make sure you have one of the meetme apps mentioned below activated in module.conf - - - - - meetmeopts - qxd - sccp-custom - - Other options (app_meetme: A,a,b,c,C,d,D,E,e,F,i,I,l,L,m,M,o,p,P,q,r,s,S,t,T,w,x,X,1) see meetme specific documentation - - - - autocall_select - - off - - - - - - backgroundImageAccess - - true - - - I'm guessing on this one, but on some devices, the background image on the display can be modified at the device. I think this is the thing that allows that to take. - - - phonePersonalization - - 0 - - - Phone personalization needs to be set to allow the server to push background or ringtones to the phone in the SEPXXXXXXXXXX.cnf.xml of each phone: - - - - musicclass - NONE - - form-control - Music Class: Available MOH Classes. These are the MOH classes listed in your current server. - - - - - - - - - - directrtp - - off - - - This option set global allow devices to do direct RTP sessions (default Off) - - - earlyrtp - - none - Immediate - - - - - - The audio strem will be open in the progress and connected state. Valid options: NONE, progress, offhook, dial, ringout. Default may be Progress. - - - simulate_enbloc - - on - - - Use simulated enbloc dialing to speedup connection when dialing while onhook (older phones) - - - - - - cfwdall - - off - - - Activate the callforward softkeys. Default is On - - - cfwdbusy - - off - - - Activate the callforward busy softkeys. Default is On - - - dndFeature - - on - - - Do Not Disturb. Default is Off - - - transfer - - on - - - Allow the use of the transfer feature - - - - - - - - ntp_config_enabled - - off - - - Enabling NTP settings in device configuration. - - - - - ntp_server - pool.ntp.org - pool.ntp.org - - NTP Server name or IP - - - ntp_server_mode - - unicast - - - - - Configure NTP Server protocol time synchronization - - - - - - - - dateformat - - Date Format: The date format for the on-screen display. Can be one of the following: (D-M-YA, M.D.Y, Y/M/D) where 'D' is Day, 'M' is Month, 'Y' is Year, 'A' is 24-hour, 'a' is 12-hour, and the separators can be '.','-','/' - - - - ntp_timezone - sccp-custom - - Date Format: Time zone - - - - - - - - Help_srst - You can also configure a Survivable Remote Site Telephony (SRST) reference as the last device in the CallManager(CM) list. This proves especially useful in a remote site configuration where the phones and Asterisk are connected over a WAN network. SRST provides users with fallback support for the IP phones that cannot access the primary, secondary, or tertiary Asterisk Node in the CallManager List because of an Asterisk Node failure or loss of connectivity across the WAN. For the remote sites attached to multiple-service routers across the WAN, SRST ensures that your remote users receive continuous (although minimal) service by providing call handling support directly from the SRST router. - When IP phones lose contact with primary, secondary, and tertiary Asterisk Nodes (CM's), they must establish a connection to a local SRST router to sustain the call-processing capability necessary to place and receive calls. The IP phone retains the IP address of the local SRST router as a default router in the Network Configuration area of the Settings menu. The Settings menu supports a maximum of five default router entries; however, the cnf.xml accommodates a maximum of three entries. When a secondary Asterisk Node is not available on the network, the local SRST Router's IP address is retained as the standby connection for Asterisk Node during normal operation. - - - - srst_Option - - disable - - - - You enabled/configured a Survivable Remote Site Telephony (SRST) reference as the last device in the CallManager(CM) list. - - - srst_userModifiable - - false - - - The user can change the personal SRST configuration on the device - - - srst_isSecure - - false - - - The user can change the personal SRST configuration on the device - - - - - - srst_Name - Enable - - You enabled configure a Survivable Remote Site Telephony (SRST) reference as the last device in the CallManager(CM) list. - - - - - srst_ip - 3 - / - - - - - - - - - Add Server - Help. - - - - srst_sip - 3 - / - - - - - - - - - Add Server - Help. - - - - - - - - - dev_servicesURL - - - - - - - - - - - dev_authenticationURL - - - - - The above is simply a dummy authentication page. It literally contains one word: AUTHORIZED (it receives UserId, Password, and devicename in the url - if you truly wish to implement special auth) - - - - - dev_idleURL - - - - - URL of CiscoIPPhoneImage. Requires a non-zero setting in idleTimeout. - - - - - dev_informationURL - - - - - - - - - dev_messagesURL - - - - - - - - - dev_directoryURL - - - - This is the URL for a CiscoIPPhoneMenu which gets appended to the end of the Missed/Received/Placed calls. I don't use it (I find it makes more sense to put my phone book under services) - - - - - dev_proxyServerURL - - - - - - - - - - - dev_idleTimeout - 60 - sccp-custom - number - - - - - - - - - - - Help_id2 - - Setting the hotline Feature on a device, will make it connect to a predefined extension as soon as the Receiver is picked up or the "New Call" Button is pressed. No number has to be given. This works even on devices which have no entry in the config file or realtime database. - The hotline function can be used in : - - - First time configuration - This will make it easier to register new devices and assign numbers - - - At a door - Where you want people to be able to only call one number - - - For unprovisioned phones - To only be able to call the helpdesk to get their phone set up - - - - Be careful with this function. Especially not to the internet. So i would restring the deny/permit to 'internal' by default in that case. - - - Allow = - Specify a list of your networks, for example: 192.168.1.0 - - - deny = - 0.0.0.0/0.0.0.0 - - - permit = - internal - - - hotline_context = - sccp - - - hotline_label = - hotline - - - - - - - hotline_enabled - - off - - - Hotline Enabled: This allows unregistered extensions to connect to the system and dial the number listed below. - - - - - hotline_extension - *111 - sccp-custom - - Hotline Extension: The number that gets called when a hotline is picked up. hint - - - - - hotline_label - Hot Line - sccp-custom - - Hotline Label: The label on the device - - - - - hotline_context - default - sccp-custom - - Hotline Context: This is the context through which the phone will connect. It should probably match your other contest. The default is "from-internal" but "from-internal-xfer" would also make sense by limiting the options for the person using the phone. - - - - dial_template - NONE - - sccp-custom - Help. - - - meetme - - off - - - Enable/Disable conferencing via meetme (on/off), make sure you have one of the meetme apps mentioned below activated in module.conf - - - - - meetmeopts - qxd - sccp-custom - - Other options (app_meetme: A,a,b,c,C,d,D,E,e,F,i,I,l,L,m,M,o,p,P,q,r,s,S,t,T,w,x,X,1) see meetme specific documentation - - - - - - - - Help_tftp_rewrite - This section is responsible for the modes of operation of external services: tftp http. - * off - Flat model cisco. All data is in the directory /tftproot - * Custom - The directory structure is strictly defined in the manager (for internal use). Requires tftpd rewrite support. - * Provision - Directory structure data is read from an external file. This project supports phones that can work on tftp and http. Support rewrite. - - - - provision_hide - - tftp_path - /tftpboot - sccp-custom - - Path to tftp home directory - - - - provision_show - - tftp_rewrite_path - /tftpboot - sccp-custom - - Use path from provision index.cnf file. You must first make sure that you have properly configured the "Provision" - - - - tftp_rewrite - - off - pro - pro - - Internal - - - Support the use of regular-expression-based filename remapping - - - - - createlangdir - - no - - - Say 'yes' if you need to create cisco default language directory in tftp path. - - - - - - - - - - mac - 000000000 - sccp-custom - - The MAC address of the phone. You must specify 12 characters in the format XXXX.XXXX.XXXX or XX-XX-XX-XX-XX-XX or XXXXXXXXXXXX - - - - - type - 7911 - - hw_select sccp-custom - The type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. - - - - addon - NONE - - hw_select sccp-custom - Addon: Addons are model specific and only work with certain base phones. This phone model is identified as being a phone that does not accept sidecars. Update devmodel if this is not correct. - - - - - - - - - mac - 000000000 - sccp-custom - - - The MAC address of the phone - - - - type - 7911 - - - hw_select sccp-custom - The type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. - - - - - - type - 79XX - sccp-custom - - - The type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. - - - - - addon - NONE - sccp-custom - - - Addon: Addons are model specific and only work with certain base phones. This phone model is identified as being a phone that does not accept sidecars. Update devmodel if this is not correct. - - - - - - - - - - description - 000000000 - sccp-custom - - - The information in the upper right corner of the device screen. Only English letters and digits ! - - - - softkeyset - default - - System Default Softkey - - - - tzoffset - 00 - - Time Zone offset - - - - netlang - English_United_States - - The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. - - - - devlang - Russian_Russia - - The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. - - - - - backgroundImage - - sccp-custom - - For phones that can display background images - display this one. Default is [empty] - - - - - ringtone - - sccp-custom - - The ringtone that the phone will default to. Can be overridden in the phone. The files RINGLIST.XML provice the basic phone ring tones, while DISTINCTIVERINGLIST.XML defines the list of possible ring tones for your other line types. They, along with the actual 'raw' ringtones, are stored in the /tftpboot/ringtones directory with the rest of the config files. - - - - - - - - - mac - 000000000 - sccp-custom - - - - - - - - - transfer - - NONE - - - - Transfer allowed - - - cfwdall - - NONE - - - - Activate the callforward softkeys. Default is On - - - cfwdbusy - - NONE - - - - Activate the callforward busy softkeys. Default is On - - - dndFeature - - NONE - - - - Do Not Disturb. Default is Off - - - directed_pickup - - on - off - - - Enable Pickup function to direct pickup an extension. Default is On - - - conf_allow - - on - off - - - Allow the use of conference - - - - - - pickup_hide - - - - directed_pickup_context - - sccp-custom - - Context where direct pickup search for extensions. if not set current contact will be use. - - - directed_pickup_modeanswer - - on - - - On (Default)= the call has been answered when picked up. Off = call manager way, the phone who picked up the call rings the call - Options: 'Immediate Answer' or 'Show CallerID' ?????? - - - - - - - useRedialMenu - - off - - - You can specifying 'useRedialMenu = yes' in the sccp.conf device section and the redial softkey will cause the "placed calls" list instead of immediately calling the last dialed number. - - - - force_dtmfmode - - auto - - - - Some phone models with bad firmware do send dtmf in a messed up order and need to be forced to skinny mode. - - - mwioncall - - NONE - - - - Set the MWI on call. - - - - mwilamp - - NONE - - - - - - - Set the MWI lamp style when MWI active to on, off, wink, flash or blink - - - - - conf_hide - - - conf_play_general_announce - - on - - - Playback General Announcements (like: 'You are Entering/Leaving the conference') - - - conf_play_part_announce - - on - - - Playback Personal/Participant Announcements, (like: 'You have been muted / You have been kicked') - - - conf_mute_on_entry - - off - - - Mute new participants from the start - - - conf_show_conflist - - on - - - Automatically show conference list to the moderator - - - - conf_music_on_hold_class - default - - form-control - Play music on hold of this class when no moderator is listening on the conference. If set to an empty string, no music on hold will be played. - - - - - - custom_network_acc - - permit - - - - Help. - - - custom_network_type - - ipv4 - - - Help. - - - - - custom_network_v - - - sccp-custom - - - custom_network_m - - sccp-custom - - - Help. - - - - - - - - - deny - / - sccp_hw_net_inherit - - - - - - - + - Add Deny network - All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'. - - - - - - permit - NONE - Inherit - false - - sccp_hw-ar_permit-grinternal - - sccp_hw_net_inherit - - - - - - - + - Add Allow network - Allow network settings. Blank fields will be ignored used Network 0.0.0.0. - - - - nat - - NONE - - - - - Device NAT support (default Auto) - - - - directrtp - - NONE - Auto - - - - This option allow devices to do direct RTP sessions (default Off) - - - earlyrtp - - NONE - - Immediate - - - - - - The audio stream will be open in the progress and connected state. Valid options: none, progress, offhook, dial, ringout. Default may be Progress. - - - - - - - dialtemplate_name - - form-control - - Help. - - - - - - - - Help_id1 - Specifies a pattern to match dialed digits against. Note: TEMPLATE must be in uppercase. - Rules: - - - match: - Pattern to match, consists of one or more elements - - - 0 1 2 3 4 5 6 7 8 9 - Match digit - - - . - Match one digit, # or * - - - * - Match zero or more digits, # or * - - - \* - Match a literal * - - - , - Play secondary dial-tone specified by tone - - - timeout: - Number of seconds to wait for more digits if this pattern matches - - - line: - Only apply template to the specified line (optional) - - - rewrite: - Rewrite the matched digits before dialing, consists of one or more elements (optional) - - - 0 1 2 3 4 5 6 7 8 9 - Replace with digit - - - %0 - The entire match - - - %1 %2 %3 %4 %5 - Replace with group of digits matched, grouping is done by consecutive literal digit or . elements - - - %% - A literal % - - - . - Each . is replaced by the digit that was matched by the corresponding . in the pattern - - - tone: - Secondary dial-tone to play when a , is matched, up to 3 can be specified (optional) - - - - - - dialtemplate - */10/* - - title - - - - - - - - text1 - - - - - - empty - Bellcore-Alerting - Bellcore-Inside - Bellcore-Outside - Bellcore-Busy - Bellcore-BusyVerify - Bellcore-Reorder - Bellcore-CallWaiting - Bellcore-Hold - Bellcore-Reminder - Bellcore-Confirmation - Bellcore-Stutter - Bellcore-Permanent - Bellcore-None - Cisco-Zip - Cisco-ZipZip - Cisco-BeepBonk - Bellcore-dr1 - Bellcore-dr2 - Bellcore-dr3 - Bellcore-dr4 - Bellcore-dr5 - Bellcore-dr6 - CallWaiting-2 - CallWaiting-3 - CallWaiting-4 - - Allow network settings. Blank fields will be ignored used Network 0.0.0.0. - - - - - From 852156878d523f0e9b3a9846e6a80622dea6c464 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 24 Jun 2021 15:40:36 +0200 Subject: [PATCH 038/181] Simplify method name --- Sccp_manager.class.php | 20 +++++++++----------- sccpManClasses/dbinterface.class.php | 4 ++-- sccpManClasses/xmlinterface.class.php | 2 +- sccpManTraits/ajaxHelper.php | 6 +++--- sccpManTraits/helperFunctions.php | 4 ++-- views/form.adddevice.php | 4 ++-- views/form.addruser.php | 2 +- views/form.addsdevice.php | 12 ++++++------ views/form.buttons.php | 12 ++++++------ views/form.sbuttons.php | 12 ++++++------ views/formShow.php | 8 ++++---- views/server.codec.php | 2 +- 12 files changed, 43 insertions(+), 45 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 946691c..d573a3f 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -69,8 +69,6 @@ * + dir "templates" * + dir "firmware" * + dir "locales" - * + Create Simple User Interface - * + sccpsimple.xml * + Add error information on the server information page (critical display error - the system can not work correctly) * - Add Warning Information on Server Info Page * - ADD Reload Line @@ -380,7 +378,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'monitor' => array('name' => 'Record Calls', 'value' => '') ); - // $lines_list = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension'); + // $lines_list = $this->dbinterface->getSccpDeviceTableData('SccpExtension'); $max_btn = ((!empty($get_settings['buttonscount']) ? $get_settings['buttonscount'] : 100)); $last_btn = $max_btn; for ($it = $max_btn; $it >= 0; $it--) { @@ -425,7 +423,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case 'monitor': $btn_t = 'speeddial'; $btn_opt = (string) $get_settings['button' . $it . '_line']; - $db_res = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension', array('name' => $btn_opt)); + $db_res = $this->dbinterface->getSccpDeviceTableData('SccpExtension', array('name' => $btn_opt)); $btn_n = $db_res[0]['label']; $btn_opt .= ',' . $btn_opt . $this->hint_context['default']; break; @@ -496,7 +494,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $save_settings = array(); $save_codec = array(); $name_dev = ''; - $db_field = $this->dbinterface->HWextension_db_SccpTableData("get_columns_sccpdevice"); + $db_field = $this->dbinterface->getSccpDeviceTableData("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') ? 'add' : 'clear'; // Possible values are delete, replace, add, clear. @@ -623,7 +621,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $save_buttons = array(); $save_settings = array(); $name_dev = ''; - $db_field = $this->dbinterface->HWextension_db_SccpTableData("get_columns_sccpuser"); + $db_field = $this->dbinterface->getSccpDeviceTableData("get_columns_sccpuser"); $hw_prefix = 'SEP'; $name_dev = $get_settings[$hdr_prefix . 'id']; $save_buttons = $this->getPhoneButtons($get_settings, $name_dev, 'sccpline'); @@ -977,13 +975,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (!empty($hw_list)) { $buton_list = array(); foreach ($hw_list as $value) { - $buton_tmp = $this->dbinterface->HWextension_db_SccpTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial', 'id' => $value['name'])); + $buton_tmp = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial', 'id' => $value['name'])); if (!empty($buton_tmp)) { $buton_list = array_merge($buton_list, $buton_tmp); } } } else { - $buton_list = $this->dbinterface->HWextension_db_SccpTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial')); + $buton_list = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial')); } if (empty($buton_list)) { return array('Response' => ' 0 buttons found ', 'data' => ''); @@ -1062,13 +1060,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $data_value = array(); $dev_line_data = null; - $dev_config = $this->dbinterface->HWextension_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id)); + $dev_config = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_byid", array('id' => $dev_id)); // Support Cisco Sip Device if (!empty($dev_config['type'])) { if (strpos($dev_config['type'], 'sip') !== false) { $sccp_native = false; $tmp_bind = $this->sipconfigs->getSipConfig(); - $dev_ext_config = $this->dbinterface->HWextension_db_SccpTableData("SccpDevice", array('name' => $dev_id, 'fields' => 'sip_ext')); + $dev_ext_config = $this->dbinterface->getSccpDeviceTableData("SccpDevice", array('name' => $dev_id, 'fields' => 'sip_ext')); $data_value = array_merge($data_value, $dev_ext_config); $data_tmp = explode(';', $dev_ext_config['sip_lines']); $data_value['sbind'] = array(); @@ -1344,7 +1342,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } // Update info from sccp_db - $tmp_data = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension'); + $tmp_data = $this->dbinterface->getSccpDeviceTableData('SccpExtension'); foreach ($tmp_data as $value) { $name_l = $value['name']; if (!empty($res[$name_l . $default_hint])) { diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 322115b..8a9eaaa 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -32,7 +32,7 @@ class dbinterface public function get_db_SccpTableByID($dataid, $data = array(), $indexField = '') { $result = array(); - $raw = $this->HWextension_db_SccpTableData($dataid, $data); + $raw = $this->getSccpDeviceTableData($dataid, $data); if (empty($raw) || empty($indexField)) { return $raw; } @@ -43,7 +43,7 @@ class dbinterface return $result; } - public function HWextension_db_SccpTableData($dataid, $data = array()) + public function getSccpDeviceTableData($dataid, $data = array()) { // $stmt is a single row fetch, $stmts is a fetchAll. $dbh = \FreePBX::Database(); diff --git a/sccpManClasses/xmlinterface.class.php b/sccpManClasses/xmlinterface.class.php index d1ea593..14464b8 100644 --- a/sccpManClasses/xmlinterface.class.php +++ b/sccpManClasses/xmlinterface.class.php @@ -417,7 +417,7 @@ class xmlinterface 'phoneServices' => 'null', 'certHash' => 'null', 'deviceProtocol' => 'SIP', 'deviceSecurityMode' => '1'); -// $var_hw_config = $this->dbinterface->HWextension_db_SccpTableData("get_sccpdevice_byid", array('id' => $dev_id)); +// $var_hw_config = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_byid", array('id' => $dev_id)); if (empty($dev_config)) { return false; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 8e7befb..29c89b1 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -114,7 +114,7 @@ trait ajaxHelper { } } else { $this->deleteSccpDeviceXML('all'); - $models = $this->dbinterface->HWextension_db_SccpTableData("SccpDevice"); + $models = $this->dbinterface->getSccpDeviceTableData("SccpDevice"); } $this->createDefaultSccpXml(); // Default XML @@ -289,7 +289,7 @@ trait ajaxHelper { return $result; break; case 'getExtensionGrid': - $result = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension'); + $result = $this->dbinterface->getSccpDeviceTableData('SccpExtension'); if (empty($result)) { return array(); } @@ -300,7 +300,7 @@ trait ajaxHelper { $cmd_type = !empty($request['type']) ? $request['type'] : ''; // Find all devices defined in the database - $dbDevices = $this->dbinterface->HWextension_db_SccpTableData('SccpDevice', array('type' => $cmd_type)); + $dbDevices = $this->dbinterface->getSccpDeviceTableData('SccpDevice', array('type' => $cmd_type)); // Return if only interested in SIP devices if ($cmd_type == 'cisco-sip') { return $dbDevices; //this may be empty diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index a25e516..7ff9ba5 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -72,7 +72,7 @@ trait helperfunctions { private function getTableDefaults($table, $trim_underscore = true) { $def_val = array(); // TODO: This is ugly and overkill - needs to be cleaned up in dbinterface - $sccpTableDesc = $this->dbinterface->HWextension_db_SccpTableData("get_columns_{$table}"); + $sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}"); foreach ($sccpTableDesc as $data) { $key = (string) $data['Field']; @@ -90,7 +90,7 @@ trait helperfunctions { private function getTableEnums($table, $trim_underscore = true) { $enumFields = array(); - $sccpTableDesc = $this->dbinterface->HWextension_db_SccpTableData("get_columns_{$table}"); + $sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}"); foreach ($sccpTableDesc as $data) { $key = (string) $data['Field']; diff --git a/views/form.adddevice.php b/views/form.adddevice.php index 369e381..ffa1ef5 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -19,7 +19,7 @@ if (!empty($_REQUEST['new_id'])) { $dev_id = $_REQUEST['new_id']; // Get device defaults from db - $sccpDeviceDesc = $this->dbinterface->HWextension_db_SccpTableData('get_columns_sccpdevice'); + $sccpDeviceDesc = $this->dbinterface->getSccpDeviceTableData('get_columns_sccpdevice'); foreach ($sccpDeviceDesc as $data) { $key = (string) $data['Field']; @@ -43,7 +43,7 @@ if (!empty($_REQUEST['id'])) { // Editing an existing Device. Overwrite any defaults that are already set for this device. $dev_id = $_REQUEST['id']; $dev_new = $dev_id; - $db_res = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array("id" => $dev_id)); + $db_res = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $dev_id)); foreach ($db_res as $key => $val) { if (!empty($val)) { switch ($key) { diff --git a/views/form.addruser.php b/views/form.addruser.php index 898d4d3..4995e02 100644 --- a/views/form.addruser.php +++ b/views/form.addruser.php @@ -11,7 +11,7 @@ $dev_new = null; if (!empty($_REQUEST['ru_id'])) { $dev_id = $_REQUEST['ru_id']; $def_val['id'] = array("keyword" => 'id', "data" => $dev_id, "seq" => "99"); - $db_res = $this->dbinterface->HWextension_db_SccpTableData('get_sccpuser', array("id" => $dev_id)); + $db_res = $this->dbinterface->getSccpDeviceTableData('get_sccpuser', array("id" => $dev_id)); if (!empty($db_res)) { foreach ($db_res as $key => $val) { if (!empty($val)) { diff --git a/views/form.addsdevice.php b/views/form.addsdevice.php index 1c0e38c..5b09bf8 100644 --- a/views/form.addsdevice.php +++ b/views/form.addsdevice.php @@ -29,7 +29,7 @@ if (!empty($_REQUEST['new_id'])) { if (!empty($_REQUEST['id'])) { $dev_id = $_REQUEST['id']; $dev_new = $dev_id; - $db_res = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array("id" => $dev_id)); + $db_res = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $dev_id)); foreach ($db_res as $key => $val) { if (!empty($val)) { switch ($key) { @@ -70,14 +70,14 @@ if (!empty($_REQUEST['id'])) { } } //print_r($db_res); - + if (!empty($device_warning)) { - ?> + ?>

    Warning in the SCCP Device

    -
    +
    $value) { echo '

    '.$key.'

    '; @@ -101,7 +101,7 @@ if (!empty($device_warning)) { - + showGroup('sccp_hw_dev_pickup', 1, 'sccp_hw', $def_val); // echo $this->showGroup('sccp_hw_dev_conference', 1, 'sccp_hw', $def_val); // echo $this->showGroup('sccp_hw_dev_network', 1, 'sccp_hw', $def_val); - ?> + ?> diff --git a/views/form.buttons.php b/views/form.buttons.php index 5708d12..2a7e3b2 100644 --- a/views/form.buttons.php +++ b/views/form.buttons.php @@ -19,8 +19,8 @@ $feature_list= array('parkinglot'=>'Park Slots','monitor'=> "Record Calls",'dev */ -$lines_list = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension'); -//$hint_list = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension'); +$lines_list = $this->dbinterface->getSccpDeviceTableData('SccpExtension'); +//$hint_list = $this->dbinterface->getSccpDeviceTableData('SccpExtension'); $hint_list = $this->getHintInformation(true, array('context'=>'park-hints')) ; // print_r($hint_list); @@ -30,8 +30,8 @@ $show_buttons =1; //print_r($hint_list); if (!empty($_REQUEST['id'])) { $dev_id = $_REQUEST['id']; - $db_buttons = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_buttons', array("id" => $dev_id)); - $db_device = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array("id" => $dev_id)); + $db_buttons = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_buttons', array("id" => $dev_id)); + $db_device = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $dev_id)); $max_buttons = $db_device['buttons']; if (!empty($db_device['addon_buttons'])) { $max_buttons += $db_device['addon_buttons']; @@ -41,7 +41,7 @@ if (!empty($_REQUEST['id'])) { if (!empty($_REQUEST['new_id'])) { $val = $_REQUEST['type']; $dev_schema = $this-> getSccpModelInformation('byid', false, "all", array('model' =>$val)); -// $db_device = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array("id" => $val)); +// $db_device = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $val)); $max_buttons = $dev_schema[0]['buttons']; if (!empty($_REQUEST['addon'])) { $val = $_REQUEST['addon']; @@ -52,7 +52,7 @@ if (!empty($_REQUEST['new_id'])) { } if (!empty($_REQUEST['ru_id'])) { $dev_id = $_REQUEST['ru_id']; - $db_buttons = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_buttons', array("id" => $dev_id)); + $db_buttons = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_buttons', array("id" => $dev_id)); $show_buttons = $max_buttons; } diff --git a/views/form.sbuttons.php b/views/form.sbuttons.php index fc60738..26cf03c 100644 --- a/views/form.sbuttons.php +++ b/views/form.sbuttons.php @@ -15,9 +15,9 @@ $forminfo =array( $buttons_type= array('empty','line','speeddial'); $feature_list= array('parkinglot'=>'Park Slots','monitor'=> 'Record Calls','devstate'=> 'Change Status'); -//$lines_list = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension'); +//$lines_list = $this->dbinterface->getSccpDeviceTableData('SccpExtension'); $lines_list = $this->sipconfigs->get_db_sip_TableData('Device'); -//$hint_list = $this->dbinterface->HWextension_db_SccpTableData('SccpExtension'); +//$hint_list = $this->dbinterface->getSccpDeviceTableData('SccpExtension'); $hint_list = $this->getHintInformation(true, array('context'=>'park-hints')) ; // print_r($lines_list); @@ -27,8 +27,8 @@ $show_buttons =1; //print_r($hint_list); if (!empty($_REQUEST['id'])) { $dev_id = $_REQUEST['id']; - $db_buttons = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_buttons', array('id' => $dev_id)); - $db_device = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array('id' => $dev_id)); + $db_buttons = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_buttons', array('id' => $dev_id)); + $db_device = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array('id' => $dev_id)); $max_buttons = $db_device['buttons']; if (!empty($db_device['addon_buttons'])) { $max_buttons += $db_device['addon_buttons']; @@ -38,7 +38,7 @@ if (!empty($_REQUEST['id'])) { if (!empty($_REQUEST['new_id'])) { $val = $_REQUEST['type']; $dev_schema = $this-> getSccpModelInformation('byid', false, 'all', array('model' =>$val)); -// $db_device = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array("id" => $val)); +// $db_device = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $val)); $max_buttons = $dev_schema[0]['buttons']; if (!empty($_REQUEST['addon'])) { $val = $_REQUEST['addon']; @@ -49,7 +49,7 @@ if (!empty($_REQUEST['new_id'])) { } if (!empty($_REQUEST['ru_id'])) { $dev_id = $_REQUEST['ru_id']; - $db_buttons = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_buttons', array('id' => $dev_id)); + $db_buttons = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_buttons', array('id' => $dev_id)); $show_buttons = $max_buttons; } diff --git a/views/formShow.php b/views/formShow.php index 8fa80e2..e06aa9e 100644 --- a/views/formShow.php +++ b/views/formShow.php @@ -649,19 +649,19 @@ foreach ($items as $child) { } if ($child['type'] == 'SDM') { if (empty($model_list)) { - $model_list = \FreePBX::Sccp_manager()->dbinterface->HWextension_db_SccpTableData("HWDevice"); + $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWDevice"); } $select_opt= $model_list; } if ($child['type'] == 'SDMS') { if (empty($model_list)) { - $model_list = \FreePBX::Sccp_manager()->dbinterface->HWextension_db_SccpTableData("HWSipDevice"); + $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWSipDevice"); } $select_opt= $model_list; } if ($child['type'] == 'SDE') { if (empty($extension_list)) { - $extension_list = \FreePBX::Sccp_manager()->dbinterface->HWextension_db_SccpTableData("HWextension"); + $extension_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWextension"); $extension_list[]=array( 'model' => 'NONE', 'vendor' => 'CISCO', 'dns' => '0'); foreach ($extension_list as &$data) { $d_name = explode(';', $data['model']); @@ -677,7 +677,7 @@ foreach ($items as $child) { } if ($child['type'] == 'SDD') { if (empty($device_list)) { - $device_list = \FreePBX::Sccp_manager()->dbinterface->HWextension_db_SccpTableData("SccpDevice"); + $device_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("SccpDevice"); $device_list[]=array('name' => 'NONE', 'description' => 'No Device'); } $select_opt = $device_list; diff --git a/views/server.codec.php b/views/server.codec.php index 4c5ded5..6c5e522 100644 --- a/views/server.codec.php +++ b/views/server.codec.php @@ -16,7 +16,7 @@ $sccp_disalow = $sccp_disalow_def; if (!empty($_REQUEST['id'])) { $dev_id = $_REQUEST['id']; - $db_res = $this->dbinterface->HWextension_db_SccpTableData('get_sccpdevice_byid', array("id" => $dev_id)); + $db_res = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $dev_id)); if (!empty($db_res['allow'])) { $i = 1; foreach (explode(';', $db_res['allow']) as $c) { From 97c4c93fb63571222450f160d11a83d63358ef3a Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 24 Jun 2021 16:11:33 +0200 Subject: [PATCH 039/181] Display Device description even if not connected --- sccpManTraits/ajaxHelper.php | 1 - views/advserver.model.php | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 29c89b1..53f7a92 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -320,7 +320,6 @@ trait ajaxHelper { unset($activeDevices[$id_name]); } else { // Device is in db but not connected - $dev_id['description'] = '- -'; $dev_id['status'] = 'not connected'; $dev_id['address'] = '- -'; } diff --git a/views/advserver.model.php b/views/advserver.model.php index 22f6f4a..a7240ab 100644 --- a/views/advserver.model.php +++ b/views/advserver.model.php @@ -42,9 +42,9 @@ - + - + @@ -261,13 +261,13 @@ return exp_model; } - function SetColColorFirm(value, row, index) { + function SetColFirmNf(value, row, index) { if (row['validate'].split(';')[0] === 'no') { return "File not found
    " + value; } return value; } - function SetColColorTempl(value, row, index) { + function SetColTemplNf(value, row, index) { if (row['validate'].split(';')[1] === 'no') { return "File not found
    " + value ; } From fb9ea641347b2892ab1f0a368aea6b30d47ffdf8 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 25 Jun 2021 06:35:51 +0200 Subject: [PATCH 040/181] Fix SQL in Install Rename Change SQL in Installer rename column Change TFTP variable name for better clarity --- Sccp_manager.class.php | 14 ++++++------ install.php | 2 +- sccpManClasses/extconfigs.class.php | 2 +- views/advserver.model.php | 1 - views/form.buttons.php | 35 +++++++++++++---------------- 5 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index d573a3f..c287bb3 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -885,7 +885,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'asterisk' => $this->sccpvalues['asterisk_etc_path']['data'], 'tftp_path' => $this->sccpvalues['tftp_path']['data'], 'tftp_templates' => $this->sccpvalues['tftp_templates']['data'], - 'tftp_path_store' => $this->sccpvalues['tftp_path_store']['data'], + 'tftp_store_path' => $this->sccpvalues['tftp_store_path']['data'], 'tftp_lang_path' => $this->sccpvalues['tftp_lang_path']['data'], 'tftp_firmware_path' => $this->sccpvalues['tftp_firmware_path']['data'], 'tftp_dialplan' => $this->sccpvalues['tftp_dialplan']['data'], @@ -1044,7 +1044,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $lang_data = $this->extconfigs->getExtConfig('sccp_lang'); $data_value['tftp_path'] = $this->sccppath["tftp_path"]; - $this->xmlinterface->create_default_XML($this->sccppath["tftp_path_store"], $data_value, $model_information, $lang_data); + $this->xmlinterface->create_default_XML($this->sccppath["tftp_store_path"], $data_value, $model_information, $lang_data); } /* @@ -1121,7 +1121,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $lang_data = $this->extconfigs->getExtConfig('sccp_lang'); if (!$sccp_native) { - return $this->xmlinterface->create_SEP_SIP_XML($this->sccppath["tftp_path_store"], $data_value, $dev_config, $dev_id, $lang_data); + return $this->xmlinterface->create_SEP_SIP_XML($this->sccppath["tftp_store_path"], $data_value, $dev_config, $dev_id, $lang_data); } return $this->xmlinterface->create_SEP_XML($this->sccppath["tftp_templates"], $data_value, $dev_config, $dev_id, $lang_data); } @@ -1131,17 +1131,17 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return false; } if ($dev_id == 'all') { - $xml_name = $this->sccppath["tftp_path_store"] . '/SEP*.cnf.xml'; + $xml_name = $this->sccppath["tftp_store_path"] . '/SEP*.cnf.xml'; array_map("unlink", glob($xml_name)); - $xml_name = $this->sccppath["tftp_path_store"] . '/ATA*.cnf.xml'; + $xml_name = $this->sccppath["tftp_store_path"] . '/ATA*.cnf.xml'; array_map("unlink", glob($xml_name)); - $xml_name = $this->sccppath["tftp_path_store"] . '/VG*.cnf.xml'; + $xml_name = $this->sccppath["tftp_store_path"] . '/VG*.cnf.xml'; array_map("unlink", glob($xml_name)); } else { if (!strpos($dev_id, 'SEP')) { return false; } - $xml_name = $this->sccppath["tftp_path_store"] . '/' . $dev_id . '.cnf.xml'; + $xml_name = $this->sccppath["tftp_store_path"] . '/' . $dev_id . '.cnf.xml'; if (file_exists($xml_name)) { unlink($xml_name); } diff --git a/install.php b/install.php index bc01f43..2cc2026 100644 --- a/install.php +++ b/install.php @@ -429,7 +429,7 @@ function InstallDB_updateSchema($db_config) } } else { if (!empty($row_data['rename'])) { - $sql_modify .= "CHANGE COLUMN {$row_fld} {$row_data['rename']} {$row_data['create']}, "; + $sql_modify .= "RENAME COLUMN {$row_fld} TO {$row_data['rename']}, "; $count_modify ++; } $row_data['fieldModified'] = FALSE; diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 890619e..5937043 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -271,7 +271,7 @@ class extconfigs ); $base_tree = array('tftp_templates' => 'templates', - 'tftp_path_store' => 'settings', + 'tftp_store_path' => 'settings', 'tftp_lang_path' => 'languages', 'tftp_firmware_path' => 'firmware', 'tftp_dialplan' => 'dialplan', diff --git a/views/advserver.model.php b/views/advserver.model.php index a7240ab..5d5d2d5 100644 --- a/views/advserver.model.php +++ b/views/advserver.model.php @@ -272,7 +272,6 @@ return "File not found
    " + value ; } return value; - } function SetRowColor(row, index) { diff --git a/views/form.buttons.php b/views/form.buttons.php index 2a7e3b2..c0c63ad 100644 --- a/views/form.buttons.php +++ b/views/form.buttons.php @@ -66,7 +66,7 @@ if (!empty($_REQUEST['ru_id'])) {

    -
    +
    @@ -87,11 +87,10 @@ if (!empty($_REQUEST['ru_id'])) { hold = To be implemented
  • transfer = To be implemented
  • multiblink = To be implemented
  • mobility = To be implemented
  • conference = To be implemented
  • ");?>
    - -
    + +
    '; echo '
    '; -// echo 'Mode : '.$show_form_mode. ' opt: '; -// print_r( $defaul_opt); - ?> -
    + ?> +
    @@ -212,7 +207,7 @@ if (!empty($_REQUEST['ru_id'])) { echo '
    '; echo ' +
    +
    +

    +
    + If they are changed, they will not be updated by future changes in chan-sccp "?> +
    + + + $data) { ?> +
    +

    +
    +
    + + +
    +
    +
    +
    + + + + +
    +
    + required pattern="[0-9A-D\*#]*"> +
    +
    + + > + + + + > + + +
    +
    +
    +
    +
    + +
    +
    +
    + +
    +
    + + +
    +
    + +
    +
    +
    +
    From b7766fcf64879caabb55dcc2360da11582c994f9 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 29 Jun 2021 16:41:53 +0200 Subject: [PATCH 055/181] First test of new interface to manage defaults hierarchy WIP Need to better manage display of system defaults when customising Need to override XML defaults --- Sccp_manager.class.php | 36 +- assets/js/sccp_manager.js | 21 + conf/sccpgeneral.xml.v433 | 3 +- sccpManTraits/helperFunctions.php | 5 +- views/formShowSysDefs.php | 1027 +++++++++++++++++++++++++++++ views/siteDefaults.php | 83 --- 6 files changed, 1075 insertions(+), 100 deletions(-) create mode 100644 views/formShowSysDefs.php delete mode 100644 views/siteDefaults.php diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index f7156a0..e3682ac 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -158,15 +158,27 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group[@name="' . $group_name . '"]') as $item) { - $htmlret = load_view(__DIR__ . '/views/formShow.php', array( - 'itm' => $item, - 'h_show' => $show_Header, - 'form_prefix' => $form_prefix, - 'fvalues' => $form_values, - 'tftp_lang' => $this->tftpLang, - 'metainfo' => $this->sccp_metainfo - ) - ); + // TODO: Clean up below after debug + if ($group_name == 'sccp_general') { + $htmlret = load_view(__DIR__ . '/views/formShowSysDefs.php', array( + 'itm' => $item, + 'h_show' => $show_Header, + 'form_prefix' => $form_prefix, + 'fvalues' => $form_values, + 'tftp_lang' => $this->tftpLang, + 'metainfo' => $this->sccp_metainfo + )); + } else { + $htmlret = load_view(__DIR__ . '/views/formShow.php', array( + 'itm' => $item, + 'h_show' => $show_Header, + 'form_prefix' => $form_prefix, + 'fvalues' => $form_values, + 'tftp_lang' => $this->tftpLang, + 'metainfo' => $this->sccp_metainfo + ) + ); + } } } else { $htmlret = load_view(__DIR__ . '/views/formShowError.php'); @@ -198,12 +210,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $action = !empty($request['action']) ? $request['action'] : ''; $this->pagedata = array( - "siteConfig" => array( - 'name' => _('Site Default Values'), - 'page' => 'views/siteDefaults.php' - ), "general" => array( - "name" => _("General SCCP Settings"), + "name" => _("Site Default Settings"), "page" => 'views/server.setting.php' ), "sccpdevice" => array( diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index d2d3aa1..30d2b3c 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -1055,3 +1055,24 @@ function sleep(milliseconds) } } } + +$(".custom").click(function() { + $(this).parents(".element-container").removeClass("has-error"); + var id = $(this).data("for"), input = $("#" + id); + var edit_style = document.getElementById("edit_" + id).style; + console.log(id); + if (input.length === 0) { + return; + } + if ($(this).is(":checked")) { + edit_style.display = 'block'; + input.prop("readonly", false); + input.val(input.data("custom")); + input.focus(); + } else { + edit_style.display = 'none'; + input.data("custom", input.val()); + input.prop("readonly", true); + input.val(input.data("default")); + } +}); diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 2c871f5..e9214aa 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -70,12 +70,11 @@ and open the template in the editor. Base Version before all crash :-) - servername - Vt + Asterisk XML Servername: This is the type of server - usually, it will be Asterisk. diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 8e03a60..530c226 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -72,8 +72,11 @@ trait helperfunctions { private function getTableDefaults($table, $trim_underscore = true) { $def_val = array(); // TODO: This is ugly and overkill - needs to be cleaned up in dbinterface + if ($table == 'sccpsettings') { + // sccpsettings has a different structure and already have values in $sccpvalues + return $this->sccpvalues; + } $sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}"); - foreach ($sccpTableDesc as $data) { $key = (string) $data['Field']; // function has 2 roles: return actual table keys (trim_underscore = false) diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php new file mode 100644 index 0000000..044a3de --- /dev/null +++ b/views/formShowSysDefs.php @@ -0,0 +1,1027 @@ + 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9', + '-08' => 'GMT -8', '-07' => 'GMT -7', '-06' => 'GMT -6', '-05' => 'GMT -5', + '-04' => 'GMT -4', '-03' => 'GMT -3', '-02' => 'GMT -2', '-01' => 'GMT -1', + '00' => 'GMT', '01' => 'GMT +1', '02' => 'GMT +2', '03' => 'GMT +3', + '04' => 'GMT +4', '05' => 'GMT +5', '06' => 'GMT +6', '07' => 'GMT +7', + '08' => 'GMT +8', '09' => 'GMT +9', '10' => 'GMT +10', '11'=> 'GMT +11', '12' => 'GMT +12'); + +$extension_list = array(); +$sofkey_list = array(); +$model_list = array(); +$device_list = array(); +$dialplan_list = array(); + +if (\FreePBX::Modules()->checkStatus("soundlang")) { + $syslangs = \FreePBX::Soundlang()->getLanguages(); + if (!is_array($syslangs)) { + $syslangs = array(); + } +} +if (function_exists('music_list')) { + $moh_list = music_list(); +// $cur = (isset($mohsilence) && $mohsilence != "" ? $mohsilence : 'default'); +} +if (!is_array($moh_list)) { + $moh_list = array('default'); +} + +$items = $itm -> children(); + +if ($h_show==1) { + $sec_class =''; + if (!empty($items ->class)) { + $sec_class = (string)$items ->class; + } + ?> + +
    +

    label) ?>

    +
    +
    + + help)) { + $child->help = 'Help is not available.'; + $child->meta_help = '1'; + } +// $child->meta_help = '1'; // Remove comments to see original help ! + + if ($child['type'] == 'IE') { + $res_input = ''; + $res_name = ''; + $usingSysDefaults = true; + $res_oid = (string)$child->input[0]->name; + $res_id = $npref.$res_oid; + if (!empty($metainfo[$res_oid])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$res_oid]['Description']; + } + } + + // --- Add Hidden option + $res_sec_class =''; + if (!empty($child ->class)) { + $res_sec_class = (string)$child ->class; + } + + if (empty($child->nameseparator)) { + $child->nameseparator = ' / '; + } + $i = 0; + + echo ''; + + foreach ($child->xpath('input') as $value) { + $res_n = (string)$value->name; + $res_name = $npref . $res_n; + if (empty($res_id)) { + $res_id = $res_name; + } + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + // TODO: Need to store sysvalues in a separate array + if (!empty($fvalues[$res_n]['systemdefault']) && ($fvalues[$res_n]['systemdefault'] != $fvalues[$res_n]['data'])) { + $usingSysDefaults = false; + } + $value->value = $fvalues[$res_n]['data']; + } + } + if (empty($value->value)) { + $value->value = $value->default; + } + if (empty($value->type)) { + $value->type = 'text'; + } + if (empty($value->class)) { + $value->class = 'form-control'; + } + $item = array('id' => $res_id, 'setting' => $child->label, 'feature' => $res_id, 'iscustom' => 'checked'); + $i ++; + } + ?> +
    +
    +
    +
    + + +
    +
    + value; ?> +
    +
    + + > + + +
    +
    +
    + +
    +
    + help);?> +
    +
    +
    + + label.' -->'; + } + if ($child['type'] == 'IED') { + $res_input = ''; + $res_name = ''; + $res_value = ''; + $opt_at = array(); + $res_n = (string)$child->name; + + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$res_n]['Description']; + } + } +// $res_value + $lnhtm = ''; + $res_id = $napref.$child->name; + $i = 0; + $max_row = 255; + if (!empty($child->max_row)) { + $max_row = $child->max_row; + } + + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $res_value = explode(';', $fvalues[$res_n]['data']); + } + } + if (empty($res_value)) { + $res_value = array((string) $child->default); +// $res_value = explode('/', (string) $child->default); + } + + echo ''; + ?> +
    +
    +
    +
    +
    +
    + + +
    + +
    + cbutton)) { + echo '
    '; + foreach ($child->xpath('cbutton') as $value) { + $res_n = $res_id.'[0]['.$value['field'].']'; + $res_vf = ''; + if ($value['value']=='NONE' && empty($res_value)) { + $res_vf = 'active'; + } + $ch_key = array_search($value['value'], $res_value); + if ($ch_key !== false) { + unset($res_value[$ch_key]); + $res_vf = 'active'; + $res_value = explode(';', implode(';', $res_value)); + } + $opt_hide =''; + $opt_class="button-checkbox"; + if (!empty($value->option_hide)) { + $opt_class .= " sccp_button_hide"; + $opt_hide = ' data-vhide="'.$value->option_hide.'" data-btn="checkbox" data-clhide="'.$value->option_hide['class'].'" '; + } + if (!empty($child->option_show)) { + if (empty($opt_hide)) { + $opt_hide =' class="sccp_button_hide" '; + } + $opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" '; + } + + if (!empty($value->option_disabled)) { + $opt_class .= " sccp_button_disabled"; + $opt_hide = ' data-vhide="'.$value->option_disabled.'" data-btn="checkbox" data-clhide="'.$value->option_disabled['class'].'" '; + } + + if (!empty($value->class)) { + $opt_class .= " ".(string)$value->class; + } + + echo ''; + } + echo '
    '; + } + $opt_class = "col-sm-7 ".$res_id."-gr"; + if (!empty($child->class)) { + $opt_class .= " ".(string)$child->class; + } + echo '
    '; + + foreach ($res_value as $dat_v) { + ?> +
    > + xpath('input') as $value) { + $res_n = $res_id.'['.$i.']['.$value['field'].']'; + $fields_id = (string)$value['field']; + $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; + if (!empty($value->class)) { + $opt_at[$fields_id]['class']='form-control ' .(string)$value->class; + } + $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; + + echo 'options)) { + foreach ($value->options ->attributes() as $optkey => $optval) { + $opt_at[$fields_id]['options'][$optkey]=(string)$optval; + echo ' '.$optkey.'="'.$optval.'"'; + } + } + echo '> '.(string)$value['nameseparator'].' '; + $i2 ++; + } + if (!empty($child->add_pluss)) { + echo ''; + } + echo '
    '; + $i++; + } + ?> + +
    + addbutton)) { + echo '
    '; + echo ''; + echo '
    '; + } + ?> +
    +
    +
    +
    +
    +
    + help);?> +
    +
    + label.' -->'; + } + + if ($child['type'] == 'IS') { + $res_n = (string)$child->name; + $res_id = $npref.$res_n; + $res_ext = str_replace($npref,'',$res_n); + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$res_n]['Description']; + } + } + + // --- Add Hiden option + $res_sec_class =''; + if (!empty($child ->class)) { + $res_sec_class = (string)$child ->class; + } + + echo ''; + ?> +
    +
    +
    + + +
    +
    + default)) { + $res_v = (string)$child->default; + } + if (!empty($child->value)) { + $res_v = (string)$child->value; + } + if (!empty($fvalues[$res_n])) { + if (($fvalues[$res_n]['data'] != '') ) { + $res_v = (string)$fvalues[$res_n]['data']; + } + } + if (!empty($child->option_hide)) { + $opt_hide = ' class="sccp_button_hide" data-vhide="'.$child->option_hide.'" data-clhide="'.$child->option_hide['class'].'" '; + } + if (!empty($child->option_show)) { + if (empty($opt_hide)) { + $opt_hide =' class="sccp_button_hide" '; + } + $opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" '; + } + foreach ($child->xpath('button') as $value) { + $val_check = strtolower((string)$value[@value]); + if ($val_check == strtolower($res_v)) { + $val_check = " checked"; + } else { + if ($val_check == '' || $val_check == 'none' ) { + if (strtolower($res_v) == 'none' || $res_v == '' ) { + $val_check = " checked"; + } else {$val_check = "";} + } else {$val_check = "";} + } + echo ''; + echo ''; + $i++; + } + ?> +
    +
    +
    + help);?> +
    +
    + + label.' -->'; + } + +/* + * Input element Select SLD - Date format + * SLZ - Time Zone + * + * SLM - Music on hold + * SLK - System KeySet + * SLP - Dial Paterns + */ + + if ($child['type'] == 'SLD' || $child['type'] == 'SLM'|| $child['type'] == 'SLK'|| $child['type'] == 'SLP') { +// $value = $child -> select; + $res_n = (string)$child ->name; + $res_id = $npref.$res_n; + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$res_n]['Description']; + } + } + + if (empty($child->class)) { + $child->class = 'form-control'; + } + + if ($child['type'] == 'SLD') { + $select_opt= $day_format; + } + + if ($child['type'] == 'SLM') { + $select_opt= $moh_list; + } + if ($child['type'] == 'SLK') { + if (empty($sofkey_list)) { + $sofkey_list = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets(); + } + $select_opt= $sofkey_list; + } + if ($child['type'] == 'SLP') { + if (empty($dialplan_list)) { + foreach (\FreePBX::Sccp_manager()->getDialPlanList() as $tmpkey) { + $tmp_id = $tmpkey['id']; + $dialplan_list[$tmp_id] = $tmp_id; + } + } + $select_opt= $dialplan_list; + } +// if ($child['type'] == 'SLZ') { +// $select_opt= $timeZoneOffsetList; +// } + + echo ''; + + ?> +
    +
    + +
    + + +
    +
    class . '" id="' . $res_id . '">'; + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + } + } + foreach ($select_opt as $key) { + echo ''; + } + ?> +
    +
    +
    + help);?> +
    +
    + label.' -->'; + } +/* + * Input element Select SLS - System Language + */ + + if ($child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SLA' || $child['type'] == 'SLZ') { +// $value = $child -> select; + $res_n = (string)$child ->name; + $res_id = $npref.$res_n; + $child->value =''; + + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$res_n]['Description']; + } + } + + if ($child['type'] == 'SLS') { + $select_opt= $syslangs; + } + if ($child['type'] == 'SLT') { + $select_opt= $tftp_lang; + } + if ($child['type'] == 'SLZ') { + $select_opt= $timeZoneOffsetList; +// $child->value = ($system_time_zone[offset]/60); + } + + if ($child['type'] == 'SLA') { + $select_opt =''; + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $res_value = explode(';', $fvalues[$res_n]['data']); + } + if (empty($res_value)) { + $res_value = array((string) $child->default); + } + foreach ($res_value as $key) { + $select_opt[$key]= $key; + } + } + } + + if (empty($child->class)) { + $child->class = 'form-control'; + } + + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + } + } + + if (empty($child->value)) { + if (!empty($child->default)) { + $child->value = $child->default; + } + } + + echo ''; + ?> +
    +
    + +
    + + +
    +
    class . '" id="' . $res_id . '">'; + foreach ($select_opt as $key => $val) { + if (is_array($val)) { + $opt_key = (isset($val['id'])) ? $val['id'] : $key; + $opt_val = (isset($val['val'])) ? $val['val'] : $val; + } else { + $opt_key = $key; + $opt_val = $val; + } + echo ''; + } + ?> +
    +
    +
    + help);?> +
    +
    + + label.' -->'; + } +/* + * Input element Select + */ + + if ($child['type'] == 'SL') { + $res_n = (string)$child->name; + $res_id = $npref.$child->name; + + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$res_n]['Description']; + } + } + + if (empty($child ->class)) { + $child->class = 'form-control'; + } + echo ''; + + ?> +
    +
    + +
    + + +
    +
    class . '" id="' . $res_id . '">'; + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + } + } + foreach ($child->xpath('select') as $value) { + if (!empty($value[@value])) { + $key = $value[@value]; + } else { + $key = (string)$value; + } + echo ''; + } + ?> + +
    +
    +
    + help);?> +
    +
    + label.' -->'; + } + + /* + * Input element Select SDM - Model List + * SDMS - Sip model List + * SDE - Extension List + */ + + if ($child['type'] == 'SDM' || $child['type'] == 'SDMS' || $child['type'] == 'SDE' || $child['type'] == 'SDD') { +// $value = $child -> select; + $res_n = (string)$child ->name; + $res_id = $npref.$res_n; + + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$res_n]['Description']; + } + } + + if (empty($child->class)) { + $child->class = 'form-control'; + } + if ($child['type'] == 'SDM') { + if (empty($model_list)) { + $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWDevice"); + } + $select_opt= $model_list; + } + if ($child['type'] == 'SDMS') { + if (empty($model_list)) { + $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWSipDevice"); + } + $select_opt= $model_list; + } + if ($child['type'] == 'SDE') { + if (empty($extension_list)) { + $extension_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWextension"); + $extension_list[]=array( 'model' => 'NONE', 'vendor' => 'CISCO', 'dns' => '0'); + foreach ($extension_list as &$data) { + $d_name = explode(';', $data['model']); + if (is_array($d_name) && (count($d_name) > 1)) { + $data['description'] = count($d_name).'x '.$d_name[0]; + } else { + $data['description'] = $data['model']; + } + } + unset($data); + } + $select_opt= $extension_list; + } + if ($child['type'] == 'SDD') { + if (empty($device_list)) { + $device_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("SccpDevice"); + $device_list[]=array('name' => 'NONE', 'description' => 'No Device'); + } + $select_opt = $device_list; + } + + echo ''; + + ?> +
    +
    + +
    + + +
    +
    class . '" id="' . $res_id . '"'; + if (isset($child->options)) { + foreach ($child->options->attributes() as $optkey => $optval) { + echo ' '.$optkey.'="'.$optval.'"'; + } + } + echo '>'; + + $fld = (string)$child->select['name']; + $flv = (string)$child->select; + $flv2 = (string)$child->select['addlabel']; + $flk = (string)$child->select['dataid']; + $flkv = (string)$child->select['dataval']; + $key = (string)$child->default; + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + $key = $fvalues[$res_n]['data']; + } + } + + foreach ($select_opt as $data) { + echo ''; + } + + ?> +
    +
    +
    + help);?> +
    +
    + label.' -->'; + } + if ($child['type'] == 'ITED') { + $res_input = ''; + $res_name = ''; + $res_na = (string)$child->name; + +// $res_value + $lnhtm = ''; + $res_id = $napref.$child->name; + $i = 0; + + if (!empty($fvalues[$res_na])) { + if (!empty($fvalues[$res_na]['data'])) { + $res_value = explode(';', $fvalues[$res_na]['data']); + } + } + if (empty($res_value)) { + $res_value = array((string) $child->default); +// $res_value = explode('/', (string) $child->default); + } + + echo ''; + ?> + + + '; + if (!empty($child->label)) { + echo ''; + } + + $res_vf = explode('/', $dat_v); + $i2 = 0; + + foreach ($child->xpath('element') as $value) { + $fields_id = (string)strtolower($value['field']); + $res_n = $res_id.'['.$i.']['.$fields_id.']'; + $res_ni = $res_id.'_'.$i.'_'.$fields_id; + + $opt_at[$fields_id]['display_prefix']=(string)$value['display_prefix']; + $opt_at[$fields_id]['display_sufix']=(string)$value['display_sufix']; + + if (empty($value->options->class)) { + $opt_at[$fields_id]['options']['class']='form-control'; + } + $opt_at[$fields_id]['type']=(string)$value['type']; + $res_opt['addon'] =''; + if (isset($value->options)) { + foreach ($value->options ->attributes() as $optkey => $optval) { + $opt_at[$fields_id]['options'][$optkey]=(string)$optval; + $res_opt['addon'] .=' '.$optkey.'="'.$optval.'"'; + } + } + + echo ''; + $i2 ++; + } + echo ''; + $i++; + } + echo '
    '.$child->label.'
    '; + $res_opt['inp_st'] = '
    '.$opt_at[$fields_id]['display_prefix'].''; + $res_opt['inp_end'] = ''.$opt_at[$fields_id]['display_sufix'].'
    '; + switch ($value['type']) { + case 'date': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + case 'number': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + case 'input': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + case 'title': + if ($i > 0) { + break; + } + case 'label': + $opt_at[$fields_id]['data'] = (string)$value; + echo ''; + break; + case 'select': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + } + echo '
    '; + if ($i > 0) { + echo ''; + } + + echo '
    '; + echo ''; + } + + if ($child['type'] == 'HLP') { + $res_n = (string)$child ->name; + $res_id = $npref.$res_n; + if (empty($child->class)) { + $child->class = 'form-control'; + } + echo ''; + + ?> + +
    +
    +

    label);?> +

    +
    +
    + xpath('element') as $value) { + switch ($value['type']) { + case 'p': + case 'h1': + case 'h2': + case 'h3': + case 'h4': + echo '<'.$value['type'].'>'._((string)$value).''; + break; + case 'table': + echo '<'.$value['type'].' class="table" >'; + foreach ($value->xpath('row') as $trow) { + echo ''; + foreach ($trow->xpath('col') as $tcol) { + echo ''._((string)$tcol).''; + } + echo ''; + } + echo ''; + break; + } + } + ?> + +
    +
    + label.' -->'; + } + if ($child['type'] == 'MINFO') { + $res_n = (string)$child ->name; + $res_id = $npref.$res_n; + if (empty($child->class)) { + $child->class = 'form-control'; + } + echo ''; + ?> + + label.' -->'; + } +/* + * Input element Select SLTZN - System Time Zone + */ + + if ($child['type'] == 'SLTZN') { +// $value = $child -> select; + $res_n = (string)$child ->name; + $res_id = $npref.$res_n; + $child->value =''; + + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$res_n]['Description']; + } + } + + if (empty($child->class)) { + $child->class = 'form-control'; + } + + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + } + } + + $child->value = \date_default_timezone_get(); + + echo ''; + ?> +
    +
    +
    +
    + + +
    +
    value; + ?> +
    +
    +
    +
    + help);?> +
    +
    + + label.' -->'; + } +} +?> +'; +} +?> diff --git a/views/siteDefaults.php b/views/siteDefaults.php deleted file mode 100644 index ba24177..0000000 --- a/views/siteDefaults.php +++ /dev/null @@ -1,83 +0,0 @@ - - array('title' => 'First Block of Defaults', - 'items' => array('item1' => array('code' => 'This is the value to edit', 'title' => 'variable1')))); -?> - -
    -
    -
    -
    -
    - -
    -
    -

    -
    - If they are changed, they will not be updated by future changes in chan-sccp "?> -
    - - - $data) { ?> -
    -

    -
    -
    - - -
    -
    -
    -
    - - - - -
    -
    - required pattern="[0-9A-D\*#]*"> -
    -
    - - > - - - - > - - -
    -
    -
    -
    -
    - -
    -
    -
    - -
    -
    - - -
    -
    -
    -
    -
    -
    -
    From ace4945eb083893e472b12acf40da0fabaa2c21b Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 30 Jun 2021 07:02:22 +0200 Subject: [PATCH 056/181] Load help from chan-sccp Load metainfo descriptions which provide help if not in XML --- Sccp_manager.class.php | 21 +++++++++++++++------ sccpManClasses/dbinterface.class.php | 1 - views/formShowSysDefs.php | 6 ++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index e3682ac..b87a79b 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -94,7 +94,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { private $hint_context = array('default' => '@ext-local'); /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!! private $val_null = 'NONE'; /// REPLACE to null Field public $sccp_model_list = array(); - public $sccp_metainfo = array(); private $cnf_wr = null; public $sccppath = array(); public $sccpvalues = array(); @@ -102,6 +101,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public $xml_data; public $class_error; //error construct public $info_warning; + public $sccp_metainfo = array(); // Move all non sccp_manager specific functions to traits use \FreePBX\modules\Sccp_Manager\sccpManTraits\helperFunctions; @@ -149,12 +149,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ public function showGroup($group_name, $show_Header, $form_prefix = 'sccp', $form_values = array()) { - if (empty($form_values)) { - $form_values = $this->sccpvalues; - } - // load xml data - moved from Construct to simplify Construct + + // load xml data - moved from Construct to simplify Construct. + // TODO: This is static data so only load first time. Left as is for dbug. $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v433'; $this->xml_data = simplexml_load_file($xml_vars); + // load metainfo from chan-sccp - help information if not in xml. Only load first time as static data. + if (empty($this->sccp_metainfo)) { + $sysConfiguration = $this->aminterface->getSCCPConfigMetaData('general'); + + foreach ($sysConfiguration['Options'] as $key => $valueArray) { + $this->sccp_metainfo[$valueArray['Name']] = $valueArray['Description']; + } + unset($sysConfiguration); + } if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group[@name="' . $group_name . '"]') as $item) { @@ -166,7 +174,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'form_prefix' => $form_prefix, 'fvalues' => $form_values, 'tftp_lang' => $this->tftpLang, - 'metainfo' => $this->sccp_metainfo + 'metainfo' => $this->sccp_metainfo, + 'sccp_defaults' => $this->sccpvalues )); } else { $htmlret = load_view(__DIR__ . '/views/formShow.php', array( diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 3730aea..a192c8d 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -247,7 +247,6 @@ class dbinterface $result = false; switch ($table_name) { case 'sccpsettings': - dbug('savevalue', $save_value); if ($mode == 'replace') { // Change mode name to be more transparent $dbh->prepare('TRUNCATE sccpsettings')->execute(); $stmt = $dbh->prepare('INSERT INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES (:keyword,:data,:seq,:type,:systemdefault)'); diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index 044a3de..e1497a4 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -58,6 +58,9 @@ if (function_exists('music_list')) { if (!is_array($moh_list)) { $moh_list = array('default'); } +if (empty($fvalues)) { + $fvalues = $sccp_defaults; +} $items = $itm -> children(); @@ -115,8 +118,7 @@ foreach ($items as $child) { } if (!empty($fvalues[$res_n])) { if (!empty($fvalues[$res_n]['data'])) { - // TODO: Need to store sysvalues in a separate array - if (!empty($fvalues[$res_n]['systemdefault']) && ($fvalues[$res_n]['systemdefault'] != $fvalues[$res_n]['data'])) { + if (!empty($sccp_defaults[$res_n]['systemdefault']) && ($sccp_defaults[$res_n]['systemdefault'] != $fvalues[$res_n]['data'])) { $usingSysDefaults = false; } $value->value = $fvalues[$res_n]['data']; From 3ec730b71bdb3e2fe7d2ae8b0944730ee61ef8dd Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 30 Jun 2021 07:05:17 +0200 Subject: [PATCH 057/181] Standardise between different formShow pages --- Sccp_manager.class.php | 3 ++- views/formShow.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index b87a79b..63c052f 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -184,7 +184,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'form_prefix' => $form_prefix, 'fvalues' => $form_values, 'tftp_lang' => $this->tftpLang, - 'metainfo' => $this->sccp_metainfo + 'metainfo' => $this->sccp_metainfo, + 'sccp_defaults' => $this->sccpvalues ) ); } diff --git a/views/formShow.php b/views/formShow.php index e06aa9e..2c3183a 100644 --- a/views/formShow.php +++ b/views/formShow.php @@ -58,6 +58,9 @@ if (function_exists('music_list')) { if (!is_array($moh_list)) { $moh_list = array('default'); } +if (empty($fvalues)) { + $fvalues = $sccp_defaults; +} $items = $itm -> children(); From 64624fa5975c4e0fc1bded41b8054f5bf21f0ab0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 30 Jun 2021 08:14:15 +0200 Subject: [PATCH 058/181] Simplify chan-sccp help usage Convert array to string when loaded, and rename arrays that hold the data for clarity --- Sccp_manager.class.php | 12 +++++---- conf/sccpgeneral.xml.v433 | 1 - views/formShow.php | 16 ++++++------ views/formShowSysDefs.php | 52 ++++++++++++++++++++++----------------- 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 63c052f..c6f78a9 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -101,7 +101,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public $xml_data; public $class_error; //error construct public $info_warning; - public $sccp_metainfo = array(); + public $sccpHelpInfo = array(); // Move all non sccp_manager specific functions to traits use \FreePBX\modules\Sccp_Manager\sccpManTraits\helperFunctions; @@ -155,11 +155,13 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $xml_vars = __DIR__ . '/conf/sccpgeneral.xml.v433'; $this->xml_data = simplexml_load_file($xml_vars); // load metainfo from chan-sccp - help information if not in xml. Only load first time as static data. - if (empty($this->sccp_metainfo)) { + if (empty($this->sccpHelpInfo)) { $sysConfiguration = $this->aminterface->getSCCPConfigMetaData('general'); foreach ($sysConfiguration['Options'] as $key => $valueArray) { - $this->sccp_metainfo[$valueArray['Name']] = $valueArray['Description']; + foreach ($valueArray['Description'] as $descKey => $descValue) { + $this->sccpHelpInfo[$valueArray['Name']] .= $descValue . '
    '; + } } unset($sysConfiguration); } @@ -174,7 +176,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'form_prefix' => $form_prefix, 'fvalues' => $form_values, 'tftp_lang' => $this->tftpLang, - 'metainfo' => $this->sccp_metainfo, + 'chanSccpHelp' => $this->sccpHelpInfo, 'sccp_defaults' => $this->sccpvalues )); } else { @@ -184,7 +186,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'form_prefix' => $form_prefix, 'fvalues' => $form_values, 'tftp_lang' => $this->tftpLang, - 'metainfo' => $this->sccp_metainfo, + 'chanSccpHelp' => $this->sccpHelpInfo, 'sccp_defaults' => $this->sccpvalues ) ); diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index e9214aa..c777dcb 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -107,7 +107,6 @@ and open the template in the editor. Base Version before all crash :-) sccp-custom - External IP Address of the firewall, required in case the PBX is running on a separate host behind it. IP Address that we're going to notify in RTP media stream as the pbx source address. Resolve Hostname (if dynamic) that we're going to resolve when setting up the RTP media stream (only active if externip=0.0.0.0 and host is natted.) 1 / diff --git a/views/formShow.php b/views/formShow.php index 2c3183a..b3c691f 100644 --- a/views/formShow.php +++ b/views/formShow.php @@ -92,7 +92,7 @@ foreach ($items as $child) { $res_id = $npref.$res_oid; if (!empty($metainfo[$res_oid])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_oid]['Description']; + $child->help = $metainfo[$res_oid]; } } @@ -179,7 +179,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } // $res_value @@ -323,7 +323,7 @@ foreach ($items as $child) { $res_ext = str_replace($npref,'',$res_n); if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -410,7 +410,7 @@ foreach ($items as $child) { $res_id = $npref.$res_n; if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -490,7 +490,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -582,7 +582,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -643,7 +643,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } @@ -935,7 +935,7 @@ foreach ($items as $child) { if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_n]['Description']; + $child->help = $metaInfo[$res_n]; } } diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index e1497a4..335daa3 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -89,11 +89,11 @@ foreach ($items as $child) { $res_input = ''; $res_name = ''; $usingSysDefaults = true; - $res_oid = (string)$child->input[0]->name; - $res_id = $npref.$res_oid; - if (!empty($metainfo[$res_oid])) { + $shortId = (string)$child->input[0]->name; + $res_id = $npref.$shortId; + if (!empty($metainfo[$shortId])) { if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$res_oid]['Description']; + $child->help = $metainfo[$shortId]; } } @@ -109,7 +109,17 @@ foreach ($items as $child) { $i = 0; echo ''; - + ?> +
    +
    +
    +
    + + +
    +
    + xpath('input') as $value) { $res_n = (string)$value->name; $res_name = $npref . $res_n; @@ -133,19 +143,16 @@ foreach ($items as $child) { if (empty($value->class)) { $value->class = 'form-control'; } + // TODO: This is a temporary workaround and should be fixed $item = array('id' => $res_id, 'setting' => $child->label, 'feature' => $res_id, 'iscustom' => 'checked'); + + if ($i > 0) { + echo $child->nameseparator; + } + echo $value->value; $i ++; } ?> -
    -
    -
    -
    - - -
    -
    - value; ?>
    @@ -158,11 +165,12 @@ foreach ($items as $child) { - @@ -368,7 +368,6 @@ foreach ($items as $child) { $i++; } ?> -
    addbutton)) { @@ -399,7 +398,8 @@ foreach ($items as $child) { $child->help = $metaInfo[$res_n]; } } - // --- Add Hidden option + + // --- Add Hidden option $res_sec_class =''; if (!empty($child ->class)) { $res_sec_class = (string)$child ->class; @@ -411,10 +411,73 @@ foreach ($items as $child) {
    - +
    +
    + + default)) { + $res_v = (string)$child->default; + } + if (!empty($child->value)) { + $res_v = (string)$child->value; + } + if (!empty($fvalues[$res_n])) { + if (($fvalues[$res_n]['data'] != '') ) { + $res_v = (string)$fvalues[$res_n]['data']; + } + } + if (!empty($sccp_defaults[$res_n]['systemdefault']) && ($sccp_defaults[$res_n]['systemdefault'] != $res_v)) { + $usingSysDefaults = false; + } + + // Output current value + echo $res_v; + ?> +
    +
    + + + > + + +
    +
    +
    + -
    help);?> -
    -
    +
    Date: Thu, 1 Jul 2021 10:11:02 +0200 Subject: [PATCH 063/181] WIP Partial fix for setting default radio buttons --- assets/js/sccp_manager.js | 24 +++++++++++++++++++++--- views/formShowSysDefs.php | 11 ++++++++--- views/server.device.php | 7 +++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 5ea8f4c..6f41438 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -1057,7 +1057,7 @@ function sleep(milliseconds) } $(".sccp-restore").click(function() { - //input is sent by data-for where for is an attribute + //input is sent by data-for where for as an attribute var id = $(this).data("for"), input = $("#" + id); var edit_style = document.getElementById("edit_" + id).style; @@ -1066,9 +1066,11 @@ $(".sccp-restore").click(function() { return; } if ($(this).is(":checked")) { + console.log('restore/checked'); edit_style.display = 'block'; input.prop("readonly", true); } else { + console.log('restore/unchecked'); edit_style.display = 'none'; input.data("custom", input.val()); input.prop("readonly", true); @@ -1077,20 +1079,36 @@ $(".sccp-restore").click(function() { }); $(".sccp-edit").click(function() { - //input is sent by data-for where for is an attribute - var id = $(this).data("for"), input = $("#" + id); + var id = $(this).data("for"), input = $("#" + id); var edit_style = document.getElementById("edit_" + id).style; + //input is sent by data-for where for is an attribute + if ($(this).data("type") === 'radio') { + input = 'radio'; + console.log('have radio type'); + // $(':radio:not(:checked)').attr('disabled', true); to make readonly + // Need to use getElementBy Name + } + + console.log(input); if (input.length === 0) { return; } if ($(this).is(":checked")) { + console.log('edit/checked'); edit_style.display = 'block'; + if (input == 'radio') { + return; + } input.prop("readonly", false); input.focus(); } else { + console.log('edit/unchecked'); edit_style.display = 'none'; + if (input == 'radio') { + return; + } input.data("custom", input.val()); input.prop("readonly", true); input.val(input.data("default")); diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index 9c5da6b..f913457 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -403,6 +403,8 @@ foreach ($items as $child) { $res_sec_class =''; if (!empty($child ->class)) { $res_sec_class = (string)$child ->class; + } else { + $res_sec_class = 'sccp-custom'; } echo ''; @@ -411,7 +413,7 @@ foreach ($items as $child) {
    - +
    @@ -449,12 +451,14 @@ foreach ($items as $child) { if ($usingSysDefaults) { // Setting a site specific value echo " data-for={$res_id}"; + echo " data-type=radio"; echo " class=sccp-edit"; echo " id=usedefault_{$res_id}"; echo " :checked"; } else { // reverting to chan-sccp default values echo " data-for={$res_id}"; + echo " data-type=radio"; echo " class=sccp-restore"; echo " id=usedefault_{$res_id}"; echo " "; @@ -471,10 +475,11 @@ foreach ($items as $child) {
    + +
    +
    help);?>
    @@ -945,32 +940,6 @@ $thisSccpView = new class{ name; - $res_id = $npref.$res_n; - if (empty($child->class)) { - $child->class = 'form-control'; - } - ?> - - name; @@ -1068,16 +1037,14 @@ foreach ($items as $child) { case 'SLM': case 'SLK': case 'SLP': - $thisSccpView->addElementSL($child, $fvalues, $sccp_defaults,$npref); - break; + //$thisSccpView->addElementSL($child, $fvalues, $sccp_defaults,$npref); + //break; case 'SLS': case 'SLT': case 'SLA': case 'SLZ': - $thisSccpView->addElementSL2($child, $fvalues, $sccp_defaults,$npref); - break; case 'SL': - $thisSccpView->addElementSL3($child, $fvalues, $sccp_defaults,$npref); + $thisSccpView->addElementSL2($child, $fvalues, $sccp_defaults,$npref); break; case 'SDM': case 'SDMS': @@ -1091,9 +1058,6 @@ foreach ($items as $child) { case 'HLP': $thisSccpView->addElementHLP($child, $fvalues, $sccp_defaults,$npref); break; - case 'MINFO': - $thisSccpView->addElementMINFO($child, $npref); - break; case 'SLTZN': $thisSccpView->addElementSLTZN($child, $fvalues, $sccp_defaults,$npref); break; From a49316515397179fb6d1012a65ec7f52eefbca1a Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 5 Jul 2021 11:02:52 +0200 Subject: [PATCH 072/181] Insert missing
    at end of SL type
    was commented out Change sccpdevice type to IE ( using a list suggests changes are legitimate. While true, they are not recommended, so now user must know exactly what to enter. --- Sccp_manager.class.php | 3 ++- conf/sccpgeneral.xml.v433 | 12 ++++++------ views/formShowSysDefs.php | 9 +++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 4a31bbf..c5f755e 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -171,7 +171,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { // TODO: Clean up below after debug if (($group_name == 'sccp_general') || ($group_name == 'sccp_qos_config') || ($group_name =='sccp_dev_config') || ($group_name =='sccp_dev_group_config') || - ($group_name =='sccp_hotline_config') || ($group_name =='sccp_dev_softkey') || ($group_name =='sccp_dev_advconfig')) { + ($group_name =='sccp_hotline_config') || ($group_name =='sccp_dev_softkey') || + ($group_name =='sccp_dev_advconfig') || $group_name == 'sccp_extpath_config') { $htmlret = load_view(__DIR__ . '/views/formShowSysDefs.php', array( 'itm' => $item, 'h_show' => $show_Header, diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 22b2846..8991ff8 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1195,13 +1195,13 @@ and open the template in the editor. Base Version before all crash :-) Support the use of regular-expression-based filename remapping - + - devicetable - sccpdevice - - - sccp-custom + + devicetable + sccpdevice + sccp-custom + Device Table: This is the devicetable for your realtime configuration. Don't change this unless you know what you are doing and have made all the appropriate changes in the rest of your Asterisk config files. There are two reasonable settings for this - the sccpdevice table or the sccpdeviceconfig view. If you do not want to use the realtime database anymore, you can set this to blank. NOT RECOMMENDED. diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index 8b2a78f..94ceec5 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -639,6 +639,9 @@ $thisSccpView = new class{ } $select_opt= $dialplan_list; break; + case 'SL': + $select_opt = array(); + break; } if (empty($child->class)) { $child->class = 'form-control'; @@ -683,8 +686,10 @@ $thisSccpView = new class{ echo '>' . $opt_val. ''; } ?> -
    -
    +
    +
    +
    +
    help);?>
    From b15729a34038405ee620c2a1af2d71738d49e3dc Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 5 Jul 2021 11:17:03 +0200 Subject: [PATCH 073/181] Change earlyrtp enum chan-sccp enum is now yes / no and all older values equate to one of these. Help updated in chan-sccp revision: 566c8695 --- conf/sccpgeneral.xml.v433 | 27 +++++++++------------------ install.php | 3 +-- module.xml | 2 +- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 8991ff8..452e39c 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -396,17 +396,13 @@ and open the template in the editor. Base Version before all crash :-) This option set global allow devices to do direct RTP sessions (default Off) - + earlyrtp - none - Immediate - - - - - - The audio strem will be open in the progress and connected state. Valid options: NONE, progress, offhook, dial, ringout. Default may be Progress. + + + + The audio stream will be open in the progress and connected state. Valid options: Yes/ No simulate_enbloc @@ -1623,7 +1619,6 @@ and open the template in the editor. Base Version before all crash :-) directrtp - Auto This option allow devices to do direct RTP sessions (default Off) @@ -1631,14 +1626,10 @@ and open the template in the editor. Base Version before all crash :-) earlyrtp - NONE - Immediate - - - - - - The audio stream will be open in the progress and connected state. Valid options: none, progress, offhook, dial, ringout. Default may be Progress. + + + + The audio stream will be open in the progress and connected state. Valid options: Yes/ No diff --git a/install.php b/install.php index 045d62c..77b9083 100644 --- a/install.php +++ b/install.php @@ -121,8 +121,7 @@ function Get_DB_config($sccp_compatible) 'park' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), 'directrtp' => array('create' => "enum('no','yes') NOT NULL default 'no'", 'modify' => "enum('no','yes')"), 'dndFeature' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - 'earlyrtp' => array('create' => "ENUM('immediate','offHook','dialing','ringout','progress','none') NOT NULL default 'none'", - 'modify' => "ENUM('immediate','offHook','dialing','ringout','progress','none')"), + 'earlyrtp' => array('create' => "ENUM('yes','no') NOT NULL default 'no'", 'modify' => "ENUM('yes','no')"), 'monitor' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), 'audio_tos' => array('create' => "VARCHAR(11) NOT NULL default '0xB8'",'modify' => "0xB8"), 'audio_cos' => array('create' => "VARCHAR(11) NOT NULL default '0x6'",'modify' => "0x6"), diff --git a/module.xml b/module.xml index 3e5c4c2..d600f86 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.0 + 14.3.0.1 setup SCCP Connectivity Steve Lad, Alex GP From a6a9850a3cf3a10c87c8c53f7d4fe8d8114500f9 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 5 Jul 2021 17:08:01 +0200 Subject: [PATCH 074/181] rewrite codec methods to be more compliant with chan-sccp Update db Fields for defaults Update save logic WIP update save defaults Field in sccpline --- Sccp_manager.class.php | 5 ++-- sccpManTraits/ajaxHelper.php | 44 +++++++++++++++++++++++++++++------- views/server.codec.php | 19 ++++++++-------- 3 files changed, 49 insertions(+), 19 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index c5f755e..104b263 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -728,7 +728,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public function getMyConfig($var = null, $id = "noid") { switch ($var) { case "voicecodecs": - $val = explode(";", $this->sccpvalues['allow']['data']); + $val = explode(",", explode("|", $this->sccpvalues['disallow|allow']['data'])[1]); $final = array(); $i = 1; foreach ($val as $value) { @@ -766,6 +766,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case 'audio': $lcodecs = $this->getMyConfig('voicecodecs'); $allCodecs = $this->FreePBX->Codecs->getAudio(); + dbug('FPBX audio', $allCodecs); break; case 'video': $lcodecs = $this->getMyConfig('voicecodecs'); @@ -807,11 +808,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $codecs[$c] = false; } } - return $codecs; } else { //Remove non digits $final = array(); + dbug('codecs', $codecs); foreach ($codecs as $codec => $order) { $order = trim($order); if (ctype_digit($order)) { diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 78a89d5..bb40b95 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -387,6 +387,7 @@ trait ajaxHelper { } function handleSubmit($request, $validateonly = false) { + dbug('request is:', $request); $hdr_prefix = 'sccp_'; $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); @@ -494,21 +495,48 @@ trait ajaxHelper { } } switch ($key) { + case 'disallow': + if (is_array($value)) { + foreach ($value as $keycodeс => $valcodeс) { + $save_codec[$i] = $keycodeс; + $i++; + }; + $tmpv = implode(",", $save_codec); + } else { + $tmpv = $value; + } + + if (empty($save_settings['disallow|allow']['data'])) { + $save_settings['disallow|allow']['data'] = $tmpv . "|"; + } else { + $save_settings[] = array( + 'keyword' => 'disallow|allow', + 'data' => $tmpv . "|" .$save_settings['disallow|allow']['data'], + 'seq' => $this->sccpvalues['disallow|allow']['seq'], + 'type' => $this->sccpvalues['disallow|allow']['type'], + 'systemdefault' => $this->sccpvalues['disallow|allow']['systemdefault'] + ); + unset($save_settings['disallow|allow']['data']); + } + break; case 'voicecodecs': case 'vcodec': foreach ($value as $keycodeс => $valcodeс) { $save_codec[$i] = $keycodeс; $i++; }; - $tmpv = implode(";", $save_codec); - if ($tmpv !== $this->sccpvalues['allow']['data']) { + $tmpv = implode(",", $save_codec); + if (empty($save_settings['disallow|allow']['data'])) { + $save_settings['disallow|allow']['data'] = $tmpv; + } else { $save_settings[] = array( - 'keyword' => 'allow', - 'data' => $tmpv, - 'seq' => $this->sccpvalues['allow']['seq'], - 'type' => $this->sccpvalues['allow']['type'], - 'systemdefault' => $this->sccpvalues['allow']['systemdefault'] - ); + 'keyword' => 'disallow|allow', + 'data' => $save_settings['disallow|allow']['data'] . $tmpv, + 'seq' => $this->sccpvalues['disallow|allow']['seq'], + 'type' => $this->sccpvalues['disallow|allow']['type'], + 'systemdefault' => $this->sccpvalues['disallow|allow']['systemdefault'] + ); + unset($save_settings['disallow|allow']['data']); } break; diff --git a/views/server.codec.php b/views/server.codec.php index 6c5e522..f23ef6b 100644 --- a/views/server.codec.php +++ b/views/server.codec.php @@ -9,10 +9,11 @@ $def_val = null; $dev_id = null; -$sccp_codec = $this->getCodecs('audio', true); +$audio_codecs = $this->getCodecs('audio', true); $video_codecs = $this->getCodecs('video', true); -$sccp_disalow_def = $this->extconfigs->getExtConfig('sccpDefaults', 'disallow'); -$sccp_disalow = $sccp_disalow_def; +$sccp_disallow_def = $this->sccpvalues['disallow|allow']['data']; +$sccp_disallow_def = explode("|",$sccp_disallow_def)[0]; +$sccp_disallow = $sccp_disallow_def; if (!empty($_REQUEST['id'])) { $dev_id = $_REQUEST['id']; @@ -23,22 +24,22 @@ if (!empty($_REQUEST['id'])) { $codec_list[$c] = $i; $i ++; } - foreach ($sccp_codec as $c => $v) { + foreach ($audio_codecs as $c => $v) { if (!isset($codec_list[$c])) { $codec_list[$c] = false; } } } if (!empty($db_res['disallow'])) { - $sccp_disalow = $db_res['disallow']; + $sccp_disallow = $db_res['disallow']; } } else { - $codec_list = $sccp_codec; + $codec_list = $audio_codecs; } ?> - +
    @@ -55,8 +56,8 @@ if (!empty($_REQUEST['id'])) {
    - - + +
    From 44e0846761a1cec2d49864c8b3556880053c8a8a Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 6 Jul 2021 08:30:38 +0200 Subject: [PATCH 075/181] Update server.codec.php Add Recommendation for disallow --- views/server.codec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/server.codec.php b/views/server.codec.php index f23ef6b..d802973 100644 --- a/views/server.codec.php +++ b/views/server.codec.php @@ -57,7 +57,7 @@ if (!empty($_REQUEST['id'])) {
    - +
    From 8b064959387adce92c7ac46209f8bdca2f3e8e36 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 6 Jul 2021 11:54:46 +0200 Subject: [PATCH 076/181] Update installer to handle chan-sccp parsable fields chan-sccp has parsable fields where two values are separated by a |. Parse these fields and their associated values and create two fields. Remove the unparsed field if it exists. --- install.php | 33 ++++++++++++++++++++++---- sccpManClasses/xmlinterface.class.php | 34 +++++++++++++-------------- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/install.php b/install.php index 2ac7674..5b7d177 100644 --- a/install.php +++ b/install.php @@ -978,13 +978,36 @@ function cleanUpSccpSettings() { if ($valueArray['Flags'][0] == 'Obsolete' || $valueArray['Flags'][0] == 'Deprecated') { continue; } - $sysConfiguration[$valueArray['Name']] = $valueArray; - if (array_key_exists($valueArray['Name'],$settingsFromDb)) { - if (!empty($sysConfiguration[$valueArray['Name']]['DefaultValue'])) { - $settingsFromDb[$valueArray['Name']]['systemdefault'] = $sysConfiguration[$valueArray['Name']]['DefaultValue']; + + // 2 special cases deny|permit & disallow|allow where need to parse on |. + $newKeyword = explode("|", $valueArray['Name'], 2); + if (isset($newKeyword[1])) { + dbug('',$newKeyword); + $newSysDef = explode("|", $valueArray['DefaultValue'], 2); + $i = 0; + foreach ($newKeyword as $dummy) { + if (array_key_exists($newKeyword[$i],$settingsFromDb)) { + if (!empty($newSysDef[$i])) { + $settingsFromDb[$newKeyword[$i]]['systemdefault'] = $newSysDef[$i]; + } + } else { + $settingsFromDb[$newKeyword[$i]] = array('keyword' => $newKeyword[$i], 'seq' => 0, 'type' => 0, 'data' => '', 'systemdefault' => $newSysDef[$i]); + } + $i++; + } + if (array_key_exists($valueArray['Name'],$settingsFromDb)){ + unset($settingsFromDb[$valueArray['Name']]); } } else { - $settingsFromDb[$valueArray['Name']] = array('keyword' => $valueArray['Name'], 'seq' => 0, 'type' => 0, 'data' => '', 'systemdefault' => $sysConfiguration[$valueArray['Name']]['DefaultValue']); + $sysConfiguration[$valueArray['Name']] = $valueArray; + if (array_key_exists($valueArray['Name'],$settingsFromDb)) { + if (!empty($sysConfiguration[$valueArray['Name']]['DefaultValue'])) { + $settingsFromDb[$valueArray['Name']]['systemdefault'] = $sysConfiguration[$valueArray['Name']]['DefaultValue']; + } + } else { + + $settingsFromDb[$valueArray['Name']] = array('keyword' => $valueArray['Name'], 'seq' => 0, 'type' => 0, 'data' => '', 'systemdefault' => $sysConfiguration[$valueArray['Name']]['DefaultValue']); + } } unset($sysConfiguration[$key]); } diff --git a/sccpManClasses/xmlinterface.class.php b/sccpManClasses/xmlinterface.class.php index a3f8f45..2ce301d 100644 --- a/sccpManClasses/xmlinterface.class.php +++ b/sccpManClasses/xmlinterface.class.php @@ -286,24 +286,22 @@ class xmlinterface $xml_work->$key = time(); break; case 'loadinformation': -// Set Path Image ???? - if (isset($dev_config["tftp_firmware"])) { - $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : ''; - } else { - $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["loadimage"] : ''; - } - if (!empty($dev_config['addon'])) { - $xnode = $xml_work->addChild('addOnModules'); - $ti = 1; - $hw_addon = explode(';', $dev_config['addon']); - foreach ($hw_addon as $add_key) { - if (!empty($dev_config['addon_info'][$dev_config['addon']])) { - $add_val = $dev_config['addon_info'][$dev_config['addon']]; - $xnode_obj = $xnode->addChild('addOnModule'); - $xnode_obj->addAttribute('idx', $ti); - $xnode_obj->addChild('loadInformation', $add_val); - $ti++; - } + if (isset($dev_config["tftp_firmware"])) { + $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["tftp_firmware"] . $dev_config["loadimage"] : ''; + } else { + $xml_work->$key = (isset($dev_config["loadimage"])) ? $dev_config["loadimage"] : ''; + } + if (!empty($dev_config['addon'])) { + $xnode = $xml_work->addChild('addOnModules'); + $ti = 1; + $hw_addon = explode(';', $dev_config['addon']); + foreach ($hw_addon as $add_key) { + if (!empty($dev_config['addon_info'][$dev_config['addon']])) { + $add_val = $dev_config['addon_info'][$dev_config['addon']]; + $xnode_obj = $xnode->addChild('addOnModule'); + $xnode_obj->addAttribute('idx', $ti); + $xnode_obj->addChild('loadInformation', $add_val); + $ti++; } } } From acdf777bcc66987ec47e45fa85ea36146546ca1a Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 6 Jul 2021 12:24:34 +0200 Subject: [PATCH 077/181] Clean up xml in cnf files Indentation was not satisfactory. Improves readability and presentation of cnf files created Thanks to @dkgroot for proposing this improvement --- module.xml | 2 +- sccpManClasses/xmlinterface.class.php | 6 +++--- sccpManTraits/helperFunctions.php | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/module.xml b/module.xml index d600f86..3e5c4c2 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/xmlinterface.class.php b/sccpManClasses/xmlinterface.class.php index 2ce301d..7b55cf2 100644 --- a/sccpManClasses/xmlinterface.class.php +++ b/sccpManClasses/xmlinterface.class.php @@ -112,7 +112,7 @@ class xmlinterface $node->addAttribute('model', $var['vendor'] . ' ' . $var['model']); } } - $xml_work->asXml($xml_name); // Save XMLDefault1.cnf.xml + \FreePBX::Sccp_manager()->saveXml($xml_work, $xml_name); // Save XMLDefault1.cnf.xml } } @@ -347,7 +347,7 @@ class xmlinterface } } - $xml_work->asXml($xml_name); // Save + \FreePBX::Sccp_manager()->saveXml($xml_work, $xml_name); // Save return time(); } @@ -667,7 +667,7 @@ class xmlinterface } } - $xml_work->asXml($xml_name); // Save + \FreePBX::Sccp_manager()->saveXml($xml_work, $xml_name); // Save } else { die('Error Hardware template :' . $xml_template . ' not found'); } diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 3531a66..2229ff3 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -213,6 +213,15 @@ trait helperfunctions { return false; } + // temporary helper function to save xml with proper indentation + public function saveXml($xml, $filename) { + $dom = new \DOMDocument("1.0"); + $dom->preserveWhiteSpace = false; + $dom->formatOutput = true; + $dom->loadXML($xml->asXML()); + $dom->save($filename); + } + public function initVarfromXml() { if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group') as $item) { From 2e5028f4384fc5689ec37cbe431fadef36db581b Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 6 Jul 2021 15:22:12 +0200 Subject: [PATCH 078/181] Finalise Codecs tab for site defaults Partially revert changes to sccpvalues keys Remove obsolete code Improve help and set as open by default Move getMyConfig to AjaxHelper as only used there --- Sccp_manager.class.php | 83 ++++-------------------------------- sccpManTraits/ajaxHelper.php | 68 ++++++++++++++--------------- views/server.codec.php | 49 +++++++-------------- 3 files changed, 58 insertions(+), 142 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 104b263..06a18ba 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -725,51 +725,21 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $save_settings; } - public function getMyConfig($var = null, $id = "noid") { - switch ($var) { - case "voicecodecs": - $val = explode(",", explode("|", $this->sccpvalues['disallow|allow']['data'])[1]); - $final = array(); - $i = 1; - foreach ($val as $value) { - $final[$value] = $i; - $i++; - } - break; - case "softkeyset": - $final = array(); - $i = 0; - if ($id == "noid") { - foreach ($this->sccp_conf_init as $key => $value) { - if ($this->sccp_conf_init[$key]['type'] == 'softkeyset') { - $final[$i] = $value; - $i++; - } - } - } else { - if (!empty($this->sccp_conf_init[$id])) { - if ($this->sccp_conf_init[$id]['type'] == 'softkeyset') { - $final = $this->sccp_conf_init[$id]; - } - } - } - - break; - } - return $final; - } - public function getCodecs($type, $showDefaults = false) { $allSupported = array(); $Sccp_Codec = array('alaw', 'ulaw', 'g722', 'g723', 'g726', 'g729', 'gsm', 'h264', 'h263', 'h261'); + // First see if have any site defaults + $val = $this->sccpvalues['allow']['data']; + if (empty($val)) { + // No site defaults so return chan-sccp defaults + $val = $this->sccpvalues['allow']['systemdefault']; + } + $lcodecs = explode(',',$val); switch ($type) { case 'audio': - $lcodecs = $this->getMyConfig('voicecodecs'); $allCodecs = $this->FreePBX->Codecs->getAudio(); - dbug('FPBX audio', $allCodecs); break; case 'video': - $lcodecs = $this->getMyConfig('voicecodecs'); $allCodecs = $this->FreePBX->Codecs->getVideo(); break; case 'text': @@ -780,23 +750,20 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $lcodecs = $this->getConfig('imagecodecs'); $allCodecs = $this->FreePBX->Codecs->getImage(true); break; - default: - throw new Exception(_('Unknown Type')); - break; } foreach ($allCodecs as $c => $v) { if (in_array($c, $Sccp_Codec)) { $allSupported[$c] = $v; } } - if (empty($lcodecs) || (!is_array($lcodecs))) { + if (empty($lcodecs)) { if (empty($allSupported)) { $lcodecs = $allCodecs; } else { $lcodecs = $allSupported; } } else { - foreach ($lcodecs as $c => $v) { + foreach ($lcodecs as $c) { if (isset($allSupported[$c])) { $codecs[$c] = true; } @@ -812,7 +779,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } else { //Remove non digits $final = array(); - dbug('codecs', $codecs); foreach ($codecs as $codec => $order) { $order = trim($order); if (ctype_digit($order)) { @@ -824,37 +790,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } - /** - * Update or Set Codecs - * @param {string} $type Codec Type - * @param {array} $codecs=array() The codecs with order, if blank set defaults - */ - public function setCodecs($type, $codecs = array()) { - $default = empty($codecs) ? true : false; - switch ($type) { - case 'audio': - $codecs = $default ? $this->FreePBX->Codecs->getAudio(true) : $codecs; - $this->setConfig("voicecodecs", $codecs); - break; - case 'video': - $codecs = $default ? $this->FreePBX->Codecs->getVideo(true) : $codecs; - $this->setConfig("videocodecs", $codecs); - break; - case 'text': - $codecs = $default ? $this->FreePBX->Codecs->getText(true) : $codecs; - $this->setConfig("textcodecs", $codecs); - break; - case 'image': - $codecs = $default ? $this->FreePBX->Codecs->getImage(true) : $codecs; - $this->setConfig("imagecodecs", $codecs); - break; - default: - throw new Exception(_('Unknown Type')); - break; - } - return true; - } - /** * Retrieve Active Codecs * return fiends Lag pack diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index bb40b95..e690f78 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -387,7 +387,6 @@ trait ajaxHelper { } function handleSubmit($request, $validateonly = false) { - dbug('request is:', $request); $hdr_prefix = 'sccp_'; $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); @@ -495,30 +494,6 @@ trait ajaxHelper { } } switch ($key) { - case 'disallow': - if (is_array($value)) { - foreach ($value as $keycodeс => $valcodeс) { - $save_codec[$i] = $keycodeс; - $i++; - }; - $tmpv = implode(",", $save_codec); - } else { - $tmpv = $value; - } - - if (empty($save_settings['disallow|allow']['data'])) { - $save_settings['disallow|allow']['data'] = $tmpv . "|"; - } else { - $save_settings[] = array( - 'keyword' => 'disallow|allow', - 'data' => $tmpv . "|" .$save_settings['disallow|allow']['data'], - 'seq' => $this->sccpvalues['disallow|allow']['seq'], - 'type' => $this->sccpvalues['disallow|allow']['type'], - 'systemdefault' => $this->sccpvalues['disallow|allow']['systemdefault'] - ); - unset($save_settings['disallow|allow']['data']); - } - break; case 'voicecodecs': case 'vcodec': foreach ($value as $keycodeс => $valcodeс) { @@ -526,17 +501,14 @@ trait ajaxHelper { $i++; }; $tmpv = implode(",", $save_codec); - if (empty($save_settings['disallow|allow']['data'])) { - $save_settings['disallow|allow']['data'] = $tmpv; - } else { + if (!($this->sccpvalues['allow']['data'] == $tmpv)) { $save_settings[] = array( - 'keyword' => 'disallow|allow', - 'data' => $save_settings['disallow|allow']['data'] . $tmpv, - 'seq' => $this->sccpvalues['disallow|allow']['seq'], - 'type' => $this->sccpvalues['disallow|allow']['type'], - 'systemdefault' => $this->sccpvalues['disallow|allow']['systemdefault'] - ); - unset($save_settings['disallow|allow']['data']); + 'keyword' => 'allow', + 'data' => $tmpv, + 'seq' => $this->sccpvalues['allow']['seq'], + 'type' => $this->sccpvalues['allow']['type'], + 'systemdefault' => $this->sccpvalues['allow']['systemdefault'] + ); } break; @@ -571,6 +543,32 @@ trait ajaxHelper { $this->createDefaultSccpXml(); return $save_settings; } + + public function getMyConfig($var = null, $id = "noid") { + // TODO: this function has little purpose - need to integrate into AjaxHelper + switch ($var) { + case "softkeyset": + $final = array(); + $i = 0; + if ($id == "noid") { + foreach ($this->sccp_conf_init as $key => $value) { + if ($this->sccp_conf_init[$key]['type'] == 'softkeyset') { + $final[$i] = $value; + $i++; + } + } + } else { + if (!empty($this->sccp_conf_init[$id])) { + if ($this->sccp_conf_init[$id]['type'] == 'softkeyset') { + $final = $this->sccp_conf_init[$id]; + } + } + } + + break; + } + return $final; + } } ?> diff --git a/views/server.codec.php b/views/server.codec.php index d802973..489a53c 100644 --- a/views/server.codec.php +++ b/views/server.codec.php @@ -6,37 +6,16 @@ * and open the template in the editor. */ - $def_val = null; $dev_id = null; $audio_codecs = $this->getCodecs('audio', true); $video_codecs = $this->getCodecs('video', true); -$sccp_disallow_def = $this->sccpvalues['disallow|allow']['data']; -$sccp_disallow_def = explode("|",$sccp_disallow_def)[0]; -$sccp_disallow = $sccp_disallow_def; +$sccp_disallow_def = $this->sccpvalues['disallow']['data']; +$sys_disallow_def = $this->sccpvalues['disallow']['systemdefault']; -if (!empty($_REQUEST['id'])) { - $dev_id = $_REQUEST['id']; - $db_res = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $dev_id)); - if (!empty($db_res['allow'])) { - $i = 1; - foreach (explode(';', $db_res['allow']) as $c) { - $codec_list[$c] = $i; - $i ++; - } - foreach ($audio_codecs as $c => $v) { - if (!isset($codec_list[$c])) { - $codec_list[$c] = false; - } - } - } - if (!empty($db_res['disallow'])) { - $sccp_disallow = $db_res['disallow']; - } -} else { - $codec_list = $audio_codecs; +if (empty($sccp_disallow_def)) { + $sccp_disallow_def = $sys_disallow_def; } - ?> @@ -56,8 +35,8 @@ if (!empty($_REQUEST['id'])) {
    - - + +
    @@ -65,7 +44,7 @@ if (!empty($_REQUEST['id'])) {
    - +
    @@ -90,13 +69,17 @@ if (!empty($_REQUEST['id'])) {
    - + Order can be changed by dragging and dropping to indicate priority. This priority applies for all extensions +
    Higher priority enabled codecs are at the top +
    Precedence for ulaw and alaw, if used, should be set according to your region +
    If your region uses alaw, it is important that alaw has the highest priority"),"Helpful information",true) ?>
    '; - foreach ($codec_list as $codec => $codec_state) { + foreach ($audio_codecs as $codec => $codec_state) { $codec_trans = _($codec); $codec_checked = $codec_state ? 'checked' : ''; echo '
  • ' @@ -141,7 +124,7 @@ if (!empty($_REQUEST['id'])) {
  • - +
    ' . '' . '  
    Date: Tue, 6 Jul 2021 17:18:17 +0200 Subject: [PATCH 080/181] Simplify getCodecs by using array functions --- Sccp_manager.class.php | 61 +++++++++++------------------------------- views/server.codec.php | 4 +-- 2 files changed, 18 insertions(+), 47 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 9095743..c8d6ade 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -727,67 +727,38 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { public function getCodecs($type, $showDefaults = false) { $allSupported = array(); - $Sccp_Codec = array('alaw', 'ulaw', 'g722', 'g723', 'g726', 'g729', 'gsm', 'h264', 'h263', 'h261'); + $sccpCodec = array_fill_keys(array('alaw', 'ulaw', 'g722', 'g723', 'g726', 'g729', 'gsm', 'h264', 'h263', 'h261'),0); // First see if have any site defaults $val = $this->sccpvalues['allow']['data']; if (empty($val)) { // No site defaults so return chan-sccp defaults $val = $this->sccpvalues['allow']['systemdefault']; } - $lcodecs = explode(',',$val); + $siteCodecs = array_fill_keys(explode(',',$val), 1); switch ($type) { case 'audio': - $allCodecs = $this->FreePBX->Codecs->getAudio(); + $fpbxCodecs = $this->FreePBX->Codecs->getAudio(); break; case 'video': - $allCodecs = $this->FreePBX->Codecs->getVideo(); + $fpbxCodecs = $this->FreePBX->Codecs->getVideo(); break; case 'text': - $lcodecs = $this->getConfig('textcodecs'); - $allCodecs = $this->FreePBX->Codecs->getText(true); + $siteCodecs = $this->getConfig('textcodecs'); + $fpbxCodecs = $this->FreePBX->Codecs->getText(true); break; case 'image': - $lcodecs = $this->getConfig('imagecodecs'); - $allCodecs = $this->FreePBX->Codecs->getImage(true); + $siteCodecs = $this->getConfig('imagecodecs'); + $fpbxCodecs = $this->FreePBX->Codecs->getImage(true); break; } - foreach ($allCodecs as $c => $v) { - if (in_array($c, $Sccp_Codec)) { - $allSupported[$c] = $v; - } - } - if (empty($lcodecs)) { - if (empty($allSupported)) { - $lcodecs = $allCodecs; - } else { - $lcodecs = $allSupported; - } - } else { - foreach ($lcodecs as $c) { - if (isset($allSupported[$c])) { - $codecs[$c] = true; - } - } - } - if ($showDefaults) { - foreach ($allSupported as $c => $v) { - if (!isset($codecs[$c])) { - $codecs[$c] = false; - } - } - return $codecs; - } else { - //Remove non digits - $final = array(); - foreach ($codecs as $codec => $order) { - $order = trim($order); - if (ctype_digit($order)) { - $final[$codec] = $order; - } - } - asort($final); - return $final; - } + // These have value set to 1 + $enabledCodecs = array_intersect_key($siteCodecs, $sccpCodec, $fpbxCodecs); + // These have value set to 0 + $allSupported = array_intersect_key($sccpCodec,$fpbxCodecs); + $disabledCodecs = array_diff_key($allSupported,$enabledCodecs); + $codecs = array_merge($enabledCodecs, $disabledCodecs); + + return $codecs; } /** diff --git a/views/server.codec.php b/views/server.codec.php index b2d7bd7..1fc4524 100644 --- a/views/server.codec.php +++ b/views/server.codec.php @@ -8,8 +8,8 @@ $def_val = null; $dev_id = null; -$audio_codecs = $this->getCodecs('audio', true); -$video_codecs = $this->getCodecs('video', true); +$audio_codecs = $this->getCodecs('audio'); +$video_codecs = $this->getCodecs('video'); $sccp_disallow_def = $this->sccpvalues['disallow']['data']; $sys_disallow_def = $this->sccpvalues['disallow']['systemdefault']; From 11da8356a5cb85a7d96fd2194ecbae4b647b1453 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 6 Jul 2021 17:20:42 +0200 Subject: [PATCH 081/181] Update Sccp_manager.class.php --- Sccp_manager.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index c8d6ade..6795d94 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -751,6 +751,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $fpbxCodecs = $this->FreePBX->Codecs->getImage(true); break; } + // Below could be squashed to 1 line, but would be unreadable. // These have value set to 1 $enabledCodecs = array_intersect_key($siteCodecs, $sccpCodec, $fpbxCodecs); // These have value set to 0 From 6429b6add94ab584a8dd18d27a4b906d5a7990b0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 8 Jul 2021 08:56:42 +0200 Subject: [PATCH 082/181] Finalise Codec Management Add video codec treatment Correct missing defaults Simplify defaults in Sccp.class --- conf/sccpgeneral.xml.v433 | 10 +- install.php | 2 +- sccpManClasses/Sccp.class.php.v433 | 262 ++++++++++------------------- sccpManTraits/ajaxHelper.php | 13 +- views/server.codec.php | 7 +- 5 files changed, 111 insertions(+), 183 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 452e39c..1f61b0f 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1051,12 +1051,20 @@ and open the template in the editor. Base Version before all crash :-)
    pickup_modeanswer - + off Directed Pickup Mode (Answer): If a call is sent with the "directed pickup" flag, the phone will answer when set to "Yes". + + directed_pickup + + off + + + Enable/disable Pickup button to do directed pickup from a specific extension. + transfer_on_hangup diff --git a/install.php b/install.php index 7aa226d..473b529 100644 --- a/install.php +++ b/install.php @@ -144,7 +144,7 @@ function Get_DB_config($sccp_compatible) 'softkeyset' => array('def_modify' => "softkeyset") ), 'sccpline' => array( - 'directed_pickup' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'directed_pickup' => array('create' => "enum('yes','no') NOT NULL default 'no'", 'modify' => "enum('yes','no')"), 'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"), 'pickup_modeanswer' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"), 'namedcallgroup' => array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 58d2c1d..b156a90 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -11,14 +11,30 @@ * getInfo * addDevice * delDevice - * getDevice - * getDefaultDeviceSettings - * getDeviceDisplay + * getDevice - Called by core to read sccpline returning fields in data_fld + * getDefaultDeviceSettings - + * getDeviceDisplay - Called by functionsInc to load sccp tab using values from Device and getDevice. * */ // namespace FreePBX\modules\Core\Drivers; class Sccp extends \FreePBX\modules\Core\Driver { + // This is a map between sccpline fields and FreePBX fields. + // TODO: List needs to be extended. Missing fields, not necessarily all required               +/* adhocNumber +               meetme +                meetmenum +               meetmeopts +                 regexten +          directed_pickup +  directed_pickup_context +        pickup_modeanswer +                 amaflags + setvar +            phonecodepage +                  trnsfvm +                    vmnum +*/ private $data_fld = array("pin"=>'pin', "label" => 'label', "accountcode" => 'account', "context" =>'context',"incominglimit"=>'incominglimit', "callgroup"=>'callgroup',"pickupgroup"=>'pickupgroup', @@ -31,18 +47,19 @@ class Sccp extends \FreePBX\modules\Core\Driver { "secondary_dialtone_digits" => 'secondary_dialtone_digits', "secondary_dialtone_tone" => 'secondary_dialtone_tone', 'namedcallgroup'=>'namedcallgroup', 'namedpickupgroup' => 'namedpickupgroup' ); + // These are gui defaults used by freePBX to for the elements in the SCCP tab in add/edit phone. private $guiDefaults =array( 'gui_checkset' => array( "elemname" => "", - "prompttext" => "", + "prompttext" => "", //ok "helptext" => "", "currentvalue" => "", "valarray" => array(), "jsonclick" => '', - "jsvalidation" => "", - "failvalidationmsg" => "", + "jsvalidation" => "", //ok + "failvalidationmsg" => "", //ok "canbeempty" => true, "maxchars" => 0, - "disable" => false, + "disable" => false, //ok "inputgroup" => false, "class" => "", "cblabel" => 'Enable', @@ -50,20 +67,25 @@ class Sccp extends \FreePBX\modules\Core\Driver { "check_enables" => 'true', "cbdisable" => false, "cbclass" => '') - ); + ); + private $line_defaults = array(); public function __construct($parent_class = null) { $this->freepbx = $parent_class; $this->database = $parent_class->Database(); - - $stmt = $this->database->prepare('DESCRIBE sccpline'); + // Get system defaults [systemdefault] and sitedefaults [data] from sccpsettings. + $stmt = $this->database->prepare("SELECT * FROM sccpsettings WHERE systemdefault !=''"); $stmt->execute(); $raw_settings = $stmt->fetchAll(\PDO::FETCH_ASSOC); - foreach ($raw_settings as $row) { - $this->line_defaults[$row["Field"]] = $row["Default"]; + foreach ($raw_settings as $key => $valueArray) { + $sccpDefaults[$valueArray['keyword']] = $valueArray['systemdefault']; + $siteDefaults[$valueArray['keyword']] = $valueArray['data']; } + // This will produce an array where site defaults take precedence over system defaults + $this->line_defaults = array_intersect_key($siteDefaults,$sccpDefaults); + unset($raw_settings, $siteDefaults, $sccpDefaults); } public function getInfo() { @@ -79,6 +101,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { } public function addDevice($id, $settings) { + // This is actually save line and is used by add and edit. global $currentcomponent; $add_fld = array ("name"=>'label',"outboundcid"=>'cid_num',"langcode"=>'language',"extdisplay"=>'description','devinfo_mailbox'=>'mailbox'); $settings['cid_num']['value'] = ''; @@ -95,8 +118,8 @@ class Sccp extends \FreePBX\modules\Core\Driver { } $allow_codec = array(); foreach($settings as $key => $val) { - if (strpos($key,'codec_') !== false ) { - $allow_codec[] =substr($key,6); + if (strncmp($key,'codec_',6) === 0 ) { + $allow_codec[] = str_replace('codec_','',$key); } } $settings['allow']['value'] = implode(",", $allow_codec); @@ -121,18 +144,17 @@ class Sccp extends \FreePBX\modules\Core\Driver { $sqlCol = 'name'; $sqlVal = "'{$id}'"; foreach($this->data_fld as $key => $val) { - if (array_key_exists($key, $this->line_defaults)) { - if (isset($settings[$val]['value'])){ + if (isset($settings[$val]['value'])){ + $sqlCol .= ", {$key}"; + $sqlVal .= ", '{$settings[$val]['value']}'"; + } else { + if (array_key_exists($key, $this->line_defaults)) { $sqlCol .= ", {$key}"; - $sqlVal .= ", '{$settings[$val]['value']}'"; - } else { - $sqlCol .= ", {$key}"; - $sqlVal .= ", DEFAULT( {$key} )"; + $sqlVal .= ", '{$this->line_defaults[$key]}'"; } } } - $sql = "REPLACE INTO sccpline ( {$sqlCol} ) VALUES ( {$sqlVal} );"; - + $sql = "REPLACE INTO sccpline ( {$sqlCol} ) VALUES ( {$sqlVal} )"; $sth = $this->database->prepare($sql); $sth->execute(); /* @@ -157,124 +179,35 @@ class Sccp extends \FreePBX\modules\Core\Driver { return true; } - public function getDevice($id) { - $sccp_line = array(); $sql = "SELECT name as id, name as name "; foreach($this->data_fld as $key => $val) { - $sql .= ',`'. $key .'` as '.$val; + $sql .= ", {$key} as {$val}"; } - $sql .= " FROM sccpline WHERE name = ?"; + $sql .= " FROM sccpline WHERE name = '{$id}'"; $sth = $this->database->prepare($sql); - $result = array(); $tech = array(); - try { + try { $sth->execute(array($id)); - $result = $sth->fetch(\PDO::FETCH_ASSOC); - $tech = $result; - $tech['dial']='SCCP/'.$id; + $tech = $sth->fetch(\PDO::FETCH_ASSOC); + $tech['dial']="SCCP/{$id}"; } catch(\Exception $e) {} - return $tech; } public function getDefaultDeviceSettings($id, $displayname, &$flag) { - - $dial = 'SCCP'; - $settings = array( - "mailbox" => array( - "value" => $this->line_defaults['mailbox'], - "flag" => $flag++ - ), - "incominglimit" => array( - "value" => $this->line_defaults['incominglimit'], - "flag" => $flag++ - ), - "context" => array( - "value" => $this->line_defaults['context'], - "flag" => $flag++ - ), - "directed_pickup_context" => array( - "value" => $this->line_defaults['directed_pickup_context'], - "flag" => $flag++ - ), - "callgroup" => array( - "value" => $this->line_defaults['callgroup'], - "flag" => $flag++ - ), - "pickupgroup" => array( - "value" => $this->line_defaults['pickupgroup'], - "flag" => $flag++ - ), - "namedcallgroup" => array( - "value" => $this->line_defaults['namedcallgroup'], - "flag" => $flag++ - ), - "namedpickupgroup" => array( - "value" => $this->line_defaults['namedpickupgroup'], - "flag" => $flag++ - ), - "adhocNumber" => array( - "value" => $this->line_defaults['adhocNumber'], - "flag" => $flag++ - ), - "secondary_dialtone_digits" => array( - "value" => $this->line_defaults['secondary_dialtone_digits'], - "flag" => $flag++ - ), - "secondary_dialtone_tone" => array( - "value" => $this->line_defaults['secondary_dialtone_tone'], - "flag" => $flag++ - ), - "directed_pickup" => array( - "value" => $this->line_defaults['directed_pickup'], - "flag" => $flag++ - ), - "pickup_modeanswer" => array( - "value" => $this->line_defaults['pickup_modeanswer'], - "flag" => $flag++ - ), - "transfer" => array( - "value" => $this->line_defaults['transfer'], - "flag" => $flag++ - ), - "echocancel" => array( - "value" => $this->line_defaults['echocancel'], - "flag" => $flag++ - ), - "dnd" => array( - "value" => $this->line_defaults['dnd'], - "flag" => $flag++ - ), - "silencesuppression" => array( - "value" => $this->line_defaults['silencesuppression'], - "flag" => $flag++ - ), - "musicclass" => array( - "value" => $this->line_defaults['musicclass'], - "flag" => $flag++ - ), - "pin" => array( - "value" => $this->line_defaults['pin'], - "flag" => $flag++ - ), - "allow" => array( - "value" => $this->line_defaults['allow'], - "flag" => $flag++ - ), - "disallow" => array( - "value" => $this->line_defaults['disallow'], - "flag" => $flag++ - ), - ); - return array( - "dial" => $dial, - "settings" => $settings - ); + // FreePBX required method + $settingsFields = array('mailbox', 'incominglimit', 'context', 'directed_pickup_context', 'callgroup', 'pickupgroup', 'namedcallgroup', + 'namedpickupgroup', 'adhocNumber', 'secondary_dialtone_digits', 'secondary_dialtone_tone', 'directed_pickup', 'pickup_modeanswer', + 'transfer', 'echocancel', 'dnd', 'silencesuppression', 'musicclass', 'pin', 'allow', 'disallow'); + foreach ($settingsFields as $key) { + $settings[$key] = array('value' => $this->line_defaults['$key'], 'flag' => $flag++); + } + return array('dial' => 'SCCP', 'settings' => $settings); } public function getDeviceDisplay($display, $deviceInfo, $currentcomponent, $primarySection) { - + dbug('deviceInfo', $deviceInfo); $section = _("SCCP Extension Details"); $section_с = _("SCCP Codec Details"); $gn_category = "sccp"; @@ -283,46 +216,29 @@ class Sccp extends \FreePBX\modules\Core\Driver { //add sccp category $currentcomponent->addTabTranslation('sccp',_('SCCP')); - //Fill Codecs Informations - - $Sccp_Codec = array('alaw', 'ulaw', 'g722', 'g723', 'g726', 'g729', 'gsm', 'h264', 'h263', 'h261'); - $allCodecs = $this->freepbx->Codecs->getAudio(true); - $allVCodecs = $this->freepbx->Codecs->getVideo(); - $ACodec_cur = array('all'); - $VCodec_cur = array('all'); - - foreach ($allCodecs as $c => $v) { - if (array_search($c,$Sccp_Codec) !=null) { - $currentcomponent->addoptlistitem('devinfo_sccp_codec', "devinfo_codec_"."$c", "$c"); - if (isset($deviceInfo['allow'])) { - if (strpos($deviceInfo['allow'],$c)!== false) { - $ACodec_cur[] ="devinfo_codec_"."$c"; - } - } - } + $systemCodecs = array_fill_keys(explode(",",$this->line_defaults['allow']),true); + // Fill Audio codecs information + $siteAudioCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getAudio()); + foreach ($siteAudioCodecs as $key => $value) { + $audioCodecButtons[] = array('value' => "devinfo_codec_{$key}", 'text' => $key); + $activeAudioCodecs[] ="devinfo_codec_{$key}"; } - - foreach ($allVCodecs as $c => $v) { - if (array_search($c,$Sccp_Codec) !=null) { - $currentcomponent->addoptlistitem('devinfo_sccp_vcodec', "devinfo_codec_"."$c", "$c"); - if (isset($deviceInfo['allow'])) { - if (strpos($deviceInfo['allow'],$c)!== false) { - $VCodec_cur[] ="devinfo_codec_"."$c"; - } - } - } + // Fill Video codecs information + $siteVideoCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getVideo()); + foreach ($siteVideoCodecs as $key => $value) { + $videoCodecButtons[] = array('value' => "devinfo_codec_{$key}", 'text' => $key); + $activeVideoCodecs[] ="devinfo_codec_{$key}"; } - $el = array( "elemname" => "devinfo_sccp_codec", "prompttext" => _('Line Audio Codec:'), "helptext" => _("Line Audio Codec"), - "currentvalue" => $ACodec_cur, - "valarray" => $currentcomponent->getoptlist('devinfo_sccp_codec'), + "currentvalue" => $activeAudioCodecs, + "valarray" => $audioCodecButtons, "class" => $section_с, "disable" => 0 ); - + // Override defaults with $el $currentcomponent->addguielem($section_с, new \gui_checkset(array_merge($this->guiDefaults['gui_checkset'],$el)), $gn_category); unset($el); @@ -330,8 +246,8 @@ class Sccp extends \FreePBX\modules\Core\Driver { "elemname" => "devinfo_sccp_vcodec", "prompttext" => _('Line Video Codec:'), "helptext" => _("Line Video Codec"), - "currentvalue" => $VCodec_cur, - "valarray" => $currentcomponent->getoptlist('devinfo_sccp_vcodec'), + "currentvalue" => $activeVideoCodecs, + "valarray" => $videoCodecButtons, "class" => $section_с, "disable" => 0 ); @@ -341,7 +257,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { $tt = _("Name or id of linked maibox"); $tmparr['mailbox'] = array('prompttext' => _('Mailbox'), 'value' => $this->line_defaults['mailbox'], 'tt' => $tt, 'level' => 1, 'section' => $section,'category' => $gn_category); - $tt = _("The SCCP channel number for this port. If you plaining to use this line as 'Shared' or use on several devices - leave this field blank or set limit to 10 calls."); + $tt = _("The SCCP channel number for this port. If you are planning to use this line as 'Shared' or use on several devices - leave this field blank or set limit to 10 calls."); $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), $this->line_defaults['incominglimit'], 'tt' => $tt, 'level' => 1, 'section' => $section,'category' => $gn_category); $tt = _("Asterisk context this device will send calls to. Only change this is you know what you are doing."); @@ -433,14 +349,14 @@ class Sccp extends \FreePBX\modules\Core\Driver { $tmparr['secondary_dialtone_tone'] = array('prompttext' => _('Secondary dialtone'), 'value' => $this->line_defaults['secondary_dialtone_tone'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'select', 'section' => $section,'category' => $gn_category); unset($select); - $select[] = array('value' => 'on', 'text' => 'Yes'); - $select[] = array('value' => 'off', 'text' => 'No'); + $select[] = array('value' => 'yes', 'text' => 'Yes'); + $select[] = array('value' => 'no', 'text' => 'No'); $tt = _("Enable/Disable the `directed` pickup softkey"); $tmparr['directed_pickup'] = array('prompttext' => _('Directed pickup'), 'value' => $this->line_defaults['directed_pickup'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); unset($select); - $select[] = array('value' => 'on', 'text' => 'Yes'); - $select[] = array('value' => 'off', 'text' => 'No'); + $select[] = array('value' => 'yes', 'text' => 'Yes'); + $select[] = array('value' => 'no', 'text' => 'No'); $tt = _("Should the picked/gpicked-up call be answered automatically"); $tmparr['pickup_modeanswer'] = array('prompttext' => _('Pickup Modeanswer'), 'value' => $this->line_defaults['pickup_modeanswer'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); @@ -452,8 +368,8 @@ class Sccp extends \FreePBX\modules\Core\Driver { $tmparr['transfer'] = array('prompttext' => _('Call Transfer'), 'value' => $this->line_defaults['transfer'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); unset($select); - $select[] = array('value' => 'on', 'text' => 'Yes'); - $select[] = array('value' => 'off', 'text' => 'No'); + $select[] = array('value' => 'yes', 'text' => 'Yes'); + $select[] = array('value' => 'no', 'text' => 'No'); $tt = _("Echo cancel"); $tmparr['echocancel'] = array('prompttext' => _('Echo cancel'), 'value' => $this->line_defaults['echocancel'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); @@ -463,23 +379,23 @@ class Sccp extends \FreePBX\modules\Core\Driver { $select[] = array('value' => 'silent', 'text' => 'Silent'); $select[] = array('value' => 'user', 'text' => 'Cycle'); $tt = _("DND: Means how will dnd react when it is set on the device level dnd can have three states: off / busy(reject) / silent / Cycle").'
    '. - _("Cycle - dnd that cycles through all three states off -> reject -> silent -> off (this is the normal behaviour)").'
    '. - _("Reject - Usesr can only switch off and on (in reject/busy mode)").'
    '. - _("Silent - Usesr can only switch off and on (in silent mode)"); + _("Cycle - DND that cycles through all three states off -> reject -> silent -> off (this is the normal behaviour)").'
    '. + _("Reject - Users can only switch off and on (in reject/busy mode)").'
    '. + _("Silent - Users can only switch off and on (in silent mode)"); $tmparr['dnd'] = array('prompttext' => _('DND'), 'value' => $this->line_defaults['dnd'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); unset($select); - $select[] = array('value' => 'on', 'text' => 'Yes'); - $select[] = array('value' => 'off', 'text' => 'No'); + $select[] = array('value' => 'yes', 'text' => 'Yes'); + $select[] = array('value' => 'no', 'text' => 'No'); $tt = _("Silence Suppression. Asterisk Not supported"); $tmparr['silencesuppression'] = array('prompttext' => _('Silence Suppression'), 'value' => $this->line_defaults['silencesuppression'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); unset($select); - $select[] = array('value' => 'default', 'text' => _('default')); + if (function_exists('music_list')){ $moh_list = music_list(); } else { - $moh_list = array('default'); + $select[] = array('value' => 'default', 'text' => _('default')); } foreach ($moh_list as $value) { $select[] = array('value' => $value, 'text' => _($value)); @@ -506,7 +422,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { $devopts = $tmparr; return $devopts; - } + } public function reload_line($id) { global $astman; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 2a04fd5..6003c7a 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -397,10 +397,10 @@ trait ajaxHelper { $errors = array(); $i = 0; $action = isset($request['sccp_createlangdir']) ? $request['sccp_createlangdir'] : ''; - // if uncheck all codecs, voicecodecs key is missing so nothing changes in db. + // if uncheck all codecs, audiocodecs key is missing so nothing changes in db. // Unsetting all codecs will now return to chan-sccp defaults. - if (!isset($request['voicecodecs'])) { - $request['voicecodecs'] = array_fill_keys(explode(',',$this->sccpvalues['allow']['systemdefault']),true); + if (!isset($request['audiocodecs'])) { + $request['audiocodecs'] = array_fill_keys(explode(',',$this->sccpvalues['allow']['systemdefault']),true); } if ($action == 'yes') { $this->initializeTFtpLanguagePath(); @@ -499,8 +499,7 @@ trait ajaxHelper { } } switch ($key) { - case 'voicecodecs': - case 'vcodec': + case 'audiocodecs': foreach ($value as $keycodeс => $valcodeс) { $save_codec[$i] = $keycodeс; $i++; @@ -516,6 +515,10 @@ trait ajaxHelper { ); } break; + case 'videocodecs': + // currently not used. To reach this case, name in video codec section of + // server.codec needs to be changed from audiocodecs to videocodecs. + break; case 'ntp_timezone': $tz_id = $value; diff --git a/views/server.codec.php b/views/server.codec.php index 1fc4524..2e2a8a9 100644 --- a/views/server.codec.php +++ b/views/server.codec.php @@ -74,7 +74,7 @@ if (empty($sccp_disallow_def)) {
    Higher priority enabled codecs are at the top
    Precedence for ulaw and alaw, if used, should be set according to your region
    If your region uses alaw, it is important that alaw has the highest priority -
    To return to chan-sccp defaults, uncheck all codecs."),"Helpful information",true) ?> +
    To return to chan-sccp defaults, uncheck ALL codecs (both Audio and Video)."),"Helpful information",true) ?> ' . ''; + // Although classed as video codecs, all stored under allow so name is audiocodecs. foreach ($video_codecs as $codec => $codec_state) { $codec_trans = _($codec); $codec_checked = $codec_state ? 'checked' : ''; @@ -138,7 +139,7 @@ if (empty($sccp_disallow_def)) { . 'move ' . ' Date: Thu, 8 Jul 2021 17:22:50 +0200 Subject: [PATCH 083/181] Refine Sccp.class Move help and other defs to sccpgeneral so that have one interface across system Correct defaults in line with chan-sccp Standardise db object, and move sql to dbinterface to remove second dependancy --- conf/sccpgeneral.xml.v433 | 144 +++++++++++ install.php | 2 +- module.xml | 2 +- sccpManClasses/Sccp.class.php.v433 | 368 +++++++++++++-------------- sccpManClasses/dbinterface.class.php | 91 ++++--- 5 files changed, 371 insertions(+), 236 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 1f61b0f..f08077f 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -15,6 +15,7 @@ and open the template in the editor. Base Version before all crash :-) * SLT - TFTP Lang * SLM - Music on hold * SLK - System KeySet + * SLG - call groups * * Input element Select SLS - System Language * Input element Select SDM - Model List * SDE - Extension List tftp_rewrite @@ -1923,4 +1924,147 @@ and open the template in the editor. Base Version before all crash :-)
    + + + + + + mailbox + + sccp-custom + + Name or id of linked maibox + + + + + incominglimit + + sccp-custom + + The SCCP channel number for this port. If you are planning to use this line as 'Shared' or use on several devices - leave this field blank or set limit to 10 calls. + + + + + context + + sccp-custom + + Context: This is the context in which your phones will operate. It should match the context you are using for the rest of your phones (if you have any). The FreePBX default is 'from-internal' + + + + + directed_pickup_context + + + sccp-custom + + Context where direct pickup search for extensions. if not set current context will be use. + + + + namedcallgroup + + Sets the named caller groups this line is a member of + + + + namedpickupgroup + + Named PickupGroup - the list is of pickup groups used on the system + + + + + secondary_dialtone_digits + + sccp-custom + + Digits to indicate an external line to user (secondary dialtone) Sample 9 or 8 (max 9 digits) + + + secondary_dialtone_tone + + + Outside dialtone frequency (default 0x22) + + + directed_pickup + + + + + Enable/disable Pickup button to do directed pickup from a specific extension. + + + pickup_modeanswer + + off + + + Directed Pickup Mode (Answer): If a call is sent with the "directed pickup" flag, the phone will answer when set to "Yes". + + + transfer + + + + + Allow the use of the transfer feature + + + echocancel + + off + + + Echo Cancel: Echo Cancellation (On or Off). + + + dnd + + + + + + + DND: Means how will dnd react when it is set on the device level dnd can have three states: off / busy(reject) / silent / Cycle + Cycle - DND that cycles through all three states off -> reject -> silent -> off (this is the normal behaviour) + Reject - Users can only switch off and on (in reject/busy mode) + Silent - Users can only switch off and on (in silent mode) + + + silencesuppression + + off + + + Silence Suppression: Silence Suppression on the phone. + + + + musicclass + NONE + + form-control + Music Class: Available MOH Classes. These are the MOH classes listed in your current server. + + + + + pin + + + Help! + + + diff --git a/install.php b/install.php index 473b529..0f22f48 100644 --- a/install.php +++ b/install.php @@ -162,7 +162,7 @@ function Get_DB_config($sccp_compatible) 'video_cos' => array('drop' => "yes"), 'videomode' => array('create' => "enum('user','auto','off') NOT NULL default 'auto'", 'modify' => "enum('user','auto','off')"), 'incominglimit' => array('create' => "INT(11) DEFAULT '6'", 'modify' => 'INT(11)', 'def_modify' => "6"), - 'transfer' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'transfer' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"), 'vmnum' => array('def_modify' => "*97"), 'musicclass' => array('def_modify' => "default"), 'disallow' => array('create' => "VARCHAR(255) NULL DEFAULT NULL"), diff --git a/module.xml b/module.xml index 3e5c4c2..d600f86 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.0 + 14.3.0.1 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index b156a90..4117071 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -42,7 +42,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { "language" => 'language', "description" => 'callerid', "cid_num" => 'cid_num', "cid_name" => 'label', "mailbox" => 'mailbox', "musicclass" => 'musicclass', "allow" => 'allow',"disallow" => 'disallow', - "videomode" => 'videomode', + "videomode" => 'videomode', 'pickup_modeanswer' => 'pickup_modeanswer', "dnd" => 'dnd', "silencesuppression" => 'silencesuppression', "secondary_dialtone_digits" => 'secondary_dialtone_digits', "secondary_dialtone_tone" => 'secondary_dialtone_tone', 'namedcallgroup'=>'namedcallgroup', 'namedpickupgroup' => 'namedpickupgroup' @@ -116,6 +116,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { } } } + dbug('addD', $settings); $allow_codec = array(); foreach($settings as $key => $val) { if (strncmp($key,'codec_',6) === 0 ) { @@ -155,6 +156,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { } } $sql = "REPLACE INTO sccpline ( {$sqlCol} ) VALUES ( {$sqlVal} )"; +dbug('sql', $sql); $sth = $this->database->prepare($sql); $sth->execute(); /* @@ -173,6 +175,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { } public function delDevice($id) { + //Required by FreePBX $sql = "DELETE FROM sccpline WHERE name = ?"; $sth = $this->database->prepare($sql); $sth->execute(array($id)); @@ -180,9 +183,10 @@ class Sccp extends \FreePBX\modules\Core\Driver { } public function getDevice($id) { - $sql = "SELECT name as id, name as name "; + // FreePBX required method + $sql = "SELECT name AS id, name AS name "; foreach($this->data_fld as $key => $val) { - $sql .= ", {$key} as {$val}"; + $sql .= ", {$key} AS {$val}"; } $sql .= " FROM sccpline WHERE name = '{$id}'"; $sth = $this->database->prepare($sql); @@ -207,28 +211,59 @@ class Sccp extends \FreePBX\modules\Core\Driver { } public function getDeviceDisplay($display, $deviceInfo, $currentcomponent, $primarySection) { - dbug('deviceInfo', $deviceInfo); + dbug('devInfo', $deviceInfo); + // load xml data to get help from same source as rest of module + $xml_vars = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v433'; + $this->xml_data = simplexml_load_file($xml_vars); + // load metainfo from chan-sccp - help information if not in xml. Only load first time as static data. + if (empty($this->sccpHelpInfo)) { + $sysConfiguration = \FreePbx::sccp_manager()->aminterface->getSCCPConfigMetaData('general'); + foreach ($sysConfiguration['Options'] as $key => $valueArray) { + foreach ($valueArray['Description'] as $descKey => $descValue) { + $this->sccpHelpInfo[$valueArray['Name']] .= $descValue . '
    '; + } + } + unset($sysConfiguration); + } + $section = _("SCCP Extension Details"); $section_с = _("SCCP Codec Details"); $gn_category = "sccp"; global $currentcomponent, $display; - $named_group = $this->getNamedGroup(); //add sccp category $currentcomponent->addTabTranslation('sccp',_('SCCP')); - - $systemCodecs = array_fill_keys(explode(",",$this->line_defaults['allow']),true); + // TODO: If we have upgraded the system codecs, need to allow new options here. + if (empty($deviceInfo['allow'])) { + // Need a codec and have none, so use system defaults + $systemCodecs = array_fill_keys(explode(",",$this->line_defaults['allow']),true); + $siteAudioCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getAudio()); + $siteVideoCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getVideo()); + } else { + // TODO: Need to show disabled options + // Have codecs for this device. + $systemCodecs = array_fill_keys(explode(",",$deviceInfo['allow']),true); //pb is here + $siteAudioCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getAudio()); + $siteVideoCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getVideo()); + } // Fill Audio codecs information - $siteAudioCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getAudio()); foreach ($siteAudioCodecs as $key => $value) { $audioCodecButtons[] = array('value' => "devinfo_codec_{$key}", 'text' => $key); $activeAudioCodecs[] ="devinfo_codec_{$key}"; } // Fill Video codecs information - $siteVideoCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getVideo()); foreach ($siteVideoCodecs as $key => $value) { $videoCodecButtons[] = array('value' => "devinfo_codec_{$key}", 'text' => $key); $activeVideoCodecs[] ="devinfo_codec_{$key}"; } + + $tmparr['disallow'] = array('prompttext' => _('Disallowed Codecs'), + 'value' => $this->line_defaults[(string)$child->name], + 'tt' => 'Codecs that are disallowed. Default and recommended value is all', + 'level' => 1, + 'section' => $section_с, + 'category' => $gn_category + ); + $el = array( "elemname" => "devinfo_sccp_codec", "prompttext" => _('Line Audio Codec:'), @@ -253,175 +288,145 @@ class Sccp extends \FreePBX\modules\Core\Driver { ); $currentcomponent->addguielem($section_с, new \gui_checkset(array_merge($this->guiDefaults['gui_checkset'],$el)), $gn_category); - $tmparr = array(); - $tt = _("Name or id of linked maibox"); - $tmparr['mailbox'] = array('prompttext' => _('Mailbox'), 'value' => $this->line_defaults['mailbox'], 'tt' => $tt, 'level' => 1, 'section' => $section,'category' => $gn_category); + $pageGroup = $this->xml_data->xpath('//page_group[@name="sccp_extension_config"]'); + $elements = $pageGroup[0]->children(); - $tt = _("The SCCP channel number for this port. If you are planning to use this line as 'Shared' or use on several devices - leave this field blank or set limit to 10 calls."); - $tmparr['incominglimit'] = array('prompttext' => _('Incoming Call Limit'), $this->line_defaults['incominglimit'], 'tt' => $tt, 'level' => 1, 'section' => $section,'category' => $gn_category); - - $tt = _("Asterisk context this device will send calls to. Only change this is you know what you are doing."); - $tmparr['context'] = array('prompttext' => _('Line context'), 'value' => $this->line_defaults['context'], 'tt' => $tt, 'level' => 1, 'section' => $section,'category' => $gn_category); - - $tt = _("Asterisk context this device will can pickup calls. Only change this is you know what you are doing."); - $tmparr['directed_pickup_context'] = array('prompttext' => _('Directed PickUp Сontext '), 'value' => $this->line_defaults['directed_pickup_context'], 'tt' => $tt, 'level' => 1, 'section' => $section,'category' => $gn_category); - - $tt = _("Sets the named caller groups this line is a member of (ast111) : "); - if (!empty($named_group['namedcallgroup'])) { - foreach ($named_group['namedcallgroup'] as $val) { - $tt .= $val. ', '; + foreach ($elements as $child) { + if (empty($child->help)) { + $child->help = 'Help is not available.'; + $child->meta_help = '1'; } - $tt .= '... '; - } - $tmparr['namedcallgroup'] = array('prompttext' => _('Named Call Group'),'value' => $this->line_defaults['namedcallgroup'], 'tt' => $tt, 'level' => 1, 'section' => $section,'category' => $gn_category); - - $tt = _("Named PickupGroup : "); - if (!empty($named_group['namedpickupgroup'])) { - foreach ($named_group['namedpickupgroup'] as $val) { - $tt .= $val. ', '; + switch ($child['type']) { + case 'IE': + $elementID = (string)$child->input[0]->name; + if (!empty($metainfo[$elementID])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$shortId]; } - $tt .= '... '; } - $tmparr['namedpickupgroup'] = array('prompttext' => _('Named Pickup Group'),'value' => $this->line_defaults['namedpickupgroup'], 'tt' => $tt, 'level' => 1, 'section' => $section,'category' => $gn_category); + $tmparr[$elementID] = array('prompttext' => _((string)$child->label), + 'value' => $this->line_defaults[$elementID], + 'tt' => (string)$child->help, + 'level' => 1, + 'section' => $section, + 'category' => $gn_category + ); + break; + case 'IS': + $select = array(); + foreach ($child->xpath('button') as $value) { + $select[] = array('value' => strtolower((string)$value[@value]), 'text' => (string)$value); + } + $tmparr[(string)$child->name] = array('prompttext' => _((string)$child->label), + 'value' => $this->line_defaults[(string)$child->name], + 'tt' => (string)$child->help, + 'select' => $select, + 'level' => 1, + 'type' => 'radio', + 'section' => $section, + 'category' => $gn_category + ); + unset($select); + break; + case 'SLD': + $select = array( + array( 'value' => '0x21', 'text' => 'Inside Dial Tone'), + array( 'value' => '0x22', 'text' => 'Outside Dial Tone'), + array( 'value' => '0x23', 'text' => 'Line Busy Tone'), + array( 'value' => '0x24', 'text' => 'Alerting Tone'), + array( 'value' => '0x25', 'text' => 'Reorder Tone'), + array( 'value' => '0x26', 'text' => 'Recorder Warning Tone'), + array( 'value' => '0x27', 'text' => 'Recorder Detected Tone'), + array( 'value' => '0x28', 'text' => 'Reverting Tone'), + array( 'value' => '0x29', 'text' => 'Receiver OffHook Tone'), + array( 'value' => '0x2A', 'text' => 'Partial Dial Tone'), + array( 'value' => '0x2B', 'text' => 'No Such Number Tone'), + array( 'value' => '0x2C', 'text' => 'Busy Verification Tone'), + array( 'value' => '0x2D', 'text' => 'Call Waiting Tone'), + array( 'value' => '0x2E', 'text' => 'Confirmation Tone'), + array( 'value' => '0x2F', 'text' => 'Camp On Indication Tone'), + array( 'value' => '0x30', 'text' => 'Recall Dial Tone'), + array( 'value' => '0x31', 'text' => 'Zip Zip'), + array( 'value' => '0x32', 'text' => 'Zip'), + array( 'value' => '0x33', 'text' => 'Beep Bonk'), + array( 'value' => '0x34', 'text' => 'Music Tone'), + array( 'value' => '0x35', 'text' => 'Hold Tone'), + array( 'value' => '0x36', 'text' => 'Test Tone'), + array( 'value' => '0x37', 'text' => 'DT Monitor Warning Tone'), + array( 'value' => '0x40', 'text' => 'Add Call Waiting'), + array( 'value' => '0x41', 'text' => 'Priority Call Wait'), + array( 'value' => '0x42', 'text' => 'Recall Dial'), + array( 'value' => '0x43', 'text' => 'Barg In'), + array( 'value' => '0x44', 'text' => 'Distinct Alert'), + array( 'value' => '0x45', 'text' => 'Priority Alert'), + array( 'value' => '0x46', 'text' => 'Reminder Ring'), + array( 'value' => '0x47', 'text' => 'Precedence RingBank'), + array( 'value' => '0x48', 'text' => 'Pre-EmptionTone'), + array( 'value' => '0x67', 'text' => '2105 HZ'), + array( 'value' => '0x68', 'text' => '2600 HZ'), + array( 'value' => '0x69', 'text' => '440 HZ'), + array( 'value' => '0x6A', 'text' => '300 HZ'), + array( 'value' => '0x77', 'text' => 'MLPP Pala'), + array( 'value' => '0x78', 'text' => 'MLPP Ica'), + array( 'value' => '0x79', 'text' => 'MLPP Vca'), + array( 'value' => '0x7A', 'text' => 'MLPP Bpa'), + array( 'value' => '0x7B', 'text' => 'MLPP Bnea'), + array( 'value' => '0x7C', 'text' => 'MLPP Upa') + ); - $tt = _("Digits to indicate an external line to user (secondary dialtone) Sample 9 or 8 (max 9 digits)"); - $tmparr['secondary_dialtone_digits'] = array('prompttext' => _('Secondary dialtone digits'), 'value' => $this->line_defaults['secondary_dialtone_digits'], 'tt' => $tt, 'level' => 1, 'section' => $section,'category' => $gn_category); - unset($select); - $select[] = array( 'value' => '0x21', 'text' => 'Inside Dial Tone'); - $select[] = array( 'value' => '0x22', 'text' => 'Outside Dial Tone'); - $select[] = array( 'value' => '0x23', 'text' => 'Line Busy Tone'); - $select[] = array( 'value' => '0x24', 'text' => 'Alerting Tone'); - $select[] = array( 'value' => '0x25', 'text' => 'Reorder Tone'); - $select[] = array( 'value' => '0x26', 'text' => 'Recorder Warning Tone'); - $select[] = array( 'value' => '0x27', 'text' => 'Recorder Detected Tone'); - $select[] = array( 'value' => '0x28', 'text' => 'Reverting Tone'); - $select[] = array( 'value' => '0x29', 'text' => 'Receiver OffHook Tone'); - $select[] = array( 'value' => '0x2A', 'text' => 'Partial Dial Tone'); - $select[] = array( 'value' => '0x2B', 'text' => 'No Such Number Tone'); - $select[] = array( 'value' => '0x2C', 'text' => 'Busy Verification Tone'); - $select[] = array( 'value' => '0x2D', 'text' => 'Call Waiting Tone'); - $select[] = array( 'value' => '0x2E', 'text' => 'Confirmation Tone'); - $select[] = array( 'value' => '0x2F', 'text' => 'Camp On Indication Tone'); - $select[] = array( 'value' => '0x30', 'text' => 'Recall Dial Tone'); - $select[] = array( 'value' => '0x31', 'text' => 'Zip Zip'); - $select[] = array( 'value' => '0x32', 'text' => 'Zip'); - $select[] = array( 'value' => '0x33', 'text' => 'Beep Bonk'); - $select[] = array( 'value' => '0x34', 'text' => 'Music Tone'); - $select[] = array( 'value' => '0x35', 'text' => 'Hold Tone'); - $select[] = array( 'value' => '0x36', 'text' => 'Test Tone'); - $select[] = array( 'value' => '0x37', 'text' => 'DT Monitor Warning Tone'); - $select[] = array( 'value' => '0x40', 'text' => 'Add Call Waiting'); - $select[] = array( 'value' => '0x41', 'text' => 'Priority Call Wait'); - $select[] = array( 'value' => '0x42', 'text' => 'Recall Dial'); - $select[] = array( 'value' => '0x43', 'text' => 'Barg In'); - $select[] = array( 'value' => '0x44', 'text' => 'Distinct Alert'); - $select[] = array( 'value' => '0x45', 'text' => 'Priority Alert'); - $select[] = array( 'value' => '0x46', 'text' => 'Reminder Ring'); - $select[] = array( 'value' => '0x47', 'text' => 'Precedence RingBank'); - $select[] = array( 'value' => '0x48', 'text' => 'Pre-EmptionTone'); - $select[] = array( 'value' => '0x67', 'text' => '2105 HZ'); - $select[] = array( 'value' => '0x68', 'text' => '2600 HZ'); - $select[] = array( 'value' => '0x69', 'text' => '440 HZ'); - $select[] = array( 'value' => '0x6A', 'text' => '300 HZ'); - $select[] = array( 'value' => '0x77', 'text' => 'MLPP Pala'); - $select[] = array( 'value' => '0x78', 'text' => 'MLPP Ica'); - $select[] = array( 'value' => '0x79', 'text' => 'MLPP Vca'); - $select[] = array( 'value' => '0x7A', 'text' => 'MLPP Bpa'); - $select[] = array( 'value' => '0x7B', 'text' => 'MLPP Bnea'); - $select[] = array( 'value' => '0x7C', 'text' => 'MLPP Upa'); -/* !TODO!: I would remove the values below this line, except for 'No Tone' */ -// $select[] = array( 'value' => '0x7F', 'text' => 'No Tone'); - $select[] = array( 'value' => '0x80', 'text' => 'Meetme Greeting Tone'); - $select[] = array( 'value' => '0x81', 'text' => 'Meetme Number Invalid Tone'); - $select[] = array( 'value' => '0x82', 'text' => 'Meetme Number Failed Tone'); - $select[] = array( 'value' => '0x83', 'text' => 'Meetme Enter Pin Tone'); - $select[] = array( 'value' => '0x84', 'text' => 'Meetme Invalid Pin Tone'); - $select[] = array( 'value' => '0x85', 'text' => 'Meetme Failed Pin Tone'); - $select[] = array( 'value' => '0x86', 'text' => 'Meetme CFB Failed Tone'); - $select[] = array( 'value' => '0x87', 'text' => 'Meetme Enter Access Code Tone'); - $select[] = array( 'value' => '0x88', 'text' => 'Meetme Access Code Invalid Tone'); - $select[] = array( 'value' => '0x89', 'text' => 'Meetme Access Code Failed Tone'); - $select[] = array('value' => 'yes', 'text' => 'Yes'); - $select[] = array('value' => 'no', 'text' => 'No'); - - $tt = _("Outside dialtone frequency (defaul 0x22)"); - $tmparr['secondary_dialtone_tone'] = array('prompttext' => _('Secondary dialtone'), 'value' => $this->line_defaults['secondary_dialtone_tone'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'select', 'section' => $section,'category' => $gn_category); - - unset($select); - $select[] = array('value' => 'yes', 'text' => 'Yes'); - $select[] = array('value' => 'no', 'text' => 'No'); - $tt = _("Enable/Disable the `directed` pickup softkey"); - $tmparr['directed_pickup'] = array('prompttext' => _('Directed pickup'), 'value' => $this->line_defaults['directed_pickup'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); - - unset($select); - $select[] = array('value' => 'yes', 'text' => 'Yes'); - $select[] = array('value' => 'no', 'text' => 'No'); - $tt = _("Should the picked/gpicked-up call be answered automatically"); - $tmparr['pickup_modeanswer'] = array('prompttext' => _('Pickup Modeanswer'), 'value' => $this->line_defaults['pickup_modeanswer'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); - - unset($select); - $select[] = array('value' => 'on', 'text' => 'Yes'); - $select[] = array('value' => 'off', 'text' => 'No'); - $tt = _("Allow call transfer."); -// $tmparr['transfer'] = array('prompttext' => _('Call Transfer'), 'value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section, 'category' => 'general'); - $tmparr['transfer'] = array('prompttext' => _('Call Transfer'), 'value' => $this->line_defaults['transfer'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); - - unset($select); - $select[] = array('value' => 'yes', 'text' => 'Yes'); - $select[] = array('value' => 'no', 'text' => 'No'); - $tt = _("Echo cancel"); - $tmparr['echocancel'] = array('prompttext' => _('Echo cancel'), 'value' => $this->line_defaults['echocancel'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); - - unset($select); - $select[] = array('value' => 'off', 'text' => 'Off'); - $select[] = array('value' => 'reject', 'text' => 'Reject'); - $select[] = array('value' => 'silent', 'text' => 'Silent'); - $select[] = array('value' => 'user', 'text' => 'Cycle'); - $tt = _("DND: Means how will dnd react when it is set on the device level dnd can have three states: off / busy(reject) / silent / Cycle").'
    '. - _("Cycle - DND that cycles through all three states off -> reject -> silent -> off (this is the normal behaviour)").'
    '. - _("Reject - Users can only switch off and on (in reject/busy mode)").'
    '. - _("Silent - Users can only switch off and on (in silent mode)"); - $tmparr['dnd'] = array('prompttext' => _('DND'), 'value' => $this->line_defaults['dnd'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); - - unset($select); - $select[] = array('value' => 'yes', 'text' => 'Yes'); - $select[] = array('value' => 'no', 'text' => 'No'); - $tt = _("Silence Suppression. Asterisk Not supported"); - $tmparr['silencesuppression'] = array('prompttext' => _('Silence Suppression'), 'value' => $this->line_defaults['silencesuppression'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section,'category' => $gn_category); - - unset($select); - - if (function_exists('music_list')){ - $moh_list = music_list(); - } else { - $select[] = array('value' => 'default', 'text' => _('default')); - } - foreach ($moh_list as $value) { - $select[] = array('value' => $value, 'text' => _($value)); + $tmparr[(string)$child->name] = array('prompttext' => _((string)$child->label), + 'value' => $this->line_defaults[(string)$child->name], + 'tt' => (string)$child->help, + 'select' => $select, + 'level' => 1, + 'type' => 'select', + 'section' => $section, + 'category' => $gn_category + ); + unset($select); + break; + case 'SLG': + $elementID = (string)$child->name; + $named_group = \FreePbx::sccp_manager()->dbinterface->getNamedGroup($elementID); + if (!empty($named_group[$elementID])) { + foreach ($named_group[$elementID] as $val) { + $select[] = array('value' => $val, 'text' => $val); + } + } + $tmparr[(string)$child->name] = array('prompttext' => _((string)$child->label), + 'value' => $this->line_defaults[(string)$child->name], + 'tt' => (string)$child->help, + 'select' => $select, + 'level' => 1, + 'section' => $section, + 'category' => $gn_category + ); + unset($select); + break; + case 'SLM': + if (function_exists('music_list')){ + foreach (music_list() as $value) { + $select[] = array('value' => $value, 'text' => _($value)); + } + } else { + $select[] = array('value' => 'default', 'text' => _('default')); + } + $tmparr[(string)$child->name] = array('prompttext' => _((string)$child->label), + 'value' => $this->line_defaults[(string)$child->name], + 'tt' => (string)$child->help, + 'select' => $select, + 'level' => 1, + 'type' => 'select', + 'section' => $section, + 'category' => $gn_category + ); + unset($select); + break; + } } - $tt = _("Music on hold"); - $tmparr['musicclass'] = array('prompttext' => _('Music on hold'), 'value' => $this->line_defaults['musicclass'], 'tt' => $tt, 'select' => $select, 'level' => 1, 'section' => $section,'category' => $gn_category); - unset($select); - - $tt = _("Sets the named pickup groups this line is a member of (this phone can pickup calls from remote phones which are in this caller group (ast111)"); - $tmparr['pin'] = array('value' => '', 'tt' => $tt, 'level' => 1, 'section' => $section ,'category' => $gn_category); - unset($select); - - $select[] = array('value' => 'off', 'text' => 'Off'); - $select[] = array('value' => 'user', 'text' => 'User'); - $select[] = array('value' => 'auto', 'text' => 'Auto'); - $tt = _("Automatic or Manual video mode. Valid values are 'auto', 'user' or 'off'. When set to 'auto', video will automatically start if both parties have a compatible code enabled. In 'user' mode the user needs to press the vidmode softkey before video will be tried. Default:'auto'"); - $tmparr['videomode'] = array('prompttext' => _('Video Mode '), 'value' => 'auto', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section_с, 'category' => $gn_category); - unset($select); - - $tt = _("Codec disallow"); - $tmparr['disallow'] = array('prompttext' => _('Codec disallow'), 'value' => 'all', 'tt' => $tt, 'level' => 1, 'section' => $section_с,'category' => $gn_category); - unset($select); - - $devopts = $tmparr; - return $devopts; + return $tmparr; } public function reload_line($id) { @@ -431,30 +436,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { return $result; } - public function getNamedGroup() { - $sql = "SELECT namedcallgroup FROM sccpline GROUP BY namedcallgroup"; - $sth = $this->database->prepare($sql); - $result = array(); - $tech = array(); - try { - $sth->execute(); - $result = $sth->fetchAll(); - foreach($result as $val) { - $tech['namedcallgroup'][] = $val[0]; - } - } catch(\Exception $e) {} - $sql = "SELECT namedpickupgroup FROM sccpline GROUP BY namedpickupgroup"; - $sth = $this->database->prepare($sql); - try { - $sth->execute(); - $result = $sth->fetchAll(); - foreach($result as $val) { - $tech['namedpickupgroup'][] = $val[0]; - } - } catch(\Exception $e) {} - return $tech; - } public function getDeviceHeaders() { return array( diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index a192c8d..482edd9 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -17,6 +17,7 @@ class dbinterface public function __construct($parent_class = null) { $this->paren_class = $parent_class; + $this->db = \FreePBX::Database(); } public function info() @@ -46,7 +47,6 @@ class dbinterface public function getSccpDeviceTableData($dataid, $data = array()) { // $stmt is a single row fetch, $stmts is a fetchAll. - $dbh = \FreePBX::Database(); $stmt = ''; $stmts = ''; if ($dataid == '') { @@ -55,9 +55,9 @@ class dbinterface switch ($dataid) { case 'SccpExtension': if (empty($data['name'])) { - $stmts = $dbh->prepare('SELECT * FROM sccpline ORDER BY name'); + $stmts = $this->db->prepare('SELECT * FROM sccpline ORDER BY name'); } else { - $stmts = $dbh->prepare('SELECT * FROM sccpline WHERE name = :name'); + $stmts = $this->db->prepare('SELECT * FROM sccpline WHERE name = :name'); $stmts->bindParam(':name', $data['name'],\PDO::PARAM_STR); } break; @@ -78,20 +78,20 @@ class dbinterface } } if (!empty($data['name'])) { //either filter by name or by type - $stmt = $dbh->prepare('SELECT ' . $fld . ' FROM sccpdeviceconfig WHERE name = :name ORDER BY name'); + $stmt = $this->db->prepare('SELECT ' . $fld . ' FROM sccpdeviceconfig WHERE name = :name ORDER BY name'); $stmt->bindParam(':name', $data['name'],\PDO::PARAM_STR); } elseif (!empty($data['type'])) { switch ($data['type']) { case "cisco-sip": - $stmts = $dbh->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE TYPE LIKE '%-sip' ORDER BY name"); + $stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE TYPE LIKE '%-sip' ORDER BY name"); break; case "cisco": // Fall through to default intentionally default: - $stmts = $dbh->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE TYPE not LIKE '%-sip' ORDER BY name"); + $stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE TYPE not LIKE '%-sip' ORDER BY name"); break; } } else { //no filter and no name provided - return all - $stmts = $dbh->prepare("SELECT {$fld} FROM sccpdeviceconfig ORDER BY name"); + $stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig ORDER BY name"); } break; case 'HWSipDevice': @@ -104,23 +104,23 @@ class dbinterface $raw_settings = $this->getDb_model_info($get = "extension", $format_list = "model"); break; case 'get_columns_sccpdevice': - $stmts = $dbh->prepare('DESCRIBE sccpdevice'); + $stmts = $this->db->prepare('DESCRIBE sccpdevice'); break; case 'get_columns_sccpuser': - $stmts = $dbh->prepare('DESCRIBE sccpuser'); + $stmts = $this->db->prepare('DESCRIBE sccpuser'); break; case 'get_columns_sccpline': - $stmts = $dbh->prepare('DESCRIBE sccpline'); + $stmts = $this->db->prepare('DESCRIBE sccpline'); break; case 'get_sccpdevice_byid': - $stmt = $dbh->prepare('SELECT t1.*, types.dns, types.buttons, types.loadimage, types.nametemplate as nametemplate, + $stmt = $this->db->prepare('SELECT t1.*, types.dns, types.buttons, types.loadimage, types.nametemplate as nametemplate, addon.buttons as addon_buttons FROM sccpdevice AS t1 LEFT JOIN sccpdevmodel as types ON t1.type=types.model LEFT JOIN sccpdevmodel as addon ON t1.addon=addon.model WHERE name = :name'); $stmt->bindParam(':name', $data['id'],\PDO::PARAM_STR); break; case 'get_sccpuser': - $stmt = $dbh->prepare('SELECT * FROM sccpuser WHERE name = :name'); + $stmt = $this->db->prepare('SELECT * FROM sccpuser WHERE name = :name'); $stmt->bindParam(':name', $data['id'],\PDO::PARAM_STR); break; case 'get_sccpdevice_buttons': @@ -132,7 +132,7 @@ class dbinterface $sql .= (empty($sql)) ? 'ref = :ref' : ' and ref = :ref'; } if (!empty($sql)) { - $stmts = $dbh->prepare("SELECT * FROM sccpbuttonconfig WHERE {$sql} ORDER BY instance"); + $stmts = $this->db->prepare("SELECT * FROM sccpbuttonconfig WHERE {$sql} ORDER BY instance"); // Now bind labels - only bind label if it exists or bind will create exception. // can only bind once have prepared, so need to test again. if (!empty($data['buttontype'])) { @@ -160,8 +160,7 @@ class dbinterface public function get_db_SccpSetting() { - $dbh = \FreePBX::Database(); - $stmt = $dbh->prepare('SELECT keyword, seq, type, data, systemdefault FROM sccpsettings ORDER BY type, seq'); + $stmt = $this->db->prepare('SELECT keyword, seq, type, data, systemdefault FROM sccpsettings ORDER BY type, seq'); $stmt->execute(); foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $key => $rowArray) { $settingsFromDb[$rowArray['keyword']] = $rowArray; @@ -172,8 +171,7 @@ class dbinterface public function get_db_sysvalues() { - $dbh = \FreePBX::Database(); - $stmt = $dbh->prepare('SHOW VARIABLES LIKE \'%group_concat%\''); + $stmt = $this->db->prepare('SHOW VARIABLES LIKE \'%group_concat%\''); $stmt->execute(); return $stmt->fetch(\PDO::FETCH_ASSOC); } @@ -184,7 +182,6 @@ class dbinterface function getDb_model_info($get = 'all', $format_list = 'all', $filter = array()) { - $dbh = \FreePBX::Database(); $sel_inf = '*, 0 as validate'; if ($format_list === 'model') { $sel_inf = 'model, vendor, dns, buttons, 0 as validate'; @@ -196,10 +193,10 @@ class dbinterface if (!strpos($filter['model'], 'loadInformation')) { $filter['model'] = 'loadInformation' . $filter['model']; } - $stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (loadinformationid = :model ) ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (loadinformationid = :model ) ORDER BY model"); $stmt->bindParam(':model', $filter['model'], \PDO::PARAM_STR); } else { - $stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model"); } break; } @@ -207,32 +204,32 @@ class dbinterface case 'byid': if (!empty($filter)) { if (!empty($filter['model'])) { - $stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE model = :model ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE model = :model ORDER BY model"); $stmt->bindParam(':model', $filter['model'],\PDO::PARAM_STR); } else { - $stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model"); } break; } break; case 'extension': - $stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns = 0) and (enabled = 1) ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns = 0) and (enabled = 1) ORDER BY model"); break; case 'enabled': //$stmt = $db->prepare('SELECT ' . {$sel_inf} . ' FROM sccpdevmodel WHERE enabled = 1 ORDER BY model'); //previously this fell through to phones. //break; // above includes expansion modules but was not original behaviour so commented out. Falls through to phones. case 'phones': - $stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) ORDER BY model"); break; case 'ciscophones': - $stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND vendor NOT LIKE '%-sip' ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND vendor NOT LIKE '%-sip' ORDER BY model"); break; case 'sipphones': - $stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND vendor LIKE '%-sip' ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND vendor LIKE '%-sip' ORDER BY model"); break; case 'all': // Fall through to default default: - $stmt = $dbh->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel ORDER BY model"); break; } $stmt->execute(); @@ -243,15 +240,14 @@ class dbinterface { // mode clear - Empty table before update // mode update - update / replace record - $dbh = \FreePBX::Database(); $result = false; switch ($table_name) { case 'sccpsettings': if ($mode == 'replace') { // Change mode name to be more transparent - $dbh->prepare('TRUNCATE sccpsettings')->execute(); - $stmt = $dbh->prepare('INSERT INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES (:keyword,:data,:seq,:type,:systemdefault)'); + $this->db->prepare('TRUNCATE sccpsettings')->execute(); + $stmt = $this->db->prepare('INSERT INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES (:keyword,:data,:seq,:type,:systemdefault)'); } else { - $stmt = $dbh->prepare('REPLACE INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES (:keyword,:data,:seq,:type,:systemdefault)'); + $stmt = $this->db->prepare('REPLACE INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES (:keyword,:data,:seq,:type,:systemdefault)'); } foreach ($save_value as $key => $dataArr) { if (empty($dataArr)) { @@ -286,13 +282,13 @@ class dbinterface if (!empty($sql_var)) { switch ($mode) { case 'delete': - $stmt = $dbh->prepare("DELETE FROM {$table_name} WHERE {$sql_key}"); + $stmt = $this->db->prepare("DELETE FROM {$table_name} WHERE {$sql_key}"); break; case 'update': - $stmt = $dbh->prepare("UPDATE {$table_name} SET {$sql_var} WHERE {$sql_key}"); + $stmt = $this->db->prepare("UPDATE {$table_name} SET {$sql_var} WHERE {$sql_key}"); break; case 'replace': - $stmt = $dbh->prepare("REPLACE INTO {$table_name} SET {$sql_var}"); + $stmt = $this->db->prepare("REPLACE INTO {$table_name} SET {$sql_var}"); break; // no default mode - must be explicit. } @@ -303,13 +299,13 @@ class dbinterface switch ($mode) { case 'delete': $sql = 'DELETE FROM sccpbuttonconfig WHERE ref = :hwid'; - $stmt = $dbh->prepare($sql); + $stmt = $this->db->prepare($sql); $stmt->bindParam(':hwid', $hwid,\PDO::PARAM_STR); $result = $stmt->execute(); break; case 'replace': foreach ($save_value as $button_array) { - $stmt = $dbh->prepare('UPDATE sccpbuttonconfig SET name =:name WHERE ref = :ref AND reftype =:reftype AND instance = :instance AND buttontype = :buttontype'); + $stmt = $this->db->prepare('UPDATE sccpbuttonconfig SET name =:name WHERE ref = :ref AND reftype =:reftype AND instance = :instance AND buttontype = :buttontype'); $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); @@ -320,7 +316,7 @@ class dbinterface break; case 'add': foreach ($save_value as $button_array) { - $stmt = $dbh->prepare('INSERT INTO sccpbuttonconfig (ref, reftype, instance, buttontype, name, options) VALUES (:ref, :reftype, :instance, :buttontype, :name, :options)'); + $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(':reftype', $button_array['reftype'],\PDO::PARAM_STR); $stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT); @@ -353,8 +349,7 @@ class dbinterface } public function updateTableDefaults($table, $field, $value) { - $dbh = \FreePBX::Database(); - $stmt = $dbh->prepare("ALTER TABLE {$table} ALTER COLUMN {$field} SET DEFAULT '{$value}'"); + $stmt = $this->db->prepare("ALTER TABLE {$table} ALTER COLUMN {$field} SET DEFAULT '{$value}'"); $stmt->execute(); } @@ -363,14 +358,13 @@ class dbinterface */ public function validate() { - $dbh = \FreePBX::Database(); $result = 0; $check_fields = [ '430' => ['_hwlang' => "varchar(12)"], '431' => ['private'=> "enum('on','off')"], '433' => ['directed_pickup'=>''] ]; - $stmt = $dbh->prepare('DESCRIBE sccpdevice'); + $stmt = $this->db->prepare('DESCRIBE sccpdevice'); $stmt->execute(); foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $value) { $id_result[$value['Field']] = $value['Type']; @@ -390,4 +384,19 @@ class dbinterface return $result; } + + public function getNamedGroup($callGroup) { + $sql = "SELECT {$callGroup} FROM sccpline GROUP BY {$callGroup}"; + $sth = $this->db->prepare($sql); + $result = array(); + $tech = array(); + try { + $sth->execute(); + $result = $sth->fetchAll(); + foreach($result as $val) { + $tech[$callGroup][] = $val[0]; + } + } catch(\Exception $e) {} + return $tech; + } } From ba4dfb2f0d86afb8007153bc0ca44cc1ec0db1a6 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 9 Jul 2021 11:18:53 +0200 Subject: [PATCH 084/181] Reset line codec choices to site defaults If all codecs are unchecked, restores values to site codecs Remove options that have no input (do not offer user empty lists) Respect site dndFeature by hiding option if off --- conf/sccpgeneral.xml.v433 | 4 +- sccpManClasses/Sccp.class.php.v433 | 70 +++++++++++++++++++----------- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index f08077f..4394d36 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1926,14 +1926,14 @@ and open the template in the editor. Base Version before all crash :-) - + mailbox sccp-custom - Name or id of linked maibox + Name or id of linked maibox: Voicemail has to be enabled for this to be available diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 4117071..e74f6a6 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -47,7 +47,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { "secondary_dialtone_digits" => 'secondary_dialtone_digits', "secondary_dialtone_tone" => 'secondary_dialtone_tone', 'namedcallgroup'=>'namedcallgroup', 'namedpickupgroup' => 'namedpickupgroup' ); - // These are gui defaults used by freePBX to for the elements in the SCCP tab in add/edit phone. + // These are gui defaults used by freePBX for the elements in the SCCP tab in add/edit phone. private $guiDefaults =array( 'gui_checkset' => array( "elemname" => "", "prompttext" => "", //ok @@ -102,7 +102,6 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function addDevice($id, $settings) { // This is actually save line and is used by add and edit. - global $currentcomponent; $add_fld = array ("name"=>'label',"outboundcid"=>'cid_num',"langcode"=>'language',"extdisplay"=>'description','devinfo_mailbox'=>'mailbox'); $settings['cid_num']['value'] = ''; $settings['cid_name']['value'] = ''; @@ -116,7 +115,6 @@ class Sccp extends \FreePBX\modules\Core\Driver { } } } - dbug('addD', $settings); $allow_codec = array(); foreach($settings as $key => $val) { if (strncmp($key,'codec_',6) === 0 ) { @@ -124,6 +122,10 @@ class Sccp extends \FreePBX\modules\Core\Driver { } } $settings['allow']['value'] = implode(",", $allow_codec); + // Reset to line defaults if no value selected + if (empty($settings['allow']['value'])) { + $settings['allow']['value'] = $this->line_defaults['allow']; + } // If set, parse outboundcid content into cid_num and cid_name sccpline fields if (!empty($settings['cid_num']['value'])) { @@ -136,6 +138,10 @@ class Sccp extends \FreePBX\modules\Core\Driver { } } + if ($this->line_defaults['dndFeature'] == 'off') { + $settings['dnd']['value'] = 'off'; + } + if (!empty($_REQUEST['vm']) && ($_REQUEST['vm'] =='enabled')){ // mailbox if (empty($settings['mailbox']['value'])) { $settings['mailbox']['value']= $id; @@ -156,13 +162,12 @@ class Sccp extends \FreePBX\modules\Core\Driver { } } $sql = "REPLACE INTO sccpline ( {$sqlCol} ) VALUES ( {$sqlVal} )"; -dbug('sql', $sql); $sth = $this->database->prepare($sql); $sth->execute(); /* If called from SCCP Phone, redirect to SCCP Phone page on submit. This was last function in add so should be safe. - Prefer to add in Hooks, but is not followed even if set for $currentcomponent + Prefer to add in Hooks, but is not followed even if set for $currentComponent Do nothing if called from QuickCreateExtension when display is not set */ if (isset($_REQUEST['display'])) { @@ -210,8 +215,9 @@ dbug('sql', $sql); return array('dial' => 'SCCP', 'settings' => $settings); } - public function getDeviceDisplay($display, $deviceInfo, $currentcomponent, $primarySection) { - dbug('devInfo', $deviceInfo); + public function getDeviceDisplay($display, $deviceInfo, $currentComponent, $primarySection) { + dbug('',$primarySection); + $activeCodecs = array(); // load xml data to get help from same source as rest of module $xml_vars = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v433'; $this->xml_data = simplexml_load_file($xml_vars); @@ -229,31 +235,33 @@ dbug('sql', $sql); $section = _("SCCP Extension Details"); $section_с = _("SCCP Codec Details"); $gn_category = "sccp"; - global $currentcomponent, $display; //add sccp category - $currentcomponent->addTabTranslation('sccp',_('SCCP')); - // TODO: If we have upgraded the system codecs, need to allow new options here. + $currentComponent->addTabTranslation('sccp',_('SCCP')); + + // get site and system defaults + $systemCodecs = array_fill_keys(explode(',',$this->line_defaults['allow']),true); + $siteAudioCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getAudio()); + $siteVideoCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getVideo()); + if (empty($deviceInfo['allow'])) { - // Need a codec and have none, so use system defaults - $systemCodecs = array_fill_keys(explode(",",$this->line_defaults['allow']),true); - $siteAudioCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getAudio()); - $siteVideoCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getVideo()); + // No allowed codecs so reset to site defaults + foreach ($systemCodecs as $lineCodec => $dummyVal) { + $activeCodecs[] = "devinfo_codec_{$lineCodec}"; + } } else { - // TODO: Need to show disabled options - // Have codecs for this device. - $systemCodecs = array_fill_keys(explode(",",$deviceInfo['allow']),true); //pb is here - $siteAudioCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getAudio()); - $siteVideoCodecs = array_intersect_key($systemCodecs, $this->freepbx->Codecs->getVideo()); + // have allowed codecs for this line + foreach (explode(',',$deviceInfo['allow']) as $lineCodec) { + $activeCodecs[] = "devinfo_codec_{$lineCodec}"; + } } + // Fill Audio codecs information foreach ($siteAudioCodecs as $key => $value) { $audioCodecButtons[] = array('value' => "devinfo_codec_{$key}", 'text' => $key); - $activeAudioCodecs[] ="devinfo_codec_{$key}"; } // Fill Video codecs information foreach ($siteVideoCodecs as $key => $value) { $videoCodecButtons[] = array('value' => "devinfo_codec_{$key}", 'text' => $key); - $activeVideoCodecs[] ="devinfo_codec_{$key}"; } $tmparr['disallow'] = array('prompttext' => _('Disallowed Codecs'), @@ -267,26 +275,26 @@ dbug('sql', $sql); $el = array( "elemname" => "devinfo_sccp_codec", "prompttext" => _('Line Audio Codec:'), - "helptext" => _("Line Audio Codec"), - "currentvalue" => $activeAudioCodecs, + "helptext" => _("Line Audio Codec. Uncheck all Audio and Video codecs to return to site defaults"), + "currentvalue" => $activeCodecs, "valarray" => $audioCodecButtons, "class" => $section_с, "disable" => 0 ); // Override defaults with $el - $currentcomponent->addguielem($section_с, new \gui_checkset(array_merge($this->guiDefaults['gui_checkset'],$el)), $gn_category); + $currentComponent->addguielem($section_с, new \gui_checkset(array_merge($this->guiDefaults['gui_checkset'],$el)), $gn_category); unset($el); $el = array( "elemname" => "devinfo_sccp_vcodec", "prompttext" => _('Line Video Codec:'), "helptext" => _("Line Video Codec"), - "currentvalue" => $activeVideoCodecs, + "currentvalue" => $activeCodecs, "valarray" => $videoCodecButtons, "class" => $section_с, "disable" => 0 ); - $currentcomponent->addguielem($section_с, new \gui_checkset(array_merge($this->guiDefaults['gui_checkset'],$el)), $gn_category); + $currentComponent->addguielem($section_с, new \gui_checkset(array_merge($this->guiDefaults['gui_checkset'],$el)), $gn_category); $pageGroup = $this->xml_data->xpath('//page_group[@name="sccp_extension_config"]'); $elements = $pageGroup[0]->children(); @@ -313,15 +321,22 @@ dbug('sql', $sql); ); break; case 'IS': + dbug('', $child); $select = array(); foreach ($child->xpath('button') as $value) { $select[] = array('value' => strtolower((string)$value[@value]), 'text' => (string)$value); } + $hideButton = false; + if (($this->line_defaults['dndFeature'] == 'off') && ($child['id'] == 5)) { + $hideButton = true; + } $tmparr[(string)$child->name] = array('prompttext' => _((string)$child->label), 'value' => $this->line_defaults[(string)$child->name], 'tt' => (string)$child->help, 'select' => $select, 'level' => 1, + 'disable' => $hideButton, + 'hidden' => $hideButton, 'type' => 'radio', 'section' => $section, 'category' => $gn_category @@ -394,11 +409,14 @@ dbug('sql', $sql); $select[] = array('value' => $val, 'text' => $val); } } + // Disable and hide list elements if there are no valid values $tmparr[(string)$child->name] = array('prompttext' => _((string)$child->label), 'value' => $this->line_defaults[(string)$child->name], 'tt' => (string)$child->help, 'select' => $select, 'level' => 1, + 'disable' => empty($named_group[$elementID][0]), + 'hidden' => empty($named_group[$elementID][0]), 'section' => $section, 'category' => $gn_category ); From d966bfa303a1082fa0162105767b188f00203917 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 9 Jul 2021 14:06:25 +0200 Subject: [PATCH 085/181] Minor typo corrections and add defaults button to device add/edit --- Sccp_manager.class.php | 5 ++++- conf/sccpgeneral.xml.v433 | 6 +++--- views/form.adddevice.php | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 6795d94..5e328a2 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -172,7 +172,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (($group_name == 'sccp_general') || ($group_name == 'sccp_qos_config') || ($group_name =='sccp_dev_config') || ($group_name =='sccp_dev_group_config') || ($group_name =='sccp_hotline_config') || ($group_name =='sccp_dev_softkey') || - ($group_name =='sccp_dev_advconfig') || $group_name == 'sccp_extpath_config') { + ($group_name =='sccp_dev_advconfig') || ($group_name == 'sccp_extpath_config') || + ($group_name =='sccp_dev_vendor_conf') || ($group_name =='sccp_hw_dev_softkey') || + ($group_name =='sccp_hw_dev_advance') || ($group_name =='sccp_hw_dev_conference')) + { $htmlret = load_view(__DIR__ . '/views/formShowSysDefs.php', array( 'itm' => $item, 'h_show' => $show_Header, diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 4394d36..2e9335e 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1426,7 +1426,7 @@ and open the template in the editor. Base Version before all crash :-) Activate the callforward NOANSWER stuff and softkeys. Default is On - dndFeature + dnd off @@ -1628,7 +1628,7 @@ and open the template in the editor. Base Version before all crash :-) directrtp - + This option allow devices to do direct RTP sessions (default Off) @@ -2031,7 +2031,7 @@ and open the template in the editor. Base Version before all crash :-) dnd - + Reject diff --git a/views/form.adddevice.php b/views/form.adddevice.php index ffa1ef5..c805776 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -37,7 +37,7 @@ if (!empty($_REQUEST['new_id'])) { } } -//Get default values. Will use these dor a new device, and modify for an existing. +//Get default values. Will use these for a new device, and modify for an existing. $def_val = $this->getTableDefaults('sccpdevice'); if (!empty($_REQUEST['id'])) { // Editing an existing Device. Overwrite any defaults that are already set for this device. From ce115dab8b4544ac6809d707fd23c9282e9ebbcf Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 10 Jul 2021 09:03:06 +0200 Subject: [PATCH 086/181] Create formCreate class Move anonymous class frpm formShowSysDefs to own class --- Sccp_manager.class.php | 4 +- conf/sccpgeneral.xml.v433 | 4 +- sccpManClasses/formcreate.class.php | 975 +++++++++++++++++++++++++++ views/formShowSysDefs.php | 983 +--------------------------- 4 files changed, 990 insertions(+), 976 deletions(-) create mode 100644 sccpManClasses/formcreate.class.php diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 5e328a2..708e4d8 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -174,7 +174,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { ($group_name =='sccp_hotline_config') || ($group_name =='sccp_dev_softkey') || ($group_name =='sccp_dev_advconfig') || ($group_name == 'sccp_extpath_config') || ($group_name =='sccp_dev_vendor_conf') || ($group_name =='sccp_hw_dev_softkey') || - ($group_name =='sccp_hw_dev_advance') || ($group_name =='sccp_hw_dev_conference')) + ($group_name =='sccp_hw_dev_advance') || ($group_name =='sccp_hw_dev_conference') || + ($group_name =='sccp_hw_dev_network') || ($group_name == 'sccp_hw_dev_edit') + ) { $htmlret = load_view(__DIR__ . '/views/formShowSysDefs.php', array( 'itm' => $item, diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 2e9335e..50a11af 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1389,8 +1389,8 @@ and open the template in the editor. Base Version before all crash :-) transfer off - - + + Transfer allowed diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php new file mode 100644 index 0000000..190910b --- /dev/null +++ b/sccpManClasses/formcreate.class.php @@ -0,0 +1,975 @@ +buttonDefLabel = 'chan-sccp'; + $this->buttonHelpLabel = 'site'; + } + + function addElementIE ($child, $fvalues, $sccp_defaults, $npref) { + $res_input = ''; + $res_name = ''; + if ($npref == 'sccp_hw_') { + $this->buttonDefLabel = 'site'; + $this->buttonHelpLabel = 'device'; + } + $usingSysDefaults = true; + // if there are multiple inputs, take the first for res_id and shortId + $shortId = (string)$child->input[0]->name; + $res_id = $npref.$shortId; + if (!empty($metainfo[$shortId])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metainfo[$shortId]; + } + } + + // --- Add Hidden option + $res_sec_class =''; + if (!empty($child ->class)) { + $res_sec_class = (string)$child ->class; + } + if (empty($child->nameseparator)) { + $child->nameseparator = ' / '; + } + $i = 0; + ?> +
    +
    +
    +
    + + +
    +
    + xpath('input') as $value) { + $res_n = (string)$value->name; + $res_name = $npref . $res_n; + //if (!empty($fvalues[$res_n])) { + $value->value = $fvalues[$res_n]['data']; + if (!empty($fvalues[$res_n]['data'])) { + if (!empty($sccp_defaults[$res_n]['systemdefault']) && ($sccp_defaults[$res_n]['systemdefault'] != $fvalues[$res_n]['data'])) { + $usingSysDefaults = false; + } + } + //} + // Default to chan-sccp defaults, not xml defaults. + //if (empty($value->value)) { + //$value->value = $sccp_defaults[$res_n]['systemdefault']; + //} + if (empty($value->type)) { + $value->type = 'text'; + } + if (empty($value->class)) { + $value->class = 'form-control'; + } + if ($i > 0) { + echo $child->nameseparator; + } + // Output current value + if (empty($value->value)) { + echo "Value not found for {$res_n}"; + } + echo $value->value; + $i ++; + } + ?> +
    +
    + + + > + + + +
    +
    +
    + +
    +
    + help);?> +
    +
    +
    + name; + + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metaInfo[$res_n]; + } + } + // $res_value + $lnhtm = ''; + $res_id = $napref.$child->name; + $i = 0; + $max_row = 255; + if (!empty($child->max_row)) { + $max_row = $child->max_row; + } + + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $res_value = explode(';', $fvalues[$res_n]['data']); + } + } + if (empty($res_value)) { + $res_value = array((string) $child->default); + // $res_value = explode('/', (string) $child->default); + } + ?> +
    +
    +
    +
    +
    +
    + + +
    + +
    + cbutton)) { + echo '
    '; + foreach ($child->xpath('cbutton') as $value) { + $res_n = $res_id.'[0]['.$value['field'].']'; + $res_vf = ''; + if ($value['value']=='NONE' && empty($res_value)) { + $res_vf = 'active'; + } + $ch_key = array_search($value['value'], $res_value); + if ($ch_key !== false) { + unset($res_value[$ch_key]); + $res_vf = 'active'; + $res_value = explode(';', implode(';', $res_value)); + } + $opt_hide =''; + $opt_class="button-checkbox"; + if (!empty($value->option_hide)) { + $opt_class .= " sccp_button_hide"; + $opt_hide = ' data-vhide="'.$value->option_hide.'" data-btn="checkbox" data-clhide="'.$value->option_hide['class'].'" '; + } + if (!empty($child->option_show)) { + if (empty($opt_hide)) { + $opt_hide =' class="sccp_button_hide" '; + } + $opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" '; + } + + if (!empty($value->option_disabled)) { + $opt_class .= " sccp_button_disabled"; + $opt_hide = ' data-vhide="'.$value->option_disabled.'" data-btn="checkbox" data-clhide="'.$value->option_disabled['class'].'" '; + } + + if (!empty($value->class)) { + $opt_class .= " ".(string)$value->class; + } + + echo ''; + } + echo '
    '; + } + $opt_class = "col-sm-7 ".$res_id."-gr"; + if (!empty($child->class)) { + $opt_class .= " ".(string)$child->class; + } + echo '
    '; + + foreach ($res_value as $dat_v) { + ?> +
    > + xpath('input') as $value) { + $res_n = $res_id.'['.$i.']['.$value['field'].']'; + $fields_id = (string)$value['field']; + $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; + if (!empty($value->class)) { + $opt_at[$fields_id]['class']='form-control ' .(string)$value->class; + } + $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; + + echo 'options)) { + foreach ($value->options ->attributes() as $optkey => $optval) { + $opt_at[$fields_id]['options'][$optkey]=(string)$optval; + echo ' '.$optkey.'="'.$optval.'"'; + } + } + echo '> '.(string)$value['nameseparator'].' '; + $i2 ++; + } + if (!empty($child->add_pluss)) { + echo ''; + } + echo '
    '; + $i++; + } + ?> +
    + addbutton)) { + echo '
    '; + echo ''; + echo '
    '; + } + ?> +
    +
    +
    +
    +
    +
    + help);?> +
    +
    + buttonDefLabel = 'site'; + $this->buttonHelpLabel = 'device'; + } + $res_n = (string)$child->name; + $res_id = $npref.$res_n; + $res_ext = str_replace($npref,'',$res_n); + $usingSysDefaults = true; + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metaInfo[$res_n]; + } + } + + // --- Add Hidden option + $res_sec_class =''; + if (!empty($child ->class)) { + $res_sec_class = (string)$child ->class; + } + ?> +
    +
    +
    +
    + + +
    + + default)) { + $res_v = (string)$child->default; + } + if (!empty($child->value)) { + $res_v = (string)$child->value; + } + if (!empty($fvalues[$res_n])) { + if (($fvalues[$res_n]['data'] != '') ) { + $res_v = (string)$fvalues[$res_n]['data']; + } + } + if (!empty($sccp_defaults[$res_n]['systemdefault'])) { + // There is a system default, so add button to customise or reset + // the closing } is after the code to include the button at line ~498 + + //-- Start include of defaults button -- + echo "
    "; + + if (!empty($sccp_defaults[$res_n]['systemdefault']) && ($sccp_defaults[$res_n]['systemdefault'] != $res_v)) { + $usingSysDefaults = false; + } + + // Output current value + // TODO: This is debug code and needs to be set to only echo res_v + echo $res_v . $res_n . $sccp_defaults[$res_n]['systemdefault'] . $usingSysDefaults; + ?> +
    +
    + + + > + + +
    +
    +
    + + +
    + help);?> +
    +
    + + name; + $res_id = $npref.$res_n; + // $select_opt is a simple array for these types. + $select_opt = array(); + + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metaInfo[$res_n]; + } + } + if (empty($child->class)) { + $child->class = 'form-control'; + } + switch ($child['type']) { + case 'SLD': + $day_format = array("D.M.Y", "D.M.YA", "Y.M.D", "YA.M.D", "M-D-Y", "M-D-YA", "D-M-Y", "D-M-YA", "Y-M-D", "YA-M-D", "M/D/Y", "M/D/YA", + "D/M/Y", "D/M/YA", "Y/M/D", "YA/M/D", "M/D/Y", "M/D/YA"); + $select_opt= $day_format; + break; + case 'SLM': + if (function_exists('music_list')) { + $moh_list = music_list(); + } + if (!is_array($moh_list)) { + $moh_list = array('default'); + } + $select_opt= $moh_list; + break; + case 'SLK': + $softKeyList = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets(); + $select_opt= $softKeyList; + break; + case 'SLP': + $dialplan_list = array(); + foreach (\FreePBX::Sccp_manager()->getDialPlanList() as $tmpkey) { + $tmp_id = $tmpkey['id']; + $dialplan_list[$tmp_id] = $tmp_id; + } + $select_opt= $dialplan_list; + break; + } + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + } + } + ?> +
    +
    +
    + + +
    +
    + class . '" id="' . $res_id . '">'; + + foreach ($select_opt as $key) { + echo ''; + } + ?> + +
    +
    +
    +
    +
    + help);?> +
    +
    +
    + name; + $res_id = $npref.$res_n; + $child->value =''; + // $select_opt is an associative array for these types. + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metaInfo[$res_n]; + } + } + switch ($child['type']) { + case 'SLS': + if (\FreePBX::Modules()->checkStatus("soundlang")) { + $syslangs = \FreePBX::Soundlang()->getLanguages(); + if (!is_array($syslangs)) { + $syslangs = array(); + } + } + $select_opt= $syslangs; + break; + case 'SLT': + $select_opt= $tftp_lang; + break; + case 'SLZ': + $timeZoneOffsetList = array('-12' => 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9', + '-08' => 'GMT -8', '-07' => 'GMT -7', '-06' => 'GMT -6', '-05' => 'GMT -5', + '-04' => 'GMT -4', '-03' => 'GMT -3', '-02' => 'GMT -2', '-01' => 'GMT -1', + '00' => 'GMT', '01' => 'GMT +1', '02' => 'GMT +2', '03' => 'GMT +3', + '04' => 'GMT +4', '05' => 'GMT +5', '06' => 'GMT +6', '07' => 'GMT +7', + '08' => 'GMT +8', '09' => 'GMT +9', '10' => 'GMT +10', '11'=> 'GMT +11', '12' => 'GMT +12'); + $select_opt= $timeZoneOffsetList; + break; + case 'SLA': + $select_opt =''; + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $res_value = explode(';', $fvalues[$res_n]['data']); + } + if (empty($res_value)) { + $res_value = array((string) $child->default); + } + foreach ($res_value as $key) { + $select_opt[$key]= $key; + } + } + case 'SLM': + if (function_exists('music_list')) { + $moh_list = music_list(); + } + if (!is_array($moh_list)) { + $moh_list = array('default'); + } + $select_opt= $moh_list; + break; + case 'SLD': + $day_format = array("D.M.Y", "D.M.YA", "Y.M.D", "YA.M.D", "M-D-Y", "M-D-YA", "D-M-Y", "D-M-YA", "Y-M-D", "YA-M-D", "M/D/Y", "M/D/YA", + "D/M/Y", "D/M/YA", "Y/M/D", "YA/M/D", "M/D/Y", "M/D/YA"); + $select_opt= $day_format; + break; + case 'SLK': + $softKeyList = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets(); + $select_opt= $softKeyList; + break; + case 'SLP': + $dialplan_list = array(); + foreach (\FreePBX::Sccp_manager()->getDialPlanList() as $tmpkey) { + $tmp_id = $tmpkey['id']; + $dialplan_list[$tmp_id] = $tmp_id; + } + $select_opt= $dialplan_list; + break; + case 'SL': + $select_opt = array(); + break; + } + if (empty($child->class)) { + $child->class = 'form-control'; + } + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + } + } + if (empty($child->value)) { + if (!empty($child->default)) { + $child->value = $child->default; + } + } + ?> +
    +
    +
    + + +
    +
    + class . '" id="' . $res_id . '">'; + foreach ($select_opt as $key => $val) { + if (is_array($val)) { + $opt_key = (isset($val['id'])) ? $val['id'] : $key; + $opt_val = (isset($val['val'])) ? $val['val'] : $val; + } else if (\FreePBX::Sccp_manager()->is_assoc($select_opt)){ + // have associative array + $opt_key = $key; + $opt_val = $val; + } else { + // Have simple array + $opt_key = $val; + $opt_val = $val; + } + echo ''; + } + ?> +
    +
    +
    +
    +
    + help);?> +
    +
    + name; + $res_id = $npref.$res_n; + + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metaInfo[$res_n]; + } + } + + if (empty($child->class)) { + $child->class = 'form-control'; + } + switch ($child['type']) { + case 'SDM': + $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWDevice"); + $select_opt= $model_list; + break; + case 'SDMS': + $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWSipDevice"); + $select_opt= $model_list; + break; + case 'SDE': + $extension_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWextension"); + $extension_list[]=array( 'model' => 'NONE', 'vendor' => 'CISCO', 'dns' => '0'); + foreach ($extension_list as &$data) { + $d_name = explode(';', $data['model']); + if (is_array($d_name) && (count($d_name) > 1)) { + $data['description'] = count($d_name).'x '.$d_name[0]; + } else { + $data['description'] = $data['model']; + } + } + unset($data); + $select_opt= $extension_list; + break; + case 'SDD': + $device_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("SccpDevice"); + $device_list[]=array('name' => 'NONE', 'description' => 'No Device'); + $select_opt = $device_list; + break; + } + ?> +
    +
    + +
    + + +
    +
    class . '" id="' . $res_id . '"'; + if (isset($child->options)) { + foreach ($child->options->attributes() as $optkey => $optval) { + echo ' '.$optkey.'="'.$optval.'"'; + } + } + echo '>'; + + $fld = (string)$child->select['name']; + $flv = (string)$child->select; + $flv2 = (string)$child->select['addlabel']; + $flk = (string)$child->select['dataid']; + $flkv = (string)$child->select['dataval']; + $key = (string)$child->default; + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + $key = $fvalues[$res_n]['data']; + } + } + + foreach ($select_opt as $data) { + echo ''; + } + + ?> + +
    +
    +
    +
    +
    + help);?> +
    +
    + name; + + // $res_value + $lnhtm = ''; + $res_id = $napref.$child->name; + $i = 0; + + if (!empty($fvalues[$res_na])) { + if (!empty($fvalues[$res_na]['data'])) { + $res_value = explode(';', $fvalues[$res_na]['data']); + } + } + if (empty($res_value)) { + $res_value = array((string) $child->default); + } + echo ""; + + foreach ($res_value as $dat_v) { + echo ' '; + if (!empty($child->label)) { + echo ''; + } + + $res_vf = explode('/', $dat_v); + $i2 = 0; + + foreach ($child->xpath('element') as $value) { + $fields_id = (string)strtolower($value['field']); + $res_n = $res_id.'['.$i.']['.$fields_id.']'; + $res_ni = $res_id.'_'.$i.'_'.$fields_id; + + $opt_at[$fields_id]['display_prefix']=(string)$value['display_prefix']; + $opt_at[$fields_id]['display_sufix']=(string)$value['display_sufix']; + + if (empty($value->options->class)) { + $opt_at[$fields_id]['options']['class']='form-control'; + } + $opt_at[$fields_id]['type']=(string)$value['type']; + $res_opt['addon'] =''; + if (isset($value->options)) { + foreach ($value->options ->attributes() as $optkey => $optval) { + $opt_at[$fields_id]['options'][$optkey]=(string)$optval; + $res_opt['addon'] .=' '.$optkey.'="'.$optval.'"'; + } + } + + echo ''; + $i2 ++; + } + echo ''; + $i++; + } + echo '
    '.$child->label.'
    '; + $res_opt['inp_st'] = '
    '.$opt_at[$fields_id]['display_prefix'].''; + $res_opt['inp_end'] = ''.$opt_at[$fields_id]['display_sufix'].'
    '; + switch ($value['type']) { + case 'date': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + case 'number': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + case 'input': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + case 'title': + if ($i > 0) { + break; + } + case 'label': + $opt_at[$fields_id]['data'] = (string)$value; + echo ''; + break; + case 'select': + echo $res_opt['inp_st'].''.$res_opt['inp_end']; + break; + } + echo '
    '; + if ($i > 0) { + echo ''; + } + + echo '
    '; + } + + function addElementHLP($child, $fvalues, $sccp_defaults,$npref) { + $res_n = (string)$child ->name; + $res_id = $npref.$res_n; + if (empty($child->class)) { + $child->class = 'form-control'; + } + ?> + +
    + +
    + xpath('element') as $value) { + switch ($value['type']) { + case 'p': + case 'h1': + case 'h2': + case 'h3': + case 'h4': + echo '<'.$value['type'].'>'._((string)$value).''; + break; + case 'table': + echo '<'.$value['type'].' class="table" >'; + foreach ($value->xpath('row') as $trow) { + echo ''; + foreach ($trow->xpath('col') as $tcol) { + echo ''._((string)$tcol).''; + } + echo ''; + } + echo ''; + break; + } + } + ?> +
    +
    + name; + $res_id = $npref.$res_n; + $child->value =''; + + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metaInfo[$res_n]; + } + } + + if (empty($child->class)) { + $child->class = 'form-control'; + } + + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + } + } + + $child->value = \date_default_timezone_get(); + ?> +
    +
    +
    +
    + + +
    +
    value; + ?> +
    +
    +
    +
    + help);?> +
    +
    + diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index 4f3df26..1ae0e60 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -18,970 +18,6 @@ * Help elemen HLP - Help Element */ - -// Execution continues at end of file after the class definition. Anonymous class -// instantiated to allow function grouping into discrete methods, and avoid multiple includes. -$thisSccpView = new class{ - public function __construct($parent_class = null) { - - } - - function addElementIE ($child, $fvalues, $sccp_defaults, $npref) { - $res_input = ''; - $res_name = ''; - $usingSysDefaults = true; - // if there are multiple inputs, take the first for res_id and shortId - $shortId = (string)$child->input[0]->name; - $res_id = $npref.$shortId; - if (!empty($metainfo[$shortId])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$shortId]; - } - } - - // --- Add Hidden option - $res_sec_class =''; - if (!empty($child ->class)) { - $res_sec_class = (string)$child ->class; - } - if (empty($child->nameseparator)) { - $child->nameseparator = ' / '; - } - $i = 0; - ?> -
    -
    -
    -
    - - -
    -
    - xpath('input') as $value) { - $res_n = (string)$value->name; - $res_name = $npref . $res_n; - //if (!empty($fvalues[$res_n])) { - $value->value = $fvalues[$res_n]['data']; - if (!empty($fvalues[$res_n]['data'])) { - if (!empty($sccp_defaults[$res_n]['systemdefault']) && ($sccp_defaults[$res_n]['systemdefault'] != $fvalues[$res_n]['data'])) { - $usingSysDefaults = false; - } - } - //} - // Default to chan-sccp defaults, not xml defaults. - //if (empty($value->value)) { - //$value->value = $sccp_defaults[$res_n]['systemdefault']; - //} - if (empty($value->type)) { - $value->type = 'text'; - } - if (empty($value->class)) { - $value->class = 'form-control'; - } - if ($i > 0) { - echo $child->nameseparator; - } - // Output current value - if (empty($value->value)) { - echo "Value not found for {$res_n}"; - } - echo $value->value; - $i ++; - } - ?> -
    -
    - - - > - - - -
    -
    -
    - -
    -
    - help);?> -
    -
    -
    - name; - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - // $res_value - $lnhtm = ''; - $res_id = $napref.$child->name; - $i = 0; - $max_row = 255; - if (!empty($child->max_row)) { - $max_row = $child->max_row; - } - - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $res_value = explode(';', $fvalues[$res_n]['data']); - } - } - if (empty($res_value)) { - $res_value = array((string) $child->default); - // $res_value = explode('/', (string) $child->default); - } - ?> -
    -
    -
    -
    -
    -
    - - -
    - -
    - cbutton)) { - echo '
    '; - foreach ($child->xpath('cbutton') as $value) { - $res_n = $res_id.'[0]['.$value['field'].']'; - $res_vf = ''; - if ($value['value']=='NONE' && empty($res_value)) { - $res_vf = 'active'; - } - $ch_key = array_search($value['value'], $res_value); - if ($ch_key !== false) { - unset($res_value[$ch_key]); - $res_vf = 'active'; - $res_value = explode(';', implode(';', $res_value)); - } - $opt_hide =''; - $opt_class="button-checkbox"; - if (!empty($value->option_hide)) { - $opt_class .= " sccp_button_hide"; - $opt_hide = ' data-vhide="'.$value->option_hide.'" data-btn="checkbox" data-clhide="'.$value->option_hide['class'].'" '; - } - if (!empty($child->option_show)) { - if (empty($opt_hide)) { - $opt_hide =' class="sccp_button_hide" '; - } - $opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" '; - } - - if (!empty($value->option_disabled)) { - $opt_class .= " sccp_button_disabled"; - $opt_hide = ' data-vhide="'.$value->option_disabled.'" data-btn="checkbox" data-clhide="'.$value->option_disabled['class'].'" '; - } - - if (!empty($value->class)) { - $opt_class .= " ".(string)$value->class; - } - - echo ''; - } - echo '
    '; - } - $opt_class = "col-sm-7 ".$res_id."-gr"; - if (!empty($child->class)) { - $opt_class .= " ".(string)$child->class; - } - echo '
    '; - - foreach ($res_value as $dat_v) { - ?> -
    > - xpath('input') as $value) { - $res_n = $res_id.'['.$i.']['.$value['field'].']'; - $fields_id = (string)$value['field']; - $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; - if (!empty($value->class)) { - $opt_at[$fields_id]['class']='form-control ' .(string)$value->class; - } - $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; - - echo 'options)) { - foreach ($value->options ->attributes() as $optkey => $optval) { - $opt_at[$fields_id]['options'][$optkey]=(string)$optval; - echo ' '.$optkey.'="'.$optval.'"'; - } - } - echo '> '.(string)$value['nameseparator'].' '; - $i2 ++; - } - if (!empty($child->add_pluss)) { - echo ''; - } - echo '
    '; - $i++; - } - ?> -
    - addbutton)) { - echo '
    '; - echo ''; - echo '
    '; - } - ?> -
    -
    -
    -
    -
    -
    - help);?> -
    -
    - name; - $res_id = $npref.$res_n; - $res_ext = str_replace($npref,'',$res_n); - $usingSysDefaults = true; - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - - // --- Add Hidden option - $res_sec_class =''; - if (!empty($child ->class)) { - $res_sec_class = (string)$child ->class; - } - ?> -
    -
    -
    -
    - - -
    - - default)) { - $res_v = (string)$child->default; - } - if (!empty($child->value)) { - $res_v = (string)$child->value; - } - if (!empty($fvalues[$res_n])) { - if (($fvalues[$res_n]['data'] != '') ) { - $res_v = (string)$fvalues[$res_n]['data']; - } - } - if (!empty($sccp_defaults[$res_n]['systemdefault'])) { - // There is a system default, so add button to customise or reset - // the closing } is after the code to include the button at line ~498 - - //-- Start include of defaults button -- - echo "
    "; - - if (!empty($sccp_defaults[$res_n]['systemdefault']) && ($sccp_defaults[$res_n]['systemdefault'] != $res_v)) { - $usingSysDefaults = false; - } - - // Output current value - // TODO: This is debug code and needs to be set to only echo res_v - echo $res_v . $res_n . $sccp_defaults[$res_n]['systemdefault'] . $usingSysDefaults; - ?> -
    -
    - - - > - - -
    -
    -
    - - -
    - help);?> -
    -
    - - name; - $res_id = $npref.$res_n; - // $select_opt is a simple array for these types. - $select_opt = array(); - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - if (empty($child->class)) { - $child->class = 'form-control'; - } - switch ($child['type']) { - case 'SLD': - $day_format = array("D.M.Y", "D.M.YA", "Y.M.D", "YA.M.D", "M-D-Y", "M-D-YA", "D-M-Y", "D-M-YA", "Y-M-D", "YA-M-D", "M/D/Y", "M/D/YA", - "D/M/Y", "D/M/YA", "Y/M/D", "YA/M/D", "M/D/Y", "M/D/YA"); - $select_opt= $day_format; - break; - case 'SLM': - if (function_exists('music_list')) { - $moh_list = music_list(); - } - if (!is_array($moh_list)) { - $moh_list = array('default'); - } - $select_opt= $moh_list; - break; - case 'SLK': - $softKeyList = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets(); - $select_opt= $softKeyList; - break; - case 'SLP': - $dialplan_list = array(); - foreach (\FreePBX::Sccp_manager()->getDialPlanList() as $tmpkey) { - $tmp_id = $tmpkey['id']; - $dialplan_list[$tmp_id] = $tmp_id; - } - $select_opt= $dialplan_list; - break; - } - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - } - } - ?> -
    -
    -
    - - -
    -
    - class . '" id="' . $res_id . '">'; - - foreach ($select_opt as $key) { - echo ''; - } - ?> - -
    -
    -
    -
    -
    - help);?> -
    -
    -
    - name; - $res_id = $npref.$res_n; - $child->value =''; - // $select_opt is an associative array for these types. - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - switch ($child['type']) { - case 'SLS': - if (\FreePBX::Modules()->checkStatus("soundlang")) { - $syslangs = \FreePBX::Soundlang()->getLanguages(); - if (!is_array($syslangs)) { - $syslangs = array(); - } - } - $select_opt= $syslangs; - break; - case 'SLT': - $select_opt= $tftp_lang; - break; - case 'SLZ': - $timeZoneOffsetList = array('-12' => 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9', - '-08' => 'GMT -8', '-07' => 'GMT -7', '-06' => 'GMT -6', '-05' => 'GMT -5', - '-04' => 'GMT -4', '-03' => 'GMT -3', '-02' => 'GMT -2', '-01' => 'GMT -1', - '00' => 'GMT', '01' => 'GMT +1', '02' => 'GMT +2', '03' => 'GMT +3', - '04' => 'GMT +4', '05' => 'GMT +5', '06' => 'GMT +6', '07' => 'GMT +7', - '08' => 'GMT +8', '09' => 'GMT +9', '10' => 'GMT +10', '11'=> 'GMT +11', '12' => 'GMT +12'); - $select_opt= $timeZoneOffsetList; - break; - case 'SLA': - $select_opt =''; - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $res_value = explode(';', $fvalues[$res_n]['data']); - } - if (empty($res_value)) { - $res_value = array((string) $child->default); - } - foreach ($res_value as $key) { - $select_opt[$key]= $key; - } - } - case 'SLM': - if (function_exists('music_list')) { - $moh_list = music_list(); - } - if (!is_array($moh_list)) { - $moh_list = array('default'); - } - $select_opt= $moh_list; - break; - case 'SLD': - $day_format = array("D.M.Y", "D.M.YA", "Y.M.D", "YA.M.D", "M-D-Y", "M-D-YA", "D-M-Y", "D-M-YA", "Y-M-D", "YA-M-D", "M/D/Y", "M/D/YA", - "D/M/Y", "D/M/YA", "Y/M/D", "YA/M/D", "M/D/Y", "M/D/YA"); - $select_opt= $day_format; - break; - case 'SLK': - $softKeyList = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets(); - $select_opt= $softKeyList; - break; - case 'SLP': - $dialplan_list = array(); - foreach (\FreePBX::Sccp_manager()->getDialPlanList() as $tmpkey) { - $tmp_id = $tmpkey['id']; - $dialplan_list[$tmp_id] = $tmp_id; - } - $select_opt= $dialplan_list; - break; - case 'SL': - $select_opt = array(); - break; - } - if (empty($child->class)) { - $child->class = 'form-control'; - } - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - } - } - if (empty($child->value)) { - if (!empty($child->default)) { - $child->value = $child->default; - } - } - ?> -
    -
    -
    - - -
    -
    - class . '" id="' . $res_id . '">'; - foreach ($select_opt as $key => $val) { - if (is_array($val)) { - $opt_key = (isset($val['id'])) ? $val['id'] : $key; - $opt_val = (isset($val['val'])) ? $val['val'] : $val; - } else if (\FreePBX::Sccp_manager()->is_assoc($select_opt)){ - // have associative array - $opt_key = $key; - $opt_val = $val; - } else { - // Have simple array - $opt_key = $val; - $opt_val = $val; - } - echo ''; - } - ?> -
    -
    -
    -
    -
    - help);?> -
    -
    - name; - $res_id = $npref.$res_n; - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - - if (empty($child->class)) { - $child->class = 'form-control'; - } - switch ($child['type']) { - case 'SDM': - $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWDevice"); - $select_opt= $model_list; - break; - case 'SDMS': - $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWSipDevice"); - $select_opt= $model_list; - break; - case 'SDE': - $extension_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWextension"); - $extension_list[]=array( 'model' => 'NONE', 'vendor' => 'CISCO', 'dns' => '0'); - foreach ($extension_list as &$data) { - $d_name = explode(';', $data['model']); - if (is_array($d_name) && (count($d_name) > 1)) { - $data['description'] = count($d_name).'x '.$d_name[0]; - } else { - $data['description'] = $data['model']; - } - } - unset($data); - $select_opt= $extension_list; - break; - case 'SDD': - $device_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("SccpDevice"); - $device_list[]=array('name' => 'NONE', 'description' => 'No Device'); - $select_opt = $device_list; - break; - } - ?> -
    -
    - -
    - - -
    -
    class . '" id="' . $res_id . '"'; - if (isset($child->options)) { - foreach ($child->options->attributes() as $optkey => $optval) { - echo ' '.$optkey.'="'.$optval.'"'; - } - } - echo '>'; - - $fld = (string)$child->select['name']; - $flv = (string)$child->select; - $flv2 = (string)$child->select['addlabel']; - $flk = (string)$child->select['dataid']; - $flkv = (string)$child->select['dataval']; - $key = (string)$child->default; - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - $key = $fvalues[$res_n]['data']; - } - } - - foreach ($select_opt as $data) { - echo ''; - } - - ?> - -
    -
    -
    -
    -
    - help);?> -
    -
    - name; - - // $res_value - $lnhtm = ''; - $res_id = $napref.$child->name; - $i = 0; - - if (!empty($fvalues[$res_na])) { - if (!empty($fvalues[$res_na]['data'])) { - $res_value = explode(';', $fvalues[$res_na]['data']); - } - } - if (empty($res_value)) { - $res_value = array((string) $child->default); - } - echo ""; - - foreach ($res_value as $dat_v) { - echo ' '; - if (!empty($child->label)) { - echo ''; - } - - $res_vf = explode('/', $dat_v); - $i2 = 0; - - foreach ($child->xpath('element') as $value) { - $fields_id = (string)strtolower($value['field']); - $res_n = $res_id.'['.$i.']['.$fields_id.']'; - $res_ni = $res_id.'_'.$i.'_'.$fields_id; - - $opt_at[$fields_id]['display_prefix']=(string)$value['display_prefix']; - $opt_at[$fields_id]['display_sufix']=(string)$value['display_sufix']; - - if (empty($value->options->class)) { - $opt_at[$fields_id]['options']['class']='form-control'; - } - $opt_at[$fields_id]['type']=(string)$value['type']; - $res_opt['addon'] =''; - if (isset($value->options)) { - foreach ($value->options ->attributes() as $optkey => $optval) { - $opt_at[$fields_id]['options'][$optkey]=(string)$optval; - $res_opt['addon'] .=' '.$optkey.'="'.$optval.'"'; - } - } - - echo ''; - $i2 ++; - } - echo ''; - $i++; - } - echo '
    '.$child->label.'
    '; - $res_opt['inp_st'] = '
    '.$opt_at[$fields_id]['display_prefix'].''; - $res_opt['inp_end'] = ''.$opt_at[$fields_id]['display_sufix'].'
    '; - switch ($value['type']) { - case 'date': - echo $res_opt['inp_st'].''.$res_opt['inp_end']; - break; - case 'number': - echo $res_opt['inp_st'].''.$res_opt['inp_end']; - break; - case 'input': - echo $res_opt['inp_st'].''.$res_opt['inp_end']; - break; - case 'title': - if ($i > 0) { - break; - } - case 'label': - $opt_at[$fields_id]['data'] = (string)$value; - echo ''; - break; - case 'select': - echo $res_opt['inp_st'].''.$res_opt['inp_end']; - break; - } - echo '
    '; - if ($i > 0) { - echo ''; - } - - echo '
    '; - } - - function addElementHLP($child, $fvalues, $sccp_defaults,$npref) { - $res_n = (string)$child ->name; - $res_id = $npref.$res_n; - if (empty($child->class)) { - $child->class = 'form-control'; - } - ?> - -
    -
    -

    label);?> -

    -
    -
    - xpath('element') as $value) { - switch ($value['type']) { - case 'p': - case 'h1': - case 'h2': - case 'h3': - case 'h4': - echo '<'.$value['type'].'>'._((string)$value).''; - break; - case 'table': - echo '<'.$value['type'].' class="table" >'; - foreach ($value->xpath('row') as $trow) { - echo ''; - foreach ($trow->xpath('col') as $tcol) { - echo ''._((string)$tcol).''; - } - echo ''; - } - echo ''; - break; - } - } - ?> -
    -
    - name; - $res_id = $npref.$res_n; - $child->value =''; - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - - if (empty($child->class)) { - $child->class = 'form-control'; - } - - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - } - } - - $child->value = \date_default_timezone_get(); - ?> -
    -
    -
    -
    - - -
    -
    value; - ?> -
    -
    -
    -
    - help);?> -
    -
    - meta_help = '1'; // Remove comments to see chan-sccp supplied help ! switch ($child['type']) { case 'IE': - $thisSccpView->addElementIE($child, $fvalues, $sccp_defaults,$npref); + \FreePbx::sccp_manager()->formcreate->addElementIE($child, $fvalues, $sccp_defaults,$npref); break; case 'IED': - $thisSccpView->addElementIED($child, $fvalues, $sccp_defaults,$npref, $napref); + \FreePbx::sccp_manager()->formcreate->addElementIED($child, $fvalues, $sccp_defaults,$npref, $napref); break; case 'IS': - $thisSccpView->addElementIS($child, $fvalues, $sccp_defaults,$npref); + \FreePbx::sccp_manager()->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref); break; case 'SLD': case 'SLM': case 'SLK': case 'SLP': - //$thisSccpView->addElementSL($child, $fvalues, $sccp_defaults,$npref); + //$this->formcreate->addElementSL($child, $fvalues, $sccp_defaults,$npref); //break; case 'SLS': case 'SLT': case 'SLA': case 'SLZ': case 'SL': - $thisSccpView->addElementSL2($child, $fvalues, $sccp_defaults,$npref); + \FreePbx::sccp_manager()->formcreate->addElementSL2($child, $fvalues, $sccp_defaults,$npref); break; case 'SDM': case 'SDMS': case 'SDE': case 'SDD': - $thisSccpView->addElementSD($child, $fvalues, $sccp_defaults,$npref); + \FreePbx::sccp_manager()->formcreate->addElementSD($child, $fvalues, $sccp_defaults,$npref); break; case 'ITED': - $thisSccpView->addElementITED($child, $fvalues, $sccp_defaults, $npref, $napref); + \FreePbx::sccp_manager()->formcreate->addElementITED($child, $fvalues, $sccp_defaults, $npref, $napref); break; case 'HLP': - $thisSccpView->addElementHLP($child, $fvalues, $sccp_defaults,$npref); + \FreePbx::sccp_manager()->formcreate->addElementHLP($child, $fvalues, $sccp_defaults,$npref); break; case 'SLTZN': - $thisSccpView->addElementSLTZN($child, $fvalues, $sccp_defaults,$npref); + \FreePbx::sccp_manager()->formcreate->addElementSLTZN($child, $fvalues, $sccp_defaults,$npref); break; } echo ""; From 71fef35ebd0e80d93a7ccbf33e35233b9816e7be Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 10 Jul 2021 10:45:42 +0200 Subject: [PATCH 087/181] Finalise FormShowSysDefs Remove debug conditionals in Sccp_manager Pass missing arguments for tftpLang Remove unused items from sccpgeneral.xml --- Sccp_manager.class.php | 41 +- conf/sccpgeneral.xml.v433 | 12 +- sccpManClasses/formcreate.class.php | 27 +- views/formShow.php | 981 ---------------------------- views/formShowSysDefs.php | 5 +- 5 files changed, 32 insertions(+), 1034 deletions(-) delete mode 100644 views/formShow.php diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 708e4d8..e864608 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -168,37 +168,16 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group[@name="' . $group_name . '"]') as $item) { - // TODO: Clean up below after debug - if (($group_name == 'sccp_general') || ($group_name == 'sccp_qos_config') || - ($group_name =='sccp_dev_config') || ($group_name =='sccp_dev_group_config') || - ($group_name =='sccp_hotline_config') || ($group_name =='sccp_dev_softkey') || - ($group_name =='sccp_dev_advconfig') || ($group_name == 'sccp_extpath_config') || - ($group_name =='sccp_dev_vendor_conf') || ($group_name =='sccp_hw_dev_softkey') || - ($group_name =='sccp_hw_dev_advance') || ($group_name =='sccp_hw_dev_conference') || - ($group_name =='sccp_hw_dev_network') || ($group_name == 'sccp_hw_dev_edit') + $htmlret = load_view(__DIR__ . '/views/formShowSysDefs.php', array( + 'itm' => $item, + 'h_show' => $show_Header, + 'form_prefix' => $form_prefix, + 'fvalues' => $form_values, + 'tftpLang' => $this->tftpLang, + 'chanSccpHelp' => $this->sccpHelpInfo, + 'sccp_defaults' => $this->sccpvalues ) - { - $htmlret = load_view(__DIR__ . '/views/formShowSysDefs.php', array( - 'itm' => $item, - 'h_show' => $show_Header, - 'form_prefix' => $form_prefix, - 'fvalues' => $form_values, - 'tftp_lang' => $this->tftpLang, - 'chanSccpHelp' => $this->sccpHelpInfo, - 'sccp_defaults' => $this->sccpvalues - )); - } else { - $htmlret = load_view(__DIR__ . '/views/formShow.php', array( - 'itm' => $item, - 'h_show' => $show_Header, - 'form_prefix' => $form_prefix, - 'fvalues' => $form_values, - 'tftp_lang' => $this->tftpLang, - 'chanSccpHelp' => $this->sccpHelpInfo, - 'sccp_defaults' => $this->sccpvalues - ) - ); - } + ); } } else { $htmlret = load_view(__DIR__ . '/views/formShowError.php'); @@ -775,7 +754,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { private function initTftpLang() { $result = array(); if (empty($this->sccppath["tftp_path"]) || empty($this->sccppath["tftp_lang_path"])) { - return; + return $result; } $dir = $this->sccppath["tftp_lang_path"]; diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 50a11af..b96617c 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1278,16 +1278,6 @@ and open the template in the editor. Base Version before all crash :-) The MAC address of the phone
    - - - type - 7911 - - - hw_select sccp-custom - The type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. - - @@ -1346,7 +1336,7 @@ and open the template in the editor. Base Version before all crash :-) devlang - Russian_Russia + English_United_States The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index 190910b..c8cca0f 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -43,8 +43,14 @@ class formcreate -
    "; + // Can have multiple inputs for a field which are displayed with a separator foreach ($child->xpath('input') as $value) { $res_n = (string)$value->name; @@ -114,6 +120,13 @@ class formcreate
    buttonHelpLabel} value for {$shortId}"; ?>
    + + + +
    "; + echo "
    "; if (!empty($sccp_defaults[$res_n]['systemdefault']) && ($sccp_defaults[$res_n]['systemdefault'] != $res_v)) { $usingSysDefaults = false; @@ -549,7 +562,7 @@ class formcreate name; $res_id = $npref.$res_n; @@ -562,16 +575,14 @@ class formcreate } switch ($child['type']) { case 'SLS': + $syslangs = array(); if (\FreePBX::Modules()->checkStatus("soundlang")) { $syslangs = \FreePBX::Soundlang()->getLanguages(); - if (!is_array($syslangs)) { - $syslangs = array(); - } } $select_opt= $syslangs; break; case 'SLT': - $select_opt= $tftp_lang; + $select_opt= $tftpLang; break; case 'SLZ': $timeZoneOffsetList = array('-12' => 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9', @@ -610,6 +621,7 @@ class formcreate $select_opt= $day_format; break; case 'SLK': + $softKeyList = array(); $softKeyList = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets(); $select_opt= $softKeyList; break; @@ -648,6 +660,7 @@ class formcreate
    class . '" id="' . $res_id . '">'; + dbug('', $res_id); foreach ($select_opt as $key => $val) { if (is_array($val)) { $opt_key = (isset($val['id'])) ? $val['id'] : $key; diff --git a/views/formShow.php b/views/formShow.php deleted file mode 100644 index ed6288c..0000000 --- a/views/formShow.php +++ /dev/null @@ -1,981 +0,0 @@ - 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9', - '-08' => 'GMT -8', '-07' => 'GMT -7', '-06' => 'GMT -6', '-05' => 'GMT -5', - '-04' => 'GMT -4', '-03' => 'GMT -3', '-02' => 'GMT -2', '-01' => 'GMT -1', - '00' => 'GMT', '01' => 'GMT +1', '02' => 'GMT +2', '03' => 'GMT +3', - '04' => 'GMT +4', '05' => 'GMT +5', '06' => 'GMT +6', '07' => 'GMT +7', - '08' => 'GMT +8', '09' => 'GMT +9', '10' => 'GMT +10', '11'=> 'GMT +11', '12' => 'GMT +12'); - -$extension_list = array(); -$sofkey_list = array(); -$model_list = array(); -$device_list = array(); -$dialplan_list = array(); - -if (\FreePBX::Modules()->checkStatus("soundlang")) { - $syslangs = \FreePBX::Soundlang()->getLanguages(); - if (!is_array($syslangs)) { - $syslangs = array(); - } -} -if (function_exists('music_list')) { - $moh_list = music_list(); -// $cur = (isset($mohsilence) && $mohsilence != "" ? $mohsilence : 'default'); -} -if (!is_array($moh_list)) { - $moh_list = array('default'); -} -if (empty($fvalues)) { - $fvalues = $sccp_defaults; -} - -$items = $itm -> children(); - -if ($h_show==1) { - $sec_class =''; - if (!empty($items ->class)) { - $sec_class = (string)$items ->class; - } - ?> - -
    -

    label) ?>

    -
    -
    - - help)) { - $child->help = 'Help is not available.'; - $child->meta_help = '1'; - } -// $child->meta_help = '1'; // Remove comments to see original help ! - - if ($child['type'] == 'IE') { - $res_input = ''; - $res_name = ''; - $shortID = (string)$child->input[0]->name; - $res_id = $npref.$shortID; - if (!empty($metainfo[$shortID])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metainfo[$shortID]; - } - } - - // --- Add Hiden option - $res_sec_class =''; - if (!empty($child ->class)) { - $res_sec_class = (string)$child ->class; - } - - if (empty($child->nameseparator)) { - $child->nameseparator = ' / '; - } - $i = 0; - - echo ''; - - ?> -
    -
    -
    - - -
    -
    - xpath('input') as $value) { - $res_n = (string)$value->name; - $res_name = $npref . $res_n; - if (empty($res_id)) { - $res_id = $res_name; - } - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $value->value = $fvalues[$res_n]['data']; - } - } - - if (empty($value->value)) { - $value->value = $value->default; - } - if (empty($value->type)) { - $value->type = 'text'; - } - if (empty($value->class)) { - $value->class = 'form-control'; - } - if ($i > 0) { - echo $child->nameseparator; - } -// - echo 'options)) { - foreach ($value->options ->attributes() as $optkey => $optval) { - echo ' '.$optkey.'="'.$optval.'"'; - } - } - if (!empty($value->min)) { - echo ' min="'.$value->min.'"'; - } - if (!empty($value->max)) { - echo ' max="'.$value->max.'"'; - } - echo '>'; - $i ++; - } - ?> -
    -
    -
    - help);?> -
    -
    - - label.' -->'; - } - if ($child['type'] == 'IED') { - $res_input = ''; - $res_value = ''; - $opt_at = array(); - $res_n = (string)$child->name; - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } -// $res_value - $lnhtm = ''; - $res_id = $napref.$child->name; - $i = 0; - $max_row = 255; - if (!empty($child->max_row)) { - $max_row = $child->max_row; - } - - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $res_value = explode(';', $fvalues[$res_n]['data']); - } - } - if (empty($res_value)) { - $res_value = array((string) $child->default); -// $res_value = explode('/', (string) $child->default); - } - - echo ''; - ?> -
    -
    -
    -
    -
    -
    - - -
    - -
    - cbutton)) { - echo '
    '; - foreach ($child->xpath('cbutton') as $value) { - $res_n = $res_id.'[0]['.$value['field'].']'; - $res_vf = ''; - if ($value['value']=='NONE' && empty($res_value)) { - $res_vf = 'active'; - } - $ch_key = array_search($value['value'], $res_value); - if ($ch_key !== false) { - unset($res_value[$ch_key]); - $res_vf = 'active'; - $res_value = explode(';', implode(';', $res_value)); - } - $opt_hide =''; - $opt_class="button-checkbox"; - if (!empty($value->option_hide)) { - $opt_class .= " sccp_button_hide"; - $opt_hide = ' data-vhide="'.$value->option_hide.'" data-btn="checkbox" data-clhide="'.$value->option_hide['class'].'" '; - } - if (!empty($child->option_show)) { - if (empty($opt_hide)) { - $opt_hide =' class="sccp_button_hide" '; - } - $opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" '; - } - - if (!empty($value->option_disabled)) { - $opt_class .= " sccp_button_disabled"; - $opt_hide = ' data-vhide="'.$value->option_disabled.'" data-btn="checkbox" data-clhide="'.$value->option_disabled['class'].'" '; - } - - if (!empty($value->class)) { - $opt_class .= " ".(string)$value->class; - } - - echo ''; - } - echo '
    '; - } - $opt_class = "col-sm-7 ".$res_id."-gr"; - if (!empty($child->class)) { - $opt_class .= " ".(string)$child->class; - } - echo '
    '; - - foreach ($res_value as $dat_v) { - ?> -
    > - xpath('input') as $value) { - $res_n = $res_id.'['.$i.']['.$value['field'].']'; - $fields_id = (string)$value['field']; - $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; - if (!empty($value->class)) { - $opt_at[$fields_id]['class']='form-control ' .(string)$value->class; - } - $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; - - echo 'options)) { - foreach ($value->options ->attributes() as $optkey => $optval) { - $opt_at[$fields_id]['options'][$optkey]=(string)$optval; - echo ' '.$optkey.'="'.$optval.'"'; - } - } - echo '> '.(string)$value['nameseparator'].' '; - $i2 ++; - } - if (!empty($child->add_pluss)) { - echo ''; - } - echo '
    '; - $i++; - } - ?> - -
    - addbutton)) { - echo '
    '; - echo ''; - echo '
    '; - } - ?> -
    -
    -
    -
    -
    -
    - help);?> -
    -
    - label.' -->'; - } - - if ($child['type'] == 'IS') { - $res_n = (string)$child->name; - $res_id = $npref.$res_n; - $res_ext = str_replace($npref,'',$res_n); - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - - // --- Add Hiden option - $res_sec_class =''; - if (!empty($child ->class)) { - $res_sec_class = (string)$child ->class; - } - - echo ''; - ?> -
    -
    -
    - - -
    -
    - default)) { - $res_v = (string)$child->default; - } - if (!empty($child->value)) { - $res_v = (string)$child->value; - } - if (!empty($fvalues[$res_n])) { - if (($fvalues[$res_n]['data'] != '') ) { - $res_v = (string)$fvalues[$res_n]['data']; - } - } - if (!empty($child->option_hide)) { - $opt_hide = ' class="sccp_button_hide" data-vhide="'.$child->option_hide.'" data-clhide="'.$child->option_hide['class'].'" '; - } - if (!empty($child->option_show)) { - if (empty($opt_hide)) { - $opt_hide =' class="sccp_button_hide" '; - } - $opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" '; - } - foreach ($child->xpath('button') as $value) { - $val_check = strtolower((string)$value[@value]); - if ($val_check == strtolower($res_v)) { - $val_check = " checked"; - } else { - if ($val_check == '' || $val_check == 'none' ) { - if (strtolower($res_v) == 'none' || $res_v == '' ) { - $val_check = " checked"; - } else {$val_check = "";} - } else {$val_check = "";} - } - echo ''; - echo ''; - $i++; - } - ?> -
    -
    -
    - help);?> -
    -
    - - label.' -->'; - } - -/* - * Input element Select SLD - Date format - * SLZ - Time Zone - * - * SLM - Music on hold - * SLK - System KeySet - * SLP - Dial Paterns - */ - - if ($child['type'] == 'SLD' || $child['type'] == 'SLM'|| $child['type'] == 'SLK'|| $child['type'] == 'SLP') { -// $value = $child -> select; - $res_n = (string)$child ->name; - $res_id = $npref.$res_n; - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - - if (empty($child->class)) { - $child->class = 'form-control'; - } - - if ($child['type'] == 'SLD') { - $select_opt= $day_format; - } - - if ($child['type'] == 'SLM') { - $select_opt= $moh_list; - } - if ($child['type'] == 'SLK') { - if (empty($sofkey_list)) { - $sofkey_list = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets(); - } - $select_opt= $sofkey_list; - } - if ($child['type'] == 'SLP') { - if (empty($dialplan_list)) { - foreach (\FreePBX::Sccp_manager()->getDialPlanList() as $tmpkey) { - $tmp_id = $tmpkey['id']; - $dialplan_list[$tmp_id] = $tmp_id; - } - } - $select_opt= $dialplan_list; - } -// if ($child['type'] == 'SLZ') { -// $select_opt= $timeZoneOffsetList; -// } - - echo ''; - - ?> -
    -
    - -
    - - -
    -
    class . '" id="' . $res_id . '">'; - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - } - } - foreach ($select_opt as $key) { - echo ''; - } - ?> -
    -
    -
    - help);?> -
    -
    - label.' -->'; - } -/* - * Input element Select SLS - System Language - */ - - if ($child['type'] == 'SLS' || $child['type'] == 'SLT' || $child['type'] == 'SLA' || $child['type'] == 'SLZ') { -// $value = $child -> select; - $res_n = (string)$child ->name; - $res_id = $npref.$res_n; - $child->value =''; - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - - if ($child['type'] == 'SLS') { - $select_opt= $syslangs; - } - if ($child['type'] == 'SLT') { - $select_opt= $tftp_lang; - } - if ($child['type'] == 'SLZ') { - $select_opt= $timeZoneOffsetList; -// $child->value = ($system_time_zone[offset]/60); - } - - if ($child['type'] == 'SLA') { - $select_opt =''; - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $res_value = explode(';', $fvalues[$res_n]['data']); - } - if (empty($res_value)) { - $res_value = array((string) $child->default); - } - foreach ($res_value as $key) { - $select_opt[$key]= $key; - } - } - } - - if (empty($child->class)) { - $child->class = 'form-control'; - } - - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - } - } - - if (empty($child->value)) { - if (!empty($child->default)) { - $child->value = $child->default; - } - } - - echo ''; - ?> -
    -
    - -
    - - -
    -
    class . '" id="' . $res_id . '">'; - foreach ($select_opt as $key => $val) { - if (is_array($val)) { - $opt_key = (isset($val['id'])) ? $val['id'] : $key; - $opt_val = (isset($val['val'])) ? $val['val'] : $val; - } else { - $opt_key = $key; - $opt_val = $val; - } - echo ''; - } - ?> -
    -
    -
    - help);?> -
    -
    - - label.' -->'; - } -/* - * Input element Select - */ - - if ($child['type'] == 'SL') { - $res_n = (string)$child->name; - $res_id = $npref.$child->name; - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - - if (empty($child ->class)) { - $child->class = 'form-control'; - } - echo ''; - - ?> -
    -
    - -
    - - -
    -
    class . '" id="' . $res_id . '">'; - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - } - } - foreach ($child->xpath('select') as $value) { - if (!empty($value[@value])) { - $key = $value[@value]; - } else { - $key = (string)$value; - } - echo ''; - } - ?> - -
    -
    -
    - help);?> -
    -
    - label.' -->'; - } - - /* - * Input element Select SDM - Model List - * SDMS - Sip model List - * SDE - Extension List - */ - - if ($child['type'] == 'SDM' || $child['type'] == 'SDMS' || $child['type'] == 'SDE' || $child['type'] == 'SDD') { -// $value = $child -> select; - $res_n = (string)$child ->name; - $res_id = $npref.$res_n; - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - - if (empty($child->class)) { - $child->class = 'form-control'; - } - if ($child['type'] == 'SDM') { - if (empty($model_list)) { - $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWDevice"); - } - $select_opt= $model_list; - } - if ($child['type'] == 'SDMS') { - if (empty($model_list)) { - $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWSipDevice"); - } - $select_opt= $model_list; - } - if ($child['type'] == 'SDE') { - if (empty($extension_list)) { - $extension_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWextension"); - $extension_list[]=array( 'model' => 'NONE', 'vendor' => 'CISCO', 'dns' => '0'); - foreach ($extension_list as &$data) { - $d_name = explode(';', $data['model']); - if (is_array($d_name) && (count($d_name) > 1)) { - $data['description'] = count($d_name).'x '.$d_name[0]; - } else { - $data['description'] = $data['model']; - } - } - unset($data); - } - $select_opt= $extension_list; - } - if ($child['type'] == 'SDD') { - if (empty($device_list)) { - $device_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("SccpDevice"); - $device_list[]=array('name' => 'NONE', 'description' => 'No Device'); - } - $select_opt = $device_list; - } - - echo ''; - - ?> -
    -
    - -
    - - -
    -
    class . '" id="' . $res_id . '"'; - if (isset($child->options)) { - foreach ($child->options->attributes() as $optkey => $optval) { - echo ' '.$optkey.'="'.$optval.'"'; - } - } - echo '>'; - - $fld = (string)$child->select['name']; - $flv = (string)$child->select; - $flv2 = (string)$child->select['addlabel']; - $flk = (string)$child->select['dataid']; - $flkv = (string)$child->select['dataval']; - $key = (string)$child->default; - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - $key = $fvalues[$res_n]['data']; - } - } - - foreach ($select_opt as $data) { - echo ''; - } - - ?> -
    -
    -
    - help);?> -
    -
    - label.' -->'; - } - if ($child['type'] == 'ITED') { - $res_input = ''; - $res_na = (string)$child->name; - -// $res_value - $lnhtm = ''; - $res_id = $napref.$child->name; - $i = 0; - - if (!empty($fvalues[$res_na])) { - if (!empty($fvalues[$res_na]['data'])) { - $res_value = explode(';', $fvalues[$res_na]['data']); - } - } - if (empty($res_value)) { - $res_value = array((string) $child->default); -// $res_value = explode('/', (string) $child->default); - } - - echo ''; - ?> - - - '; - if (!empty($child->label)) { - echo ''; - } - - $res_vf = explode('/', $dat_v); - $i2 = 0; - - foreach ($child->xpath('element') as $value) { - $fields_id = (string)strtolower($value['field']); - $res_n = $res_id.'['.$i.']['.$fields_id.']'; - $res_ni = $res_id.'_'.$i.'_'.$fields_id; - - $opt_at[$fields_id]['display_prefix']=(string)$value['display_prefix']; - $opt_at[$fields_id]['display_sufix']=(string)$value['display_sufix']; - - if (empty($value->options->class)) { - $opt_at[$fields_id]['options']['class']='form-control'; - } - $opt_at[$fields_id]['type']=(string)$value['type']; - $res_opt['addon'] =''; - if (isset($value->options)) { - foreach ($value->options ->attributes() as $optkey => $optval) { - $opt_at[$fields_id]['options'][$optkey]=(string)$optval; - $res_opt['addon'] .=' '.$optkey.'="'.$optval.'"'; - } - } - - echo ''; - $i2 ++; - } - echo ''; - $i++; - } - echo '
    '.$child->label.'
    '; - $res_opt['inp_st'] = '
    '.$opt_at[$fields_id]['display_prefix'].''; - $res_opt['inp_end'] = ''.$opt_at[$fields_id]['display_sufix'].'
    '; - switch ($value['type']) { - case 'date': - echo $res_opt['inp_st'].''.$res_opt['inp_end']; - break; - case 'number': - echo $res_opt['inp_st'].''.$res_opt['inp_end']; - break; - case 'input': - echo $res_opt['inp_st'].''.$res_opt['inp_end']; - break; - case 'title': - if ($i > 0) { - break; - } - case 'label': - $opt_at[$fields_id]['data'] = (string)$value; - echo ''; - break; - case 'select': - echo $res_opt['inp_st'].''.$res_opt['inp_end']; - break; - } - echo '
    '; - if ($i > 0) { - echo ''; - } - - echo '
    '; - echo ''; - } - - if ($child['type'] == 'HLP') { - $res_n = (string)$child ->name; - $res_id = $npref.$res_n; - if (empty($child->class)) { - $child->class = 'form-control'; - } - echo ''; - - ?> - -
    -
    -

    label);?> -

    -
    -
    - xpath('element') as $value) { - switch ($value['type']) { - case 'p': - case 'h1': - case 'h2': - case 'h3': - case 'h4': - echo '<'.$value['type'].'>'._((string)$value).''; - break; - case 'table': - echo '<'.$value['type'].' class="table" >'; - foreach ($value->xpath('row') as $trow) { - echo ''; - foreach ($trow->xpath('col') as $tcol) { - echo ''._((string)$tcol).''; - } - echo ''; - } - echo ''; - break; - } - } - ?> - -
    -
    - label.' -->'; - } - if ($child['type'] == 'MINFO') { - $res_n = (string)$child ->name; - $res_id = $npref.$res_n; - if (empty($child->class)) { - $child->class = 'form-control'; - } - echo ''; - ?> - - label.' -->'; - } -/* - * Input element Select SLTZN - System Time Zone - */ - - if ($child['type'] == 'SLTZN') { -// $value = $child -> select; - $res_n = (string)$child ->name; - $res_id = $npref.$res_n; - $child->value =''; - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - - if (empty($child->class)) { - $child->class = 'form-control'; - } - - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - } - } - - $child->value = \date_default_timezone_get(); - - echo ''; - ?> -
    -
    -
    -
    - - -
    -
    value; - ?> -
    -
    -
    -
    - help);?> -
    -
    - - label.' -->'; - } -} -?> -'; -} -?> diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index 1ae0e60..fa2245e 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -55,7 +55,6 @@ foreach ($items as $child) { $child->meta_help = '1'; } echo ""; -// $child->meta_help = '1'; // Remove comments to see chan-sccp supplied help ! switch ($child['type']) { case 'IE': \FreePbx::sccp_manager()->formcreate->addElementIE($child, $fvalues, $sccp_defaults,$npref); @@ -70,14 +69,12 @@ foreach ($items as $child) { case 'SLM': case 'SLK': case 'SLP': - //$this->formcreate->addElementSL($child, $fvalues, $sccp_defaults,$npref); - //break; case 'SLS': case 'SLT': case 'SLA': case 'SLZ': case 'SL': - \FreePbx::sccp_manager()->formcreate->addElementSL2($child, $fvalues, $sccp_defaults,$npref); + \FreePbx::sccp_manager()->formcreate->addElementSL2($child, $fvalues, $sccp_defaults,$npref, $tftpLang); break; case 'SDM': case 'SDMS': From 2a98d8cfdb3d75a18a29eca003ebd8b95d2c3340 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 10 Jul 2021 12:17:46 +0200 Subject: [PATCH 088/181] Override chan-sccp default context --- install.php | 8 ++++++-- views/hardware.phone.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/install.php b/install.php index 0f22f48..8eea9f1 100644 --- a/install.php +++ b/install.php @@ -998,16 +998,20 @@ function cleanUpSccpSettings() { unset($settingsFromDb[$valueArray['Name']]); } } else { + ($sysConfiguration[$valueArray['Name']]['DefaultValue'] == '(null)') ? '' : $sysConfiguration[$valueArray['Name']]['DefaultValue']; $sysConfiguration[$valueArray['Name']] = $valueArray; if (array_key_exists($valueArray['Name'],$settingsFromDb)) { if (!empty($sysConfiguration[$valueArray['Name']]['DefaultValue'])) { + // Preserve sequence and type $settingsFromDb[$valueArray['Name']]['systemdefault'] = $sysConfiguration[$valueArray['Name']]['DefaultValue']; } } else { - - $settingsFromDb[$valueArray['Name']] = array('keyword' => $valueArray['Name'], 'seq' => 0, 'type' => 0, 'data' => '', 'systemdefault' => $sysConfiguration[$valueArray['Name']]['DefaultValue']); + $settingsFromDb[$valueArray['Name']] = array('keyword' => $valueArray['Name'], 'seq' => 0, 'type' => 0, 'data' => '', 'systemdefault' => $sysConfiguration[$valueArray['Name']]['DefaultValue']); } } + // Override certain chan-sccp defaults as they are based on a non-FreePbx system + $settingsFromDb['context']['systemdefault'] = 'from-internal' + unset($sysConfiguration[$key]); } unset($sysConfiguration['Options']); diff --git a/views/hardware.phone.php b/views/hardware.phone.php index a18f259..562e30c 100644 --- a/views/hardware.phone.php +++ b/views/hardware.phone.php @@ -36,7 +36,7 @@ - + From 30cbe1ba95a171e3a9bcb3f4ae7a33c7a7f55b3e Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 10 Jul 2021 13:05:28 +0200 Subject: [PATCH 089/181] Correct output regex Supplied by and thanks to @vaDrn --- contrib/rewrite.rules | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/contrib/rewrite.rules b/contrib/rewrite.rules index 50d5815..f2c5a45 100644 --- a/contrib/rewrite.rules +++ b/contrib/rewrite.rules @@ -58,13 +58,13 @@ ri ^(P00405000700.sbn)$ firmware/7910/\1 ri ^(CP7912080004SCCP080108A.sbin)$ firmware/7912/\1 # 7915 firmware (ancient) -ri ^(B015-1-0-)(+\.SBN)$ firmware/7915/\1 +ri ^(B015-1-0-)(.+\.SBN)$ firmware/7915/\1\2 # 7916 firmware (ancient) -ri ^(B016-1-0-)(+\.SBN)$ firmware/7916/\1 +ri ^(B016-1-0-)(.+\.SBN)$ firmware/7916/\1\2 # 7920 firmware (ancient) -ri ^(cmterm_7920)(+\.bin)$ firmware/7920/\1 +ri ^(cmterm_7920)(.+\.bin)$ firmware/7920/\1\2 # 7921_7925 firmware (ancient) ri ^(APPS-1.4.3.4.SBN)$ firmware/7921/\1 @@ -106,10 +106,10 @@ ri ^(cmterm_7936.3-3-21-0.bin)$ firmware/7936/\1 ri ^(apps37sccp.1-4-5-7.bin)$ firmware/7937/\1 # 7940_7960 firmware (ancient) -ri ^(P0030801SR)(.+\.bin)$ firmware/7940/\1 -ri ^(P0030801SR)(.+\.loads)$ firmware/7940/\1 -ri ^(P0030801SR)(.+\.sb2)$ firmware/7940/\1 -ri ^(P0030801SR)(.+\.sbn)$ firmware/7940/\1 +ri ^(P0030801SR)(.+\.bin)$ firmware/7940/\1\2 +ri ^(P0030801SR)(.+\.loads)$ firmware/7940/\1\2 +ri ^(P0030801SR)(.+\.sb2)$ firmware/7940/\1\2 +ri ^(P0030801SR)(.+\.sbn)$ firmware/7940/\1\2 # 7941_7961 firmware (java-based) ri ^(apps41)(.+\.sbn)$ firmware/7941/\1\2 @@ -192,6 +192,7 @@ ri ^(.+)\/(.+-dictionary-ext.xml)$ languages/\1/\2 ri ^(.+)\/(.+-tones.xml)$ languages/\1/\2 ri ^(.+)\/(.+-font.xml)$ languages/\1/\2 ri ^(.+)\/(.+-kate.xml)$ languages/\1/\2 +ri ^(.+)\/(gk.+)(\.cfg)$ languages/\1/\2\3 #ri ^(.+)\/(.+-tones.xml)$ locales/countries/\1/\2 From 248abe6cb78526d32d9a6d09f73af92a861150f2 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 10 Jul 2021 17:51:55 +0200 Subject: [PATCH 090/181] Clean up and correct missing save settings Remove unnecessary method from formcreate Correct indentation in formcreate Remove debug code in Sccp.class correct logic for updating TFTP mode --- sccpManClasses/Sccp.class.php.v433 | 2 - sccpManClasses/extconfigs.class.php | 77 ++++++++------ sccpManClasses/formcreate.class.php | 150 +++++++--------------------- sccpManTraits/ajaxHelper.php | 10 +- views/formShowSysDefs.php | 2 +- 5 files changed, 87 insertions(+), 154 deletions(-) diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index e74f6a6..b06aa4d 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -216,7 +216,6 @@ class Sccp extends \FreePBX\modules\Core\Driver { } public function getDeviceDisplay($display, $deviceInfo, $currentComponent, $primarySection) { - dbug('',$primarySection); $activeCodecs = array(); // load xml data to get help from same source as rest of module $xml_vars = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v433'; @@ -321,7 +320,6 @@ class Sccp extends \FreePBX\modules\Core\Driver { ); break; case 'IS': - dbug('', $child); $select = array(); foreach ($child->xpath('button') as $value) { $select[] = array('value' => strtolower((string)$value[@value]), 'text' => (string)$value); diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 6e95fba..c07bbbb 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -249,27 +249,27 @@ class extconfigs 'languages' => 'languages', 'templates' => 'templates', 'dialplan' => 'dialplan', - 'softkey' => 'softkey' + 'softkey' => 'softkey', + 'ringtones' => 'ringtones', + 'wallpapers' => 'wallpapers' ); - - $adv_tree['pro'] = array('templates' => 'tftproot', - 'settings' => 'tftproot', - 'locales' => 'tftproot', - 'firmware' => 'tftproot', - 'languages' => 'locales', - 'dialplan' => 'tftproot', - 'softkey' => 'tftproot' - ); - - $adv_tree['def'] = array('templates' => 'tftproot', - 'settings' => '', - 'locales' => '', - 'firmware' => '', - 'languages' => 'tftproot', - 'dialplan' => '', - 'softkey' => '' - ); - + $adv_tree = array('pro' => array('templates' => 'tftproot', + 'settings' => 'tftproot', + 'locales' => 'tftproot', + 'firmware' => 'tftproot', + 'languages' => 'locales', + 'dialplan' => 'tftproot', + 'softkey' => 'tftproot' + ), + 'def' => array('templates' => 'tftproot', + 'settings' => '', + 'locales' => '', + 'firmware' => '', + 'languages' => 'tftproot', + 'dialplan' => '', + 'softkey' => '' + ) + ); $base_tree = array('tftp_templates_path' => 'templates', 'tftp_store_path' => 'settings', 'tftp_lang_path' => 'languages', @@ -277,18 +277,17 @@ class extconfigs 'tftp_dialplan_path' => 'dialplan', 'tftp_softkey_path' => 'softkey' ); - $base_config = array(); if (!empty($settingsFromDb['tftp_rewrite_path']['data'])) { - // Have a setting in sccpsettings. It should start with $tftpRootPath - // If not we will replace it with $tftpRootPath. Avoids issues with legacy values - if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$settingsFromDb['tftp_path']['data'])) { + // Have a setting in sccpsettings. It should start with $tftp_path + // If not we will replace it with $tftp_path. Avoids issues with legacy values + if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$settingsFromDb['tftp_path']['data'])) { - $adv_ini = "{$tftpRootPath}/index.cnf"; - $settingsToDb['tftp_rewrite_path'] = $settingsFromDb['tftp_rewrite_path']; - $settingsToDb['tftp_rewrite_path']['data'] = $tftpRootPath; - } + $adv_ini = "{$settingsFromDb['tftp_path']['data']}/index.cnf"; + $settingsToDb['tftp_rewrite_path'] = $settingsFromDb['tftp_rewrite_path']; + $settingsToDb['tftp_rewrite_path']['data'] = $settingsFromDb['tftp_path']['data']; + } $adv_ini = "{$settingsFromDb['tftp_rewrite_path']["data"]}/index.cnf"; } @@ -301,14 +300,14 @@ class extconfigs $adv_ini_array = parse_ini_file($adv_ini); $adv_config = array_merge($adv_config, $adv_ini_array); } + $settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'pro', 'systemdefault' => ''); break; case 'on': case 'internal': case 'off': - break; default: - // not defined so set here - $settingsToDb["tftp_rewrite"] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'off'); + // not defined so set here to off + $settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'off', 'systemdefault' => ''); } foreach ($adv_tree[$adv_tree_mode] as $key => $value) { @@ -322,10 +321,11 @@ class extconfigs } } } + foreach ($base_tree as $key => $value) { $base_config[$key] = $adv_config[$value]; // Save to sccpsettings - $settingsToDb[$key] =array( 'keyword' => $key, 'seq' => 20, 'type' => 0, 'data' => $adv_config[$value]); + $settingsToDb[$key] =array( 'keyword' => $key, 'seq' => 20, 'type' => 0, 'data' => $adv_config[$value], 'systemdefault' => ''); if (!is_dir($base_config[$key])) { if (!mkdir($base_config[$key], 0755, true)) { die_freepbx(_('Error creating dir : ' . $base_config[$key])); @@ -342,7 +342,18 @@ class extconfigs } // Remove keys that are not required before returning $base_config. unset($base_config['asterisk'], $base_config['sccp_conf'], $base_config['tftp_path']); - return $base_config; + return $settingsToDb; + } + private function initializeTFtpLanguagePath() { + $dir = $this->sccppath["tftp_lang_path"]; + foreach ($this->extconfigs->getExtConfig('sccp_lang') as $lang_key => $lang_value) { + $filename = $dir . DIRECTORY_SEPARATOR . $lang_value['locale']; + if (!file_exists($filename)) { + if (!mkdir($filename, 0777, true)) { + die('Error creating tftp language directory'); + } + } + } } public function validate_RealTime( $connector ) diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index c8cca0f..ee6d4c6 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -476,93 +476,7 @@ class formcreate name; - $res_id = $npref.$res_n; - // $select_opt is a simple array for these types. - $select_opt = array(); - - if (!empty($metainfo[$res_n])) { - if ($child->meta_help == '1' || $child->help == 'Help!') { - $child->help = $metaInfo[$res_n]; - } - } - if (empty($child->class)) { - $child->class = 'form-control'; - } - switch ($child['type']) { - case 'SLD': - $day_format = array("D.M.Y", "D.M.YA", "Y.M.D", "YA.M.D", "M-D-Y", "M-D-YA", "D-M-Y", "D-M-YA", "Y-M-D", "YA-M-D", "M/D/Y", "M/D/YA", - "D/M/Y", "D/M/YA", "Y/M/D", "YA/M/D", "M/D/Y", "M/D/YA"); - $select_opt= $day_format; - break; - case 'SLM': - if (function_exists('music_list')) { - $moh_list = music_list(); - } - if (!is_array($moh_list)) { - $moh_list = array('default'); - } - $select_opt= $moh_list; - break; - case 'SLK': - $softKeyList = \FreePBX::Sccp_manager()->aminterface->sccp_list_keysets(); - $select_opt= $softKeyList; - break; - case 'SLP': - $dialplan_list = array(); - foreach (\FreePBX::Sccp_manager()->getDialPlanList() as $tmpkey) { - $tmp_id = $tmpkey['id']; - $dialplan_list[$tmp_id] = $tmp_id; - } - $select_opt= $dialplan_list; - break; - } - if (!empty($fvalues[$res_n])) { - if (!empty($fvalues[$res_n]['data'])) { - $child->value = $fvalues[$res_n]['data']; - } - } - ?> -
    -
    -
    - - -
    -
    - class . '" id="' . $res_id . '">'; - - foreach ($select_opt as $key) { - echo ''; - } - ?> - -
    -
    -
    -
    -
    - help);?> -
    -
    -
    - name; $res_id = $npref.$res_n; @@ -652,42 +566,46 @@ class formcreate } ?>
    -
    -
    +
    +
    +
    -
    - +
    + class . '" id="' . $res_id . '">'; - dbug('', $res_id); - foreach ($select_opt as $key => $val) { - if (is_array($val)) { - $opt_key = (isset($val['id'])) ? $val['id'] : $key; - $opt_val = (isset($val['val'])) ? $val['val'] : $val; - } else if (\FreePBX::Sccp_manager()->is_assoc($select_opt)){ - // have associative array - $opt_key = $key; - $opt_val = $val; - } else { - // Have simple array - $opt_key = $val; - $opt_val = $val; - } - echo ''; - } - ?> + foreach ($select_opt as $key => $val) { + if (is_array($val)) { + $opt_key = (isset($val['id'])) ? $val['id'] : $key; + $opt_val = (isset($val['val'])) ? $val['val'] : $val; + } else if (\FreePBX::Sccp_manager()->is_assoc($select_opt)){ + // have associative array + $opt_key = $key; + $opt_val = $val; + } else { + // Have simple array + $opt_key = $val; + $opt_val = $val; + } + echo '"; + } + ?> + +
    -
    -
    -
    +
    +
    +
    help);?> -
    +
    +
    initializeTFtpLanguagePath(); } + foreach ($request as $key => $value) { // Originally saved all to sccpvalues. Now will save to db defaults if appropriate // TODO: Need to verify the tables defined in showGroup - some options maybe @@ -448,7 +449,7 @@ trait ajaxHelper { $key = (str_replace($hdr_prefix, '', $key, $count_mods)); if ($count_mods) { if (!empty($this->sccpvalues[$key]) && (!($this->sccpvalues[$key]['data'] == $value))) { - $save_settings[] = array( + $save_settings[$this->sccpvalues[$key]['keyword']] = array( 'keyword' => $this->sccpvalues[$key]['keyword'], 'data' => $value, 'seq' => $this->sccpvalues[$key]['seq'], @@ -457,7 +458,6 @@ trait ajaxHelper { ); } } - $key = (str_replace($hdr_arprefix, '', $key, $count_mods)); if ($count_mods) { $arr_data = ''; @@ -537,11 +537,14 @@ trait ajaxHelper { } } + $extSettings = $this->extconfigs->updateTftpStructure(array_merge($this->sccpvalues, $save_settings)); + $save_settings = array_merge($save_settings, $extSettings); if (!empty($save_settings)) { $this->saveSccpSettings($save_settings); $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); } + foreach ($dbSaveArray as $rowToSave) { $this->dbinterface->updateTableDefaults($rowToSave['table'], $rowToSave['field'], $rowToSave['Default']); } @@ -549,6 +552,9 @@ trait ajaxHelper { $this->createDefaultSccpConfig(); // Rewrite Config. $save_settings[] = array('status' => true); $this->createDefaultSccpXml(); + + + return $save_settings; } diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index fa2245e..be79ba1 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -74,7 +74,7 @@ foreach ($items as $child) { case 'SLA': case 'SLZ': case 'SL': - \FreePbx::sccp_manager()->formcreate->addElementSL2($child, $fvalues, $sccp_defaults,$npref, $tftpLang); + \FreePbx::sccp_manager()->formcreate->addElementSL($child, $fvalues, $sccp_defaults,$npref, $tftpLang); break; case 'SDM': case 'SDMS': From 5a184ededb6c149a33390e81ace2f2143d41654f Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 11 Jul 2021 16:52:24 +0200 Subject: [PATCH 091/181] Integrate Provision functionality into Sccp_Manager Create required directory structure Check if mapping support is enabled Check if mapping rules are defined Change options available based on above Create index.cnf and sccpManagerRewrite.rules --- Sccp_manager.class.php | 1 + conf/sccpgeneral.xml.v433 | 22 +++++++++-------- contrib/rewrite.rules | 8 +++++- contrib/tftp.xinetd | 2 +- install.php | 10 +++++--- sccpManClasses/extconfigs.class.php | 26 ++++++++++++++++++-- sccpManClasses/formcreate.class.php | 15 +++++++++++- sccpManTraits/helperFunctions.php | 34 ++++++++++++++++++++++++++ views/server.info.php | 38 +++++++++++++++++------------ views/server.setting.php | 1 - 10 files changed, 122 insertions(+), 35 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index e864608..1425643 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -205,6 +205,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ public function settingsShowPage() { + $this->checkTftpMapping(); $request = $_REQUEST; $action = !empty($request['action']) ? $request['action'] : ''; diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index b96617c..b837f35 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1163,9 +1163,9 @@ and open the template in the editor. Base Version before all crash :-) Help_tftp_rewrite This section is responsible for the modes of operation of external services: tftp http. - * off - Flat model cisco. All data is in the directory /tftproot - * Custom - The directory structure is strictly defined in the manager (for internal use). Requires tftpd rewrite support. - * Provision - Directory structure data is read from an external file. This project supports phones that can work on tftp and http. Support rewrite. + * off - Flat model cisco. All data is in the directory TFTP Server Path + * Provision - The directory structure is strictly defined in the manager. Requires tftpd mapping support. + * Custom - TFTP Directory structure can be extended by index.cnf. This supports phones that can work on tftp and http. Remapping support is required @@ -1173,7 +1173,7 @@ and open the template in the editor. Base Version before all crash :-) provision_hide tftp_path - /tftpboot + sccp-custom Path to tftp home directory. This was determined by the Sccp_manager installer and should only be changed if the tftp root has been modified since installation @@ -1188,16 +1188,18 @@ and open the template in the editor. Base Version before all crash :-) Use path from provision index.cnf file. You must first make sure that you have properly configured the "Provision" - + tftp_rewrite off - pro - pro - - Internal - + custom + custom + Custom + Provision + Off + + Support the use of regular-expression-based filename remapping diff --git a/contrib/rewrite.rules b/contrib/rewrite.rules index f2c5a45..fc635b8 100644 --- a/contrib/rewrite.rules +++ b/contrib/rewrite.rules @@ -1,5 +1,9 @@ # -# TFTPd Rewrite for SCCP_Manager Custom remaping +# TFTPd Rewrite for SCCP_Manager Custom remapping +# +# This file is maintained by Sccp_Manager, and will be overwritten by the installer +# a copy of the original can be found at sccpManagerRewrite.rules.bu +# # /firmware # /settings # /wallpapers @@ -174,6 +178,8 @@ ri ^(ATA030204SCCP090202A.zup)$ firmware/ata186/\1 # Sub-Directory Handling # settings +# Do not disable the first rule - this is required by sccp_manager +#ri ^(.+\.tlzz)?$ settings/\1 #ri ^(.+\.tlv)?$ settings/\1 #ri ^\/(.+\.tlv)?$ settings/\1 #ri ^((.+\.cnf.xml)(\.enc)?(\.sgn)?)$ settings/\1 diff --git a/contrib/tftp.xinetd b/contrib/tftp.xinetd index 6ea6509..cfea06a 100644 --- a/contrib/tftp.xinetd +++ b/contrib/tftp.xinetd @@ -10,7 +10,7 @@ service tftp wait = yes user = root server = /usr/sbin/in.tftpd - server_args = -c -s -v /tftpboot -m /tftpboot/rewrite.rules + server_args = -c -s -v /tftpboot -m -m /etc/asterisk/sccpManagerRewrite.rules disable = no per_source = 11 cps = 100 2 diff --git a/install.php b/install.php index 8eea9f1..ee1e31d 100644 --- a/install.php +++ b/install.php @@ -893,8 +893,8 @@ function checkTftpServer() { die_freepbx(_("Either TFTP server is down or TFTP root is non standard. Please fix, refresh, and try again")); } - $settingsToDb['asterisk_etc_path'] =array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir); - $settingsFromDb['asterisk_etc_path']['data'] = $confDir; + $settingsToDb['asterisk_etc_path'] = array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir); + $settingsFromDb['asterisk_etc_path'] = $settingsToDb['asterisk_etc_path']; foreach ($settingsToDb as $settingToSave) { $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']});"; @@ -904,7 +904,11 @@ function checkTftpServer() { } unset($settingsToDb[$settingToSave['keyword']]); } - + // put the rewrite rules into the required location + if (file_exists("{$confDir}/sccpManagerRewrite.rules")) { + rename("{$confDir}/sccpManagerRewrite.rules", "{$confDir}/sccpManagerRewrite.rules.bu"); + } + copy($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules',"{$confDir}/sccpManagerRewrite.rules"); $settingsToDb = $extconfigs->updateTftpStructure($settingsFromDb); foreach ($settingsToDb as $settingKey => $settingVal) { diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index c07bbbb..470e855 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -254,12 +254,15 @@ class extconfigs 'wallpapers' => 'wallpapers' ); $adv_tree = array('pro' => array('templates' => 'tftproot', + 'firmware' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', - 'firmware' => 'tftproot', 'languages' => 'locales', + 'templates' => 'tftproot', 'dialplan' => 'tftproot', - 'softkey' => 'tftproot' + 'softkey' => 'tftproot', + 'ringtones' => 'tftproot', + 'wallpapers' => 'tftproot' ), 'def' => array('templates' => 'tftproot', 'settings' => '', @@ -300,8 +303,21 @@ class extconfigs $adv_ini_array = parse_ini_file($adv_ini); $adv_config = array_merge($adv_config, $adv_ini_array); } + // rewrite adv_ini to reflect the new $adv_config + if (file_exists($adv_ini)){ + rename($adv_ini, "{$adv_ini}.old"); + } + $indexFile = fopen($adv_ini,'w'); + fwrite($indexFile, "[main]\n"); + foreach ($adv_config as $advKey => $advVal) { + fwrite($indexFile, "{$advKey} = {$advVal}\n"); + } + fclose($indexFile); + $settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'pro', 'systemdefault' => ''); break; + case 'unavailable': + $settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'unavailable', 'systemdefault' => ''); case 'on': case 'internal': case 'off': @@ -332,6 +348,12 @@ class extconfigs } } } + // Set up tftproot/settings so that can test if mapping is Enabled and configured. + if (!is_dir("{$settingsFromDb['tftp_path']['data']}/settings")) { + if (!mkdir("{$settingsFromDb['tftp_path']['data']}/settings", 0755, true)) { + die_freepbx(_('Error creating dir : ' . $base_config[$key])); + } + } // TODO: Need to add index.cnf, after setting defaults correctly if (!file_exists($base_config["tftp_templates_path"] . '/XMLDefault.cnf.xml_template')) { $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index ee6d4c6..2c814e2 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -449,7 +449,20 @@ class formcreate } $opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" '; } + // If TFTP remapping is not available, disable options that require it + $disabledButtons = array(); + if (($child['id'] == 21) && ($sccp_defaults['tftp_rewrite']['data'] == 'unavailable')) { + $disabledButtons = (array)$child->option_disable; + $unavailableButton = $child->addChild('button','Unavailable'); + $unavailableButton->addAttribute('value', 'unavailable'); + dbug('',$child); + } + foreach ($child->xpath('button') as $value) { + $opt_disabled = ''; + if (in_array($value, $disabledButtons )) { + $opt_disabled = 'disabled'; + } $val_check = strtolower((string)$value[@value]); if ($val_check == strtolower($res_v)) { $val_check = " checked"; @@ -460,7 +473,7 @@ class formcreate } else {$val_check = "";} } else {$val_check = "";} } - echo ""; + echo ""; echo ""; $i++; } diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 2229ff3..c12212f 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -213,6 +213,40 @@ trait helperfunctions { return false; } + public function checkTftpMapping(){ + exec('in.tftpd -V', $tftpInfo); + $info['TFTP Server'] = array('Version' => 'Not Found', 'about' => 'Mapping not available'); + + if (isset($tftpInfo[0])) { + $tftpInfo = explode(',',$tftpInfo[0]); + $info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => 'Mapping not available'); + $tftpInfo[1] = trim($tftpInfo[1]); + $this->sccpvalues['tftp-rewrite']['data'] = 'unavailable'; + if ($tftpInfo[1] == 'with remap') { + $info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => $tftpInfo[1]); + + $remoteFileName = ".sccp_manager_remap_probe_sentinel_temp".mt_rand(0, 9999999).".tlzz"; + $remoteFileContent = "# This is a test file created by Sccp_Manager. It can be deleted without impact"; + $testFtpDir = "{$this->sccpvalues['tftp_path']['data']}/settings"; + + // write a sentinel to a tftp subdirectory to see if mapping is working + + if (is_dir($testFtpDir) && is_writable($testFtpDir)) { + // TODO: Need to be sure that installer creates this directory + $tempFile = "${testFtpDir}/{$remoteFileName}"; + file_put_contents($tempFile, $remoteFileContent); + + // try to pull the written file through tftp. + // this way we can determine if mapping is active and using sccp_manager maps + if ($remoteFileContent != $this->tftpReadTestFile($remoteFileName)) { + // Did not find sentinel so mapping not available + $this->sccpvalues['tftp_rewrite']['data'] = 'unavailable'; + } + unlink($tempFile); + } + } + } + } // temporary helper function to save xml with proper indentation public function saveXml($xml, $filename) { $dom = new \DOMDocument("1.0"); diff --git a/views/server.info.php b/views/server.info.php index c1a2e47..811b212 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -36,29 +36,35 @@ $info['aminterface'] = $this->aminterface->info(); $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']); -/* -if (!$this->srvinterface->useAmiInterface) { - $info['aminterface']['about'] .= ' -- Disabled'; - $info['Core_sccp'] = array('Version' => $core['Version'], 'about' => 'Sccp ver.' . $core['Version'] . ' r' . $core['vCode'] . ' Revision :' . $core['RevisionNum'] . ' Hash :' . $core['RevisionHash'] . ' ----Warning: Upgrade chan_sccp to use full ami functionality'); -} -*/ -$info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about' => 'Asterisk.'); + 'about' => "Sccp ver: {$core['Version']} r{$core['vCode']} Revision: {$core['RevisionNum']} Hash: {$core['RevisionHash']}"); +$info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about' => 'Asterisk.'); if (!empty($this->sccpvalues['SccpDBmodel'])) { $info['DB Model'] = array('Version' => $this->sccpvalues['SccpDBmodel']['data'], 'about' => 'SCCP DB Configure'); } -if (!empty($this->sccpvalues['tftp_rewrite'])) { - if ($this->sccpvalues['tftp_rewrite']['data'] == 'pro') { - $info['Provision_SCCP'] = array('Version' => 'base', 'about' => 'Provision Sccp enabled'); - } else { - $info['TFTP_Rewrite'] = array('Version' => 'base', 'about' => 'Rewrite Supported'); + +// Start testing tftp server settings - this should be moved after debug to extConfigs + +if (!empty($this->sccpvalues['tftp_rewrite']['data'])) { + switch ($this->sccpvalues['tftp_rewrite']['data']) { + case 'custom': + case 'pro': + $info['Provision_SCCP'] = array('Version' => 'base', 'about' => 'Provision Sccp enabled'); + break; + case 'unavailable': + $info['TFTP Mapping'] = array('Version' => 'off', 'about' => 'remapping is available, but mapping file not included in tftpd-hpa default settings.
    + Add option
    + -m /etc/asterisk/sccpManagerRewrite.rules
    + to the tftpd defaults, location dependant on the system, and restart the tftpd server'); + break; + default: + $info['TFTP_Mapping'] = array('Version' => 'off', 'about' => 'Rewrite Supported'); + break; } } + +// Finished testing tftp server options $info['Сompatible'] = array('Version' => $compatible, 'about' => 'Ok'); if (!empty($this->sccpvalues['SccpDBmodel'])) { if ($compatible > $this->sccpvalues['SccpDBmodel']['data']) { diff --git a/views/server.setting.php b/views/server.setting.php index 55acd1a..623df04 100644 --- a/views/server.setting.php +++ b/views/server.setting.php @@ -28,7 +28,6 @@ echo $this->showGroup('sccp_dev_time_s', 1); echo $this->showGroup('sccp_net', 1); echo $this->showGroup('sccp_lang', 1); - echo $this->showGroup('sccp_extpath_config', 1); ?> From 651f3adb44326fdbcf16f93c80213e4f33d91877 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 12 Jul 2021 12:26:56 +0200 Subject: [PATCH 092/181] Finalise TFTP Mapping treatment User no longer can select on or pro: If remapping is enabled and rules are set, then must use pro or phones will not find files Otherwise is Off (flat directory) --- Sccp_manager.class.php | 2 +- conf/sccpgeneral.xml.v433 | 10 +++--- contrib/rewrite.rules | 2 +- install.php | 39 ++++++++++------------- module.xml | 2 +- sccpManClasses/extconfigs.class.php | 48 ++++++++++------------------- sccpManClasses/formcreate.class.php | 11 ++----- sccpManTraits/ajaxHelper.php | 17 +++++----- sccpManTraits/helperFunctions.php | 13 +++++--- views/formShowSysDefs.php | 9 +++++- views/server.info.php | 28 ++++++++++++----- 11 files changed, 88 insertions(+), 93 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 1425643..ea49bd2 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -749,7 +749,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { /** * Retrieve Active Codecs - * return fiends Lag pack + * return finds Languageg pack */ private function initTftpLang() { diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index b837f35..c3a00f9 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1165,7 +1165,9 @@ and open the template in the editor. Base Version before all crash :-) This section is responsible for the modes of operation of external services: tftp http. * off - Flat model cisco. All data is in the directory TFTP Server Path * Provision - The directory structure is strictly defined in the manager. Requires tftpd mapping support. - * Custom - TFTP Directory structure can be extended by index.cnf. This supports phones that can work on tftp and http. Remapping support is required + The mode is determined by Sccp_manager based on the presence of a mapping file in TFTP defaults + and must be the same as the tftp server, or the phones will not find required files + To change the mode, add or remove the -m option.
    @@ -1188,18 +1190,14 @@ and open the template in the editor. Base Version before all crash :-) Use path from provision index.cnf file. You must first make sure that you have properly configured the "Provision" - + tftp_rewrite off - custom - custom - Custom Provision Off - Support the use of regular-expression-based filename remapping diff --git a/contrib/rewrite.rules b/contrib/rewrite.rules index fc635b8..a59b15d 100644 --- a/contrib/rewrite.rules +++ b/contrib/rewrite.rules @@ -179,7 +179,7 @@ ri ^(ATA030204SCCP090202A.zup)$ firmware/ata186/\1 # settings # Do not disable the first rule - this is required by sccp_manager -#ri ^(.+\.tlzz)?$ settings/\1 +ri ^(.+\.tlzz)?$ settings/\1 #ri ^(.+\.tlv)?$ settings/\1 #ri ^\/(.+\.tlv)?$ settings/\1 #ri ^((.+\.cnf.xml)(\.enc)?(\.sgn)?)$ settings/\1 diff --git a/install.php b/install.php index ee1e31d..5128255 100644 --- a/install.php +++ b/install.php @@ -854,6 +854,11 @@ function checkTftpServer() { global $thisInstaller; $confDir = $cnf_int->get('ASTETCDIR'); $tftpRootPath = ""; + // put the rewrite rules into the required location + if (file_exists("{$confDir}/sccpManagerRewrite.rules")) { + rename("{$confDir}/sccpManagerRewrite.rules", "{$confDir}/sccpManagerRewrite.rules.bu"); + } + copy($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules',"{$confDir}/sccpManagerRewrite.rules"); // TODO: add option to use external server $remoteFileName = ".sccp_manager_installer_probe_sentinel_temp".mt_rand(0, 9999999); @@ -873,9 +878,7 @@ function checkTftpServer() { $tftpRootPath = $dirToTest; outn("
  • " . _("Found ftp root dir at {$tftpRootPath}") . "
  • "); if ($settingsFromDb['tftp_path']['data'] != $tftpRootPath) { - $settingsToDb["tftp_path"] = array( 'keyword' => 'tftp_path', 'seq' => 2, 'type' => 0, 'data' => $tftpRootPath); - // Need to set the new value here to pass to extconfigs below - $settingsFromDb['tftp_path']['data'] = $tftpRootPath; + $settingsFromDb["tftp_path"] = array( 'keyword' => 'tftp_path', 'seq' => 2, 'type' => 0, 'data' => $tftpRootPath, 'systemdefault' => ''); } // Found sentinel file. Remove it and exit loop if (file_exists($tempFile)) { @@ -893,27 +896,19 @@ function checkTftpServer() { die_freepbx(_("Either TFTP server is down or TFTP root is non standard. Please fix, refresh, and try again")); } - $settingsToDb['asterisk_etc_path'] = array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir); - $settingsFromDb['asterisk_etc_path'] = $settingsToDb['asterisk_etc_path']; + $settingsFromDb['asterisk_etc_path'] = array( 'keyword' => 'asterisk_etc_path', 'seq' => 20, 'type' => 0, 'data' => $confDir, 'systemdefault' => ''); - foreach ($settingsToDb as $settingToSave) { - $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']});"; - $results = $db->query($sql); - if (DB::IsError($results)) { - die_freepbx(_("Error updating sccpsettings. $sql")); - } - unset($settingsToDb[$settingToSave['keyword']]); + // Get TFTP mapping Status + $settingsFromDb['tftp_rewrite'] = array('keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 0, 'data' => 'off', 'systemdefault' => ''); + if (\FreePbx::Sccp_manager()->checkTftpMapping()) { + $settingsFromDb['tftp_rewrite']['data'] = 'pro'; } - // put the rewrite rules into the required location - if (file_exists("{$confDir}/sccpManagerRewrite.rules")) { - rename("{$confDir}/sccpManagerRewrite.rules", "{$confDir}/sccpManagerRewrite.rules.bu"); - } - copy($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules',"{$confDir}/sccpManagerRewrite.rules"); - $settingsToDb = $extconfigs->updateTftpStructure($settingsFromDb); - foreach ($settingsToDb as $settingKey => $settingVal) { - $settingsFromDb[$settingKey]['data'] = $settingVal; - $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type) VALUES ('{$settingKey}', '{$settingVal}', 20, 0)"; + // Populate TFTP paths in SccpSettings + $settingsFromDb = $extconfigs->updateTftpStructure($settingsFromDb); + + foreach ($settingsFromDb as $settingToSave) { + $sql = "REPLACE INTO sccpsettings (keyword, data, seq, type, systemdefault) VALUES ('{$settingToSave['keyword']}', '{$settingToSave['data']}', {$settingToSave['seq']}, {$settingToSave['type']}, '{$settingToSave['systemdefault']}')"; $results = $db->query($sql); if (DB::IsError($results)) { die_freepbx(_("Error updating sccpsettings. $sql")); @@ -1014,7 +1009,7 @@ function cleanUpSccpSettings() { } } // Override certain chan-sccp defaults as they are based on a non-FreePbx system - $settingsFromDb['context']['systemdefault'] = 'from-internal' + $settingsFromDb['context']['systemdefault'] = 'from-internal'; unset($sysConfiguration[$key]); } diff --git a/module.xml b/module.xml index d600f86..3e5c4c2 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 470e855..8a6f397 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -280,7 +280,7 @@ class extconfigs 'tftp_dialplan_path' => 'dialplan', 'tftp_softkey_path' => 'softkey' ); - $base_config = array(); + $baseConfig = array(); if (!empty($settingsFromDb['tftp_rewrite_path']['data'])) { // Have a setting in sccpsettings. It should start with $tftp_path @@ -288,8 +288,7 @@ class extconfigs if (!strpos($settingsFromDb['tftp_rewrite_path']["data"],$settingsFromDb['tftp_path']['data'])) { $adv_ini = "{$settingsFromDb['tftp_path']['data']}/index.cnf"; - $settingsToDb['tftp_rewrite_path'] = $settingsFromDb['tftp_rewrite_path']; - $settingsToDb['tftp_rewrite_path']['data'] = $settingsFromDb['tftp_path']['data']; + $settingsFromDb['tftp_rewrite_path']['data'] = $settingsFromDb['tftp_path']['data']; } $adv_ini = "{$settingsFromDb['tftp_rewrite_path']["data"]}/index.cnf"; } @@ -313,17 +312,14 @@ class extconfigs fwrite($indexFile, "{$advKey} = {$advVal}\n"); } fclose($indexFile); - - $settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'pro', 'systemdefault' => ''); + $settingsFromDb['tftp_rewrite']['data'] = 'pro'; break; - case 'unavailable': - $settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'unavailable', 'systemdefault' => ''); case 'on': case 'internal': case 'off': default: // not defined so set here to off - $settingsToDb['tftp_rewrite'] =array( 'keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 2, 'data' => 'off', 'systemdefault' => ''); + $settingsFromDb['tftp_rewrite']['data'] = 'off'; } foreach ($adv_tree[$adv_tree_mode] as $key => $value) { @@ -339,43 +335,31 @@ class extconfigs } foreach ($base_tree as $key => $value) { - $base_config[$key] = $adv_config[$value]; - // Save to sccpsettings - $settingsToDb[$key] =array( 'keyword' => $key, 'seq' => 20, 'type' => 0, 'data' => $adv_config[$value], 'systemdefault' => ''); - if (!is_dir($base_config[$key])) { - if (!mkdir($base_config[$key], 0755, true)) { - die_freepbx(_('Error creating dir : ' . $base_config[$key])); + $baseConfig[$key] = $adv_config[$value]; + if (!is_dir($baseConfig[$key])) { + if (!mkdir($baseConfig[$key], 0755, true)) { + die_freepbx(_("Error creating dir: $baseConfig[$key]")); } } } // Set up tftproot/settings so that can test if mapping is Enabled and configured. if (!is_dir("{$settingsFromDb['tftp_path']['data']}/settings")) { if (!mkdir("{$settingsFromDb['tftp_path']['data']}/settings", 0755, true)) { - die_freepbx(_('Error creating dir : ' . $base_config[$key])); + die_freepbx(_("Error creating dir: {$settingsFromDb['tftp_path']['data']}/settings")); } } // TODO: Need to add index.cnf, after setting defaults correctly - if (!file_exists($base_config["tftp_templates_path"] . '/XMLDefault.cnf.xml_template')) { - $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; - $dst_path = $base_config["tftp_templates_path"] . '/'; - foreach (glob($src_path . '*.*_template') as $filename) { + if (!file_exists("{$baseConfig['tftp_templates_path']}/XMLDefault.cnf.xml_template")) { + $src_path = "{$_SERVER['DOCUMENT_ROOT']}/admin/modules/sccp_manager/conf/"; + $dst_path = "{$baseConfig["tftp_templates_path"]}/"; + foreach (glob("{$src_path}*.*_template") as $filename) { copy($filename, $dst_path . basename($filename)); } } - // Remove keys that are not required before returning $base_config. - unset($base_config['asterisk'], $base_config['sccp_conf'], $base_config['tftp_path']); - return $settingsToDb; - } - private function initializeTFtpLanguagePath() { - $dir = $this->sccppath["tftp_lang_path"]; - foreach ($this->extconfigs->getExtConfig('sccp_lang') as $lang_key => $lang_value) { - $filename = $dir . DIRECTORY_SEPARATOR . $lang_value['locale']; - if (!file_exists($filename)) { - if (!mkdir($filename, 0777, true)) { - die('Error creating tftp language directory'); - } - } + foreach ($baseConfig as $baseKey => $baseValue) { + $settingsFromDb[$baseKey] = array('keyword' => $baseKey, 'seq' => 20, 'type' => 0, 'data' => $baseValue, 'systemdefault' => ''); } + return $settingsFromDb; } public function validate_RealTime( $connector ) diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index 2c814e2..f7eff97 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -328,7 +328,7 @@ class formcreate buttonDefLabel = 'site'; $this->buttonHelpLabel = 'device'; @@ -449,14 +449,7 @@ class formcreate } $opt_hide .= ' data-vshow="'.$child->option_show.'" data-clshow="'.$child->option_show['class'].'" '; } - // If TFTP remapping is not available, disable options that require it - $disabledButtons = array(); - if (($child['id'] == 21) && ($sccp_defaults['tftp_rewrite']['data'] == 'unavailable')) { - $disabledButtons = (array)$child->option_disable; - $unavailableButton = $child->addChild('button','Unavailable'); - $unavailableButton->addAttribute('value', 'unavailable'); - dbug('',$child); - } + foreach ($child->xpath('button') as $value) { $opt_disabled = ''; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index eac8891..d205cc3 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -387,6 +387,7 @@ trait ajaxHelper { } function handleSubmit($request, $validateonly = false) { + dbug('',$request); $hdr_prefix = 'sccp_'; $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); @@ -448,15 +449,16 @@ trait ajaxHelper { $key = (str_replace($hdr_prefix, '', $key, $count_mods)); if ($count_mods) { - if (!empty($this->sccpvalues[$key]) && (!($this->sccpvalues[$key]['data'] == $value))) { - $save_settings[$this->sccpvalues[$key]['keyword']] = array( - 'keyword' => $this->sccpvalues[$key]['keyword'], + if (!empty($this->sccpvalues[$key]) && ($this->sccpvalues[$key]['data'] != $value)) { + $save_settings[$key] = array( + 'keyword' => $key, 'data' => $value, 'seq' => $this->sccpvalues[$key]['seq'], 'type' => $this->sccpvalues[$key]['type'], 'systemdefault' => $this->sccpvalues[$key]['systemdefault'] ); } + } $key = (str_replace($hdr_arprefix, '', $key, $count_mods)); if ($count_mods) { @@ -488,8 +490,8 @@ trait ajaxHelper { $arr_data = substr($arr_data, 0, -1); } if (!($this->sccpvalues[$key]['data'] == $arr_data)) { - $save_settings[] = array( - 'keyword' => $this->sccpvalues[$key]['keyword'], + $save_settings[$key] = array( + 'keyword' => $key, 'data' => $arr_data, 'seq' => $this->sccpvalues[$key]['seq'], 'type' => $this->sccpvalues[$key]['type'], @@ -506,7 +508,7 @@ trait ajaxHelper { }; $tmpv = implode(",", $save_codec); if (!($this->sccpvalues['allow']['data'] == $tmpv)) { - $save_settings[] = array( + $save_settings['allow'] = array( 'keyword' => 'allow', 'data' => $tmpv, 'seq' => $this->sccpvalues['allow']['seq'], @@ -525,7 +527,7 @@ trait ajaxHelper { $TZdata = $this->extconfigs->getExtConfig('sccp_timezone', $tz_id); if (!empty($TZdata)) { $value = $TZdata['offset']/60; - $save_settings[] = array( + $save_settings['tzoffset'] = array( 'keyword' => 'tzoffset', 'data' => $value, 'seq' => '98', @@ -539,6 +541,7 @@ trait ajaxHelper { $extSettings = $this->extconfigs->updateTftpStructure(array_merge($this->sccpvalues, $save_settings)); $save_settings = array_merge($save_settings, $extSettings); + dbug('saveSettingsAfter', $save_settings); if (!empty($save_settings)) { $this->saveSccpSettings($save_settings); $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index c12212f..280e1c2 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -221,7 +221,7 @@ trait helperfunctions { $tftpInfo = explode(',',$tftpInfo[0]); $info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => 'Mapping not available'); $tftpInfo[1] = trim($tftpInfo[1]); - $this->sccpvalues['tftp-rewrite']['data'] = 'unavailable'; + $this->sccpvalues['tftp_rewrite']['data'] = 'off'; if ($tftpInfo[1] == 'with remap') { $info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => $tftpInfo[1]); @@ -232,20 +232,23 @@ trait helperfunctions { // write a sentinel to a tftp subdirectory to see if mapping is working if (is_dir($testFtpDir) && is_writable($testFtpDir)) { - // TODO: Need to be sure that installer creates this directory $tempFile = "${testFtpDir}/{$remoteFileName}"; file_put_contents($tempFile, $remoteFileContent); - // try to pull the written file through tftp. // this way we can determine if mapping is active and using sccp_manager maps - if ($remoteFileContent != $this->tftpReadTestFile($remoteFileName)) { + if ($remoteFileContent == $this->tftpReadTestFile($remoteFileName)) { + //found the file and contents are correct + $this->sccpvalues['tftp_rewrite']['data'] = 'pro'; + } else { // Did not find sentinel so mapping not available - $this->sccpvalues['tftp_rewrite']['data'] = 'unavailable'; + $this->sccpvalues['tftp_rewrite']['data'] = 'off'; } unlink($tempFile); } + return true; } } + return false; } // temporary helper function to save xml with proper indentation public function saveXml($xml, $filename) { diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index be79ba1..a47dba2 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -50,6 +50,7 @@ if ($h_show==1) { } foreach ($items as $child) { + $disabledButtons = array(); if (empty($child->help)) { $child->help = 'Help is not available.'; $child->meta_help = '1'; @@ -62,8 +63,14 @@ foreach ($items as $child) { case 'IED': \FreePbx::sccp_manager()->formcreate->addElementIED($child, $fvalues, $sccp_defaults,$npref, $napref); break; + case 'ISC': + // This is a special case for Provision mode. Set some parameters here and fall through to IS. + $disabledButtons = array('pro' => 'Provision'); + if ($sccp_defaults['tftp_rewrite']['data'] == 'pro') { + $disabledButtons = array('off' => 'Off'); + } case 'IS': - \FreePbx::sccp_manager()->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref); + \FreePbx::sccp_manager()->formcreate->addElementIS($child, $fvalues, $sccp_defaults,$npref, $disabledButtons); break; case 'SLD': case 'SLM': diff --git a/views/server.info.php b/views/server.info.php index 811b212..ad9494c 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -44,7 +44,17 @@ if (!empty($this->sccpvalues['SccpDBmodel'])) { $info['DB Model'] = array('Version' => $this->sccpvalues['SccpDBmodel']['data'], 'about' => 'SCCP DB Configure'); } -// Start testing tftp server settings - this should be moved after debug to extConfigs +exec('in.tftpd -V', $tftpInfo); +$info['TFTP Server'] = array('Version' => 'Not Found', 'about' => 'Mapping not available'); + +if (isset($tftpInfo[0])) { + $tftpInfo = explode(',',$tftpInfo[0]); + $info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => 'Mapping not available'); + $tftpInfo[1] = trim($tftpInfo[1]); + if ($tftpInfo[1] == 'with remap') { + $info['TFTP Server'] = array('Version' => $tftpInfo[0], 'about' => $tftpInfo[1]); + } +} if (!empty($this->sccpvalues['tftp_rewrite']['data'])) { switch ($this->sccpvalues['tftp_rewrite']['data']) { @@ -52,14 +62,16 @@ if (!empty($this->sccpvalues['tftp_rewrite']['data'])) { case 'pro': $info['Provision_SCCP'] = array('Version' => 'base', 'about' => 'Provision Sccp enabled'); break; - case 'unavailable': - $info['TFTP Mapping'] = array('Version' => 'off', 'about' => 'remapping is available, but mapping file not included in tftpd-hpa default settings.
    - Add option
    - -m /etc/asterisk/sccpManagerRewrite.rules
    - to the tftpd defaults, location dependant on the system, and restart the tftpd server'); - break; default: - $info['TFTP_Mapping'] = array('Version' => 'off', 'about' => 'Rewrite Supported'); + if ($tftpInfo[1] == 'with remap') { + $info['TFTP_Mapping'] = array('Version' => 'off', 'about' => "TFTP mapping is available but the mapping file is not included in tftpd-hpa default settings.
    + To enable Provision mode, add option
    + -m /etc/asterisk/sccpManagerRewrite.rules
    + to the tftpd defaults, (location dependant on the system), and restart the tftpd server"); + + } else { + $info['TFTP_Mapping'] = array('Version' => 'off', 'about' => "Mapping capability is not built into the TFTP server. To enable Provision, upgrade the TFTP server."); + } break; } } From 2b709c9037dfc7ab8efbabb603fe867c7233c56e Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 12 Jul 2021 12:36:29 +0200 Subject: [PATCH 093/181] remove index.cnf Is created by extconfigs with actual server values --- contrib/index.cnf | 12 ------------ contrib/rewrite.rules | 1 + 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 contrib/index.cnf diff --git a/contrib/index.cnf b/contrib/index.cnf deleted file mode 100644 index 7bec03f..0000000 --- a/contrib/index.cnf +++ /dev/null @@ -1,12 +0,0 @@ -[main] -debug = on ; The output in the browser window for more information -tftproot = /tftpboot -;default_language = English_United_States - -firmware = firmware -settings = /tftpboot -wallpapers = /tftpboot/Desktops -ringtones = ringtones -locales = locales -countries = countries -languages = /tftpboot/languages diff --git a/contrib/rewrite.rules b/contrib/rewrite.rules index a59b15d..7e55b22 100644 --- a/contrib/rewrite.rules +++ b/contrib/rewrite.rules @@ -3,6 +3,7 @@ # # This file is maintained by Sccp_Manager, and will be overwritten by the installer # a copy of the original can be found at sccpManagerRewrite.rules.bu +# For any changes to this file to be effective, the tftp server will have to be restarted. # # /firmware # /settings From 6e26428b1dd6bdc5007927976badaaebc751b4f9 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 12 Jul 2021 13:50:09 +0200 Subject: [PATCH 094/181] Update rewrite rules Add header with credits Add specific rule for sccp_manager Add correct fields to parse xml for sccpvalues Add new option to update files from @dkgroot/provision --- conf/mappingRulesHeader | 9 +++++++++ conf/sccpgeneral.xml.v433 | 10 +++++++++- contrib/rewrite.rules | 9 +-------- install.php | 5 +++-- sccpManTraits/ajaxHelper.php | 1 - sccpManTraits/helperFunctions.php | 6 +++--- 6 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 conf/mappingRulesHeader diff --git a/conf/mappingRulesHeader b/conf/mappingRulesHeader new file mode 100644 index 0000000..e31c4a6 --- /dev/null +++ b/conf/mappingRulesHeader @@ -0,0 +1,9 @@ +# +# TFTPd Mapping Rules for SCCP_Manager Provision +# +# This file is maintained by Sccp_Manager, and will be overwritten by the installer +# a copy of the original can be found at sccpManagerRewrite.rules.bu +# For any changes to this file to be effective, the tftp server will have to be restarted. +# +# The rules below are provided by dkgroot/provision project https://github.com/dkgroot/provision_sccp +# diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index c3a00f9..1398d3a 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1226,6 +1226,14 @@ and open the template in the editor. Base Version before all crash :-) Say 'yes' if you need to create cisco default language directory in tftp path.
    + + getExternalData + + no + + + If this is set to yes, Sccp_manager will try to get data files from dkgroot/Provision (languages, ring tones, firmware etc). This is enabled at your own risk - Sccp_Manager cannot vouch for the security or accuracy of these files, and this option is included to assist in getting up to speed as rapidly as possible. + system_rouminguser @@ -1356,7 +1364,7 @@ and open the template in the editor. Base Version before all crash :-) sccp-custom - The ringtone that the phone will default to. Can be overridden in the phone. The files RINGLIST.XML provice the basic phone ring tones, while DISTINCTIVERINGLIST.XML defines the list of possible ring tones for your other line types. They, along with the actual 'raw' ringtones, are stored in the /tftpboot/ringtones directory with the rest of the config files. + The ringtone that the phone will default to. Can be overridden in the phone. The files RINGLIST.XML provides the basic phone ring tones, while DISTINCTIVERINGLIST.XML defines the list of possible ring tones for your other line types. They, along with the actual 'raw' ringtones, are stored in the /tftpboot/ringtones directory with the rest of the config files. diff --git a/contrib/rewrite.rules b/contrib/rewrite.rules index 7e55b22..f2c5a45 100644 --- a/contrib/rewrite.rules +++ b/contrib/rewrite.rules @@ -1,10 +1,5 @@ # -# TFTPd Rewrite for SCCP_Manager Custom remapping -# -# This file is maintained by Sccp_Manager, and will be overwritten by the installer -# a copy of the original can be found at sccpManagerRewrite.rules.bu -# For any changes to this file to be effective, the tftp server will have to be restarted. -# +# TFTPd Rewrite for SCCP_Manager Custom remaping # /firmware # /settings # /wallpapers @@ -179,8 +174,6 @@ ri ^(ATA030204SCCP090202A.zup)$ firmware/ata186/\1 # Sub-Directory Handling # settings -# Do not disable the first rule - this is required by sccp_manager -ri ^(.+\.tlzz)?$ settings/\1 #ri ^(.+\.tlv)?$ settings/\1 #ri ^\/(.+\.tlv)?$ settings/\1 #ri ^((.+\.cnf.xml)(\.enc)?(\.sgn)?)$ settings/\1 diff --git a/install.php b/install.php index 5128255..6eab166 100644 --- a/install.php +++ b/install.php @@ -858,8 +858,9 @@ function checkTftpServer() { if (file_exists("{$confDir}/sccpManagerRewrite.rules")) { rename("{$confDir}/sccpManagerRewrite.rules", "{$confDir}/sccpManagerRewrite.rules.bu"); } - copy($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules',"{$confDir}/sccpManagerRewrite.rules"); - + copy($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/mappingRulesHeader',"{$confDir}/sccpManagerRewrite.rules"); + file_put_contents("{$confDir}/sccpManagerRewrite.rules", file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules'), FILE_APPEND); + file_put_contents("{$confDir}/sccpManagerRewrite.rules", "\n# Do not disable this rule - this is required by sccp_manager\nri ^(.+\.tlzz)?$ settings/\\1", FILE_APPEND); // TODO: add option to use external server $remoteFileName = ".sccp_manager_installer_probe_sentinel_temp".mt_rand(0, 9999999); $remoteFileContent = "# This is a test file created by Sccp_Manager. It can be deleted without impact"; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index d205cc3..2a9753c 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -541,7 +541,6 @@ trait ajaxHelper { $extSettings = $this->extconfigs->updateTftpStructure(array_merge($this->sccpvalues, $save_settings)); $save_settings = array_merge($save_settings, $extSettings); - dbug('saveSettingsAfter', $save_settings); if (!empty($save_settings)) { $this->saveSccpSettings($save_settings); $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 280e1c2..92825ff 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -280,7 +280,7 @@ trait helperfunctions { $tp = 1; } if (empty($this->sccpvalues[(string) $value->name])) { - $this->sccpvalues[(string) $value->name] = array('keyword' => (string) $value->name, 'data' => $datav, 'type' => $tp, 'seq' => $seq); + $this->sccpvalues[(string) $value->name] = array('keyword' => (string) $value->name, 'data' => $datav, 'type' => $tp, 'seq' => $seq, 'systemdefault' => ''); } } } @@ -291,7 +291,7 @@ trait helperfunctions { $datav = (string) $child->value; } if (empty($this->sccpvalues[(string) $child->name])) { - $this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq); + $this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq, 'systemdefault' => ''); } } if (in_array($child['type'], array('SLD', 'SLS', 'SLT', 'SL', 'SLM', 'SLZ', 'SLTZN', 'SLA'))) { @@ -301,7 +301,7 @@ trait helperfunctions { $datav = (string) $child->value; } if (empty($this->sccpvalues[(string) $child->name])) { - $this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq); + $this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq, 'systemdefault' => ''); } } } From 2ffe4028e6cb399f26e667f1c7606cc726366153 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 12 Jul 2021 16:32:57 +0200 Subject: [PATCH 095/181] Add download function WIP - debug with ringtones --- sccpManClasses/extconfigs.class.php | 12 ++++++++---- sccpManTraits/ajaxHelper.php | 3 +-- sccpManTraits/helperFunctions.php | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 8a6f397..481803f 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -265,20 +265,24 @@ class extconfigs 'wallpapers' => 'tftproot' ), 'def' => array('templates' => 'tftproot', + 'firmware' => '', 'settings' => '', 'locales' => '', - 'firmware' => '', 'languages' => 'tftproot', 'dialplan' => '', - 'softkey' => '' + 'softkey' => '', + 'ringtones' => '', + 'wallpapers' => '' ) ); $base_tree = array('tftp_templates_path' => 'templates', + 'tftp_firmware_path' => 'firmware', 'tftp_store_path' => 'settings', 'tftp_lang_path' => 'languages', - 'tftp_firmware_path' => 'firmware', 'tftp_dialplan_path' => 'dialplan', - 'tftp_softkey_path' => 'softkey' + 'tftp_softkey_path' => 'softkey', + 'tftp_ringtones_path' => 'ringtones', + 'tftp_wallpapers_path' => 'wallpapers' ); $baseConfig = array(); diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 2a9753c..9f59784 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -387,7 +387,6 @@ trait ajaxHelper { } function handleSubmit($request, $validateonly = false) { - dbug('',$request); $hdr_prefix = 'sccp_'; $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); @@ -555,7 +554,7 @@ trait ajaxHelper { $save_settings[] = array('status' => true); $this->createDefaultSccpXml(); - + $this->getFilesFromProvisioner(); return $save_settings; } diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 92825ff..82bfa0c 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -259,6 +259,20 @@ trait helperfunctions { $dom->save($filename); } + public function getFilesFromProvisioner() { + + $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/tftpboot/"; + // Ringtones + $ringDir = 'ringtones/'; + $ringList = 'ringlist.xml'; + $xmlData = simplexml_load_file("{$provisionerUrl}{$ringDir}{$ringList}"); + //preg_match_all("|>([0-9a-z]+.xml)|U", $availableFiles, $out); + foreach ($xmlData as $child) { + $fileToSave = str_replace("\\","/",(string)$child->FileName); + file_put_contents("{$this->sccppath['tftp_path']}/{$fileToSave}",file_get_contents("{$provisionerUrl}{$fileToSave}")); + } + } + public function initVarfromXml() { if ((array) $this->xml_data) { foreach ($this->xml_data->xpath('//page_group') as $item) { From ef77bce159d8cfac874586d6e09e70d0971335f7 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 14 Jul 2021 13:10:15 +0200 Subject: [PATCH 096/181] Add retrieve device files --- assets/js/sccp_manager.js | 9 ++++++ sccpManTraits/ajaxHelper.php | 8 ++++- sccpManTraits/helperFunctions.php | 25 ++++++++++++---- views/advserver.model.php | 50 +++++++++++++++++++++++++++++-- 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index f146090..ecf3ce6 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -513,7 +513,16 @@ $(document).ready(function () { } // ----------------------- Server.model form ---------------- + if ($(this).data('id') === 'get_ext_files') { + var dev_cmd = 'get_ext_files'; + var dev_fld = ["device"]; + datas = 'enabled=0' + 'type=firmware' + 'name=' + '&'; + for (var i = 0; i < dev_fld.length; i++) { + datas = datas + dev_fld[i] + '=' + $('#ext_' + dev_fld[i]).val() + '&'; + } + ; + } if ($(this).data('id') === 'model_add') { var dev_cmd = 'model_add'; // var dev_fld = ["model","vendor","dns","buttons","loadimage","loadinformationid","validate","enabled"]; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 9f59784..b9b20d9 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -21,6 +21,7 @@ trait ajaxHelper { case 'getUserGrid': case 'getSoftKey': case 'getDialTemplate': + case 'get_ext_files': case 'create_hw_tftp': case 'reset_dev': case 'reset_token': @@ -382,6 +383,11 @@ trait ajaxHelper { break; case 'validateMac': break; + case 'get_ext_files': + dbug('request is ', $_REQUEST); + return true; + break; + } } @@ -554,7 +560,7 @@ trait ajaxHelper { $save_settings[] = array('status' => true); $this->createDefaultSccpXml(); - $this->getFilesFromProvisioner(); + //$this->getFileListFromProvisioner(); return $save_settings; } diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 82bfa0c..69950e7 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -250,7 +250,7 @@ trait helperfunctions { } return false; } - // temporary helper function to save xml with proper indentation + // helper function to save xml with proper indentation public function saveXml($xml, $filename) { $dom = new \DOMDocument("1.0"); $dom->preserveWhiteSpace = false; @@ -259,13 +259,28 @@ trait helperfunctions { $dom->save($filename); } - public function getFilesFromProvisioner() { + public function getFileListFromProvisioner() { - $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/tftpboot/"; + $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/"; + + // Get master tftpboot directory structure + + file_put_contents("{$this->sccppath['tftp_path']}/masterFilesStructure.xml",file_get_contents("{$provisionerUrl}tools/tftpbootFiles.xml")); + //$xmlData = simplexml_load_file("{$provisionerUrl}tools/tftpbootFiles.xml"); + return true; + + } + + public function getFilesFromProvisioner($type = "",$name = "",$device = "") { + + $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/"; + + // Get master tftpboot directory structure + $xmlData = simplexml_load_file("{$provisionerUrl}tools/tftpbootFiles.xml"); // Ringtones - $ringDir = 'ringtones/'; + $ringDir = 'tftpboot/ringtones/'; $ringList = 'ringlist.xml'; - $xmlData = simplexml_load_file("{$provisionerUrl}{$ringDir}{$ringList}"); + //$xmlData = simplexml_load_file("{$provisionerUrl}{$ringDir}{$ringList}"); //preg_match_all("|>([0-9a-z]+.xml)|U", $availableFiles, $out); foreach ($xmlData as $child) { $fileToSave = str_replace("\\","/",(string)$child->FileName); diff --git a/views/advserver.model.php b/views/advserver.model.php index 5d5d2d5..3361159 100644 --- a/views/advserver.model.php +++ b/views/advserver.model.php @@ -32,6 +32,8 @@
  • +
    @@ -61,7 +63,7 @@ '; } ?> +installedLangs From d7fd77dfe82e8ab90cc07fb8bf029895b578e79f Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 18 Jul 2021 11:30:19 +0200 Subject: [PATCH 099/181] Get locales from provisioner Add progress bar and xhr handler --- Sccp_manager.class.php | 27 ++--- assets/css/sccp_manager.css | 3 +- assets/js/sccp_manager.js | 102 +++++++++++++++-- conf/sccpgeneral.xml.v433 | 17 +-- install.php | 1 + sccpManClasses/extconfigs.class.php | 1 + sccpManClasses/formcreate.class.php | 171 +++++++++++++++++++++++++++- sccpManTraits/ajaxHelper.php | 3 +- sccpManTraits/helperFunctions.php | 46 +++++++- views/advserver.model.php | 4 +- views/formShowSysDefs.php | 6 +- 11 files changed, 332 insertions(+), 49 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 79ec882..7009fe8 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -754,6 +754,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { private function findInstLangs() { //locales and languages are installed in the tftp_lang_path $result = array(); + // TODO: Installer comes here so need to set default / ? $langDir = $this->sccppath["tftp_lang_path"]; $localeJar = 'be-sccp.jar'; // This jar should exist if the locale is populated $langArr = $this->extconfigs->getExtConfig('sccp_lang'); @@ -839,11 +840,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $dir = $this->sccppath["tftp_dialplan_path"] . '/dial*.xml'; $base_len = strlen($this->sccppath["tftp_dialplan_path"]) + 1; $res = glob($dir); - $dp_list = array(); foreach ($res as $key => $value) { $res[$key] = array('id' => substr($value, $base_len, -4), 'file' => substr($value, $base_len)); } - return $res; } @@ -877,34 +876,32 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } /* - * Update Butons Labels on mysql DB + * Update buttons Labels on mysql DB */ private function updateSccpButtons($hw_list = array()) { $save_buttons = array(); + $button_list = array(); if (!empty($hw_list)) { - $buton_list = array(); foreach ($hw_list as $value) { - $buton_tmp = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial', 'id' => $value['name'])); - if (!empty($buton_tmp)) { - $buton_list = array_merge($buton_list, $buton_tmp); - } + $button_tmp = (array)$this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial', 'id' => $value['name'])); + $button_list = array_merge($button_list, $button_tmp); } } else { - $buton_list = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial')); + $button_list = $this->dbinterface->getSccpDeviceTableData("get_sccpdevice_buttons", array('buttontype' => 'speeddial')); } - if (empty($buton_list)) { + if (empty($button_list)) { return array('Response' => ' 0 buttons found ', '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) { + $extList = $extList = $this->dbinterface->get_db_SccpTableByID("SccpExtension", array(), 'name'); + foreach ($button_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']; + if (!empty($extList[$btn_id])) { + if ($extList[$btn_id]['label'] != $value['name']) { + $btn_data['name'] = $extList[$btn_id]['label']; foreach ($copy_fld as $ckey) { $btn_data[$ckey] = $value[$ckey]; } diff --git a/assets/css/sccp_manager.css b/assets/css/sccp_manager.css index 0d64c6c..05077eb 100644 --- a/assets/css/sccp_manager.css +++ b/assets/css/sccp_manager.css @@ -10,10 +10,9 @@ and open the template in the editor. .sccpmultiselect { min-height: 100px; padding: 1px 1px; - + } .sccpbtn { min-height: 10px; padding: 1px 1px; } - diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 6e7e7f9..6aed2ce 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -195,6 +195,8 @@ $(document).ready(function () { }); // --------------------------------------- + + $('.btnMultiselect').click(function (e) { var kid = $(this).data('id'); if ($(this).data('key') === 'Right') { @@ -482,6 +484,8 @@ $(document).ready(function () { }); + + $('.sccp_update').on('click', function (e) { // console.log($(this).data('id')); @@ -513,16 +517,6 @@ $(document).ready(function () { } // ----------------------- Server.model form ---------------- - if ($(this).data('id') === 'get_ext_files') { - var dev_cmd = 'get_ext_files'; - var dev_fld = ["device"]; - datas = 'enabled=0' + '&' + 'type=firmware' + '&' + 'name=' + '&'; - - for (var i = 0; i < dev_fld.length; i++) { - datas = datas + dev_fld[i] + '=' + $('#ext_' + dev_fld[i]).val() + '&'; - } - ; - } if ($(this).data('id') === 'model_add') { var dev_cmd = 'model_add'; // var dev_fld = ["model","vendor","dns","buttons","loadimage","loadinformationid","validate","enabled"]; @@ -631,7 +625,10 @@ $(document).ready(function () { url: 'ajax.php?module=sccp_manager&command=' + dev_cmd, data: datas, success: function (data) { -// console.log(data); + //$('.progress-bar').css('width', data.progress + '%'); + //console.log(data.progress); + + $('#pleaseWaitDialog').modal('hide'); if (data.status === true) { if (data.table_reload === true) { $('table').bootstrapTable('refresh'); @@ -664,6 +661,81 @@ $(document).ready(function () { } }); + + $('.sccp_get_ext').on('click', function (e) { +// console.log($(this).data('id')); + + +// ----------------------- Get external Files---------------- + if ($(this).data('id') === 'get_ext_files') { + var dev_cmd = 'get_ext_files'; + var dev_fld = ["device", "locale"]; + datas = 'type=' + $(this).data('type') + '&' + 'name=' + '&'; + + for (var i = 0; i < dev_fld.length; i++) { + datas = datas + dev_fld[i] + '=' + $('#ext_' + dev_fld[i]).val() + '&'; + } + ; + } + + if (dev_cmd !== '') { + $.ajax({ + // Need to modify xhr here to add listener + xhr: function() { + const controller = new AbortController(); + var xhr = new XMLHttpRequest(); + xhr.addEventListener('progress', function(evt) { + var result = evt.srcElement.responseText.split(','); + var percentComplete = result[result.length - 2]; //last element is empty. + $('#progress-bar').css('width', percentComplete + '%'); + if (percentComplete == 100 ) { + controller.abort(); + } + }, true, { signal: controller.signal }); + return xhr; + }, + type: 'POST', + url: 'ajax.php?module=sccp_manager&command=' + dev_cmd, + data: datas, + success: function (data) { + + $('#pleaseWaitDialog').modal('hide'); + data = JSON.parse(data.replace(/^(.*\{)/,"\{")); + if (data.status === true) { + if (data.table_reload === true) { + $('table').bootstrapTable('refresh'); + } + if (data.message) { + fpbxToast(data.message,_('Operation Result'), 'success'); + if (data.reload === true) { + //Need setTimout or reload will kill Toast + setTimeout(function(){location.reload();},500); + } + } + } else { + if (Array.isArray(data.message)) { + data.message.forEach(function (entry) { + fpbxToast(data.message[1],_('Error Result'), 'warning'); + }); + } else { + if (data.message) { + fpbxToast(data.message,_('Error Result'), 'warning'); + } else { + if (data) { + bs_alert(data,data.status); + } + } + } + } + } + + }); + } + + }); + + + $('#cr_sccp_phone_xml').on('click', function (e) { // console.log("asasdasdasdasd"); // console.log($('#update-sccp-phone').find(':selected').data('val')); @@ -1055,6 +1127,14 @@ function hex2bin(hex) return String.fromCharCode.apply(String, bytes); } +function showProgress() { + $('#pleaseWaitDialog').modal(); +} + +function closeProgress() { + $('#pleaseWaitDialog').modal('hide'); +} + function sleep(milliseconds) { var start = new Date().getTime(); diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 1398d3a..43b0045 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -12,7 +12,8 @@ and open the template in the editor. Base Version before all crash :-) * Input element Select SLD - Date format * SLZ - Time Zone * SLTZN - Time Zone List - * SLT - TFTP Lang + * SLT - Installed Languages + * SLTD - Device Languages * SLM - Music on hold * SLK - System KeySet * SLG - call groups @@ -246,14 +247,14 @@ and open the template in the editor. Base Version before all crash :-) netlangEnglish_United_States - The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. + The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. If No language packs found is shown, you need to add locales in the tftp server - + devlang English_United_States - The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. + The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. If No language packs found is shown, you need to add locales in the tftp server @@ -1334,19 +1335,19 @@ and open the template in the editor. Base Version before all crash :-) Time Zone offset - + netlang English_United_States - The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. + The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. If No language packs found is shown, you need to add locales in the tftp server - + devlang English_United_States - The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. + The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. If No language packs found is shown, you need to add locales in the tftp server diff --git a/install.php b/install.php index 6eab166..8ca382c 100644 --- a/install.php +++ b/install.php @@ -867,6 +867,7 @@ function checkTftpServer() { $possibleFtpDirs = array('/srv', '/srv/tftp','/var/lib/tftp', '/tftpboot'); // write a couple of sentinels to different distro tftp locations in the filesystem + // TODO: Depending on distro, do we have write permissions foreach ($possibleFtpDirs as $dirToTest) { if (is_dir($dirToTest) && is_writable($dirToTest)) { $tempFile = "${dirToTest}/{$remoteFileName}"; diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 9c8d923..117e569 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -305,6 +305,7 @@ class extconfigs if (file_exists($adv_ini)){ rename($adv_ini, "{$adv_ini}.old"); } + // TODO: index file is not declared $indexFile = fopen($adv_ini,'w'); fwrite($indexFile, "[main]\n"); foreach ($adv_config as $advKey => $advVal) { diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index ee49732..91663c2 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -501,8 +501,12 @@ class formcreate } $select_opt= $syslangs; break; - case 'SLT': - $select_opt= $installedLangs; + case 'SLTD': + $select_opt = array('xx' => 'No language packs found'); + if (!empty($installedLangs)) { + $select_opt = (array)$installedLangs; + + } break; case 'SLZ': $timeZoneOffsetList = array('-12' => 'GMT -12', '-11' => 'GMT -11', '-10' => 'GMT -10', '-09' => 'GMT -9', @@ -514,7 +518,7 @@ class formcreate $select_opt= $timeZoneOffsetList; break; case 'SLA': - $select_opt =''; + $select_opt = array(); if (!empty($fvalues[$res_n])) { if (!empty($fvalues[$res_n]['data'])) { $res_value = explode(';', $fvalues[$res_n]['data']); @@ -616,6 +620,167 @@ class formcreate name; + $res_id = $npref.$res_n; + $child->value =''; + // $select_opt is an associative array for these types. + if (!empty($metainfo[$res_n])) { + if ($child->meta_help == '1' || $child->help == 'Help!') { + $child->help = $metaInfo[$res_n]; + } + } + $select_opt = array('xx' => 'No language packs found'); + if (!empty($installedLangs)) { + $select_opt = $installedLangs; + } + + if (empty($child->class)) { + $child->class = 'form-control'; + } + if (!empty($fvalues[$res_n])) { + if (!empty($fvalues[$res_n]['data'])) { + $child->value = $fvalues[$res_n]['data']; + } + } + if (empty($child->value)) { + if (!empty($child->default)) { + $child->value = $child->default; + } + } + $langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang'); + $localeArray = array_combine(array_keys($langArr),array_column($langArr, 'locale')); + $requestType = 'locale'; + ?> +
    +
    +
    + + + + + + +
    + + +
    +
    +
    + class . '" id="' . $res_id . '">'; + foreach ($select_opt as $key => $val) { + $opt_key = $key; + $opt_val = $val; + + echo '"; + } + ?> + +
    +
    +
    + +
    + +
    +
    +
    +
    + help);?> +
    +
    +
    + + getFilesFromProvisioner($request['type'],$request['name'],$request['device']); - return $result; + return $this->getFilesFromProvisioner($request); break; } } diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index f911d96..6432b23 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -271,15 +271,17 @@ trait helperfunctions { } - public function getFilesFromProvisioner($type = '',$name = '',$device = '') { + public function getFilesFromProvisioner($request) { + dbug($request); $filesToGet = array(); $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/"; if (!$tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) { $this->getFileListFromProvisioner(); $tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml"); } - switch ($type) { + switch ($request['type']) { case 'firmware': + $device = $request['device']; if (!is_dir("{$this->sccppath['tftp_firmware_path']}/{$device}")) { mkdir("{$this->sccppath['tftp_firmware_path']}/{$device}", 0755); } @@ -290,13 +292,49 @@ trait helperfunctions { file_put_contents("{$this->sccppath['tftp_firmware_path']}/{$device}/{$srcFile}", file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile)); } - return "thanks for trying Diederik :-)"; - break; + $msg = "Firmware for {$device} has been successfully downloaded"; + break; + case 'locales': + $locale = $request['locale']; + $langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang'); + $language = $langArr[$locale]['locale']; + if (!is_dir("{$this->sccppath['tftp_lang_path']}/{$language}")) { + mkdir("{$this->sccppath['tftp_lang_path']}/{$language}", 0755); + } + + $localeDir = $tftpBootXml->xpath("//Directory[@name='locales']"); + $localeDir = $localeDir[0]->xpath("//Directory[@name='languages']"); + $result = $localeDir[0]->xpath("//Directory[@name='{$language}']"); + $filesToGet = (array)$result[0]->FileName; + + $totalFiles = count($filesToGet); + $filesRetrieved = 0; + + foreach ($filesToGet as $srcFile) { + + file_put_contents("{$this->sccppath['tftp_lang_path']}/{$language}/{$srcFile}", + file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile)); + $filesRetrieved ++; + $percentComplete = $filesRetrieved *100 / $totalFiles; + + //$data = array('data' => array('percentComplete' => $percentComplete)); + $data = "{$percentComplete},"; + //echo "id: $filesRetrieved" . PHP_EOL; + //echo json_encode($data); + echo $data; + //echo PHP_EOL; + ob_flush(); + flush(); + + } + $msg = "{$locale} Locale has been successfully downloaded"; + break; default: return false; break; } + return array('status' => true, 'message' => $msg, 'reload' => true); } public function initVarfromXml() { diff --git a/views/advserver.model.php b/views/advserver.model.php index f24c682..180eb85 100644 --- a/views/advserver.model.php +++ b/views/advserver.model.php @@ -172,7 +172,7 @@
    - +
    @@ -188,7 +188,7 @@
    diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index 402b48e..bcb1022 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -77,12 +77,15 @@ foreach ($items as $child) { case 'SLK': case 'SLP': case 'SLS': - case 'SLT': + case 'SLTD': case 'SLA': case 'SLZ': case 'SL': \FreePbx::sccp_manager()->formcreate->addElementSL($child, $fvalues, $sccp_defaults,$npref, $installedLangs); break; + case 'SLT': + \FreePbx::sccp_manager()->formcreate->addElementSLT($child, $fvalues, $sccp_defaults,$npref, $installedLangs); + break; case 'SDM': case 'SDMS': case 'SDE': @@ -105,4 +108,3 @@ if ($h_show==1) { echo ''; } ?> -installedLangs From 913cbd14c42717b8693c147e49041280f4d2e7a8 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 18 Jul 2021 12:23:17 +0200 Subject: [PATCH 100/181] Set default for LangDir When Sccp_manager construct is called by the installer, this variable is not set. The installer sets it later --- Sccp_manager.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 7009fe8..caa8fe3 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -754,8 +754,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { private function findInstLangs() { //locales and languages are installed in the tftp_lang_path $result = array(); - // TODO: Installer comes here so need to set default / ? - $langDir = $this->sccppath["tftp_lang_path"]; + $langDir = '/'; //set default for when called by installer on virgin system + if (!empty($this->sccppath["tftp_lang_path"])) { + $langDir = $this->sccppath["tftp_lang_path"]; + } $localeJar = 'be-sccp.jar'; // This jar should exist if the locale is populated $langArr = $this->extconfigs->getExtConfig('sccp_lang'); $localeArray = array_combine(array_keys($langArr),array_column($langArr, 'locale')); From 5c4bbaabba19045a0e19651dc35d0a0adf5cb56a Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 18 Jul 2021 12:33:08 +0200 Subject: [PATCH 101/181] Ignore $adv_ini if not set Installer and sccp_manager construct - empty variable. Do not use if not set (will be set later) --- sccpManClasses/extconfigs.class.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 117e569..2dc1940 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -305,14 +305,15 @@ class extconfigs if (file_exists($adv_ini)){ rename($adv_ini, "{$adv_ini}.old"); } - // TODO: index file is not declared - $indexFile = fopen($adv_ini,'w'); - fwrite($indexFile, "[main]\n"); - foreach ($adv_config as $advKey => $advVal) { - fwrite($indexFile, "{$advKey} = {$advVal}\n"); + if (!empty($adv_ini)) { + $indexFile = fopen($adv_ini,'w'); + fwrite($indexFile, "[main]\n"); + foreach ($adv_config as $advKey => $advVal) { + fwrite($indexFile, "{$advKey} = {$advVal}\n"); + } + fclose($indexFile); + $settingsFromDb['tftp_rewrite']['data'] = 'pro'; } - fclose($indexFile); - $settingsFromDb['tftp_rewrite']['data'] = 'pro'; break; case 'on': case 'internal': From 3d690907678fa3b86aa6fc687049a604bbec09d0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 18 Jul 2021 12:50:53 +0200 Subject: [PATCH 102/181] Fix finding master file --- sccpManTraits/helperFunctions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 6432b23..08c7ca0 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -275,10 +275,11 @@ trait helperfunctions { dbug($request); $filesToGet = array(); $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/"; - if (!$tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) { + if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) { $this->getFileListFromProvisioner(); - $tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml"); } + $tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml"); + switch ($request['type']) { case 'firmware': $device = $request['device']; From d9fa0ad8bf0fb8a9eb1698a20434673727f21a22 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 18 Jul 2021 12:51:16 +0200 Subject: [PATCH 103/181] Update module.xml --- module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module.xml b/module.xml index 3e5c4c2..d600f86 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.0 + 14.3.0.1 setup SCCP Connectivity Steve Lad, Alex GP From b3b3858965c97a9e184265fac83496ee56860865 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 19 Jul 2021 08:04:12 +0200 Subject: [PATCH 104/181] standardise get ext file modal and add via include Create standard modal for insertion via include in firmcreate class and adserver view --- assets/js/sccp_manager.js | 3 - sccpManClasses/formcreate.class.php | 92 ++--------------------------- sccpManTraits/ajaxHelper.php | 73 ++++++++++++++++++++++- sccpManTraits/helperFunctions.php | 66 --------------------- views/advserver.model.php | 57 ++++-------------- views/getFileModal.html | 75 +++++++++++++++++++++++ 6 files changed, 163 insertions(+), 203 deletions(-) create mode 100644 views/getFileModal.html diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 6aed2ce..9503f6d 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -625,10 +625,7 @@ $(document).ready(function () { url: 'ajax.php?module=sccp_manager&command=' + dev_cmd, data: datas, success: function (data) { - //$('.progress-bar').css('width', data.progress + '%'); - //console.log(data.progress); - $('#pleaseWaitDialog').modal('hide'); if (data.status === true) { if (data.table_reload === true) { $('table').bootstrapTable('refresh'); diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index 91663c2..6125126 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -650,97 +650,16 @@ class formcreate } } $langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang'); - $localeArray = array_combine(array_keys($langArr),array_column($langArr, 'locale')); + $selectArray = array_combine(array_keys($langArr),array_column($langArr, 'locale')); $requestType = 'locale'; ?>
    - - - - - -
    @@ -764,10 +683,9 @@ class formcreate
    -
    -
    diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index c231591..cc46ec1 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -546,7 +546,6 @@ trait ajaxHelper { $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); } - foreach ($dbSaveArray as $rowToSave) { $this->dbinterface->updateTableDefaults($rowToSave['table'], $rowToSave['field'], $rowToSave['Default']); } @@ -555,8 +554,6 @@ trait ajaxHelper { $save_settings[] = array('status' => true); $this->createDefaultSccpXml(); - //$this->getFileListFromProvisioner(); - return $save_settings; } @@ -585,6 +582,76 @@ trait ajaxHelper { } return $final; } + + public function getFilesFromProvisioner($request) { + dbug($request); + $filesToGet = array(); + $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/"; + if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) { + $this->getFileListFromProvisioner(); + } + $tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml"); + + switch ($request['type']) { + case 'firmware': + $device = $request['device']; + if (!is_dir("{$this->sccppath['tftp_firmware_path']}/{$device}")) { + mkdir("{$this->sccppath['tftp_firmware_path']}/{$device}", 0755); + } + $firmwareDir = $tftpBootXml->xpath("//Directory[@name='firmware']"); + $result = $firmwareDir[0]->xpath("//Directory[@name={$device}]"); + $filesToGet = (array)$result[0]->FileName; + $totalFiles = count($filesToGet); + $filesRetrieved = 0; + + foreach ($filesToGet as $srcFile) { + file_put_contents("{$this->sccppath['tftp_firmware_path']}/{$device}/{$srcFile}", + file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile)); + $filesRetrieved ++; + $percentComplete = $filesRetrieved *100 / $totalFiles; + $data = "{$percentComplete},"; + echo $data; + ob_flush(); + flush(); + } + $msg = "Firmware for {$device} has been successfully downloaded"; + break; + case 'locale': + $locale = $request['locale']; + $langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang'); + $language = $langArr[$locale]['locale']; + + if (!is_dir("{$this->sccppath['tftp_lang_path']}/{$language}")) { + mkdir("{$this->sccppath['tftp_lang_path']}/{$language}", 0755); + } + + $localeDir = $tftpBootXml->xpath("//Directory[@name='locales']"); + $localeDir = $localeDir[0]->xpath("//Directory[@name='languages']"); + $result = $localeDir[0]->xpath("//Directory[@name='{$language}']"); + $filesToGet = (array)$result[0]->FileName; + + $totalFiles = count($filesToGet); + $filesRetrieved = 0; + + foreach ($filesToGet as $srcFile) { + file_put_contents("{$this->sccppath['tftp_lang_path']}/{$language}/{$srcFile}", + file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile)); + $filesRetrieved ++; + $percentComplete = $filesRetrieved *100 / $totalFiles; + $data = "{$percentComplete},"; + echo $data; + ob_flush(); + flush(); + + } + $msg = "{$locale} Locale has been successfully downloaded"; + break; + default: + return false; + break; + } + return array('status' => true, 'message' => $msg, 'reload' => true); + } } ?> diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 08c7ca0..7815b61 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -271,72 +271,6 @@ trait helperfunctions { } - public function getFilesFromProvisioner($request) { - dbug($request); - $filesToGet = array(); - $provisionerUrl = "https://github.com/dkgroot/provision_sccp/raw/master/"; - if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) { - $this->getFileListFromProvisioner(); - } - $tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml"); - - switch ($request['type']) { - case 'firmware': - $device = $request['device']; - if (!is_dir("{$this->sccppath['tftp_firmware_path']}/{$device}")) { - mkdir("{$this->sccppath['tftp_firmware_path']}/{$device}", 0755); - } - $firmwareDir = $tftpBootXml->xpath("//Directory[@name='firmware']"); - $result = $firmwareDir[0]->xpath("//Directory[@name={$device}]"); - $filesToGet = (array)$result[0]->FileName; - foreach ($filesToGet as $srcFile) { - file_put_contents("{$this->sccppath['tftp_firmware_path']}/{$device}/{$srcFile}", - file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile)); - } - $msg = "Firmware for {$device} has been successfully downloaded"; - break; - case 'locales': - $locale = $request['locale']; - $langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang'); - $language = $langArr[$locale]['locale']; - - if (!is_dir("{$this->sccppath['tftp_lang_path']}/{$language}")) { - mkdir("{$this->sccppath['tftp_lang_path']}/{$language}", 0755); - } - - $localeDir = $tftpBootXml->xpath("//Directory[@name='locales']"); - $localeDir = $localeDir[0]->xpath("//Directory[@name='languages']"); - $result = $localeDir[0]->xpath("//Directory[@name='{$language}']"); - $filesToGet = (array)$result[0]->FileName; - - $totalFiles = count($filesToGet); - $filesRetrieved = 0; - - foreach ($filesToGet as $srcFile) { - - file_put_contents("{$this->sccppath['tftp_lang_path']}/{$language}/{$srcFile}", - file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile)); - $filesRetrieved ++; - $percentComplete = $filesRetrieved *100 / $totalFiles; - - //$data = array('data' => array('percentComplete' => $percentComplete)); - $data = "{$percentComplete},"; - //echo "id: $filesRetrieved" . PHP_EOL; - //echo json_encode($data); - echo $data; - //echo PHP_EOL; - ob_flush(); - flush(); - - } - $msg = "{$locale} Locale has been successfully downloaded"; - break; - default: - return false; - break; - } - return array('status' => true, 'message' => $msg, 'reload' => true); - } public function initVarfromXml() { if ((array) $this->xml_data) { diff --git a/views/advserver.model.php b/views/advserver.model.php index 180eb85..ca51ac7 100644 --- a/views/advserver.model.php +++ b/views/advserver.model.php @@ -148,52 +148,21 @@
    +sccppath['tftp_path']}/masterFilesStructure.xml"); +$firmwareDir = $tftpBootXml->xpath("//Directory[@name='firmware']"); - +foreach ($firmwareDir[0] as $child) { + if (!empty((string)$child['name'])) { + $selectArray[(string)$child['name']] = (string)$child['name']; + } +}; +include($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/views/getFileModal.html'); + +?>
    - + From a4aa4eb03bae3fb9eaf9339818cac1c945f68636 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 21 Jul 2021 08:57:43 +0200 Subject: [PATCH 111/181] Simplify db queries and change alignment --- sccpManClasses/dbinterface.class.php | 14 +++++++++++++- sccpManTraits/ajaxHelper.php | 9 ++++----- views/hardware.extension.php | 4 ++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index f259558..b8b5077 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -55,7 +55,7 @@ class dbinterface return false; } switch ($dataid) { - case 'sccp': + case 'extGrid': // only called by getExtensionGrid from hardware.extension.php view $stmts = $this->db->prepare('SELECT sccpline.name, sccpline.label, sccpbuttonconfig.ref as mac FROM sccpline INNER JOIN sccpbuttonconfig ON sccpline.name=sccpbuttonconfig.name'); @@ -68,6 +68,18 @@ class dbinterface $stmts->bindParam(':name', $data['name'],\PDO::PARAM_STR); } break; + case 'phoneGrid': + $fld = 'name, name as mac, type, button, addon, _description as description'; + switch ($data['type']) { + case "cisco-sip": + $stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE type LIKE '%-sip' ORDER BY name"); + break; + case "sccp": // Fall through to default intentionally + default: + $stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE type not LIKE '%-sip' ORDER BY name"); + break; + } + break; case 'SccpDevice': if (empty($data['fields'])) { $fld = 'name, name as mac, type, button, addon, _description as description'; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 7db3732..938314d 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -315,19 +315,18 @@ trait ajaxHelper { break; case 'getPhoneGrid': $dbDevices = array(); - $cmd_type = !empty($request['type']) ? $request['type'] : ''; - // Find all devices defined in the database - $dbDevices = $this->dbinterface->getSccpDeviceTableData('SccpDevice', array('type' => $cmd_type)); + // Find all devices defined in the database. + $dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $request['type'])); // Return if only interested in SIP devices - if ($cmd_type == 'cisco-sip') { + if ($request['type'] == 'cisco-sip') { return $dbDevices; //this may be empty } // Find all devices currently connected $activeDevices = $this->aminterface->sccp_get_active_device(); foreach ($dbDevices as &$dev_id) { - $id_name = $dev_id['name']; + $id_name = $dev_id['mac']; if (!empty($activeDevices[$id_name])) { // Device is in db and is connected $dev_id['description'] = $activeDevices[$id_name]['descr']; diff --git a/views/hardware.extension.php b/views/hardware.extension.php index d72b473..2f3b1ea 100644 --- a/views/hardware.extension.php +++ b/views/hardware.extension.php @@ -20,13 +20,13 @@ if (!empty($this->sccpvalues['system_rouminguser'])) {
     
    -
    +
    - + From 3475efc2c6f192117d3d7a8dad98b1e8bf6da057 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 21 Jul 2021 11:30:50 +0200 Subject: [PATCH 112/181] Database request modifications and page improvements Add device to extensions page - permits to see unassigned lines and shared lines easily Reformat status to centred change 'replace' in sccp class to only 'insert on duplicate key' (UPSET equivalent) Change request in phoneGrid to left join to show all lines, even unassigned to a device --- sccpManClasses/Sccp.class.php.v433 | 23 +++++++---------------- sccpManClasses/dbinterface.class.php | 4 +--- sccpManTraits/ajaxHelper.php | 2 -- views/hardware.extension.php | 2 +- 4 files changed, 9 insertions(+), 22 deletions(-) diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 89ccb3a..1ebd4b3 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -155,25 +155,16 @@ class Sccp extends \FreePBX\modules\Core\Driver { } } - $sqlCol = 'name'; - $sqlVal = "'{$id}'"; + // only store values that have been set; if need to display a default, must show in page. + $sqlSet = "name='{$id}'"; foreach($this->data_fld as $key => $val) { - if (isset($settings[$val]['value'])){ - $sqlCol .= ", {$key}"; - $sqlVal .= ", '{$settings[$val]['value']}'"; - } else { - if (array_key_exists($key, $this->line_defaults)) { - $sqlCol .= ", {$key}"; - if (!empty($this->line_defaults[$key])) { - $sqlVal .= ", '{$this->line_defaults[$key]}'"; - } else { - $sqlVal .= NULL; - } - } + if (!empty($settings[$val]['value'])) { + $sqlSet .= ", {$key}='{$settings[$val]['value']}'"; } } - $sql = "REPLACE INTO sccpline ( {$sqlCol} ) VALUES ( {$sqlVal} )"; - $sth = $this->database->prepare($sql); + + $stmt = "INSERT INTO sccpline SET {$sqlSet} ON DUPLICATE KEY UPDATE {$sqlSet}"; + $sth = $this->database->prepare($stmt); $sth->execute(); /* If called from SCCP Phone, redirect to SCCP Phone page on submit. diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index b8b5077..8664091 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -47,8 +47,6 @@ class dbinterface public function getSccpDeviceTableData($dataid, $data = array()) { // $stmt is a single row fetch, $stmts is a fetchAll. - dbug($dataid); - dbug($data); $stmt = ''; $stmts = ''; if ($dataid == '') { @@ -58,7 +56,7 @@ class dbinterface case 'extGrid': // only called by getExtensionGrid from hardware.extension.php view $stmts = $this->db->prepare('SELECT sccpline.name, sccpline.label, sccpbuttonconfig.ref as mac - FROM sccpline INNER JOIN sccpbuttonconfig ON sccpline.name=sccpbuttonconfig.name'); + FROM sccpline LEFT JOIN sccpbuttonconfig ON sccpline.name=sccpbuttonconfig.name ORDER BY sccpline.name'); break; case 'SccpExtension': if (empty($data['name'])) { diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 938314d..598503e 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -294,9 +294,7 @@ trait ajaxHelper { if (empty($lineList)) { return array(); } - dbug($lineList); $activeDevices = $this->aminterface->sccp_get_active_device(); - dbug($activeDevices); if (!empty($activeDevices)) { foreach ($lineList as $key => $lineArr) { if (isset($activeDevices[$lineArr['mac']])) { diff --git a/views/hardware.extension.php b/views/hardware.extension.php index 2f3b1ea..c261ccb 100644 --- a/views/hardware.extension.php +++ b/views/hardware.extension.php @@ -23,9 +23,9 @@ if (!empty($this->sccpvalues['system_rouminguser'])) {
    - + From 3a53e9ac8be520b41913cabdb441b6b6afbddb73 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 21 Jul 2021 12:54:05 +0200 Subject: [PATCH 113/181] Optimise database calls Remove unnecessary post processing on returned object --- sccpManClasses/aminterface.class.php | 2 +- sccpManClasses/dbinterface.class.php | 13 +++++++------ sccpManTraits/ajaxHelper.php | 10 ++++------ 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sccpManClasses/aminterface.class.php b/sccpManClasses/aminterface.class.php index 742c326..fbe2f26 100644 --- a/sccpManClasses/aminterface.class.php +++ b/sccpManClasses/aminterface.class.php @@ -392,7 +392,7 @@ class aminterface $result = array(); if ($this->_connect_state) { $_action = new \FreePBX\modules\Sccp_manager\aminterface\SCCPShowDevicesAction(); - $result = $this->send($_action)->getResult(); + $result = (array)$this->send($_action)->getResult(); } return $result; } diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 8664091..a1c7b72 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -46,7 +46,7 @@ class dbinterface public function getSccpDeviceTableData($dataid, $data = array()) { - // $stmt is a single row fetch, $stmts is a fetchAll. + // $stmt is a single row fetch, $stmts is a fetchAll while stmtU is fetchAll UNIQUE $stmt = ''; $stmts = ''; if ($dataid == '') { @@ -171,18 +171,19 @@ class dbinterface } elseif (!empty($stmts)) { $stmts->execute(); $raw_settings = $stmts->fetchAll(\PDO::FETCH_ASSOC); + } elseif (!empty($stmtU)) { + //returns an assoc array indexed on first field + $stmtU->execute(); + $raw_settings = $stmtU->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); } return $raw_settings; } public function get_db_SccpSetting() { - $stmt = $this->db->prepare('SELECT keyword, seq, type, data, systemdefault FROM sccpsettings ORDER BY type, seq'); + $stmt = $this->db->prepare('SELECT keyword, sccpsettings.* FROM sccpsettings ORDER BY type, seq'); $stmt->execute(); - foreach ($stmt->fetchAll(\PDO::FETCH_ASSOC) as $key => $rowArray) { - $settingsFromDb[$rowArray['keyword']] = $rowArray; - unset($settingsFromDb[$key]); - } + $settingsFromDb = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); return $settingsFromDb; } diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 598503e..198f5d2 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -298,13 +298,11 @@ trait ajaxHelper { if (!empty($activeDevices)) { foreach ($lineList as $key => $lineArr) { if (isset($activeDevices[$lineArr['mac']])) { - $tpm_info = $activeDevices[$lineArr['mac']]; - if (!empty($tpm_info)) { - $lineList[$key]['line_status'] = $tpm_info['status']; - $lineList[$key]['line_status'] .= " | {$tpm_info['act']}"; + $actDevStat = $activeDevices[$lineArr['mac']]; + if (!empty($actDevStat)) { + $lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}"; } else { - $lineList[$key]['line_status'] = ''; - $lineList[$key]['line_status'] .= '|'; + $lineList[$key]['line_status'] = '|'; } } } From 215cacae4164050fcffaeb87e5870a9a6b8cc75d Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 21 Jul 2021 16:44:23 +0200 Subject: [PATCH 114/181] Get Country tones with locales Get country files with locales WIP incompatibility between provision, its rewrite rules and the file structure WIP - need to clean up get files from provisioner --- Sccp_manager.class.php | 11 ++--- module.xml | 2 +- sccpManClasses/extconfigs.class.php | 12 +++-- sccpManTraits/ajaxHelper.php | 71 +++++++++++++++++++---------- views/getFileModal.html | 6 ++- 5 files changed, 66 insertions(+), 36 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 5ec82c9..7a09353 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -809,7 +809,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'tftp_lang_path' => $this->sccpvalues['tftp_lang_path']['data'], 'tftp_firmware_path' => $this->sccpvalues['tftp_firmware_path']['data'], 'tftp_dialplan_path' => $this->sccpvalues['tftp_dialplan_path']['data'], - 'tftp_softkey_path' => $this->sccpvalues['tftp_softkey_path']['data'] + 'tftp_softkey_path' => $this->sccpvalues['tftp_softkey_path']['data'], + 'tftp_countries_path' => $this->sccpvalues['tftp_countries_path']['data'] ); $read_config = $this->cnf_read->getConfig('sccp.conf'); @@ -868,11 +869,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function deleteDialPlan($get_file) { - if (!empty($get_file)) { - $file = $this->sccppath["tftp_dialplan_path"] . '/' . $get_file . '.xml'; - if (file_exists($file)) { - $res = unlink($file); - } + $file = $this->sccppath["tftp_dialplan_path"] . '/' . $get_file . '.xml'; + if (file_exists($file)) { + $res = unlink($file); } return $res; } diff --git a/module.xml b/module.xml index d600f86..3e5c4c2 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 8e31d36..8186646 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -246,7 +246,8 @@ class extconfigs 'dialplan' => 'dialplan', 'softkey' => 'softkey', 'ringtones' => 'ringtones', - 'wallpapers' => 'wallpapers' + 'wallpapers' => 'wallpapers', + 'countries' => 'countries' ); $adv_tree = array('pro' => array('templates' => 'tftproot', 'firmware' => 'tftproot', @@ -257,7 +258,8 @@ class extconfigs 'dialplan' => 'tftproot', 'softkey' => 'tftproot', 'ringtones' => 'tftproot', - 'wallpapers' => 'tftproot' + 'wallpapers' => 'tftproot', + 'countries' => 'locales' ), 'def' => array('templates' => 'tftproot', 'firmware' => '', @@ -267,7 +269,8 @@ class extconfigs 'dialplan' => '', 'softkey' => '', 'ringtones' => '', - 'wallpapers' => '' + 'wallpapers' => '', + 'countries' => '' ) ); $base_tree = array('tftp_templates_path' => 'templates', @@ -277,7 +280,8 @@ class extconfigs 'tftp_dialplan_path' => 'dialplan', 'tftp_softkey_path' => 'softkey', 'tftp_ringtones_path' => 'ringtones', - 'tftp_wallpapers_path' => 'wallpapers' + 'tftp_wallpapers_path' => 'wallpapers', + 'tftp_countries_path' => 'countries' ); $baseConfig = array(); diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 198f5d2..f3a7013 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -295,16 +295,12 @@ trait ajaxHelper { return array(); } $activeDevices = $this->aminterface->sccp_get_active_device(); - if (!empty($activeDevices)) { - foreach ($lineList as $key => $lineArr) { - if (isset($activeDevices[$lineArr['mac']])) { - $actDevStat = $activeDevices[$lineArr['mac']]; - if (!empty($actDevStat)) { - $lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}"; - } else { - $lineList[$key]['line_status'] = '|'; - } - } + foreach ($lineList as $key => $lineArr) { + if (array_key_exists($lineArr['mac'], $activeDevices)) { + $actDevStat = $activeDevices[$lineArr['mac']]; + $lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}"; + } else { + $lineList[$key]['line_status'] = '|'; } } return $lineList; @@ -629,33 +625,60 @@ trait ajaxHelper { break; case 'locale': $locale = $request['locale']; + $totalFiles = 0; $langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang'); $language = $langArr[$locale]['locale']; if (!is_dir("{$this->sccppath['tftp_lang_path']}/{$language}")) { mkdir("{$this->sccppath['tftp_lang_path']}/{$language}", 0755); } - + // Get locales $localeDir = $tftpBootXml->xpath("//Directory[@name='locales']"); $localeDir = $localeDir[0]->xpath("//Directory[@name='languages']"); $result = $localeDir[0]->xpath("//Directory[@name='{$language}']"); - $filesToGet = (array)$result[0]->FileName; + $filesToGet['languages'] = (array)$result[0]->FileName; + $totalFiles += count($filesToGet['languages']); + $languagesSrcDir = (string)$result[0]->DirectoryPath; + $languagesDstDir = "{$this->sccppath['tftp_lang_path']}/{$language}"; + + // Get countries. Country is a substring of locale with exception of korea + $country = explode('_', $language); + array_shift($country); + + $countryName = array_shift($country); + while (count($country)>=1) { + $countryName .= '_' . array_shift($country); + } + + if (!is_dir("{$this->sccppath['tftp_countries_path']}/{$countryName}")) { + mkdir("{$this->sccppath['tftp_countries_path']}/{$countryName}", 0755); + } + + $countryDir = $tftpBootXml->xpath("//Directory[@name='locales']"); + $countryDir = $countryDir[0]->xpath("//Directory[@name='countries']"); + $result = $countryDir[0]->xpath("//Directory[@name='{$countryName}']"); + $filesToGet['countries'] = (array)$result[0]->FileName; + $totalFiles += count($filesToGet['countries']); + $countriesSrcDir = (string)$result[0]->DirectoryPath; + $countriesDstDir = "{$this->sccppath['tftp_countries_path']}/{$countryName}"; - $totalFiles = count($filesToGet); $filesRetrieved = 0; - foreach ($filesToGet as $srcFile) { - file_put_contents("{$this->sccppath['tftp_lang_path']}/{$language}/{$srcFile}", - file_get_contents($provisionerUrl . (string)$result[0]->DirectoryPath . $srcFile)); - $filesRetrieved ++; - $percentComplete = $filesRetrieved *100 / $totalFiles; - $data = "{$percentComplete},"; - echo $data; - ob_flush(); - flush(); - + foreach (array('languages', 'countries') as $section){ + $srcDir = ${"{$section}SrcDir"}; + $dstDir = ${"{$section}DstDir"}; + foreach ($filesToGet[$section] as $srcFile) { + file_put_contents("{$dstDir}/{$srcFile}", + file_get_contents($provisionerUrl . $srcDir . $srcFile)); + $filesRetrieved ++; + $percentComplete = $filesRetrieved *100 / $totalFiles; + $data = "{$percentComplete},"; + echo $data; + ob_flush(); + flush(); + } } - $msg = "{$locale} Locale has been successfully downloaded"; + $msg = "{$locale} Locale and Country tones have been successfully downloaded"; break; default: return false; diff --git a/views/getFileModal.html b/views/getFileModal.html index 9d965f1..30aec63 100644 --- a/views/getFileModal.html +++ b/views/getFileModal.html @@ -33,7 +33,11 @@ echo " From 4151b4fdae5a2ea9835da5d69193d647e69d77f4 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 23 Jul 2021 12:14:46 +0200 Subject: [PATCH 115/181] Restructure languages and locales management Base off of provision file structure Store netlang and devlang Stop usage of extconfig ->sccplang --- Sccp_manager.class.php | 212 +++++++------------------- assets/js/sccp_manager.js | 4 +- conf/sccpgeneral.xml.v433 | 33 ++-- install.php | 17 +-- module.xml | 1 - sccpManClasses/formcreate.class.php | 52 +++++-- sccpManClasses/xmlinterface.class.php | 93 ++++++++--- sccpManTraits/ajaxHelper.php | 212 +++++++++++++++++++++++--- sccpManTraits/helperFunctions.php | 2 +- views/formShowSysDefs.php | 6 +- views/getFileModal.html | 20 ++- 11 files changed, 394 insertions(+), 258 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 7a09353..86ba027 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -139,7 +139,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); //Initialise core settings $this->initializeSccpPath(); //Set required Paths $this->updateTimeZone(); // Get timezone from FreePBX - $this->findInstLangs(); + //$this->findInstLangs(); $this->saveSccpSettings(); } @@ -172,7 +172,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { 'h_show' => $show_Header, 'form_prefix' => $form_prefix, 'fvalues' => $form_values, - 'installedLangs' => $this->installedLangs, + 'installedLangs' => $this->findInstLangs(), 'chanSccpHelp' => $this->sccpHelpInfo, 'sccp_defaults' => $this->sccpvalues ) @@ -496,141 +496,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { return $res; } - function saveSccpDevice($get_settings, $validateonly = false) { - $hdr_prefix = 'sccp_hw_'; - $hdr_arprefix = 'sccp_hw-ar_'; - $hdr_vendPrefix = 'sccp_hw_vendorconfig'; - - $save_buttons = array(); - $save_settings = array(); - $save_codec = array(); - $name_dev = ''; - $db_field = $this->dbinterface->getSccpDeviceTableData("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') ? 'add' : 'clear'; // Possible values are delete, replace, add, clear. - $hw_prefix = 'SEP'; - if (!empty($get_settings[$hdr_prefix . 'type'])) { - $value = $get_settings[$hdr_prefix . 'type']; - if (strpos($value, 'ATA') !== false) { - $hw_prefix = 'ATA'; - } - if (strpos($value, 'VG') !== false) { - $hw_prefix = 'VG'; - } - } - foreach ($db_field as $data) { - $key = (string) $data['Field']; - $value = ""; - switch ($key) { - case 'name': - if (!empty($get_settings[$hdr_prefix . 'mac'])) { - $value = $get_settings[$hdr_prefix . 'mac']; - $value = strtoupper(str_replace(array('.', '-', ':'), '', $value)); // Delete mac separators from string - $value = sprintf("%012s", $value); - if ($hw_prefix == 'VG') { - $value = $hw_prefix . $value . '0'; - } else { - $value = $hw_prefix . $value; - } - $name_dev = $value; - } - break; - case 'phonecodepage': - $value = 'null'; - // TODO: getExtConfig(sccp_lang ....) does not accept any additional arguments and will return an array - if (!empty($get_settings[$hdr_prefix . 'devlang'])) { - $lang_data = $this->extconfigs->getExtConfig('sccp_lang', $get_settings[$hdr_prefix . 'devlang']); - if (!empty($lang_data)) { - $value = $lang_data['codepage']; - } - } - break; - case '_hwlang': - if (empty($get_settings[$hdr_prefix . 'netlang']) || empty($get_settings[$hdr_prefix . 'devlang'])) { - $value = 'null'; - } else { - $value = $get_settings[$hdr_prefix . 'netlang'] . ':' . $get_settings[$hdr_prefix . 'devlang']; - } - break; - default: - // handle vendor prefix - if (!empty($get_settings[$hdr_vendPrefix . $key])) { - $value = $get_settings[$hdr_vendPrefix . $key]; - } - // handle array prefix - if (!empty($get_settings[$hdr_arprefix . $key])) { - $arr_data = ''; - $arr_clear = false; - foreach ($get_settings[$hdr_arprefix . $key] as $vkey => $vval) { - $tmp_data = ''; - foreach ($vval as $vkey => $vval) { - switch ($vkey) { - case 'inherit': - if ($vval == 'on') { - $arr_clear = true; - // Злобный ХАК ?!TODO!? - if ($key == 'permit') { - $save_settings['deny'] = 'NONE'; - } - } - break; - case 'internal': - if ($vval == 'on') { - $tmp_data .= 'internal;'; - } - break; - default: - $tmp_data .= $vval . '/'; - break; - } - } - if (strlen($tmp_data) > 2) { - while (substr($tmp_data, -1) == '/') { - $tmp_data = substr($tmp_data, 0, -1); - } - $arr_data .= $tmp_data . ';'; - } - } - while (substr($arr_data, -1) == ';') { - $arr_data = substr($arr_data, 0, -1); - } - if ($arr_clear) { - $value = 'NONE'; - } else { - $value = $arr_data; - } - } - // Now only have normal prefix - if (!empty($get_settings["{$hdr_prefix}{$key}"])) { - $value = $get_settings["{$hdr_prefix}{$key}"]; - } else if (!empty($get_settings["sccp_hw{$key}"])) { - //have an underscore db field - $value = $get_settings["sccp_hw{$key}"]; - } - } - if (!empty($value)) { - $save_settings[$key] = $value; - } - } - // Save this device. - $this->dbinterface->write('sccpdevice', $save_settings, 'replace'); - // Retrieve the phone buttons and write back to - // update sccpdeviceconfig via Trigger - $save_buttons = $this->getPhoneButtons($get_settings, $name_dev, $hw_type); - $this->dbinterface->write('sccpbuttons', $save_buttons, $update_hw, '', $name_dev); - // Create new XML for this device, and then reset or restart the device - // so that it loads the file from TFT. - $this->createSccpDeviceXML($name_dev); - if ($hw_id == 'new') { - $this->aminterface->sccpDeviceReset($name_dev, 'reset'); - } else { - $this->aminterface->sccpDeviceReset($name_dev, 'restart'); - } - - return $save_settings; - } - function handleRoamingUsers($get_settings, $validateonly = false) { $hdr_prefix = 'sccp_ru_'; $hdr_arprefix = 'sccp_ru-ar_'; @@ -650,13 +515,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { case 'name': $value = $name_dev; break; - case '_hwlang': - if (empty($get_settings[$hdr_prefix . 'netlang']) || empty($get_settings[$hdr_prefix . 'devlang'])) { - $value = 'null'; - } else { - $value = $get_settings[$hdr_prefix . 'netlang'] . ':' . $get_settings[$hdr_prefix . 'devlang']; - } - break; default: if (!empty($get_settings[$hdr_prefix . $key])) { $value = $get_settings[$hdr_prefix . $key]; @@ -758,25 +616,59 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ private function findInstLangs() { - //locales and languages are installed in the tftp_lang_path - $result = array(); - $langDir = '/'; //set default for when called by installer on virgin system - if (!empty($this->sccppath["tftp_lang_path"])) { - $langDir = $this->sccppath["tftp_lang_path"]; - } - $localeJar = 'be-sccp.jar'; // This jar should exist if the locale is populated - $langArr = $this->extconfigs->getExtConfig('sccp_lang'); - $localeArray = array_combine(array_keys($langArr),array_column($langArr, 'locale')); + //locales and country tones are installed in the tftp_lang_path + //Available packs from provisioner are in masterFilesStructure.xml in tftpRoot Path + // TODO: Need to include this file as part of module in case download not allowed/available - foreach (array_diff(scandir($langDir),array('.', '..')) as $subDir) { - if (is_dir($langDir . DIRECTORY_SEPARATOR . $subDir)) { - $filename = $langDir . DIRECTORY_SEPARATOR . $subDir . DIRECTORY_SEPARATOR . $localeJar; - if (file_exists($filename)) { - $result = array_merge(array_intersect($localeArray,array($subDir)),$result); + $searchDir = '/'; //set default for when called by installer on virgin system + $result = array(); + + if (!file_exists("{$this->sccppath['tftp_path']}/masterFilesStructure.xml")) { + $this->getFileListFromProvisioner(); + } + $tftpBootXml = simplexml_load_file("{$this->sccppath['tftp_path']}/masterFilesStructure.xml"); + + foreach (array('languages', 'countries') as $pack) { + switch ($pack) { + case 'languages': + if (!empty($this->sccppath['tftp_lang_path'])) { + $searchDir = $this->sccppath['tftp_lang_path']; + } + $simpleXmlArr = $tftpBootXml->xpath("//Directory[@name='languages']//DirectoryPath[contains(.,'languages/')]"); + array_shift($simpleXmlArr); // First element is the parent directory + foreach ($simpleXmlArr as $rowIn) { + $tmpArr = explode('/',(string)$rowIn); + array_pop($tmpArr); //last element is empty + $result[$pack]['available'][] = array_pop($tmpArr); + } + $fileToFind = 'be-sccp.jar'; // This file should exist if the locale is populated + break; + case 'countries': + if (!empty($this->sccppath["tftp_countries_path"])) { + $searchDir = $this->sccppath['tftp_countries_path']; + } + $simpleXmlArr = $tftpBootXml->xpath("//Directory[@name='countries']//DirectoryPath[contains(.,'countries/')]"); + array_shift($simpleXmlArr); // First element is the parent directory + foreach ($simpleXmlArr as $rowIn) { + $tmpArr = explode('/',(string)$rowIn); + array_pop($tmpArr); //last element is empty + $result[$pack]['available'][] = array_pop($tmpArr); + } + $fileToFind = 'g3-tones.xml'; // This file should exist if the locale is populated + break; + } + + foreach (array_diff(scandir($searchDir),array('.', '..')) as $subDir) { + if (is_dir($searchDir . DIRECTORY_SEPARATOR . $subDir)) { + $filename = $searchDir . DIRECTORY_SEPARATOR . $subDir . DIRECTORY_SEPARATOR . $fileToFind; + if (file_exists($filename)) { + $result[$pack]['have'][] = $subDir; + } } } } $this->installedLangs = $result; + return $result; } /* @@ -1131,14 +1023,14 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $this->sccp_conf_init['general'][$key] = explode(';', $content); break; case "devlang": - + /* $lang_data = $this->extconfigs->getExtConfig('sccp_lang', $value['data']); if (!empty($lang_data)) { - // TODO: getExtConfig(sccp_lang ....) does not accept any additional arguments and will return an array // TODO: will always get here, but lang_data['codepage'] will be empty as not a valid key $this->sccp_conf_init['general']['phonecodepage'] = $lang_data['codepage']; } break; + */ case "netlang": // Remove Key case "tftp_path": case "sccp_compatible": // This is equal to SccpDBmodel diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 9503f6d..dc0ad4f 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -666,7 +666,7 @@ $(document).ready(function () { // ----------------------- Get external Files---------------- if ($(this).data('id') === 'get_ext_files') { var dev_cmd = 'get_ext_files'; - var dev_fld = ["device", "locale"]; + var dev_fld = ["device", "locale", "country"]; datas = 'type=' + $(this).data('type') + '&' + 'name=' + '&'; for (var i = 0; i < dev_fld.length; i++) { @@ -697,7 +697,9 @@ $(document).ready(function () { success: function (data) { $('#pleaseWaitDialog').modal('hide'); + console.log(data); data = JSON.parse(data.replace(/^(.*\{)/,"\{")); + console.log(data); if (data.status === true) { if (data.table_reload === true) { $('table').bootstrapTable('refresh'); diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 191f5c3..01528b3 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -242,22 +242,23 @@ and open the template in the editor. Base Version before all crash :-) SCCP Language: This is the language for your hints and other features of the phone. If you don't have any languages installed or are using a single language, you can leave this blank. - - - netlang - English_United_States - - The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. If No language packs found is shown, you need to add locales in the tftp server - - - + + devlang English_United_States The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. If No language packs found is shown, you need to add locales in the tftp server + + + netlang + United_States + + The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. If No language packs found is shown, you need to add locales in the tftp server + + @@ -1335,13 +1336,6 @@ and open the template in the editor. Base Version before all crash :-) Time Zone offset - - - netlang - English_United_States - - The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. If No language packs found is shown, you need to add locales in the tftp server - devlang @@ -1349,6 +1343,13 @@ and open the template in the editor. Base Version before all crash :-) The user locale allows the phone to display text (menu items, soft keys etc.) native to the phone's language. If No language packs found is shown, you need to add locales in the tftp server + + + netlang + English_United_States + + The Network locales allows the phone to play tones (ringing, busy etc.) native to the phone's country. If No language packs found is shown, you need to add locales in the tftp server + phonepersonalization diff --git a/install.php b/install.php index 16d4116..b6b9506 100644 --- a/install.php +++ b/install.php @@ -249,7 +249,10 @@ function Get_DB_config($sccp_compatible) '_sccp_cos' => array('create' => "VARCHAR(11) NOT NULL default '0x4'", 'modify' => "VARCHAR(11)"), '_dev_sshPassword' => array('create' => "VARCHAR(25) NOT NULL default 'cisco'"), '_dev_sshUserId' => array('create' => "VARCHAR(25) NOT NULL default 'cisco'"), - '_phonepersonalization' => array('create' => "VARCHAR(25) NOT NULL default '0'", 'modify' => "VARCHAR(25)") + '_phonepersonalization' => array('create' => "VARCHAR(25) NOT NULL default '0'", 'modify' => "VARCHAR(25)"), + '_hwlang' => array ('drop' => 'yes'), + '_devlang' => array('create' => "VARCHAR(25) NULL default NULL", 'modify' => "VARCHAR(25)"), + '_netlang' => array('create' => "VARCHAR(25) NULL default NULL", 'modify' => "VARCHAR(25)") ), 'sccpline' => array ( '_regcontext' => array('create' => "VARCHAR(20) NULL default 'sccpregistration'", 'modify' => "VARCHAR(20)"), @@ -927,13 +930,10 @@ function cleanUpSccpSettings() { global $sccp_compatible; // Get current default settings from db - $stmt = $db->prepare("SELECT * FROM sccpsettings"); + $stmt = $db->prepare("SELECT keyword, sccpsettings.* FROM sccpsettings"); $stmt->execute(); - $settingsFromDb = $stmt->fetchAll(\PDO::FETCH_ASSOC); - foreach ($settingsFromDb as $key => $rowArray) { - $settingsFromDb[$rowArray['keyword']] = $rowArray; - unset($settingsFromDb[$key]); - } + $settingsFromDb = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); + // See if a previous version was installed outn("
  • " . _("Checking for previous version of Sccp_manager.") . "
  • "); if (!isset($settingsFromDb['sccp_compatible']['data'])) { @@ -970,7 +970,7 @@ function cleanUpSccpSettings() { } $settingsFromDb = array_merge($settingsFromDb, array_diff_key($thisInstaller->sccpvalues, $settingsFromDb)); unset($thisInstaller->sccpvalues); - + // get chan-sccp defaults $sysConfiguration = $aminterface->getSCCPConfigMetaData('general'); @@ -1019,7 +1019,6 @@ function cleanUpSccpSettings() { unset($sysConfiguration[$key]); } unset($sysConfiguration['Options']); - // Write settings back to db $sql = "TRUNCATE sccpsettings"; $results = $db->query($sql); diff --git a/module.xml b/module.xml index 3e5c4c2..28e6e6d 100644 --- a/module.xml +++ b/module.xml @@ -71,7 +71,6 @@ - diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index 6125126..9251361 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -502,10 +502,17 @@ class formcreate $select_opt= $syslangs; break; case 'SLTD': + // Device Language $select_opt = array('xx' => 'No language packs found'); - if (!empty($installedLangs)) { - $select_opt = (array)$installedLangs; - + if (!empty($installedLangs['languages']['have'])) { + $select_opt = (array)$installedLangs['languages']['have']; + } + break; + case 'SLTN': + // Network Language + $select_opt = array('xx' => 'No country packs found'); + if (!empty($installedLangs['countries']['have'])) { + $select_opt = (array)$installedLangs['countries']['have']; } break; case 'SLZ': @@ -620,22 +627,40 @@ class formcreate name; $res_id = $npref.$res_n; $child->value =''; + $selectArray = array(); // $select_opt is an associative array for these types. if (!empty($metainfo[$res_n])) { if ($child->meta_help == '1' || $child->help == 'Help!') { $child->help = $metaInfo[$res_n]; } } - $select_opt = array('xx' => 'No language packs found'); - if (!empty($installedLangs)) { - $select_opt = $installedLangs; + + switch ($child['type']) { + case 'SLDA': + $select_opt = array('xx' => 'No language packs found'); + if (!empty($installedLangs['languages']['have'])) { + $select_opt = $installedLangs['languages']['have']; + } + $selectArray = $installedLangs['languages']['available']; + $requestType = 'locale'; + break; + + case 'SLNA': + $select_opt = array('xx' => 'No country packs found'); + if (!empty($installedLangs['countries']['have'])) { + $select_opt = $installedLangs['countries']['have']; + } + $selectArray = $installedLangs['countries']['available']; + $requestType = 'country'; + break; } + if (empty($child->class)) { $child->class = 'form-control'; } @@ -649,9 +674,7 @@ class formcreate $child->value = $child->default; } } - $langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang'); - $selectArray = array_combine(array_keys($langArr),array_column($langArr, 'locale')); - $requestType = 'locale'; + ?>
    @@ -671,9 +694,8 @@ class formcreate foreach ($select_opt as $key => $val) { $opt_key = $key; $opt_val = $val; - - echo '"; @@ -683,7 +705,7 @@ class formcreate
    -
    diff --git a/sccpManClasses/xmlinterface.class.php b/sccpManClasses/xmlinterface.class.php index 7b55cf2..e744acf 100644 --- a/sccpManClasses/xmlinterface.class.php +++ b/sccpManClasses/xmlinterface.class.php @@ -122,6 +122,47 @@ class xmlinterface // Need to merge the two arrays so that device specific values override system values // Values that cannot be sent to the device by chan-sccp are prefixed by an underscore // so need to be sure that we apply the same convention to system wide defaults. + $langCodeArray = array( + 'Arabic_Saudi_Arabia' => 'ar', + 'Bulgarian_Bulgaria' => 'bg', + 'Czech_Czech_Republic' => 'cz', + 'Danish_Denmark' => 'da', + 'German_Germany' => 'de', + 'Greek_Greece' => 'el', + 'AU_English_United_States' => 'en', + 'English_United_Kingdom' => 'en', + 'English_United_States' => 'en', + 'Spanish_Spain' => 'es', + 'Estonian_Estonia' => 'et', + 'Finnish_Finland' => 'fi', + 'French_Canada' => 'fr', + 'French_France' => 'fr', + 'Hebrew_Israel' => 'he', + 'Croatian_Croatia' => 'hr', + 'Hungarian_Hungary' => 'hu', + 'Italian_Italy' => 'it', + 'Japanese_Japan' => 'ja', + 'Korean_Korea_Republic' => 'ko', + 'Lithuanian_Lithuania' => 'lt', + 'Latvian_Latvia' => 'lv', + 'Dutch_Netherlands' => 'nl', + 'Norwegian_Norway' => 'no', + 'Polish_Poland' => 'pl', + 'Portuguese_Brazil' => 'pt', + 'Portuguese_Portugal' => 'pt', + 'Romanian_Romania' => 'ro', + 'Russian_Russian_Federation' => 'ru', + 'Slovak_Slovakia' => 'sk', + 'Slovenian_Slovenia' => 'sl', + 'Serbian_Republic_of_Montenegro' => 'sr', + 'Serbian_Republic_of_Serbia' => 'rs', + 'Swedish_Sweden' => 'sv', + 'Thai_Thailand' => 'th', + 'Turkish_Turkey' => 'tr', + 'Chinese_China' => 'cn', + 'Chinese_Taiwan' => 'zh' + ); + $data_values = array_merge($data_values, $dev_config); $var_xml_general_fields = array('authenticationurl' => 'dev_authenticationURL', 'informationurl' => 'dev_informationURL', 'messagesurl' => 'dev_messagesURL', 'servicesurl' => 'dev_servicesURL', 'directoryurl' => 'dev_directoryURL', 'idleurl' => 'dev_idleURL', @@ -313,31 +354,39 @@ class xmlinterface break; case 'userlocale': - case 'networklocaleinfo': + // Device language + $lang = $data_values['devlang']; + if (!empty($dev_config['_devlang'])) { + $lang = $dev_config['_devlang']; + } + $xml_node->winCharSet = $dev_config['phonecodepage']; + $xml_node->name = $dev_config['_devlang']; + $xml_node->langCode = 'en'; + if (isset($langCodeArray['_devlang'])) { + $xml_node->langCode = $langCodeArray['_devlang']; + } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + break; case 'networklocale': - $hwlang = ''; - $lang = ''; - if (!empty($dev_config["_hwlang"])) { - $hwlang = explode(':', $dev_config["_hwlang"]); + $lang = $data_values['_netlang']; + if (!empty($dev_config['_netlang'])) { + $lang = $dev_config['_netlang']; } - if (($key_l == 'networklocaleinfo') || ($key_l == 'networklocale')) { - $lang = (empty($hwlang[0])) ? $data_values['netlang'] : $hwlang[0]; + if (($lang != null) && (!empty($lang))) { + $xml_work->$key = $lang; + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } else { - $lang = (empty($hwlang[1])) ? $data_values['devlang'] : $hwlang[1]; + $xml_work->$key = ''; + } + break; + case 'networklocaleinfo': + $lang = $data_values['_netlang']; + if (!empty($dev_config['_netlang'])) { + $lang = $dev_config['_netlang']; } - if (($lang != 'null') && (!empty($lang))) { - if ($key_l == 'networklocale') { - $xml_work->$key = $lang; - } else { - if (isset($lang_info[$lang])) { - $xml_node->name = $lang_info[$lang]['locale']; - $xml_node->langCode = $lang_info[$lang]['code']; - if ($key_l == 'userlocale') { - $xml_node->winCharSet = $lang_info[$lang]['codepage']; - } - $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); - } - } + if (($lang != null) && (!empty($lang))) { + $xml_node->name = $dev_config['_netlang']; + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } else { $xml_work->$key = ''; } @@ -714,7 +763,7 @@ class xmlinterface $put_file = (string) $get_settings['idtemplate']; } } else { - $errors = array('Fields Dial Plan Name is requered !!'); + $errors = array('Fields Dial Plan Name is required !!'); } if (empty($errors)) { diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index f3a7013..5c0112c 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -433,7 +433,7 @@ trait ajaxHelper { // Value unchanged or null so ignore and go to next key. continue; } - $dbSaveArray[] = array('table' => 'sccpdevice', 'field' => $key, 'Default' => $value); + $dbSaveArray[$key] = array('table' => 'sccpdevice', 'field' => $key, 'Default' => $value); continue; } $key = (str_replace('sccpline_', '', $key, $count_mods)); @@ -450,24 +450,11 @@ trait ajaxHelper { // Value unchanged so ignore and get next key. continue; } - $dbSaveArray[] = array('table' => 'sccpline', 'field' => $key, 'Default' => $value); + $dbSaveArray[$key] = array('table' => 'sccpline', 'field' => $key, 'Default' => $value); unset($request[$key]); continue; } - $key = (str_replace($hdr_prefix, '', $key, $count_mods)); - if ($count_mods) { - if (!empty($this->sccpvalues[$key]) && ($this->sccpvalues[$key]['data'] != $value)) { - $save_settings[$key] = array( - 'keyword' => $key, - 'data' => $value, - 'seq' => $this->sccpvalues[$key]['seq'], - 'type' => $this->sccpvalues[$key]['type'], - 'systemdefault' => $this->sccpvalues[$key]['systemdefault'] - ); - } - - } $key = (str_replace($hdr_arprefix, '', $key, $count_mods)); if ($count_mods) { $arr_data = ''; @@ -508,6 +495,21 @@ trait ajaxHelper { } } } + + $key = (str_replace($hdr_prefix, '', $key, $count_mods)); + if ($count_mods) { + if (!empty($this->sccpvalues[$key]) && ($this->sccpvalues[$key]['data'] != $value)) { + $save_settings[$key] = array( + 'keyword' => $key, + 'data' => $value, + 'seq' => $this->sccpvalues[$key]['seq'], + 'type' => $this->sccpvalues[$key]['type'], + 'systemdefault' => $this->sccpvalues[$key]['systemdefault'] + ); + } + + } + switch ($key) { case 'audiocodecs': foreach ($value as $keycodeс => $valcodeс) { @@ -545,6 +547,7 @@ trait ajaxHelper { } break; } + } $extSettings = $this->extconfigs->updateTftpStructure(array_merge($this->sccpvalues, $save_settings)); @@ -554,12 +557,12 @@ trait ajaxHelper { $this->sccpvalues = $this->dbinterface->get_db_SccpSetting(); } - foreach ($dbSaveArray as $rowToSave) { + foreach ($dbSaveArray as $key => $rowToSave) { $this->dbinterface->updateTableDefaults($rowToSave['table'], $rowToSave['field'], $rowToSave['Default']); } $this->createDefaultSccpConfig(); // Rewrite Config. - $save_settings[] = array('status' => true); + $save_settings[] = array('status' => true, ); $this->createDefaultSccpXml(); return $save_settings; @@ -624,10 +627,9 @@ trait ajaxHelper { $msg = "Firmware for {$device} has been successfully downloaded"; break; case 'locale': - $locale = $request['locale']; + $language = $request['locale']; $totalFiles = 0; - $langArr = \FreePBX::Sccp_manager()->extconfigs->getExtConfig('sccp_lang'); - $language = $langArr[$locale]['locale']; + if (!is_dir("{$this->sccppath['tftp_lang_path']}/{$language}")) { mkdir("{$this->sccppath['tftp_lang_path']}/{$language}", 0755); @@ -678,14 +680,176 @@ trait ajaxHelper { flush(); } } - $msg = "{$locale} Locale and Country tones have been successfully downloaded"; + $msg = "{$language} Locale and Country tones have been successfully downloaded"; + break; + case 'country': + $countryName = $request['country']; + $totalFiles = 0; + + if (!is_dir("{$this->sccppath['tftp_countries_path']}/{$countryName}")) { + mkdir("{$this->sccppath['tftp_countries_path']}/{$countryName}", 0755); + } + + $result = $tftpBootXml->xpath("//Directory[@name='{$countryName}']"); + $filesToGet['countries'] = (array)$result[0]->FileName; + $totalFiles += count($filesToGet['countries']); + $countriesSrcDir = (string)$result[0]->DirectoryPath; + $countriesDstDir = "{$this->sccppath['tftp_countries_path']}/{$countryName}"; + + $filesRetrieved = 0; + + foreach (array('countries') as $section){ + $srcDir = ${"{$section}SrcDir"}; + $dstDir = ${"{$section}DstDir"}; + foreach ($filesToGet[$section] as $srcFile) { + file_put_contents("{$dstDir}/{$srcFile}", + file_get_contents($provisionerUrl . $srcDir . $srcFile)); + $filesRetrieved ++; + $percentComplete = $filesRetrieved *100 / $totalFiles; + $data = "{$percentComplete},"; + echo $data; + ob_flush(); + flush(); + } + } + $msg = "{$countryName} country tones have been successfully downloaded"; + break; + default: + return false; break; - default: - return false; - break; } return array('status' => true, 'message' => $msg, 'reload' => true); } + + function saveSccpDevice($get_settings, $validateonly = false) { + dbug($get_settings); + $hdr_prefix = 'sccp_hw_'; + $hdr_arprefix = 'sccp_hw-ar_'; + $hdr_vendPrefix = 'sccp_hw_vendorconfig'; + + $save_buttons = array(); + $save_settings = array(); + $save_codec = array(); + $name_dev = ''; + $db_field = $this->dbinterface->getSccpDeviceTableData("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') ? 'add' : 'clear'; // Possible values are delete, replace, add, clear. + $hw_prefix = 'SEP'; + if (!empty($get_settings[$hdr_prefix . 'type'])) { + $value = $get_settings[$hdr_prefix . 'type']; + if (strpos($value, 'ATA') !== false) { + $hw_prefix = 'ATA'; + } + if (strpos($value, 'VG') !== false) { + $hw_prefix = 'VG'; + } + } + foreach ($db_field as $data) { + $key = (string) $data['Field']; + $value = ""; + switch ($key) { + case 'name': + if (!empty($get_settings[$hdr_prefix . 'mac'])) { + $value = $get_settings[$hdr_prefix . 'mac']; + $value = strtoupper(str_replace(array('.', '-', ':'), '', $value)); // Delete mac separators from string + $value = sprintf("%012s", $value); + if ($hw_prefix == 'VG') { + $value = $hw_prefix . $value . '0'; + } else { + $value = $hw_prefix . $value; + } + $name_dev = $value; + } + break; + case 'phonecodepage': + $value = 'ISO8859-1'; + // TODO: May be other exceptions. Historically this is the only one handled + if (!empty($get_settings["{$hdr_prefix}devlang"])) { + if ($get_settings["{$hdr_prefix}devlang"] == "Russian_Russian_Federation") { + $value = 'CP1251'; + } + } + break; + default: + // handle vendor prefix + if (!empty($get_settings[$hdr_vendPrefix . $key])) { + $value = $get_settings[$hdr_vendPrefix . $key]; + } + // handle array prefix + if (!empty($get_settings[$hdr_arprefix . $key])) { + $arr_data = ''; + $arr_clear = false; + foreach ($get_settings[$hdr_arprefix . $key] as $vkey => $vval) { + $tmp_data = ''; + foreach ($vval as $vkey => $vval) { + switch ($vkey) { + case 'inherit': + if ($vval == 'on') { + $arr_clear = true; + // Злобный ХАК ?!TODO!? + if ($key == 'permit') { + $save_settings['deny'] = 'NONE'; + } + } + break; + case 'internal': + if ($vval == 'on') { + $tmp_data .= 'internal;'; + } + break; + default: + $tmp_data .= $vval . '/'; + break; + } + } + if (strlen($tmp_data) > 2) { + while (substr($tmp_data, -1) == '/') { + $tmp_data = substr($tmp_data, 0, -1); + } + $arr_data .= $tmp_data . ';'; + } + } + while (substr($arr_data, -1) == ';') { + $arr_data = substr($arr_data, 0, -1); + } + if ($arr_clear) { + $value = 'NONE'; + } else { + $value = $arr_data; + } + } + // Now only have normal prefix + if (!empty($get_settings["{$hdr_prefix}{$key}"])) { + $value = $get_settings["{$hdr_prefix}{$key}"]; + } else if (!empty($get_settings["sccp_hw{$key}"])) { + //have an underscore db field + $value = $get_settings["sccp_hw{$key}"]; + } + } + if (!empty($value)) { + $save_settings[$key] = $value; + } + } + // Save this device. + $this->dbinterface->write('sccpdevice', $save_settings, 'replace'); + // Retrieve the phone buttons and write back to + // update sccpdeviceconfig via Trigger + $save_buttons = $this->getPhoneButtons($get_settings, $name_dev, $hw_type); + $this->dbinterface->write('sccpbuttons', $save_buttons, $update_hw, '', $name_dev); + // Create new XML for this device, and then reset or restart the device + // so that it loads the file from TFT. + $this->createSccpDeviceXML($name_dev); + if ($hw_id == 'new') { + $this->aminterface->sccpDeviceReset($name_dev, 'reset'); + } else { + $this->aminterface->sccpDeviceReset($name_dev, 'restart'); + } + $msg = "Device Saved"; + + return array('status' => true, 'message' => $msg, 'reload' => true); + } + } ?> diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 7815b61..a5a2bf9 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -307,7 +307,7 @@ trait helperfunctions { $this->sccpvalues[(string) $child->name] = array('keyword' => (string) $child->name, 'data' => $datav, 'type' => '2', 'seq' => $seq, 'systemdefault' => ''); } } - if (in_array($child['type'], array('SLD', 'SLS', 'SLT', 'SL', 'SLM', 'SLZ', 'SLTZN', 'SLA'))) { + if (in_array($child['type'], array('SLD', 'SLS', 'SLT', 'SLNA', 'SLDA', 'SL', 'SLM', 'SLZ', 'SLTZN', 'SLA'))) { if (empty($child->value)) { $datav = (string) $child->default; } else { diff --git a/views/formShowSysDefs.php b/views/formShowSysDefs.php index bcb1022..e03936e 100644 --- a/views/formShowSysDefs.php +++ b/views/formShowSysDefs.php @@ -78,13 +78,15 @@ foreach ($items as $child) { case 'SLP': case 'SLS': case 'SLTD': + case 'SLTN': case 'SLA': case 'SLZ': case 'SL': \FreePbx::sccp_manager()->formcreate->addElementSL($child, $fvalues, $sccp_defaults,$npref, $installedLangs); break; - case 'SLT': - \FreePbx::sccp_manager()->formcreate->addElementSLT($child, $fvalues, $sccp_defaults,$npref, $installedLangs); + case 'SLDA': + case 'SLNA': + \FreePbx::sccp_manager()->formcreate->addElementSLNA($child, $fvalues, $sccp_defaults,$npref, $installedLangs); break; case 'SDM': case 'SDMS': diff --git a/views/getFileModal.html b/views/getFileModal.html index 30aec63..f9733be 100644 --- a/views/getFileModal.html +++ b/views/getFileModal.html @@ -1,5 +1,5 @@ -
    @@ -149,7 +149,7 @@ sccppath['tftp_path']}/masterFilesStructure.xml"); $firmwareDir = $tftpBootXml->xpath("//Directory[@name='firmware']"); From 80cf629c0fa9d001e1b3a03560535bf2b987a7b0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 24 Jul 2021 09:39:57 +0200 Subject: [PATCH 120/181] Update ajaxHelper.php --- sccpManTraits/ajaxHelper.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 324b54b..1c8d258 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -732,11 +732,15 @@ trait ajaxHelper { } break; case 'phonecodepage': - $value = 'ISO8859-1'; - // TODO: May be other exceptions. Historically this is the only one handled + // TODO: May be other exceptions so use switch. Historically this is the only one handled if (!empty($get_settings["{$hdr_prefix}devlang"])) { - if ($get_settings["{$hdr_prefix}devlang"] == "Russian_Russian_Federation") { - $value = 'CP1251'; + switch ($get_settings["{$hdr_prefix}devlang"]) { + case 'Russian_Russian_Federation': + $value = 'CP1251'; + break; + default: + $value = 'ISO8859-1'; + break; } } break; From 26f750296a0e8e3d25462032d64c018f4e15f0e5 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 25 Jul 2021 13:42:42 +0200 Subject: [PATCH 121/181] Fix various issues with buttons Add choice of default line on add device Partially fix buttoncount (will not work if default device is selected) Correct database save logic for buttons - triggers should be OK but more verification needed Fix various save issues where defaults not correctly set Delete default buttons when deleting line to avoid orphans --- Sccp_manager.class.php | 8 ++--- assets/js/sccp_manager.js | 7 ++++ conf/sccpgeneral.xml.v433 | 16 ++++++--- sccpManClasses/Sccp.class.php.v433 | 9 +++-- sccpManClasses/dbinterface.class.php | 51 ++++++++++++++++++++-------- sccpManClasses/formcreate.class.php | 19 +++++++---- sccpManTraits/ajaxHelper.php | 4 +-- views/form.adddevice.php | 2 ++ views/form.buttons.php | 18 ++++++---- views/formShowSysDefs.php | 1 + 10 files changed, 95 insertions(+), 40 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 5140b24..22a1465 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -383,6 +383,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { function getPhoneButtons($get_settings, $ref_id = '', $ref_type = 'sccpdevice') { // get Model Buttons info + dbug($get_settings); $res = array(); $def_feature = array('parkinglot' => array('name' => 'P.slot', 'value' => 'default'), 'devstate' => array('name' => 'Coffee', 'value' => 'coffee'), @@ -489,10 +490,11 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { break; } if (!empty($btn_t)) { - $res[] = array('ref' => $ref_id, 'reftype' => $ref_type, 'instance' => (string) ($it + 1), 'type' => $btn_t, 'name' => $btn_n, 'options' => $btn_opt); + $res[] = array('ref' => $ref_id, 'reftype' => $ref_type, 'instance' => (string) ($it + 1), 'buttontype' => $btn_t, 'name' => $btn_n, 'options' => $btn_opt); } } } + dbug($res); return $res; } @@ -796,7 +798,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (empty($button_list)) { return array('Response' => ' 0 buttons found ', 'data' => ''); } - $copy_fld = array('ref', 'reftype', 'instance', 'buttontype'); + $copy_fld = array('ref', 'reftype', 'instance', 'buttontype', 'options'); $extList = $extList = $this->dbinterface->get_db_SccpTableByID("SccpExtension", array(), 'name'); foreach ($button_list as $value) { $btn_opt = explode(',', $value['options']); @@ -1068,9 +1070,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function getSccpModelInformation($get = "all", $validate = false, $format_list = "all", $filter = array()) { - // $file_ext = array('.loads', '.LOADS', '.sbn', '.SBN', '.bin', '.BIN','.zup','.ZUP'); $file_ext = array('.loads', '.sbn', '.bin', '.zup'); - // $dir = $this->sccppath["tftp_path"]; $dir = $this->sccppath['tftp_firmware_path']; $dir_tepl = $this->sccppath['tftp_templates_path']; diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index dc0ad4f..70e2473 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -296,6 +296,7 @@ $(document).ready(function () { } var btn_add = $('#sccp_hw_addon').find(':selected').data('val'); + $('#buttonscount').attr('value',btn_dev + btn_add); $('.line_button').each(function () { if ($(this).data('id') < btn_dev + btn_add) { $(this).removeClass('hidden'); @@ -307,6 +308,12 @@ $(document).ready(function () { }); + $('.lineSelect').change(function (e) { + var type_id = $('#sccp_hw_defaultLine').find(':selected').data('id'); + $("select.lineid_0 option:selected").prop("selected",false); + $("select.lineid_0 option[value=" + type_id + "]").prop("selected",true); + }); + $('.sccp_button_hide').each(function () { // On page create !! var dev_id = $(this).data('vhide'); diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 01528b3..fce9f7c 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1263,7 +1263,7 @@ and open the template in the editor. Base Version before all crash :-) type7911 - hw_select sccp-custom + hw_select form-controlThe type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. @@ -1271,7 +1271,7 @@ and open the template in the editor. Base Version before all crash :-) addon NONE - hw_select sccp-custom + hw_select form-control Addon: Addons are model specific and only work with certain base phones. This phone model is identified as being a phone that does not accept sidecars. Update devmodel if this is not correct. @@ -1322,6 +1322,14 @@ and open the template in the editor. Base Version before all crash :-) The information in the upper right corner of the device screen. Only English letters and digits ! + + + defaultLine + + + lineSelect form-control + Select the default line for this device + softkeyset @@ -1894,7 +1902,7 @@ and open the template in the editor. Base Version before all crash :-) type 7911 - hw_select sccp-custom + form-control hw_select The type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. @@ -1902,7 +1910,7 @@ and open the template in the editor. Base Version before all crash :-) addon NONE - hw_select sccp-custom + hw_select form-control Addon: Addons are model specific and only work with certain base phones. This phone model is identified as being a phone that does not accept sidecars. Update devmodel if this is not correct. diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 1ebd4b3..798057e 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -182,9 +182,12 @@ class Sccp extends \FreePBX\modules\Core\Driver { } public function delDevice($id) { - //Required by FreePBX - $sql = "DELETE FROM sccpline WHERE name = ?"; - $sth = $this->database->prepare($sql); + //Required by FreePBX. + // Delete associated default line buttons or will leave orphans + $sth = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE ref = ? AND instance = 1 AND buttontype = 'line'"); + $sth->execute(array($id)); + + $sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ?"); $sth->execute(array($id)); return true; } diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index a1c7b72..afaed23 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -49,6 +49,7 @@ class dbinterface // $stmt is a single row fetch, $stmts is a fetchAll while stmtU is fetchAll UNIQUE $stmt = ''; $stmts = ''; + $stmtU = ''; if ($dataid == '') { return false; } @@ -60,7 +61,7 @@ class dbinterface break; case 'SccpExtension': if (empty($data['name'])) { - $stmts = $this->db->prepare('SELECT * FROM sccpline ORDER BY name'); + $stmtU = $this->db->prepare('SELECT name, sccpline.* FROM sccpline ORDER BY name'); } else { $stmts = $this->db->prepare('SELECT * FROM sccpline WHERE name = :name'); $stmts->bindParam(':name', $data['name'],\PDO::PARAM_STR); @@ -111,15 +112,6 @@ class dbinterface $stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig ORDER BY name"); } break; - case 'HWSipDevice': - $raw_settings = $this->getDb_model_info($get = "sipphones", $format_list = "model"); - break; - case 'HWDevice': - $raw_settings = $this->getDb_model_info($get = "ciscophones", $format_list = "model"); - break; - case 'HWextension': - $raw_settings = $this->getDb_model_info($get = "extension", $format_list = "model"); - break; case 'get_columns_sccpdevice': $stmts = $this->db->prepare('DESCRIBE sccpdevice'); break; @@ -140,6 +132,13 @@ class dbinterface $stmt = $this->db->prepare('SELECT * FROM sccpuser WHERE name = :name'); $stmt->bindParam(':name', $data['id'],\PDO::PARAM_STR); break; + case 'getAssignedExtensions': + // all extensions that are designed as default lines + $stmtU = $this->db->prepare("SELECT DISTINCT name, name FROM sccpbuttonconfig WHERE buttontype = 'line' AND instance =1"); + break; + case 'getDefaultLine': + $stmt = $this->db->prepare("SELECT name FROM sccpbuttonconfig WHERE ref = '{$data['id']}' and instance =1 and buttontype = 'line'"); + break; case 'get_sccpdevice_buttons': $sql = ''; if (!empty($data['buttontype'])) { @@ -162,7 +161,7 @@ class dbinterface $raw_settings = array(); } break; - // No default case so will give exception of $raw_settings undefined if there + // No default case so will give exception of $raw_settings undefined if the // dataid is not in the switch. } if (!empty($stmt)) { @@ -323,29 +322,51 @@ class dbinterface break; case 'replace': foreach ($save_value as $button_array) { - $stmt = $this->db->prepare('UPDATE sccpbuttonconfig SET name =:name WHERE ref = :ref AND reftype =:reftype AND instance = :instance AND buttontype = :buttontype'); + $stmt = $this->db->prepare('UPDATE sccpbuttonconfig SET name =:name WHERE ref = :ref AND reftype =:reftype AND instance = :instance AND buttontype = :buttontype AND options = :options'); $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['type'],\PDO::PARAM_STR); + $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); $result= $stmt->execute(); } break; + case 'add': + 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 + 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(':reftype', $button_array['reftype'],\PDO::PARAM_STR); $stmt->bindParam(':instance', $button_array['instance'],\PDO::PARAM_INT); - $stmt->bindParam(':buttontype', $button_array['type'],\PDO::PARAM_STR); + $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); $result = $stmt->execute(); } break; + */ case 'clear'; - // Clear is equivalent of delete + insert. + // Clear is equivalent of delete + insert. Mode is used in order to activate trigger. $this->write('sccpbuttons', '', $mode = 'delete','', $hwid); $this->write('sccpbuttons', $save_value, $mode = 'add','', $hwid); break; diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index 9251361..e1ac17e 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -537,6 +537,7 @@ class formcreate $select_opt[$key]= $key; } } + case 'SLM': if (function_exists('music_list')) { $moh_list = music_list(); @@ -741,15 +742,23 @@ class formcreate } switch ($child['type']) { case 'SDM': - $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWDevice"); + $model_list = \FreePBX::Sccp_manager()->dbinterface->getDb_model_info('ciscophones', 'model'); $select_opt= $model_list; break; case 'SDMS': - $model_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWSipDevice"); + $model_list = \FreePBX::Sccp_manager()->dbinterface->getDb_model_info('sipphones', 'model'); $select_opt= $model_list; break; + case 'SDML': + $assignedExts = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData('getAssignedExtensions'); + $select_opt = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData('SccpExtension'); + foreach ($assignedExts as $name => $nameArr ) { + $select_opt[$name]['label'] .= " - in use"; + } + $child->default = $fvalues['defaultLine']; + break; case 'SDE': - $extension_list = \FreePBX::Sccp_manager()->dbinterface->getSccpDeviceTableData("HWextension"); + $extension_list = \FreePBX::Sccp_manager()->dbinterface->getDb_model_info('extension', 'model'); $extension_list[]=array( 'model' => 'NONE', 'vendor' => 'CISCO', 'dns' => '0'); foreach ($extension_list as &$data) { $d_name = explode(';', $data['model']); @@ -771,7 +780,6 @@ class formcreate ?>
    -
    @@ -786,7 +794,7 @@ class formcreate echo '>'; $fld = (string)$child->select['name']; - $flv = (string)$child->select; + $flv = (string)$child->select['name']; $flv2 = (string)$child->select['addlabel']; $flk = (string)$child->select['dataid']; $flkv = (string)$child->select['dataval']; @@ -797,7 +805,6 @@ class formcreate $key = $fvalues[$res_n]['data']; } } - foreach ($select_opt as $data) { echo '
    - DEF LINE'; @@ -178,7 +184,7 @@ if (!empty($_REQUEST['ru_id'])) { ?> - formcreate->addElementSD($child, $fvalues, $sccp_defaults,$npref); From a1e52d01a43a9a9bbf9dbced9d09ea33e806b328 Mon Sep 17 00:00:00 2001 From: Diederik de Groot Date: Sun, 25 Jul 2021 12:27:05 +0000 Subject: [PATCH 122/181] Rename `Device SEP ID` to `Device ID` Use "XX:XX:XX:XX:XX:XX" as the default display format for device MAC Address References #28 --- conf/sccpgeneral.xml.v433 | 12 ++++++------ i18n/ru_RU/LC_MESSAGES/sccp_manager.mo | Bin 44111 -> 44050 bytes i18n/ru_RU/LC_MESSAGES/sccp_manager.po | 10 +++++----- i18n/sccp_manager.pot | 6 +++--- views/form.adddevice.php | 4 ++-- views/form.addsdevice.php | 5 +++-- views/hardware.phone.php | 2 +- views/hardware.sphone.php | 2 +- 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index fce9f7c..b9e1416 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1250,13 +1250,13 @@ and open the template in the editor. Base Version before all crash :-) - + mac 000000000 sccp-custom - The MAC address of the phone. You must specify 12 characters in the format XXXX.XXXX.XXXX or XX-XX-XX-XX-XX-XX or XXXXXXXXXXXX + The MAC address of the phone. You must specify 12 characters in the format XXXX.XXXX.XXXX, XX:XX:XX:XX:XX:XX, XX-XX-XX-XX-XX-XX or XXXXXXXXXXXX @@ -1279,7 +1279,7 @@ and open the template in the editor. Base Version before all crash :-) - + mac 000000000 @@ -1389,7 +1389,7 @@ and open the template in the editor. Base Version before all crash :-) - + mac 000000000 @@ -1889,13 +1889,13 @@ and open the template in the editor. Base Version before all crash :-) - + mac 000000000 sccp-custom - The MAC address of the phone. You must specify 12 characters in the format XXXX.XXXX.XXXX or XX-XX-XX-XX-XX-XX or XXXXXXXXXXXX + The MAC address of the phone. You must specify 12 characters in the format XXXX.XXXX.XXXX, XX:XX:XX:XX:XX:XX, XX-XX-XX-XX-XX-XX or XXXXXXXXXXXX diff --git a/i18n/ru_RU/LC_MESSAGES/sccp_manager.mo b/i18n/ru_RU/LC_MESSAGES/sccp_manager.mo index 4e99ebbcb77c66d4dd423c716b4c591de6491f74..f18da953b3ba3784ad2f05ef38ceaabd66c6686b 100644 GIT binary patch delta 3992 zcmXZf3sBWn9>DS6pNC5ExCmEX>gDMR5fKm!6%7=xM!0GrVJlZ*eT$-EpmmXuk}V_t zxQ?qi81_)h*}66+Zo0FR`|2U?G%Y$hhVEuMsnuq!?QHJ%=ef*WKIixUpa1!v^E;0V zXZr#=`U2XEy~9Mr6D=|ry%>TW7>xVyG`@-`eypl~}ajdyvqdwS;JMb7%SEk0%7(R~Lv4VJ!fjAxMi?}fo z7h@By$58yvfBl}{NP2sb>nTW6B136idl)~|G@OYOh;!`>SSHP;dlpiEYT?i7ah7fI5QTqppQdQR{t$ z`huYGrhYtXoPpt3tU>L-YSdJ3!6En}K7$AGSD5mU$cNa5FJoB&oyYzH z@;{Zrz{wn}bYv#pB7S`erx@7YHFIUyf>o&P{R?%(sXSDU z6Hx25VG!=c8QA5epdVIj_RG?TnLpwnYU_hjP`A&+*u(vqc!JoPCGsqu zL_G%z-K=izyHQ`fe2&N_Y(VYkZPc~l-S~(IS&|miIX;E@efb$C;dgi$qf14e#_#br zSjWWv0z=BoNGeeqJb>x=4(f|9p$l(eABN90^{(Mji~0YNg3i(F^F){)37c;g(JYK) z1XalTle))5##ne1#eDawLh;fh0+8ViL|-De?oZSxNrmC{(W!8HLYaxy4C`9BOiJwK)fJ)-VcU zH>P6FT9bha)WzF`W3dN^;5F2Ce@2~x*jh3`yZLyNc=UR+h-2!=zs}{+I@9nMc!4;0 zgBj@;Xp!Pc8`;-bKpOPOZG6g{fV)xS-}&QDPzUlQYDOX&Os0-tEb(7ar{)Uk0e9O= zK~omgXj0?EOyWGh%TV|AZcN04Eu0BB8S}9VHKpfKNB&<-#=%?7i*s=R@q8SFPx#}d zc%9h0lENP-EO^?#eKHEkRoc?b*Dw!sqR#mbq(K*HLJNlzj>7~D+-_3o zLampBy3Z>x4p(6sZbug$!D;vr7V7>FZ8al#1T}R_Fozd!N1e-_=d>bUPMC-(&zlSs z<80zu)C~0CNbEx$vHo>m0_i7qEjD{fIY++ibqTa8oCLL8Gse{BH{& zExSbCrDEr977RB^_V9lY@%zY*l!(1%zc!7E9Tcj{&KGUT12h2-*!4Otp)ZBM^V}+ z?yU0PorqO@^aRnLem+Hf^6j@B+14bx-|>dE+TIaa!ZIOXf5|WIkYbz#9b`KHT5f& z*4Q7rhTFL=hwXON`EIzPgDsEmUTRCK?=APiA@({?W(-w(yU%Sq*L<$2_f+o*E%m$Jj zlekwcp>7>-GLA`%OFE_<+Xga@r7=mzwkB#S)oNopO(*?7oEv7o`JMM$&hnn+>aO;n zkJ^KF6nO_2V=5wz>5cW+9eo&#`|$!E!D;wHlrd#^21~FaB>e%QQW1htENMB3| zhGRL_V-5Dghk^U*rJnc3Pca^;$~dvqt{(P_wH0SzCh-X0TxXtFRiwFX*YZ&DWc1)1 zRM*y^y1WzB#4j)e-$D;w#yyTPe?zsjCeFUM9eWZVLcMlFB@t*T!-C>UqxlE3DvO{ z)H1$+s<%ffbz>~{LT?HM%~>ug15;5I%tgJpG!U=D`NZ2%8TtxIn)wbxFrK`sLs_Wr z^HKHAKy{=NgK!-_fg5b>H5)0^b7K>(#;)mh&NiSbdIMSF<|JwazeTOGVK(kAq&`eu>ucb7&=)j6bwffocx^6V>4o{4vf&eSZn{-Jfw9cAz?#pJU7qa57HBT{+}GlGXePHO(~(l_AU>1N*22R)d>6yUuxIfq>VOFuYcugQDs%I&5tpLsdw?2o1|OAS0qVUb z?1IfW0Z(`-Xe9qajqE?T2!qFSY_eafkYpGaZ|lQi)b^Q%@9?}7&k=`AGUjFc5Ooer zE+)l1pN(pG|72rU;we-|ti^qBXEv9P!zxhLZpj<~) zd>lB9XYKFjd$@r69T?C3na`7Mti!?hM|9&OOv1==n~?(4 z^XaJHAG4A|9KL}}r+F_B2UXa88jl*uB-Adb!VLT+c95YzVJh*J1-9ZxsLaGv+C`X% z_lbw2QlCJ&|B55ftAn5~n^*fiA2q@mn2TGn3tqxicm>It$zN#KNE2!|yoG!58+76B zMRvr;kR+OqkR+Mp#de@u@oVB=EhhhcDI8v6%n*DR%N+h4gdA#S^fG%6RO4OZ&8SpY zFSi+KLM`6&I20daG{#riDa}Jo!EC%wy({q^@r%`V5zne2|C!wQs>W8_e+7pT@p#lo z``2>*lj2oafOVunNAB4=djeiV#rFbnk2Q86gHRcng8lI}K80P^+Np7)4!EIS3QE~H zjKfk)$J&5LQTzHDdT`D<{)vifFc&{VeHZ-`JMvr{NIV_Ya1D0F9oP+D3&e-;4zahH z!bJ)@*W2w;%DJfu7hnu-Ms@HoYHggsWW0+}7)1uvPzvgKF>3!epw`w&?1ODM)}c|< zR3$g?6HNQ2j6wl7+OY-uY_zNN5?1g*8*0w88|@;UgV%_cU_TtY$)<8X>b+{zK5xRl z_$Cg<%jm}2I2OBY=AU2M|HTwEl5IE;58^NyzKmLwkGJSW(!bSCK{+Y|4OoIFP#JiP zi5RubjyNAD63<3;U_WY?eSpg7b&R2X^Cg9G81#zmc@f4EKZAO41tw!74#(3Nins7* z_y~vL#-G|uoW(=LzsCez_9}-H?#5QUjSm>$IX?DkZjS%l&eaE~MfD}dp=SrbY&aej zAHZIC5jD4e2;6^w>OjQK&N(%ca53@ka2E{?+hw=!hd#~@?w{Fh%yW2uH~DV}Vzut! zCNH+VX3R@GXndW~6aO38nP$pfyI(J$I{eH&>vH53vl&a#v)`V0EAVaN22{s$4%l5V z7uB(H)Z)H+V7e`Q!40ii=OFvP3&$xo5O+Ijx791iZF3k?f;oC|9v%F+h3A-d-2UuN z@ZAZ`aYp;%!pc%-@qQkc{zh_TbA8I?;`;ti+1B4u-?6YNXSgrQmF^hd1XrOJOy~b6 zrE*)&r4vMdH@OPAM)*#;vYi~?O;@wi;@cKpsAb%_DJt 'mac', "data" => $val, "seq" => "99"); $val = $_REQUEST['type']; $def_val['type'] = array("keyword" => 'type', "data" => $val, "seq" => "99"); @@ -66,7 +66,7 @@ if (!empty($_REQUEST['id'])) { case 'name': $key = 'mac'; //This is the key that formShow expects $val = str_replace(array('SEP','ATA','VG'), '', $val); - $val = implode('.', sscanf($val, '%4s%4s%4s')); // Convert to Cisco display Format + $val = implode(':', sscanf($val, '%2s%2s%2s%2s%2s%2s')); // Convert to Cisco display Format $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); break; case '_hwlang': diff --git a/views/form.addsdevice.php b/views/form.addsdevice.php index 5b09bf8..e2cfb4c 100644 --- a/views/form.addsdevice.php +++ b/views/form.addsdevice.php @@ -17,7 +17,7 @@ $def_val['directed_pickup_context'] = array("keyword" => 'directed_pickup_conte if (!empty($_REQUEST['new_id'])) { $dev_id = $_REQUEST['new_id']; $val = str_replace(array('SEP','ATA','VG'), '', $dev_id); - $val = implode('.', sscanf($val, '%4s%4s%4s')); // Convert to Cisco display Format + $val = implode(':', sscanf($val, '%2s%2s%2s%2s%2s%2s')); // Convert to Cisco display Format $def_val['mac'] = array("keyword" => 'mac', "data" => $val, "seq" => "99"); $val = $_REQUEST['type']; $def_val['type'] = array("keyword" => 'type', "data" => $val, "seq" => "99"); @@ -51,7 +51,8 @@ if (!empty($_REQUEST['id'])) { case 'name': $key = 'mac'; $val = str_replace(array('SEP','ATA','VG'), '', $val); - $val = implode('.', sscanf($val, '%4s%4s%4s')); // Convert to Cisco display Format + $val = implode(':', sscanf($val, '%2s%2s%2s%2s%2s%2s')); // Convert to Cisco display Format + $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); break; case '_hwlang': $tmpar = explode(":", $val); diff --git a/views/hardware.phone.php b/views/hardware.phone.php index 562e30c..d350909 100644 --- a/views/hardware.phone.php +++ b/views/hardware.phone.php @@ -35,7 +35,7 @@
    - + diff --git a/views/hardware.sphone.php b/views/hardware.sphone.php index 7d5094a..c1321a7 100644 --- a/views/hardware.sphone.php +++ b/views/hardware.sphone.php @@ -29,7 +29,7 @@ - + From 4e9dcb09f3047708ea8c4a1f4bde129cea0569ea Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 25 Jul 2021 16:03:02 +0200 Subject: [PATCH 123/181] Fix return link if default button changed --- assets/js/sccp_manager.js | 10 ++++++++-- views/form.buttons.php | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 70e2473..2c4e67b 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -309,9 +309,15 @@ $(document).ready(function () { }); $('.lineSelect').change(function (e) { - var type_id = $('#sccp_hw_defaultLine').find(':selected').data('id'); + var line_id = $('#sccp_hw_defaultLine option:selected').val(); $("select.lineid_0 option:selected").prop("selected",false); - $("select.lineid_0 option[value=" + type_id + "]").prop("selected",true); + $("select.lineid_0 option[value=" + line_id + "]").prop("selected",true); + }); + + $('#button0_line').change(function (e) { + var line_id = $('#button0_line option:selected').val(); + $("#sccp_hw_defaultLine option:selected").prop("selected",false); + $("#sccp_hw_defaultLine option[value=" + line_id + "]").prop("selected",true); }); $('.sccp_button_hide').each(function () { diff --git a/views/form.buttons.php b/views/form.buttons.php index e5517e0..15fc7a4 100644 --- a/views/form.buttons.php +++ b/views/form.buttons.php @@ -184,10 +184,10 @@ if (!empty($_REQUEST['ru_id'])) { ?> - '.$data['name'].' / '.$data['label'].''; } ?> From b659f55170aa451b6631487a552ab797de6657c0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 28 Jul 2021 15:48:57 +0200 Subject: [PATCH 124/181] Remove _ prefixes in db column names Mariadb does not accept _prefixed fields by spec, and these columns may give future issues. Migrate all fields in installer to remove this prefix (without data loss) and: Create new view sccplineconfig for chan-sccp where only accepted fields are shown Update sccpdeviceconfig to only show accepted fields Update extconfigs.conf to use sccplineconfig Remove references to _ prefixed fields --- conf/sccpgeneral.xml.v433 | 2 +- install.php | 361 ++++++++++++++++---------- sccpManClasses/dbinterface.class.php | 4 +- sccpManClasses/xmlinterface.class.php | 30 +-- sccpManTraits/ajaxHelper.php | 1 - 5 files changed, 241 insertions(+), 157 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index fce9f7c..99289d6 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1315,7 +1315,7 @@ and open the template in the editor. Base Version before all crash :-) - _description + description 000000000 sccp-custom diff --git a/install.php b/install.php index b6b9506..c7d87d7 100644 --- a/install.php +++ b/install.php @@ -64,6 +64,7 @@ cleanUpSccpSettings(); InstallDB_createButtonConfigTrigger(); InstallDB_CreateSccpDeviceConfigView($sccp_compatible); +createViewSccplineconfig(); InstallDB_updateDBVer($sccp_compatible); if ($chanSCCPWarning) { outn("
    "); @@ -99,7 +100,6 @@ function Get_DB_config($sccp_compatible) 'disallow' => array('drop' => "yes"), 'callhistory_answered_elsewhere' => array('create' => "enum('Ignore','Missed Calls','Received Calls', 'Placed Calls') NOT NULL default 'Ignore'", 'modify' => "enum('Ignore','Missed Calls','Received Calls','Placed Calls')"), - 'description' => array('rename' => "_description"), 'hwlang' => array('rename' => "_hwlang"), '_hwlang' => array('create' => 'VARCHAR(12) NULL DEFAULT NULL'), '_loginname' => array('create' => 'VARCHAR(20) NULL DEFAULT NULL AFTER `_hwlang`'), @@ -214,53 +214,98 @@ function Get_DB_config($sccp_compatible) ) ); // Below fields allow configuration of these settings on a per device basis - // whereas previously they were all global. - // By prefixing with an underscore, these fields are ignored by chan-sccp - // which is not an issue as they are not "runtime" + // whereas previously they were all global.Some of these are not supported by chan-sccp; + // The supported fields are listed in the view sccpdeviceconfig. $db_config_v5 = array( 'sccpdevice' => array( - '_logserver' => array('create' => "VARCHAR(100) NULL default null", 'modify' => "VARCHAR(20)"), - '_daysdisplaynotactive' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), - '_displayontime' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), - '_displayonduration' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), - '_displayidletimeout' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), - '_settingsaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_videocapability' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_webaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_webadmin' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_pcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), - '_spantopcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), - '_voicevlanaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_enablecdpswport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_enablecdppcport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_enablelldpswport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_enablelldppcport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - '_firstdigittimeout' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), - '_digittimeout' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), - '_cfwdnoanswer_timeout' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), - '_autoanswer_ring_time' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), - '_autoanswer_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)"), - '_callwaiting_tone' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), - '_callanswerorder' => array('create' => "enum('oldestfirst','latestfirst') NOT NULL default 'latestfirst'", + 'logserver' => array('create' => "VARCHAR(100) NULL default null", 'modify' => "VARCHAR(20)"), + 'daysdisplaynotactive' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'displayontime' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'displayonduration' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'displayidletimeout' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'settingsaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'videocapability' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'webaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'webadmin' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'pcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'spantopcport' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'voicevlanaccess' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'enablecdpswport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'enablecdppcport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'enablelldpswport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'enablelldppcport' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), + 'firstdigittimeout' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'digittimeout' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'cfwdnoanswer_timeout' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'autoanswer_ring_time' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'autoanswer_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)"), + 'callwaiting_tone' => array('create' => "VARCHAR(20) NULL default null", 'modify' => "VARCHAR(20)"), + 'callanswerorder' => array('create' => "enum('oldestfirst','latestfirst') NOT NULL default 'latestfirst'", 'modify' => "enum('oldestfirst','latestfirst')"), - '_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)"), - '_dev_sshPassword' => array('create' => "VARCHAR(25) NOT NULL default 'cisco'"), - '_dev_sshUserId' => array('create' => "VARCHAR(25) NOT NULL default 'cisco'"), - '_phonepersonalization' => array('create' => "VARCHAR(25) NOT NULL default '0'", 'modify' => "VARCHAR(25)"), + '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)"), + 'dev_sshPassword' => array('create' => "VARCHAR(25) NOT NULL default 'cisco'"), + 'dev_sshUserId' => array('create' => "VARCHAR(25) NOT NULL default 'cisco'"), + 'phonepersonalization' => array('create' => "VARCHAR(25) NOT NULL default '0'", 'modify' => "VARCHAR(25)"), + 'loginname' => array('create' => 'VARCHAR(20) NULL DEFAULT NULL'), + 'profileid' => array('create' => "INT(11) NOT NULL DEFAULT '0'"), + 'dialrules' => array('create' => "VARCHAR(255) NULL DEFAULT NULL"), + 'description' => array('create' => "VARCHAR(45) NULL DEFAULT NULL"), '_hwlang' => array ('drop' => 'yes'), - '_devlang' => array('create' => "VARCHAR(25) NULL default NULL", 'modify' => "VARCHAR(25)"), - '_netlang' => array('create' => "VARCHAR(25) NULL default NULL", 'modify' => "VARCHAR(25)") + 'devlang' => array('create' => "VARCHAR(25) NULL default NULL", 'modify' => "VARCHAR(25)"), + 'netlang' => array('create' => "VARCHAR(25) NULL default NULL", 'modify' => "VARCHAR(25)"), + '_devlang' => array('rename' => "devlang"), + '_netlang' => array('rename' => "netlang"), + '_logserver' => array('rename' => 'logserver'), + '_daysdisplaynotactive' => array('rename' => 'daysdisplaynotactive'), + '_displayontime' => array('rename' => 'displayontime'), + '_displayonduration' => array('rename' => 'displayonduration'), + '_displayidletimeout' => array('rename' => 'displayidletimeout'), + '_settingsaccess' => array('rename' => 'settingsaccess'), + '_videocapability' => array('rename' => 'videocapability'), + '_webaccess' => array('rename' => 'webaccess'), + '_webadmin' => array('rename' => 'webadmin'), + '_pcport' => array('rename' => 'pcport'), + '_spantopcport' => array('rename' => 'spantopcport'), + '_voicevlanaccess' => array('rename' => 'voicevlanaccess'), + '_enablecdpswport' => array('rename' => 'enablecdpswport'), + '_enablecdppcport' => array('rename' => 'enablecdppcport'), + '_enablelldpswport' => array('rename' => 'enablelldpswport'), + '_enablelldppcport' => array('rename' => 'enablelldppcport'), + '_firstdigittimeout' => array('rename' => 'firstdigittimeout'), + '_digittimeout' => array('rename' => 'digittimeout'), + '_cfwdnoanswer_timeout' => array('rename' => 'cfwdnoanswer_timeout'), + '_autoanswer_ring_time' => array('rename' => 'autoanswer_ring_time'), + '_autoanswer_tone' => array('rename' => 'autoanswer_tone'), + '_remotehangup_tone' => array('rename' => 'remotehangup_tone'), + '_transfer_tone' => array('rename' => 'transfer_tone'), + '_callwaiting_tone' => array('rename' => 'callwaiting_tone'), + '_callanswerorder' => array('rename' => 'callanswerorder'), + '_sccp_tos' => array('rename' => 'sccp_tos'), + '_sccp_cos' => array('rename' => 'sccp_cos'), + '_dev_sshPassword' => array('rename' => 'dev_sshPassword'), + '_dev_sshUserId' => array('rename' => 'dev_sshUserId'), + '_phonepersonalization' => array('rename' => '_phonepersonalization'), + '_loginname' => array('rename' => 'loginname'), + '_profileid' => array('rename' => 'profileid'), + '_dialrules' => array('rename' => 'dialrules'), + '_description' => array('rename' => 'description') ), 'sccpline' => array ( - '_regcontext' => array('create' => "VARCHAR(20) NULL default 'sccpregistration'", 'modify' => "VARCHAR(20)"), - '_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')"), - '_callLogBlfEnabled' => array('create' => "enum('3','2') NOT NULL default '2'", 'modify' => "enum('3','2')") + 'regcontext' => array('create' => "VARCHAR(20) NULL default 'sccpregistration'", 'modify' => "VARCHAR(20)"), + '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')"), + 'callLogBlfEnabled' => array('create' => "enum('3','2') NOT NULL default '2'", 'modify' => "enum('3','2')"), + '_regcontext' => array('rename' => 'regcontext'), + '_transfer_on_hangup' => array('rename' => 'transfer_on_hangup'), + '_autoselectline_enabled' => array('rename' => 'autoselectline_enabled'), + '_autocall_select' => array('rename' => 'autocall_select'), + '_backgroundImageAccess' => array('rename' => 'backgroundImageAccess'), + '_callLogBlfEnabled' => array('rename' => 'callLogBlfEnabled') ), 'sccpsettings' => array ( 'systemdefault' => array('create' => "VARCHAR(255) NULL default ''") @@ -338,111 +383,121 @@ function InstallDB_updateSchema($db_config) } $count_modify = 0; outn("
  • " . _("Modify Database schema") . "
  • "); - foreach ($db_config as $tabl_name => &$tab_modif) { - // 0 - name 1-type 4- default - $sql = "DESCRIBE {$tabl_name};"; - $stmt = $db->prepare("DESCRIBE {$tabl_name}"); - $stmt->execute(); - $db_result = $stmt->fetchAll(); - if (DB::IsError($db_result)) { - die_freepbx("Can not get information from " . $tabl_name . " table\n"); - } - foreach ($db_result as $tabl_data) { - $fld_id = $tabl_data[0]; - $db_config[$tabl_name][$fld_id]['fieldExists'] = FALSE; - // Filter commands to avoid applying unnecessary - if (!empty($tab_modif[$fld_id])) { - // Potentially have something to modify in schema - $db_config[$tabl_name][$fld_id]['fieldExists'] = TRUE; - if (!empty($tab_modif[$fld_id]['modify'])) { - if (strtoupper($tab_modif[$fld_id]['modify']) == strtoupper($tabl_data[1])) { - unset($db_config[$tabl_name][$fld_id]['modify']); - } - // Modifying field so do not then need to modify defaults as this should do that - if (!empty($tab_modif[$fld_id]['def_modify'])) { - unset($db_config[$tabl_name][$fld_id]['def_modify']); - } - } - if (!empty($tab_modif[$fld_id]['def_modify'])) { - if (strtoupper($tab_modif[$fld_id]['def_modify']) == strtoupper($tabl_data[4])) { - unset($db_config[$tabl_name][$fld_id]['def_modify']); - } - } - if (!empty($tab_modif[$fld_id]['rename'])) { - $fld_id_source = $tab_modif[$fld_id]['rename']; - $db_config[$tabl_name][$fld_id_source]['fieldExists'] = TRUE; - if (!empty($db_config[$tabl_name][$fld_id_source]['create'])) { - $db_config[$tabl_name][$fld_id]['create'] = $db_config[$tabl_name][$fld_id_source]['create']; - } else { - $db_config[$tabl_name][$fld_id]['create'] = strtoupper($tabl_data[1]).(($tabl_data[2] == 'NO') ?' NOT NULL': ' NULL'); - $db_config[$tabl_name][$fld_id]['create'] .= ' DEFAULT '. ((empty($tabl_data[4]))?'NULL': "'". $tabl_data[4]."'" ); - } - } - } - } + foreach ($db_config as $tabl_name => $tab_modif) { $sql_create = ''; $sql_modify = ''; - $sql_update = ''; + $sql_rename = ''; - foreach ($tab_modif as $row_fld => $row_data) { - if (!$row_data['fieldExists']) { - if (!empty($row_data['create'])) { - $sql_create .= "ADD COLUMN {$row_fld} {$row_data['create']}, "; - $count_modify ++; - } - } else { - if (!empty($row_data['rename'])) { - $sql_modify .= "RENAME COLUMN {$row_fld} TO {$row_data['rename']}, "; - $count_modify ++; - } - $row_data['fieldModified'] = FALSE; - if (!empty($row_data['modify'])) { - if (!empty($row_data['create'])) { - // Use values in create to set defaults - $sql_modify .= "MODIFY COLUMN {$row_fld} {$row_data['create']}, "; - } else { - $sql_modify .= "MODIFY COLUMN {$row_fld} {$row_data['modify']} DEFAULT {$row_data['def_modify']}, "; - } - if (strpos($row_data['modify'], 'enum') !== false) { - $sql_update .= "UPDATE " . $tabl_name . " set `" . $row_fld . "`=case when lower(`" . $row_fld . "`) in ('yes','true','1') then 'on' when lower(`" . $row_fld . "`) in ('no', 'false', '0') then 'off' else `" . $row_fld . "` end; "; - } - $count_modify ++; - } - if (!empty($row_data['def_modify'])) { - $sql_modify .= "ALTER COLUMN {$row_fld} SET DEFAULT '{$row_data['def_modify']}', "; - $count_modify ++; - } - if (!empty($row_data['drop'])) { + $stmt = $db->prepare("DESCRIBE {$tabl_name}"); + $stmt->execute(); + $db_result = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); + if (DB::IsError($db_result)) { + die_freepbx("Can not get information for " . $tabl_name . " table\n"); + } + + // filter modifications based on field existance and prepare sql + foreach ($db_result as $fld_id => $tabl_data) { + if (!empty($tab_modif[$fld_id])) { + // have column in table so potentially something to update + // if dropping column, prepare sql and continue + if (!empty($tab_modif[$fld_id]['drop'])) { $sql_create .= "DROP COLUMN {$row_fld}, "; + unset($tab_modif[$fld_id]['drop']); + continue; + } + + if (!empty($tab_modif[$fld_id]['modify'])) { + // Check if modify type is same as current type + if (strtoupper($tab_modif[$fld_id]['modify']) == strtoupper($tabl_data['Type'])) { + // Type has not changed so unset + unset($tab_modif[$fld_id]['modify']); + } else { + if (!empty($tab_modif[$fld_id]['def_modify'])) { + // if a default has been modified, use it here and unset + $sql_modify .= "MODIFY COLUMN {$fld_id} {$tab_modif[$fld_id]['modify']} DEFAULT {$tab_modif[$fld_id]['def_modify']}, "; + // def_modify has been used so unset + unset($tab_modif[$fld_id]['def_modify']); + } else if (!empty($tab_modif[$fld_id]['create'])) { + // use create attributes + $sql_modify .= "MODIFY COLUMN {$fld_id} {$tab_modif[$fld_id]['create']}, "; + } else { + // No default to modify so leave unchanged + $sql_modify .= "MODIFY COLUMN {$fld_id} {$tab_modif[$fld_id]['modify']}, "; + } + $count_modify ++; + } + } + + if (!empty($tab_modif[$fld_id]['def_modify'])) { + // Check if def_modify value is same as current value + if (strtoupper($tab_modif[$fld_id]['def_modify']) == strtoupper($tabl_data['Default'])) { + // Defaults have not changed so unset + unset($tab_modif[$fld_id]['def_modify']); + } else { + $sql_modify .= "ALTER COLUMN {$row_fld} SET DEFAULT '{$tab_modif[$fld_id]['def_modify']}', "; + $count_modify ++; + } + } + + if (!empty($tab_modif[$fld_id]['rename'])) { + // Field currently exists so need to rename (and keep data) + // for backward compatibility use CHANGE - REPLACE is only available in MariaDb > 10.5. + $fld_id_newName = $tab_modif[$fld_id]['rename']; + // Does a create exist for newName + if (!empty($tab_modif[$fld_id_newName]['create'])) { + //carry the attributes from the new create to the rename + $sql_rename .= "CHANGE COLUMN IF EXISTS {$fld_id} {$fld_id_newName} {$tab_modif[$fld_id_newName]['create']}, "; + // do not create newName as modifying existing + unset($tab_modif[$fld_id_newName]['create']); + } else { + // add current attributes to the new name. + $existingAttrs = strtoupper($tabl_data['Type']).(($tabl_data['Null'] == 'NO') ?' NOT NULL': ' NULL') . + ((empty($tabl_data['Default']))?'': ' DEFAULT ' . "'" . $tabl_data['Default']."'"); + $sql_rename .= "CHANGE COLUMN IF EXISTS {$fld_id} {$fld_id_newName} {$existingAttrs}, "; + } + unset($tab_modif[$fld_id]['rename']); $count_modify ++; } + // is there a create for this field + if (!empty($tab_modif[$fld_id]['create'])) { + // unset as cannot create existing field + unset($tab_modif[$fld_id]['create']); + } } } - if (!empty($sql_update)) { - outn("
  • " . _("Updating table rows :") . $affected_rows . "
  • "); - $sql_update = 'BEGIN; ' . $sql_update . ' COMMIT;'; - sql($sql_update); - $affected_rows = $db->affectedRows(); - outn("
  • " . _("Updated table rows :") . $affected_rows . "
  • "); + // only case left to handle is create as all others handled above + foreach ($tab_modif as $row_fld => $row_data) { + if (!empty($row_data['create'])) { + $sql_create .= "ADD COLUMN {$row_fld} {$row_data['create']}, "; + $count_modify ++; + } } - + //Now execute sql statements if (!empty($sql_create)) { - outn("
  • " . _("Adding new columns ...") . "
  • "); + outn("
  • " . _("Adding/dropping columns ...") . "
  • "); $sql_create = "ALTER TABLE {$tabl_name} " .substr($sql_create, 0, -2); try { $check = $db->query($sql_create); } catch (\Exception $e) { - die_freepbx("Can't add column to {$tabl_name}. SQL: {$sql_create} \n"); + die_freepbx("Can't add/drop column in {$tabl_name}. SQL: {$sql_create} \n"); } } if (!empty($sql_modify)) { outn("
  • " . _("Modifying table columns ") . $tabl_name ."
  • "); - $sql_modify = "ALTER TABLE {$tabl_name} " . substr($sql_modify, 0, -2); try { $check = $db->query($sql_modify); } catch (\Exception $e) { - die_freepbx("Can not modify {$tabl_name}. SQL: {$sql_create} \n"); + die_freepbx("Can not modify {$tabl_name}. SQL: {$sql_modify} \n"); + } + } + if (!empty($sql_rename)) { + outn("
  • " . _("Renaming table columns ") . $tabl_name ."
  • "); + $sql_rename = "ALTER TABLE {$tabl_name} " . substr($sql_rename, 0, -2); + try { + $check = $db->query($sql_rename); + } catch (\Exception $e) { + die_freepbx("Can not modify {$tabl_name}. SQL: {$sql_rename} \n"); } } } @@ -642,9 +697,9 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) { global $db; outn("
  • " . _("(Re)Create sccpdeviceconfig view") . "
  • "); - $sql = ""; $sql = "DROP VIEW IF EXISTS sccpdeviceconfig; - DROP VIEW IF EXISTS sccpuserconfig;"; + DROP VIEW IF EXISTS sccpuserconfig; + "; /// global $hw_mobil; // From logserver to end only applies to db ver > 433 @@ -668,16 +723,23 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) $sql .= "CREATE OR REPLACE ALGORITHM = MERGE VIEW sccpdeviceconfig AS - SELECT case sccpdevice._profileid - when 0 then - (select GROUP_CONCAT(CONCAT_WS( ',', defbutton.buttontype, defbutton.name, defbutton.options ) SEPARATOR ';') from sccpbuttonconfig as defbutton where defbutton.ref = sccpdevice.name ORDER BY defbutton.instance ) - when 1 then - (select GROUP_CONCAT(CONCAT_WS( ',', userbutton.buttontype, userbutton.name, userbutton.options ) SEPARATOR ';') from sccpbuttonconfig as userbutton where userbutton.ref = sccpdevice._loginname ORDER BY userbutton.instance ) - when 2 then - (select GROUP_CONCAT(CONCAT_WS( ',', homebutton.buttontype, homebutton.name, homebutton.options ) SEPARATOR ';') from sccpbuttonconfig as homebutton where homebutton.ref = sccpuser.homedevice ORDER BY homebutton.instance ) - end as button, if(sccpdevice._profileid = 0, sccpdevice._description, sccpuser.description) as description, sccpdevice.* + SELECT CASE sccpdevice.profileid + WHEN 0 THEN + (SELECT GROUP_CONCAT(CONCAT_WS(',', defbutton.buttontype, defbutton.name, defbutton.options ) SEPARATOR ';') FROM sccpbuttonconfig AS defbutton WHERE defbutton.ref = sccpdevice.name ORDER BY defbutton.instance ) + WHEN 1 THEN + (SELECT GROUP_CONCAT(CONCAT_WS(',', userbutton.buttontype, userbutton.name, userbutton.options ) SEPARATOR ';') FROM sccpbuttonconfig AS userbutton WHERE userbutton.ref = sccpdevice.loginname ORDER BY userbutton.instance ) + WHEN 2 THEN + (SELECT GROUP_CONCAT(CONCAT_WS(',', homebutton.buttontype, homebutton.name, homebutton.options ) SEPARATOR ';') FROM sccpbuttonconfig AS homebutton WHERE homebutton.ref = sccpuser.homedevice ORDER BY homebutton.instance ) + END + AS button, if(sccpdevice.profileid = 0, sccpdevice.description, sccpuser.description) AS description, sccpdevice.name, sccpdevice.type, + sccpdevice.addon, sccpdevice.tzoffset, sccpdevice.imageversion, sccpdevice.deny, sccpdevice.permit, sccpdevice.earlyrtp, sccpdevice.mwilamp, sccpdevice.mwioncall, + sccpdevice.dndFeature, sccpdevice.transfer, sccpdevice.cfwdall, sccpdevice.cfwdbusy, sccpdevice.private, sccpdevice.privacy, sccpdevice.nat, sccpdevice.directrtp, + sccpdevice.softkeyset, sccpdevice.audio_tos, sccpdevice.audio_cos, sccpdevice.video_tos, sccpdevice.video_cos, sccpdevice.conf_allow, + sccpdevice.conf_play_general_announce, sccpdevice.conf_play_part_announce, sccpdevice.conf_mute_on_entry, sccpdevice.conf_music_on_hold_class, + sccpdevice.conf_show_conflist, sccpdevice.force_dtmfmode, sccpdevice.setvar, sccpdevice.backgroundImage, sccpdevice.backgroundThumbnail, + sccpdevice.ringtone, sccpdevice.callhistory_answered_elsewhere, sccpdevice.useRedialMenu, sccpdevice.cfwdnoanswer, sccpdevice.park, sccpdevice.monitor FROM sccpdevice - LEFT JOIN sccpuser sccpuser ON ( sccpuser.name = sccpdevice._loginname ) + LEFT JOIN sccpuser sccpuser ON ( sccpuser.name = sccpdevice.loginname ) GROUP BY sccpdevice.name;"; } @@ -687,6 +749,29 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) } return true; } + +function createViewSccplineconfig() { + global $db; + outn("
  • " . _("(Re)Create sccplineconfig view") . "
  • "); + + $sql = "DROP VIEW IF EXISTS sccplineconfig; + "; + $sql .= "CREATE OR REPLACE + VIEW sccplineconfig AS + SELECT sccpline.id, sccpline.pin ,sccpline.label, sccpline.description, sccpline.context, sccpline.incominglimit, sccpline.transfer, sccpline.mailbox, + sccpline.vmnum, sccpline.cid_name, sccpline.cid_num, sccpline.disallow, sccpline.allow, sccpline.trnsfvm, sccpline.secondary_dialtone_digits, + sccpline.secondary_dialtone_tone, sccpline.musicclass, sccpline.language, sccpline.accountcode, sccpline.echocancel, sccpline.silencesuppression, + sccpline.callgroup, sccpline.pickupgroup, sccpline.adhocNumber, sccpline.meetme, sccpline.meetmenum, sccpline.meetmeopts, sccpline.regexten, + sccpline.directed_pickup, sccpline.directed_pickup_context, sccpline.pickup_modeanswer, sccpline.amaflags, sccpline.dnd, sccpline.videomode, + sccpline.setvar, sccpline.namedcallgroup, sccpline.namedpickupgroup, sccpline.phonecodepage + FROM sccpline"; + $results = $db->query($sql); + if (DB::IsError($results)) { + die_freepbx(sprintf(_("Error updating sccplineconfig view. Command was: %s; error was: %s "), $sql, $results->getMessage())); + } + return true; +} + function createBackUpConfig() { global $amp_conf; @@ -767,7 +852,7 @@ function Setup_RealTime() } } $def_bd_section = $amp_conf['AMPDBNAME']; - $def_ext_config = array('sccpdevice' => "mysql,{$def_bd_section},sccpdeviceconfig",'sccpline' => "mysql,{$def_bd_section},sccpline"); + $def_ext_config = array('sccpdevice' => "mysql,{$def_bd_section},sccpdeviceconfig",'sccpline' => "mysql,{$def_bd_section},sccplineconfig"); // Check extconfig file for correct connector values $ext_conf = ''; @@ -970,7 +1055,7 @@ function cleanUpSccpSettings() { } $settingsFromDb = array_merge($settingsFromDb, array_diff_key($thisInstaller->sccpvalues, $settingsFromDb)); unset($thisInstaller->sccpvalues); - + // get chan-sccp defaults $sysConfiguration = $aminterface->getSCCPConfigMetaData('general'); diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index afaed23..03c2899 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -68,7 +68,7 @@ class dbinterface } break; case 'phoneGrid': - $fld = 'name, name as mac, type, button, addon, _description as description'; + $fld = 'name, name as mac, type, button, addon, description'; switch ($data['type']) { case "cisco-sip": $stmts = $this->db->prepare("SELECT {$fld} FROM sccpdeviceconfig WHERE type LIKE '%-sip' ORDER BY name"); @@ -81,7 +81,7 @@ class dbinterface break; case 'SccpDevice': if (empty($data['fields'])) { - $fld = 'name, name as mac, type, button, addon, _description as description'; + $fld = 'name, name as mac, type, button, addon, description'; } else { switch ($data['fields']) { case "all": diff --git a/sccpManClasses/xmlinterface.class.php b/sccpManClasses/xmlinterface.class.php index e744acf..19af246 100644 --- a/sccpManClasses/xmlinterface.class.php +++ b/sccpManClasses/xmlinterface.class.php @@ -170,8 +170,8 @@ class xmlinterface 'secureinformationurl' => 'dev_secureinformationURL', 'securemessagesurl'=>'dev_securemessagesURL', 'secureservicesurl'=>'dev_secureservicesURL', 'securedirectoryurl'=>'dev_securedirectoryURL', 'secureidleurl' => 'dev_secureidleURL', 'proxyserverurl' => 'dev_proxyServerURL', 'idletimeout' => 'dev_idleTimeout', - 'sshuserid' => '_dev_sshUserId', 'sshpassword' => '_dev_sshPassword', 'deviceprotocol' => 'dev_deviceProtocol', - 'phonepersonalization' => '_phonepersonalization' + 'sshuserid' => 'dev_sshUserId', 'sshpassword' => 'dev_sshPassword', 'deviceprotocol' => 'dev_deviceProtocol', + 'phonepersonalization' => 'phonepersonalization' ); $var_xml_general_vars = array('capfAuthMode' => 'null', 'capfList' => 'null', 'mobility' => 'null', 'phoneServices' => 'null', 'certHash' => 'null', @@ -356,36 +356,36 @@ class xmlinterface case 'userlocale': // Device language $lang = $data_values['devlang']; - if (!empty($dev_config['_devlang'])) { - $lang = $dev_config['_devlang']; + if (!empty($dev_config['devlang'])) { + $lang = $dev_config['devlang']; } $xml_node->winCharSet = $dev_config['phonecodepage']; - $xml_node->name = $dev_config['_devlang']; + $xml_node->name = $dev_config['devlang']; $xml_node->langCode = 'en'; - if (isset($langCodeArray['_devlang'])) { - $xml_node->langCode = $langCodeArray['_devlang']; + if (isset($langCodeArray['devlang'])) { + $xml_node->langCode = $langCodeArray['devlang']; } $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); break; case 'networklocale': - $lang = $data_values['_netlang']; - if (!empty($dev_config['_netlang'])) { - $lang = $dev_config['_netlang']; + $lang = $data_values['netlang']; + if (!empty($dev_config['netlang'])) { + $lang = $dev_config['netlang']; } if (($lang != null) && (!empty($lang))) { $xml_work->$key = $lang; $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } else { $xml_work->$key = ''; - } + } break; case 'networklocaleinfo': - $lang = $data_values['_netlang']; - if (!empty($dev_config['_netlang'])) { - $lang = $dev_config['_netlang']; + $lang = $data_values['netlang']; + if (!empty($dev_config['netlang'])) { + $lang = $dev_config['netlang']; } if (($lang != null) && (!empty($lang))) { - $xml_node->name = $dev_config['_netlang']; + $xml_node->name = $dev_config['netlang']; $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } else { $xml_work->$key = ''; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index fa93276..dcc5fe9 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -307,7 +307,6 @@ trait ajaxHelper { break; case 'getPhoneGrid': $dbDevices = array(); - // Find all devices defined in the database. $dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $request['type'])); // Return if only interested in SIP devices From 48a2793886c37a1d2ffdf2a90e38ea05f0250cb3 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 08:05:33 +0200 Subject: [PATCH 125/181] Add directed_pickup field Previously shown but not updated --- module.xml | 2 +- sccpManClasses/Sccp.class.php.v433 | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/module.xml b/module.xml index 28e6e6d..33f9036 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.0 + 14.3.0.1 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 798057e..e31c62e 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -44,8 +44,10 @@ class Sccp extends \FreePBX\modules\Core\Driver { "musicclass" => 'musicclass', "allow" => 'allow',"disallow" => 'disallow', "videomode" => 'videomode', 'pickup_modeanswer' => 'pickup_modeanswer', "dnd" => 'dnd', "silencesuppression" => 'silencesuppression', - "secondary_dialtone_digits" => 'secondary_dialtone_digits', "secondary_dialtone_tone" => 'secondary_dialtone_tone', - 'namedcallgroup'=>'namedcallgroup', 'namedpickupgroup' => 'namedpickupgroup' + "secondary_dialtone_digits" => 'secondary_dialtone_digits', + "secondary_dialtone_tone" => 'secondary_dialtone_tone', + 'namedcallgroup'=>'namedcallgroup', 'namedpickupgroup' => 'namedpickupgroup', + 'directed_pickup' => 'directed_pickup' ); // These are gui defaults used by freePBX for the elements in the SCCP tab in add/edit phone. private $guiDefaults =array( @@ -109,6 +111,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function addDevice($id, $settings) { // This is actually save line and is used by add and edit. + dbug($settings); $add_fld = array ("name"=>'label',"outboundcid"=>'cid_num',"langcode"=>'language',"extdisplay"=>'description','devinfo_mailbox'=>'mailbox'); $settings['cid_num']['value'] = ''; $settings['cid_name']['value'] = ''; From 646a975a5fed8f1a6f55d7fd0c2ddfc5d8e59818 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 08:26:11 +0200 Subject: [PATCH 126/181] Update xmlinterface.class.php Update locale cases for SIP phones --- sccpManClasses/xmlinterface.class.php | 63 +++++++++++++++------------ 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/sccpManClasses/xmlinterface.class.php b/sccpManClasses/xmlinterface.class.php index 19af246..7d5d926 100644 --- a/sccpManClasses/xmlinterface.class.php +++ b/sccpManClasses/xmlinterface.class.php @@ -120,8 +120,6 @@ class xmlinterface { // TODO: $data_values are system wide defaults, $dev_config are specific defice values. // Need to merge the two arrays so that device specific values override system values - // Values that cannot be sent to the device by chan-sccp are prefixed by an underscore - // so need to be sure that we apply the same convention to system wide defaults. $langCodeArray = array( 'Arabic_Saudi_Arabia' => 'ar', 'Bulgarian_Bulgaria' => 'bg', @@ -372,7 +370,7 @@ class xmlinterface if (!empty($dev_config['netlang'])) { $lang = $dev_config['netlang']; } - if (($lang != null) && (!empty($lang))) { + if (isset($lang)) { $xml_work->$key = $lang; $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } else { @@ -384,8 +382,8 @@ class xmlinterface if (!empty($dev_config['netlang'])) { $lang = $dev_config['netlang']; } - if (($lang != null) && (!empty($lang))) { - $xml_node->name = $dev_config['netlang']; + if (isset($lang)) { + $xml_node->name = $lang; $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } else { $xml_work->$key = ''; @@ -680,33 +678,40 @@ class xmlinterface $xml_node->backgroundImageAccess = (($data_values['backgroundImageAccess'] == 'on') || ($data_values['backgroundImageAccess'] == 'true') ) ? 'true' : 'false'; $xml_node->callLogBlfEnabled = $data_values['callLogBlfEnabled']; break; - - case 'userLocale': - case 'networkLocaleInfo': - case 'networkLocale': - $hwlang = ''; - $lang = ''; - if (!empty($dev_config["_hwlang"])) { - $hwlang = explode(':', $dev_config["_hwlang"]); + case 'userlocale': + // Device language + $lang = $data_values['devlang']; + if (!empty($dev_config['devlang'])) { + $lang = $dev_config['devlang']; } - if (($key == 'networkLocaleInfo') || ($key == 'networkLocale')) { - $lang = (empty($hwlang[0])) ? $data_values['netlang'] : $hwlang[0]; + $xml_node->winCharSet = $dev_config['phonecodepage']; + $xml_node->name = $dev_config['devlang']; + $xml_node->langCode = 'en'; + if (isset($langCodeArray['devlang'])) { + $xml_node->langCode = $langCodeArray['devlang']; + } + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); + break; + case 'networklocale': + $lang = $data_values['netlang']; + if (!empty($dev_config['netlang'])) { + $lang = $dev_config['netlang']; + } + if (isset($lang)) { + $xml_work->$key = $lang; + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } else { - $lang = (empty($hwlang[1])) ? $data_values['devlang'] : $hwlang[1]; + $xml_work->$key = ''; } - if (($lang != 'null') && (!empty($lang))) { - if ($key == 'networkLocale') { - $xml_work->$key = $lang; - } else { - if (isset($lang_info[$lang])) { - $xml_node->name = $lang_info[$lang]['locale']; - $xml_node->langCode = $lang_info[$lang]['code']; - if ($key == 'userLocale') { - $xml_node->winCharSet = $lang_info[$lang]['codepage']; - } - $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); - } - } + break; + case 'networklocaleinfo': + $lang = $data_values['netlang']; + if (!empty($dev_config['netlang'])) { + $lang = $dev_config['netlang']; + } + if (isset($lang)) { + $xml_node->name = $lang; + $this->replaceSimpleXmlNode($xml_work->$key, $xml_node); } else { $xml_work->$key = ''; } From b753482898c2014d62d8004f609cc63a77466031 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 08:43:40 +0200 Subject: [PATCH 127/181] Correct defaults after db schema change --- assets/js/sccp_manager.js | 3 --- conf/sccpgeneral.xml.v433 | 1 - views/form.adddevice.php | 9 +-------- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 2c4e67b..ef3ccb7 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -284,8 +284,6 @@ $(document).ready(function () { // console.log('HwSelect'); var type_id = $('#sccp_hw_type').find(':selected').data('id'); var btn_dev = $('#sccp_hw_type').find(':selected').data('val'); -// var btn_add=$('#sccp_hw_addon').find(':selected').data('val'); - if (type_id === 1) { if ($('#sccp_hw_addon').val() !== 'NONE') { $('#sccp_hw_addon').val('NONE').change(); @@ -305,7 +303,6 @@ $(document).ready(function () { $(this).addClass('hidden'); } }); - }); $('.lineSelect').change(function (e) { diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 99289d6..3a1d5c9 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1304,7 +1304,6 @@ and open the template in the editor. Base Version before all crash :-) addon NONE sccp-custom - Addon: Addons are model specific and only work with certain base phones. This phone model is identified as being a phone that does not accept sidecars. Update devmodel if this is not correct.
    diff --git a/views/form.adddevice.php b/views/form.adddevice.php index 8468c79..186d9e2 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -69,20 +69,14 @@ if (!empty($_REQUEST['id'])) { $val = implode('.', sscanf($val, '%4s%4s%4s')); // Convert to Cisco display Format $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); break; - case '_hwlang': - $tmpar = explode(":", $val); - $def_val['netlang'] = array("keyword" => 'netlang', "data" => $tmpar[0], "seq" => "99"); - $def_val['devlang'] = array("keyword" => 'devlang', "data" => $tmpar[1], "seq" => "99"); - break; // case 'permit': // case 'deny': // $def_val[$key . '_net'] = array("keyword" => $key, "data" => before('/', $val), "seq" => "99"); // $key = $key . '_mask'; // $val = after('/', $val); // break; - case '_phonepersonalization': + case 'phonepersonalization': $def_val['phonepersonalization'] = array("keyword" => 'phonepersonalization', "data" => $val, "seq" => "99"); - default: // Overwrite existing defaults after checking that data is still valid after schema updates // Do not strip underscores as these fields are new in the schema and so should be valid. @@ -104,7 +98,6 @@ if (!empty($_REQUEST['id'])) { } } } - } if (!empty($device_warning)) { From d43570b471510775ab2d2728b4f8dfbf50339f7b Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 13:50:31 +0200 Subject: [PATCH 128/181] Enable addition of sidecars to an existing device --- assets/js/sccp_manager.js | 22 ++++++++++++++++------ conf/sccpgeneral.xml.v433 | 11 +++++------ sccpManClasses/formcreate.class.php | 2 +- views/form.buttons.php | 17 +++++++++-------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index ef3ccb7..6c3b326 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -281,7 +281,8 @@ $(document).ready(function () { }); // Form.adddevice $('.hw_select').change(function (e) { -// console.log('HwSelect'); + // data-val contains the number of buttons for this type + // data-id contains the max number of addons (1 = 0, 3 = 2) var type_id = $('#sccp_hw_type').find(':selected').data('id'); var btn_dev = $('#sccp_hw_type').find(':selected').data('val'); if (type_id === 1) { @@ -290,17 +291,26 @@ $(document).ready(function () { } $('#sccp_hw_addon').attr("disabled", "disabled"); } else { - $('#sccp_hw_addon').removeAttr('disabled'); + $('#sccp_hw_addon').prop('disabled',false); + } + // when edit, btn_dev is undefined as no select, so send btn_dev with page + if (btn_dev == null) { + var btn_dev = $('#devButtonCnt').val(); } - var btn_add = $('#sccp_hw_addon').find(':selected').data('val'); - $('#buttonscount').attr('value',btn_dev + btn_add); + // btn_add is empty if none selected + if ((btn_add == null) || (btn_add == '')) { + var btn_add = 0; + } + var totButtons = parseInt(btn_dev, 10) + parseInt(btn_add, 10); + $('#buttonscount').attr('value', totButtons); $('.line_button').each(function () { - if ($(this).data('id') < btn_dev + btn_add) { + if ($(this).data('id') < totButtons) { $(this).removeClass('hidden'); - $(this).removeAttr('hidden') + $(this).removeAttr('hidden'); } else { $(this).addClass('hidden'); + $(this).attr('hidden', true); } }); }); diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 3a1d5c9..48e3d92 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1298,13 +1298,12 @@ and open the template in the editor. Base Version before all crash :-) The type of phone: 7911, 7940, 7960, etc. Important note: the 'G' models are handled as the base model (e.g., 7962G is handled as 7962). In the Display mode, this field is read-only because the MAC address and the model number are a pair. - + - - addon - NONE - sccp-custom - + addon + NONE + + hw_select form-control Addon: Addons are model specific and only work with certain base phones. This phone model is identified as being a phone that does not accept sidecars. Update devmodel if this is not correct. diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index e1ac17e..184805a 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -759,7 +759,7 @@ class formcreate break; case 'SDE': $extension_list = \FreePBX::Sccp_manager()->dbinterface->getDb_model_info('extension', 'model'); - $extension_list[]=array( 'model' => 'NONE', 'vendor' => 'CISCO', 'dns' => '0'); + $extension_list[] = array( 'model' => 'NONE', 'vendor' => 'CISCO', 'dns' => '0'); foreach ($extension_list as &$data) { $d_name = explode(';', $data['model']); if (is_array($d_name) && (count($d_name) > 1)) { diff --git a/views/form.buttons.php b/views/form.buttons.php index 15fc7a4..48e224a 100644 --- a/views/form.buttons.php +++ b/views/form.buttons.php @@ -31,30 +31,30 @@ $hint_list = $this->getHintInformation(true, array('context'=>'park-hints')) ; // print_r($hint_list); $line_id =0; -$max_buttons =56; //Don't know hardware type so et a maximum. On save, this is set to actual max buttons +$max_buttons =56; //Don't know hardware type so set a maximum. On save, this is set to actual max buttons $show_buttons =1; //print_r($hint_list); if (!empty($_REQUEST['id'])) { $dev_id = $_REQUEST['id']; $db_buttons = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_buttons', array("id" => $dev_id)); $db_device = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $dev_id)); - $max_buttons = $db_device['buttons']; + $show_buttons = $db_device['buttons']; if (!empty($db_device['addon_buttons'])) { - $max_buttons += $db_device['addon_buttons']; + $show_buttons += $db_device['addon_buttons']; } - $show_buttons = $max_buttons; + //$show_buttons = $max_buttons; } if (!empty($_REQUEST['new_id'])) { $val = $_REQUEST['type']; $dev_schema = $this-> getSccpModelInformation('byid', false, "all", array('model' =>$val)); // $db_device = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $val)); - $max_buttons = $dev_schema[0]['buttons']; + $show_buttons = $dev_schema[0]['buttons']; if (!empty($_REQUEST['addon'])) { $val = $_REQUEST['addon']; $dev_schema = $this-> getSccpModelInformation('byid', false, "all", array('model' =>$val)); - $max_buttons += $dev_schema[0]['buttons']; + $show_buttons += $dev_schema[0]['buttons']; } - $show_buttons = $max_buttons; + //$show_buttons = $max_buttons; } if (!empty($_REQUEST['ru_id'])) { $dev_id = $_REQUEST['ru_id']; @@ -67,7 +67,8 @@ if (!empty($_REQUEST['ru_id'])) { - + +

    From 1f910c7e97611104a71e22d7ad5e09c32b035428 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 15:40:23 +0200 Subject: [PATCH 129/181] Force entry of correct mac address before save is enabled Move focus to Mac field and stay until a correct Mac address is entered, disabling Save buttons until correct Motive: a device record with an empty Mac address requires manual removal. --- assets/js/sccp_manager.js | 11 +++++++++-- conf/sccpgeneral.xml.v433 | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 6c3b326..1fffeb4 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -214,12 +214,19 @@ $(document).ready(function () { e.preventDefault(); }); - $('#sccp_hw_mac').change(function() { + $('#sccp_hw_mac').focus(); + + $('#sccp_hw_mac').focusout(function() { var value = $(this).val(); const regex = new RegExp('^([0-9A-Fa-f]{2}[:.-]?){5}([0-9A-Fa-f]{2})$'); if ( regex.test(value) === false ) { + $('#ajaxsubmit2').attr('disabled', 'disabled'); + $('#ajaxsubmit').attr('disabled', 'disabled'); fpbxToast(_('Invalid Mac Address'),_('Invalid Mac Address'), 'warning'); - setTimeout(function(){document.getElementById("sccp_hw_mac").focus();},2000); + setTimeout(function(){ $('#sccp_hw_mac').focus();},2000); + } else { + $('#ajaxsubmit2').removeAttr('disabled'); + $('#ajaxsubmit').removeAttr('disabled'); }; }); diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 48e3d92..47522ad 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1253,8 +1253,9 @@ and open the template in the editor. Base Version before all crash :-) mac - 000000000 + sccp-custom + The MAC address of the phone. You must specify 12 characters in the format XXXX.XXXX.XXXX or XX-XX-XX-XX-XX-XX or XXXXXXXXXXXX
    @@ -1282,7 +1283,7 @@ and open the template in the editor. Base Version before all crash :-) mac - 000000000 + sccp-custom From f2d15ebd5e3269f62ba3a418325b64f202aebb06 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:28:05 +0200 Subject: [PATCH 130/181] Correct del extension to remove all associated buttons --- assets/js/sccp_manager.js | 2 +- sccpManClasses/Sccp.class.php.v433 | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 1fffeb4..264bc9c 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -213,7 +213,7 @@ $(document).ready(function () { } e.preventDefault(); }); - + // Set focus on the mac entry field. It will not stay but ensures that focusout brings it back $('#sccp_hw_mac').focus(); $('#sccp_hw_mac').focusout(function() { diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index e31c62e..5e135b7 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -187,8 +187,12 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function delDevice($id) { //Required by FreePBX. // Delete associated default line buttons or will leave orphans - $sth = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE ref = ? AND instance = 1 AND buttontype = 'line'"); - $sth->execute(array($id)); + foreach (array($id) as $openId) { + $sth = $this->database->prepare("DELETE FROM sccpbuttonconfig WHERE name LIKE :openID AND buttontype = 'line'"); + $openId = "{$openId}%"; + $sth->bindParam(':openID', $openId); + $sth->execute(); + } $sth = $this->database->prepare("DELETE FROM sccpline WHERE name = ?"); $sth->execute(array($id)); From fb254076110b1fd8d618beac4bedf1fe1301f1e6 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 17:20:43 +0200 Subject: [PATCH 131/181] Improve presentation of shared lines --- sccpManTraits/ajaxHelper.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index dcc5fe9..c235801 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -296,13 +296,30 @@ trait ajaxHelper { } $activeDevices = $this->aminterface->sccp_get_active_device(); foreach ($lineList as $key => $lineArr) { - if (array_key_exists($lineArr['mac'], $activeDevices)) { - $actDevStat = $activeDevices[$lineArr['mac']]; - $lineList[$key]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}"; + if (!empty($outLineList[$lineList[$key]['name']])) { + $outLineList[$lineList[$key]['name']]['mac'] .= "
    ".$lineList[$key]['mac']; + if (array_key_exists($lineArr['mac'], $activeDevices)) { + $actDevStat = $activeDevices[$lineArr['mac']]; + $outLineList[$lineList[$key]['name']]['line_status'] .= "
    " . "{$actDevStat['status']} | {$actDevStat['act']}"; + } else { + $outLineList[$lineList[$key]['name']]['line_status'] .= "
    " . '|'; + } } else { - $lineList[$key]['line_status'] = '|'; + $outLineList[$lineList[$key]['name']] = $lineList[$key]; + if (array_key_exists($lineArr['mac'], $activeDevices)) { + $actDevStat = $activeDevices[$lineArr['mac']]; + $outLineList[$lineList[$key]['name']]['line_status'] = "{$actDevStat['status']} | {$actDevStat['act']}"; + } else { + // create a new output list + $outLineList[$lineList[$key]['name']] = $lineList[$key]; + $outLineList[$lineList[$key]['name']]['line_status'] = '|'; + } } } + unset($lineList); + foreach ($outLineList as $valueArray) { + $lineList[] = $valueArray; + } return $lineList; break; case 'getPhoneGrid': From 472d73489e32cff6d62c80a577889a9226a1840f Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 29 Jul 2021 17:21:18 +0200 Subject: [PATCH 132/181] Update ajaxHelper.php --- sccpManTraits/ajaxHelper.php | 1 + 1 file changed, 1 insertion(+) diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index c235801..dbe8515 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -317,6 +317,7 @@ trait ajaxHelper { } } unset($lineList); + // Html wants an anonymous array rather than a keyed array, so remove keys. foreach ($outLineList as $valueArray) { $lineList[] = $valueArray; } From d432ff7a05a950d521ef13f7fae1fcbf7acd972f Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 07:27:31 +0200 Subject: [PATCH 133/181] Ensure that addons cannot be added in edit on devices that do not have addons --- assets/js/sccp_manager.js | 28 ++++++++++++++++++++++------ views/form.buttons.php | 1 + 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 264bc9c..5f3e9ed 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -287,12 +287,12 @@ $(document).ready(function () { }); }); // Form.adddevice - $('.hw_select').change(function (e) { - // data-val contains the number of buttons for this type - // data-id contains the max number of addons (1 = 0, 3 = 2) + $('.hw_select').mouseover(function (e) { var type_id = $('#sccp_hw_type').find(':selected').data('id'); - var btn_dev = $('#sccp_hw_type').find(':selected').data('val'); - if (type_id === 1) { + if (type_id == null) { + var type_id = $('#addonCnt').val(); + } + if (type_id == 1) { if ($('#sccp_hw_addon').val() !== 'NONE') { $('#sccp_hw_addon').val('NONE').change(); } @@ -300,9 +300,25 @@ $(document).ready(function () { } else { $('#sccp_hw_addon').prop('disabled',false); } - // when edit, btn_dev is undefined as no select, so send btn_dev with page + }); + + $('.hw_select').change(function (e) { + // data-val contains the number of buttons for this type + // data-id contains the max number of addons (1 = 0, 3 = 2) + var type_id = $('#sccp_hw_type').find(':selected').data('id'); + var btn_dev = $('#sccp_hw_type').find(':selected').data('val'); + // when edit, btn_dev is undefined as no select, so send btn_dev and type_id with page if (btn_dev == null) { var btn_dev = $('#devButtonCnt').val(); + var type_id = $('#addonCnt').val(); + } + if (type_id == 1) { + if ($('#sccp_hw_addon').val() !== 'NONE') { + $('#sccp_hw_addon').val('NONE').change(); + } + $('#sccp_hw_addon').attr("disabled", "disabled"); + } else { + $('#sccp_hw_addon').prop('disabled',false); } var btn_add = $('#sccp_hw_addon').find(':selected').data('val'); // btn_add is empty if none selected diff --git a/views/form.buttons.php b/views/form.buttons.php index 48e224a..968cf6b 100644 --- a/views/form.buttons.php +++ b/views/form.buttons.php @@ -69,6 +69,7 @@ if (!empty($_REQUEST['ru_id'])) { +

    From a267f075c84614964d76f19353148bda417a874d Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 08:39:53 +0200 Subject: [PATCH 134/181] include silent lines in extension view --- sccpManClasses/dbinterface.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 03c2899..2af41b4 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -56,8 +56,9 @@ class dbinterface switch ($dataid) { case 'extGrid': // only called by getExtensionGrid from hardware.extension.php view - $stmts = $this->db->prepare('SELECT sccpline.name, sccpline.label, sccpbuttonconfig.ref as mac - FROM sccpline LEFT JOIN sccpbuttonconfig ON sccpline.name=sccpbuttonconfig.name ORDER BY sccpline.name'); + $stmts = $this->db->prepare("SELECT sccpline.name, sccpline.label, sccpbuttonconfig.ref as mac + FROM sccpline LEFT JOIN sccpbuttonconfig + ON sccpline.name = TRIM(TRAILING '!silent' FROM sccpbuttonconfig.name) ORDER BY sccpline.name"); break; case 'SccpExtension': if (empty($data['name'])) { From 60f7d74cf4f594f7ee876156f548ea0a8f98c97d Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 09:12:51 +0200 Subject: [PATCH 135/181] Update Sccp Info --- sccpManClasses/extconfigs.class.php | 2 +- views/server.info.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 8186646..73d5d5f 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -379,7 +379,7 @@ class extconfigs $cnf_read = \FreePBX::LoadConfig(); // We are running inside FreePBX so must use the same database - $def_config = array('sccpdevice' => 'mysql,' . $amp_conf['AMPDBNAME'] . ',sccpdeviceconfig', 'sccpline' => 'mysql,' . $amp_conf['AMPDBNAME'] . ',sccpline'); + $def_config = array('sccpdevice' => 'mysql,' . $amp_conf['AMPDBNAME'] . ',sccpdeviceconfig', 'sccpline' => 'mysql,' . $amp_conf['AMPDBNAME'] . ',sccplineconfig'); $backup_ext = array('_custom.conf', '.conf', '_additional.conf'); $def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'], 'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'], diff --git a/views/server.info.php b/views/server.info.php index ad9494c..7d54fae 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -113,6 +113,8 @@ if (empty($ast_realtime)) { } // There are potential issues with string Type Declarations in PHP 5. $info['PHP'] = array('Version' => phpversion(), 'about' => version_compare(phpversion(), '7.0.0', '>' ) ? 'OK' : 'PHP 7 Preferred - Please upgrade if possible'); +$mariaDbInfo = exec('mysql -V'); +$info['MariaDb'] = array('Version' => explode(" ",$mariaDbInfo)[3], 'about' => $mariaDbInfo); if (empty($conf_realtime)) { $info['ConfigsRealTime'] = array('Version' => 'Error', 'about' => '
    Realtime configuration was not found
    '); From 97c1f6d5d4848e317f662db2fc0fb0d8d16c1cad Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 10:18:27 +0200 Subject: [PATCH 136/181] Minor settings changes --- conf/sccpgeneral.xml.v433 | 2 +- install.php | 3 ++- module.xml | 2 +- sccpManClasses/dbinterface.class.php | 1 - sccpManClasses/formcreate.class.php | 3 +-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 47522ad..58c6c13 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -218,7 +218,7 @@ and open the template in the editor. Base Version before all crash :-) ccm_addressInternal - 0.0.0.0:2000 + 0.0.0.0/2000 diff --git a/install.php b/install.php index c7d87d7..4953688 100644 --- a/install.php +++ b/install.php @@ -990,7 +990,7 @@ function checkTftpServer() { // Get TFTP mapping Status $settingsFromDb['tftp_rewrite'] = array('keyword' => 'tftp_rewrite', 'seq' => 20, 'type' => 0, 'data' => 'off', 'systemdefault' => ''); - if (\FreePbx::Sccp_manager()->checkTftpMapping()) { + if ($thisInstaller->checkTftpMapping()) { $settingsFromDb['tftp_rewrite']['data'] = 'pro'; } @@ -1100,6 +1100,7 @@ function cleanUpSccpSettings() { } // Override certain chan-sccp defaults as they are based on a non-FreePbx system $settingsFromDb['context']['systemdefault'] = 'from-internal'; + $settingsFromDb['directed_pickup']['systemdefault'] = 'no'; unset($sysConfiguration[$key]); } diff --git a/module.xml b/module.xml index 33f9036..28e6e6d 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 2af41b4..d16470c 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -400,7 +400,6 @@ class dbinterface { $result = 0; $check_fields = [ - '430' => ['_hwlang' => "varchar(12)"], '431' => ['private'=> "enum('on','off')"], '433' => ['directed_pickup'=>''] ]; diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index 184805a..fc86a9a 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -384,8 +384,7 @@ class formcreate } // Output current value - // TODO: This is debug code and needs to be set to only echo res_v - echo $res_v . $res_n . $sccp_defaults[$res_n]['systemdefault'] . $usingSysDefaults; + echo $res_v; ?>
    From 40cace04e400903d9216ab43034f8494ba0ceeea Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 10:36:38 +0200 Subject: [PATCH 137/181] Increase granularity of backup name --- install.php | 2 +- module.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index 4953688..e9ef819 100644 --- a/install.php +++ b/install.php @@ -791,7 +791,7 @@ function createBackUpConfig() outn("PHPx.x-zip not installed where x.x is the installed PHP version. Install it before continuing !"); die_freepbx(); } - $filename = $dir . "/sccp_install_backup" . date("Ymd"). ".zip"; + $filename = $dir . "/sccp_install_backup" . date("Ymdhis"). ".zip"; if ($zip->open($filename, \ZIPARCHIVE::CREATE)) { foreach ($backup_files as $file) { foreach ($backup_ext as $b_ext) { diff --git a/module.xml b/module.xml index 28e6e6d..33f9036 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.0 + 14.3.0.1 setup SCCP Connectivity Steve Lad, Alex GP From 85e77ab34cd8eaf7e57f5729d3c26ba3bd4d1dc3 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 11:04:01 +0200 Subject: [PATCH 138/181] Insert missing field in sccplineconfig view --- install.php | 2 +- module.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.php b/install.php index e9ef819..d9ad975 100644 --- a/install.php +++ b/install.php @@ -758,7 +758,7 @@ function createViewSccplineconfig() { "; $sql .= "CREATE OR REPLACE VIEW sccplineconfig AS - SELECT sccpline.id, sccpline.pin ,sccpline.label, sccpline.description, sccpline.context, sccpline.incominglimit, sccpline.transfer, sccpline.mailbox, + SELECT sccpline.name, sccpline.id, sccpline.pin ,sccpline.label, sccpline.description, sccpline.context, sccpline.incominglimit, sccpline.transfer, sccpline.mailbox, sccpline.vmnum, sccpline.cid_name, sccpline.cid_num, sccpline.disallow, sccpline.allow, sccpline.trnsfvm, sccpline.secondary_dialtone_digits, sccpline.secondary_dialtone_tone, sccpline.musicclass, sccpline.language, sccpline.accountcode, sccpline.echocancel, sccpline.silencesuppression, sccpline.callgroup, sccpline.pickupgroup, sccpline.adhocNumber, sccpline.meetme, sccpline.meetmenum, sccpline.meetmeopts, sccpline.regexten, diff --git a/module.xml b/module.xml index 33f9036..28e6e6d 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP From d8287157bda3be97d6ad82c25efefc4287d7e566 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 11:23:13 +0200 Subject: [PATCH 139/181] Remove videomode field from sccplineconfig Not recognised by chan-sccp --- install.php | 4 ++-- module.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/install.php b/install.php index d9ad975..8d2ae4f 100644 --- a/install.php +++ b/install.php @@ -762,8 +762,8 @@ function createViewSccplineconfig() { sccpline.vmnum, sccpline.cid_name, sccpline.cid_num, sccpline.disallow, sccpline.allow, sccpline.trnsfvm, sccpline.secondary_dialtone_digits, sccpline.secondary_dialtone_tone, sccpline.musicclass, sccpline.language, sccpline.accountcode, sccpline.echocancel, sccpline.silencesuppression, sccpline.callgroup, sccpline.pickupgroup, sccpline.adhocNumber, sccpline.meetme, sccpline.meetmenum, sccpline.meetmeopts, sccpline.regexten, - sccpline.directed_pickup, sccpline.directed_pickup_context, sccpline.pickup_modeanswer, sccpline.amaflags, sccpline.dnd, sccpline.videomode, - sccpline.setvar, sccpline.namedcallgroup, sccpline.namedpickupgroup, sccpline.phonecodepage + sccpline.directed_pickup, sccpline.directed_pickup_context, sccpline.pickup_modeanswer, sccpline.amaflags, sccpline.dnd, sccpline.setvar, + sccpline.namedcallgroup, sccpline.namedpickupgroup, sccpline.phonecodepage FROM sccpline"; $results = $db->query($sql); if (DB::IsError($results)) { diff --git a/module.xml b/module.xml index 28e6e6d..33f9036 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.0 + 14.3.0.1 setup SCCP Connectivity Steve Lad, Alex GP From 1338336dd9c292322214e5407bdfbdb68ac4f63d Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 12:04:32 +0200 Subject: [PATCH 140/181] Add phonecodepage column to sccpdeviceconfig --- install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.php b/install.php index 8d2ae4f..c8cda1d 100644 --- a/install.php +++ b/install.php @@ -737,7 +737,7 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) sccpdevice.softkeyset, sccpdevice.audio_tos, sccpdevice.audio_cos, sccpdevice.video_tos, sccpdevice.video_cos, sccpdevice.conf_allow, sccpdevice.conf_play_general_announce, sccpdevice.conf_play_part_announce, sccpdevice.conf_mute_on_entry, sccpdevice.conf_music_on_hold_class, sccpdevice.conf_show_conflist, sccpdevice.force_dtmfmode, sccpdevice.setvar, sccpdevice.backgroundImage, sccpdevice.backgroundThumbnail, - sccpdevice.ringtone, sccpdevice.callhistory_answered_elsewhere, sccpdevice.useRedialMenu, sccpdevice.cfwdnoanswer, sccpdevice.park, sccpdevice.monitor + sccpdevice.ringtone, sccpdevice.callhistory_answered_elsewhere, sccpdevice.useRedialMenu, sccpdevice.cfwdnoanswer, sccpdevice.park, sccpdevice.monitor, sccpdevice.phonecodepage FROM sccpdevice LEFT JOIN sccpuser sccpuser ON ( sccpuser.name = sccpdevice.loginname ) GROUP BY sccpdevice.name;"; From e8cabfbd1a056a11f46711c235ec3bb1d8301994 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 14:05:00 +0200 Subject: [PATCH 141/181] Improve parsing of firewall rules --- conf/sccpgeneral.xml.v433 | 2 +- module.xml | 2 +- sccpManClasses/formcreate.class.php | 11 ++++++----- sccpManTraits/ajaxHelper.php | 23 +++++++++++------------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 583c421..443187a 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -218,7 +218,7 @@ and open the template in the editor. Base Version before all crash :-) ccm_address Internal - 0.0.0.0/2000 + 0.0.0.0:2000 diff --git a/module.xml b/module.xml index 33f9036..28e6e6d 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.0 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index fc86a9a..0652bdd 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -213,7 +213,6 @@ class formcreate } if (empty($res_value)) { $res_value = array((string) $child->default); - // $res_value = explode('/', (string) $child->default); } ?>
    @@ -280,17 +279,19 @@ class formcreate ?>
    > xpath('input') as $value) { $res_n = $res_id.'['.$i.']['.$value['field'].']'; $fields_id = (string)$value['field']; - $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; + //$opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; if (!empty($value->class)) { $opt_at[$fields_id]['class']='form-control ' .(string)$value->class; } - $opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; - + //$opt_at[$fields_id]['nameseparator']=(string)$value['nameseparator']; + if (!empty((string)$value['nameseparator'])) { + $res_vf = explode((string)$value['nameseparator'], $dat_v); + } echo 'options)) { foreach ($value->options ->attributes() as $optkey => $optval) { diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index dbe8515..6dcba53 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -415,6 +415,7 @@ trait ajaxHelper { } function handleSubmit($request, $validateonly = false) { + dbug($request); $hdr_prefix = 'sccp_'; $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); @@ -477,29 +478,27 @@ trait ajaxHelper { $arr_data = ''; if (!empty($this->sccpvalues[$key])) { foreach ($value as $vkey => $vval) { - $tmp_data = ''; + //$tmp_data = ''; foreach ($vval as $vkey => $vval) { switch ($vkey) { case 'inherit': case 'internal': if ($vval == 'on') { - $tmp_data .= 'internal;'; + $arr_data .= 'internal;'; } break; + case 'port': + $arr_data .= ":{$vval}"; + break; + case 'mask': + $arr_data .= "/{$vval}"; + break; default: - $tmp_data .= $vval . '/'; + $arr_data .= $vval; break; } } - if (strlen($tmp_data) > 2) { - while (substr($tmp_data, -1) == '/') { - $tmp_data = substr($tmp_data, 0, -1); - } - $arr_data .= $tmp_data . ';'; - } - } - while (substr($arr_data, -1) == ';') { - $arr_data = substr($arr_data, 0, -1); + //$arr_data .= $tmp_data; } if (!($this->sccpvalues[$key]['data'] == $arr_data)) { $save_settings[$key] = array( From b7a64e854f911fa03528d7483ad880a2afc8e371 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 14:05:59 +0200 Subject: [PATCH 142/181] Update ajaxHelper.php --- sccpManTraits/ajaxHelper.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 6dcba53..c16004b 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -477,9 +477,8 @@ trait ajaxHelper { if ($count_mods) { $arr_data = ''; if (!empty($this->sccpvalues[$key])) { - foreach ($value as $vkey => $vval) { - //$tmp_data = ''; - foreach ($vval as $vkey => $vval) { + foreach ($value as $valArr) { + foreach ($valArr as $vkey => $vval) { switch ($vkey) { case 'inherit': case 'internal': @@ -498,7 +497,6 @@ trait ajaxHelper { break; } } - //$arr_data .= $tmp_data; } if (!($this->sccpvalues[$key]['data'] == $arr_data)) { $save_settings[$key] = array( From 3ea36f54590b9e2be2e2fb894225b04135009845 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 14:39:15 +0200 Subject: [PATCH 143/181] add keepalive --- conf/sccpgeneral.xml.v433 | 22 ++++++++++++++++++++++ install.php | 16 +++++++++------- module.xml | 2 +- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 443187a..8685df0 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -415,6 +415,17 @@ and open the template in the editor. Base Version before all crash :-) Use simulated enbloc dialing to speedup connection when dialing while onhook (older phones) + + + + keepalive + 60 + sccp-custom + number + + + Time between Keep Alive checks. Valid range is 60-300 seconds. After much trial-and-error, the minimum (60) seems to work just fine. + phonepersonalization @@ -1655,6 +1666,17 @@ and open the template in the editor. Base Version before all crash :-) The audio stream will be open in the progress and connected state. Valid options: Yes/ No + + + + keepalive + 60 + sccp-custom + number + + + Time between Keep Alive checks. Valid range is 60-300 seconds. After much trial-and-error, the minimum (60) seems to work just fine. + diff --git a/install.php b/install.php index c8cda1d..c1ed252 100644 --- a/install.php +++ b/install.php @@ -291,7 +291,8 @@ function Get_DB_config($sccp_compatible) '_loginname' => array('rename' => 'loginname'), '_profileid' => array('rename' => 'profileid'), '_dialrules' => array('rename' => 'dialrules'), - '_description' => array('rename' => 'description') + '_description' => array('rename' => 'description'), + 'keepalive' => array('create' => "INT(11) DEFAULT '60'", 'modify' => 'INT(11)', 'def_modify' => "60") ), 'sccpline' => array ( 'regcontext' => array('create' => "VARCHAR(20) NULL default 'sccpregistration'", 'modify' => "VARCHAR(20)"), @@ -732,12 +733,13 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) (SELECT GROUP_CONCAT(CONCAT_WS(',', homebutton.buttontype, homebutton.name, homebutton.options ) SEPARATOR ';') FROM sccpbuttonconfig AS homebutton WHERE homebutton.ref = sccpuser.homedevice ORDER BY homebutton.instance ) END AS button, if(sccpdevice.profileid = 0, sccpdevice.description, sccpuser.description) AS description, sccpdevice.name, sccpdevice.type, - sccpdevice.addon, sccpdevice.tzoffset, sccpdevice.imageversion, sccpdevice.deny, sccpdevice.permit, sccpdevice.earlyrtp, sccpdevice.mwilamp, sccpdevice.mwioncall, - sccpdevice.dndFeature, sccpdevice.transfer, sccpdevice.cfwdall, sccpdevice.cfwdbusy, sccpdevice.private, sccpdevice.privacy, sccpdevice.nat, sccpdevice.directrtp, - sccpdevice.softkeyset, sccpdevice.audio_tos, sccpdevice.audio_cos, sccpdevice.video_tos, sccpdevice.video_cos, sccpdevice.conf_allow, - sccpdevice.conf_play_general_announce, sccpdevice.conf_play_part_announce, sccpdevice.conf_mute_on_entry, sccpdevice.conf_music_on_hold_class, - sccpdevice.conf_show_conflist, sccpdevice.force_dtmfmode, sccpdevice.setvar, sccpdevice.backgroundImage, sccpdevice.backgroundThumbnail, - sccpdevice.ringtone, sccpdevice.callhistory_answered_elsewhere, sccpdevice.useRedialMenu, sccpdevice.cfwdnoanswer, sccpdevice.park, sccpdevice.monitor, sccpdevice.phonecodepage + sccpdevice.addon, sccpdevice.tzoffset, sccpdevice.imageversion, sccpdevice.deny, sccpdevice.permit, sccpdevice.earlyrtp, sccpdevice.mwilamp, + sccpdevice.mwioncall, sccpdevice.dndFeature, sccpdevice.transfer, sccpdevice.cfwdall, sccpdevice.cfwdbusy, sccpdevice.private, sccpdevice.privacy, + sccpdevice.nat, sccpdevice.directrtp, sccpdevice.softkeyset, sccpdevice.audio_tos, sccpdevice.audio_cos, sccpdevice.video_tos, sccpdevice.video_cos, + sccpdevice.conf_allow, sccpdevice.conf_play_general_announce, sccpdevice.conf_play_part_announce, sccpdevice.conf_mute_on_entry, + sccpdevice.conf_music_on_hold_class, sccpdevice.conf_show_conflist, sccpdevice.force_dtmfmode, sccpdevice.setvar, sccpdevice.backgroundImage, + sccpdevice.backgroundThumbnail, sccpdevice.ringtone, sccpdevice.callhistory_answered_elsewhere, sccpdevice.useRedialMenu, sccpdevice.cfwdnoanswer, + sccpdevice.park, sccpdevice.monitor, sccpdevice.phonecodepage, sccpdevice.keepalive FROM sccpdevice LEFT JOIN sccpuser sccpuser ON ( sccpuser.name = sccpdevice.loginname ) GROUP BY sccpdevice.name;"; diff --git a/module.xml b/module.xml index 28e6e6d..33f9036 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.0 + 14.3.0.1 setup SCCP Connectivity Steve Lad, Alex GP From e313b9da3ff56a68374b31fd153d010f7e1bfbc8 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 30 Jul 2021 22:43:35 +0200 Subject: [PATCH 144/181] Change pathname style from {} to . Instability seen when pathnames with globals enclosed in {} - revert to . style pathnames --- install.php | 8 ++++---- sccpManClasses/extconfigs.class.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/install.php b/install.php index c1ed252..311bb32 100644 --- a/install.php +++ b/install.php @@ -737,7 +737,7 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) sccpdevice.mwioncall, sccpdevice.dndFeature, sccpdevice.transfer, sccpdevice.cfwdall, sccpdevice.cfwdbusy, sccpdevice.private, sccpdevice.privacy, sccpdevice.nat, sccpdevice.directrtp, sccpdevice.softkeyset, sccpdevice.audio_tos, sccpdevice.audio_cos, sccpdevice.video_tos, sccpdevice.video_cos, sccpdevice.conf_allow, sccpdevice.conf_play_general_announce, sccpdevice.conf_play_part_announce, sccpdevice.conf_mute_on_entry, - sccpdevice.conf_music_on_hold_class, sccpdevice.conf_show_conflist, sccpdevice.force_dtmfmode, sccpdevice.setvar, sccpdevice.backgroundImage, + sccpdevice.conf_music_on_hold_class, sccpdevice.conf_show_conflist, sccpdevice.force_dtmfmode, sccpdevice.setvar, sccpdevice.backgroundImage, sccpdevice.backgroundThumbnail, sccpdevice.ringtone, sccpdevice.callhistory_answered_elsewhere, sccpdevice.useRedialMenu, sccpdevice.cfwdnoanswer, sccpdevice.park, sccpdevice.monitor, sccpdevice.phonecodepage, sccpdevice.keepalive FROM sccpdevice @@ -923,7 +923,7 @@ function Setup_RealTime() function addDriver($sccp_compatible) { outn("
  • " . _("Adding driver ...") . "
  • "); - $file = "{$_SERVER['DOCUMENT_ROOT']}/admin/modules/core/functions.inc/drivers/Sccp.class.php"; + $file = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php'; $contents = ""; file_put_contents($file, $contents); @@ -931,7 +931,7 @@ function addDriver($sccp_compatible) { $dir = $cnf_int->get('ASTETCDIR'); if (!file_exists("{$dir}/sccp.conf")) { // System re Config outn("
  • " . _("Adding default configuration file ...") . "
  • "); - $sccpfile = file_get_contents("{$_SERVER['DOCUMENT_ROOT']}/admin/modules/sccp_manager/conf/sccp.conf"); + $sccpfile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf'); file_put_contents("{$dir}/sccp.conf", $sccpfile); } } @@ -1044,7 +1044,7 @@ function cleanUpSccpSettings() { */ // Clean up sccpsettings to remove legacy values. - $xml_vars = "{$_SERVER['DOCUMENT_ROOT']}/admin/modules/sccp_manager/conf/sccpgeneral.xml.v{$sccp_compatible}"; + $xml_vars = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v{$sccp_compatible}'; $thisInstaller->xml_data = simplexml_load_file($xml_vars); $thisInstaller->initVarfromXml(); foreach ( array_diff_key($settingsFromDb,$thisInstaller->sccpvalues) as $key => $valueArray) { diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 73d5d5f..5ad23ea 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -352,7 +352,7 @@ class extconfigs } // TODO: Need to add index.cnf, after setting defaults correctly if (!file_exists("{$baseConfig['tftp_templates_path']}/XMLDefault.cnf.xml_template")) { - $src_path = "{$_SERVER['DOCUMENT_ROOT']}/admin/modules/sccp_manager/conf/"; + $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; $dst_path = "{$baseConfig["tftp_templates_path"]}/"; foreach (glob("{$src_path}*.*_template") as $filename) { copy($filename, $dst_path . basename($filename)); From 43a656cebcf59f848e6c4da83238caeab2b3d2d8 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 31 Jul 2021 12:30:24 +0200 Subject: [PATCH 145/181] Correct XML Path in installer and optimise findAllFiles XML Path in installer was in single quotes - corrected Remove unnecessary tests in findallfiles --- Sccp_manager.class.php | 33 +++++++----------- install.php | 2 +- sccpManClasses/dbinterface.class.php | 2 +- sccpManTraits/helperFunctions.php | 52 ++++++++++------------------ 4 files changed, 34 insertions(+), 55 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 22a1465..68e6b29 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1070,31 +1070,24 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function getSccpModelInformation($get = "all", $validate = false, $format_list = "all", $filter = array()) { - $file_ext = array('.loads', '.sbn', '.bin', '.zup'); + $file_ext = array('.loads', '.sbn', '.bin', '.zup', '.sbin'); $dir = $this->sccppath['tftp_firmware_path']; - $dir_tepl = $this->sccppath['tftp_templates_path']; - $search_mode = ''; - if (!empty($this->sccpvalues['tftp_rewrite'])) { - $search_mode = $this->sccpvalues['tftp_rewrite']['data']; - switch ($search_mode) { - case 'pro': - case 'on': - case 'internal': - $dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly'); - break; - case 'off': - default: // Place in root TFTP dir - $dir_list = $this->findAllFiles($dir, $file_ext); - break; - } - } else { - $dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly'); + $search_mode = $this->sccpvalues['tftp_rewrite']['data']; + switch ($search_mode) { + case 'pro': + case 'on': + case 'internal': + $dir_list = $this->findAllFiles($dir, $file_ext, 'fileonly'); + break; + case 'off': + default: // Place in root TFTP dir + $dir_list = $this->findAllFiles($dir, $file_ext); + break; } $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'] = '-;-'; if (!empty($raw_settings[$i]['loadimage'])) { $raw_settings[$i]['validate'] = 'no;'; if (((strtolower($raw_settings[$i]['vendor']) == 'cisco') || (strtolower($raw_settings[$i]['vendor']) == 'cisco-sip')) && !empty($dir_list)) { @@ -1122,7 +1115,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $raw_settings[$i]['validate'] = '-;'; } if (!empty($raw_settings[$i]['nametemplate'])) { - $file = $dir_tepl . '/' . $raw_settings[$i]['nametemplate']; + $file = $this->sccppath['tftp_templates_path'] . '/' . $raw_settings[$i]['nametemplate']; if (file_exists($file)) { $raw_settings[$i]['validate'] .= 'yes'; } else { diff --git a/install.php b/install.php index 311bb32..a720b2c 100644 --- a/install.php +++ b/install.php @@ -1044,7 +1044,7 @@ function cleanUpSccpSettings() { */ // Clean up sccpsettings to remove legacy values. - $xml_vars = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v{$sccp_compatible}'; + $xml_vars = $_SERVER['DOCUMENT_ROOT'] . "/admin/modules/sccp_manager/conf/sccpgeneral.xml.v{$sccp_compatible}"; $thisInstaller->xml_data = simplexml_load_file($xml_vars); $thisInstaller->initVarfromXml(); foreach ( array_diff_key($settingsFromDb,$thisInstaller->sccpvalues) as $key => $valueArray) { diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index d16470c..dd68f9a 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -202,7 +202,7 @@ class dbinterface { $sel_inf = '*, 0 as validate'; if ($format_list === 'model') { - $sel_inf = 'model, vendor, dns, buttons, 0 as validate'; + $sel_inf = "model, vendor, dns, buttons, '-;-' as validate"; } switch ($get) { case 'byciscoid': diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index a0e168e..6bfec78 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -113,51 +113,37 @@ trait helperfunctions { return $enumFields; } - private function findAllFiles($dir, $file_mask = null, $mode = 'full') { - $result = null; - if (empty($dir) || (!file_exists($dir))) { + private function findAllFiles($searchDir, $file_mask = array(), $mode = 'full') { + $result = array(); + if (!is_dir($searchDir)) { return $result; } - - $root = scandir($dir); - foreach ($root as $value) { - if ($value === '.' || $value === '..') { - continue; - } - if (is_file("$dir/$value")) { - $filter = false; + foreach (array_diff(scandir($searchDir),array('.', '..')) as $value) { + if (is_file("$searchDir/$value")) { + $foundFile = true; if (!empty($file_mask)) { - if (is_array($file_mask)) { - foreach ($file_mask as $k) { - if (strpos(strtolower($value), strtolower($k)) !== false) { - $filter = true; - } - } - } else { - if (strpos(strtolower($value), strtolower($file_mask)) !== false) { - $filter = true; + $foundFile = false; + foreach ($file_mask as $k) { + if (strpos($value, $k)) { + $foundFile = true; + break; } } - } else { - $filter = true; } - if ($filter) { + if ($foundFile) { if ($mode == 'fileonly') { - $result[] = "$value"; + $result[] = $value; } else { - $result[] = "$dir/$value"; + $result[] = "$searchDir/$value"; } - } else { - $result[] = null; } continue; } - $sub_fiend = $this->findAllFiles("$dir/$value", $file_mask, $mode); - if (!empty($sub_fiend)) { - foreach ($sub_fiend as $sub_value) { - if (!empty($sub_value)) { - $result[] = $sub_value; - } + // Now iterate over sub directories + $sub_find = $this->findAllFiles("$searchDir/$value", $file_mask, $mode); + if (!empty($sub_find)) { + foreach ($sub_find as $sub_value) { + $result[] = $sub_value; } } } From d8d2f946ce12db789f9bde79397eed77cc72d5d8 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 31 Jul 2021 15:41:32 +0200 Subject: [PATCH 146/181] Minor optimisations --- Sccp_manager.class.php | 36 +++++++++++++--------------- sccpManClasses/dbinterface.class.php | 2 +- sccpManTraits/helperFunctions.php | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 68e6b29..4c9d38a 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1090,25 +1090,23 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { for ($i = 0; $i < count($raw_settings); $i++) { if (!empty($raw_settings[$i]['loadimage'])) { $raw_settings[$i]['validate'] = 'no;'; - if (((strtolower($raw_settings[$i]['vendor']) == 'cisco') || (strtolower($raw_settings[$i]['vendor']) == 'cisco-sip')) && !empty($dir_list)) { - foreach ($dir_list as $filek) { - switch ($search_mode) { - case 'pro': - case 'on': - case 'internal': - if (strpos(strtolower($filek), strtolower($raw_settings[$i]['loadimage'])) !== false) { - $raw_settings[$i]['validate'] = 'yes;'; - } - break; - case 'internal2': - break; - case 'off': - default: // Place in root TFTP dir - if (strpos(strtolower($filek), strtolower($dir . '/' . $raw_settings[$i]['loadimage'])) !== false) { - $raw_settings[$i]['validate'] = 'yes;'; - } - break; - } + foreach ($dir_list as $filek) { + switch ($search_mode) { + case 'pro': + case 'on': + case 'internal': + if (strpos($filek, $raw_settings[$i]['loadimage']) !== false) { + $raw_settings[$i]['validate'] = 'yes;'; + } + break; + case 'internal2': + break; + case 'off': + default: // Place in root TFTP dir + if (strpos($filek, strtolower($dir . '/' . $raw_settings[$i]['loadimage'])) !== false) { + $raw_settings[$i]['validate'] = 'yes;'; + } + break; } } } else { diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index dd68f9a..55cc299 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -237,7 +237,7 @@ class dbinterface //$stmt = $db->prepare('SELECT ' . {$sel_inf} . ' FROM sccpdevmodel WHERE enabled = 1 ORDER BY model'); //previously this fell through to phones. //break; // above includes expansion modules but was not original behaviour so commented out. Falls through to phones. case 'phones': - $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) ORDER BY model"); + $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns != 0) and (enabled = 1) ORDER BY model"); break; case 'ciscophones': $stmt = $this->db->prepare("SELECT {$sel_inf} FROM sccpdevmodel WHERE (dns > 0) and (enabled = 1) AND vendor NOT LIKE '%-sip' ORDER BY model"); diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 6bfec78..791513a 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -124,7 +124,7 @@ trait helperfunctions { if (!empty($file_mask)) { $foundFile = false; foreach ($file_mask as $k) { - if (strpos($value, $k)) { + if (strpos($value, $k) !== false) { $foundFile = true; break; } From ab7b295b8753b8c46a7cc1691d01cf820a00b4e6 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 31 Jul 2021 17:07:37 +0200 Subject: [PATCH 147/181] switch basedir path source Use $amp_conf['AMPWEBROOT'] instead of $_SERVER['DOCUMENT_ROOT'] as at least in one case the latter appears to be empty --- install.php | 25 ++++++++++++++++--------- sccpManClasses/Sccp.class.php.v433 | 3 ++- sccpManClasses/extconfigs.class.php | 3 ++- sccpManClasses/formcreate.class.php | 3 ++- sccpManTraits/bmoFunctions.php | 3 ++- views/advserver.model.php | 3 ++- 6 files changed, 26 insertions(+), 14 deletions(-) diff --git a/install.php b/install.php index a720b2c..253b758 100644 --- a/install.php +++ b/install.php @@ -341,9 +341,10 @@ function CheckSCCPManagerDBVersion() function CheckPermissions() { + global $amp_conf; outn("
  • " . _("Checking Filesystem Permissions") . "
  • "); - $dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/views'; - if (fileowner($_SERVER['DOCUMENT_ROOT']) != fileowner($dst)) { + $dst = $amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/views'; + if (fileowner($amp_conf['AMPWEBROOT']) != fileowner($dst)) { die_freepbx('Please (re-)check permissions by running "amportal chown. Installation Failed"'); } } @@ -922,16 +923,17 @@ function Setup_RealTime() } function addDriver($sccp_compatible) { + global $amp_conf; + global $cnf_int; outn("
  • " . _("Adding driver ...") . "
  • "); - $file = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php'; + $file = $amp_conf['AMPWEBROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php'; $contents = ""; file_put_contents($file, $contents); - global $cnf_int; $dir = $cnf_int->get('ASTETCDIR'); if (!file_exists("{$dir}/sccp.conf")) { // System re Config outn("
  • " . _("Adding default configuration file ...") . "
  • "); - $sccpfile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf'); + $sccpfile = file_get_contents($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf'); file_put_contents("{$dir}/sccp.conf", $sccpfile); } } @@ -942,14 +944,15 @@ function checkTftpServer() { global $settingsFromDb; global $extconfigs; global $thisInstaller; + global $amp_conf; $confDir = $cnf_int->get('ASTETCDIR'); $tftpRootPath = ""; // put the rewrite rules into the required location if (file_exists("{$confDir}/sccpManagerRewrite.rules")) { rename("{$confDir}/sccpManagerRewrite.rules", "{$confDir}/sccpManagerRewrite.rules.bu"); } - copy($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/mappingRulesHeader',"{$confDir}/sccpManagerRewrite.rules"); - file_put_contents("{$confDir}/sccpManagerRewrite.rules", file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules'), FILE_APPEND); + copy($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/conf/mappingRulesHeader',"{$confDir}/sccpManagerRewrite.rules"); + file_put_contents("{$confDir}/sccpManagerRewrite.rules", file_get_contents($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/contrib/rewrite.rules'), FILE_APPEND); file_put_contents("{$confDir}/sccpManagerRewrite.rules", "\n# Do not disable this rule - this is required by sccp_manager\nri ^(.+\.tlzz)?$ settings/\\1", FILE_APPEND); // TODO: add option to use external server $remoteFileName = ".sccp_manager_installer_probe_sentinel_temp".mt_rand(0, 9999999); @@ -1015,6 +1018,7 @@ function cleanUpSccpSettings() { global $db; global $aminterface; global $sccp_compatible; + global $amp_conf; // Get current default settings from db $stmt = $db->prepare("SELECT keyword, sccpsettings.* FROM sccpsettings"); @@ -1042,9 +1046,12 @@ function cleanUpSccpSettings() { } } */ - + // TODO: It seems that DOCUMENT ROOT is not always set so maybe should switch to AMPWEBROOT. + // need to declare amp_conf global each time. + //global $amp_conf; + //dbug($amp_conf['AMPWEBROOT']); // Clean up sccpsettings to remove legacy values. - $xml_vars = $_SERVER['DOCUMENT_ROOT'] . "/admin/modules/sccp_manager/conf/sccpgeneral.xml.v{$sccp_compatible}"; + $xml_vars = $amp_conf['AMPWEBROOT'] . "/admin/modules/sccp_manager/conf/sccpgeneral.xml.v{$sccp_compatible}"; $thisInstaller->xml_data = simplexml_load_file($xml_vars); $thisInstaller->initVarfromXml(); foreach ( array_diff_key($settingsFromDb,$thisInstaller->sccpvalues) as $key => $valueArray) { diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 5e135b7..931de55 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -228,9 +228,10 @@ class Sccp extends \FreePBX\modules\Core\Driver { } public function getDeviceDisplay($display, $deviceInfo, $currentComponent, $primarySection) { + global $amp_conf; $activeCodecs = array(); // load xml data to get help from same source as rest of module - $xml_vars = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v433'; + $xml_vars = $amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/conf/sccpgeneral.xml.v433'; $this->xml_data = simplexml_load_file($xml_vars); // load metainfo from chan-sccp - help information if not in xml. Only load first time as static data. if (empty($this->sccpHelpInfo)) { diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php index 5ad23ea..d8dd747 100644 --- a/sccpManClasses/extconfigs.class.php +++ b/sccpManClasses/extconfigs.class.php @@ -237,6 +237,7 @@ class extconfigs ); public function updateTftpStructure($settingsFromDb) { + global $amp_conf; $adv_config = array('tftproot' => $settingsFromDb['tftp_path']['data'], 'firmware' => 'firmware', 'settings' => 'settings', @@ -352,7 +353,7 @@ class extconfigs } // TODO: Need to add index.cnf, after setting defaults correctly if (!file_exists("{$baseConfig['tftp_templates_path']}/XMLDefault.cnf.xml_template")) { - $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/'; + $src_path = $amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/conf/'; $dst_path = "{$baseConfig["tftp_templates_path"]}/"; foreach (glob("{$src_path}*.*_template") as $filename) { copy($filename, $dst_path . basename($filename)); diff --git a/sccpManClasses/formcreate.class.php b/sccpManClasses/formcreate.class.php index 0652bdd..cb0634a 100644 --- a/sccpManClasses/formcreate.class.php +++ b/sccpManClasses/formcreate.class.php @@ -630,6 +630,7 @@ class formcreate function addElementSLNA($child, $fvalues, $sccp_defaults,$npref, $installedLangs) { // Input element Select SLS - System Language with add from external + global $amp_conf; $res_n = (string)$child ->name; $res_id = $npref.$res_n; $child->value =''; @@ -681,7 +682,7 @@ class formcreate
    diff --git a/sccpManTraits/bmoFunctions.php b/sccpManTraits/bmoFunctions.php index a212910..633ad4f 100644 --- a/sccpManTraits/bmoFunctions.php +++ b/sccpManTraits/bmoFunctions.php @@ -138,8 +138,9 @@ trait bmoFunctions { } public function getRightNav($request) { + global $amp_conf; if (isset($request['tech_hardware']) && ($request['tech_hardware'] == 'cisco')) { - return load_view($_SERVER['DOCUMENT_ROOT'] .'/admin/modules/sccp_manager/views/hardware.rnav.php', array('request' => $request)); + return load_view($amp_conf['AMPWEBROOT'] .'/admin/modules/sccp_manager/views/hardware.rnav.php', array('request' => $request)); } } diff --git a/views/advserver.model.php b/views/advserver.model.php index f2c9751..081cebb 100644 --- a/views/advserver.model.php +++ b/views/advserver.model.php @@ -5,6 +5,7 @@ * and open the template in the editor. */ $requestType = 'firmware'; +global $amp_conf; ?>
    @@ -160,7 +161,7 @@ foreach ($firmwareDir[0] as $child) { } }; -include($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/views/getFileModal.html'); +include($amp_conf['AMPWEBROOT'] . '/admin/modules/sccp_manager/views/getFileModal.html'); ?> -
    +
    - + From 2c8842d21a286f5fee8310f58638cca09c501b91 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 4 Aug 2021 07:24:28 +0200 Subject: [PATCH 153/181] Correct initialisation res_conf is an array --- install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.php b/install.php index 253b758..33cd4c9 100644 --- a/install.php +++ b/install.php @@ -899,7 +899,7 @@ function Setup_RealTime() } // Check database settings - $res_conf = ''; + $res_conf = array(); if (file_exists($dir . '/res_mysql.conf')) { $res_conf = $cnf_read->getConfig('res_mysql.conf'); if (empty($res_conf[$def_bd_section])) { From b133b2bc3a40f22b42d6dc1eb336a47a6371de7f Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 4 Aug 2021 10:55:26 +0200 Subject: [PATCH 154/181] Change sccpdeviceconfig view create statement Should not use ALGORITHM=MERGE when using GROUP BY --- install.php | 1 - module.xml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/install.php b/install.php index 33cd4c9..379b235 100644 --- a/install.php +++ b/install.php @@ -723,7 +723,6 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) GROUP BY sccpuser.name; "; } else { $sql .= "CREATE OR REPLACE - ALGORITHM = MERGE VIEW sccpdeviceconfig AS SELECT CASE sccpdevice.profileid WHEN 0 THEN diff --git a/module.xml b/module.xml index 33f9036..d1f771d 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.1 + 14.3.0.2 setup SCCP Connectivity Steve Lad, Alex GP From f1cc0f1bf6d8ac68d8868be08314cde8f65c5384 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 4 Aug 2021 12:36:18 +0200 Subject: [PATCH 155/181] Remove IF EXISTS condition on rename Know that the column exists so this is unnecessary and fails in MariaDb 5.5 --- install.php | 6 ++++-- module.xml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/install.php b/install.php index 379b235..d0253ca 100644 --- a/install.php +++ b/install.php @@ -323,6 +323,7 @@ function Get_DB_config($sccp_compatible) $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']); $db_config_v4['sccpsettings'] = $db_config_v5['sccpsettings']; + dbug($db_config_v4['sccpdevice']); } return $db_config_v4; } @@ -448,14 +449,14 @@ function InstallDB_updateSchema($db_config) // Does a create exist for newName if (!empty($tab_modif[$fld_id_newName]['create'])) { //carry the attributes from the new create to the rename - $sql_rename .= "CHANGE COLUMN IF EXISTS {$fld_id} {$fld_id_newName} {$tab_modif[$fld_id_newName]['create']}, "; + $sql_rename .= "CHANGE COLUMN {$fld_id} {$fld_id_newName} {$tab_modif[$fld_id_newName]['create']}, "; // do not create newName as modifying existing unset($tab_modif[$fld_id_newName]['create']); } else { // add current attributes to the new name. $existingAttrs = strtoupper($tabl_data['Type']).(($tabl_data['Null'] == 'NO') ?' NOT NULL': ' NULL') . ((empty($tabl_data['Default']))?'': ' DEFAULT ' . "'" . $tabl_data['Default']."'"); - $sql_rename .= "CHANGE COLUMN IF EXISTS {$fld_id} {$fld_id_newName} {$existingAttrs}, "; + $sql_rename .= "CHANGE COLUMN {$fld_id} {$fld_id_newName} {$existingAttrs}, "; } unset($tab_modif[$fld_id]['rename']); $count_modify ++; @@ -496,6 +497,7 @@ function InstallDB_updateSchema($db_config) if (!empty($sql_rename)) { outn("
  • " . _("Renaming table columns ") . $tabl_name ."
  • "); $sql_rename = "ALTER TABLE {$tabl_name} " . substr($sql_rename, 0, -2); + dbug($sql_rename); try { $check = $db->query($sql_rename); } catch (\Exception $e) { diff --git a/module.xml b/module.xml index d1f771d..b0aeb58 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.2 + 14.3.0.4 setup SCCP Connectivity Steve Lad, Alex GP From b3fc62caa79fd30f29d9eddac3decf7a89745ae0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Wed, 4 Aug 2021 13:22:42 +0200 Subject: [PATCH 156/181] Update dbinterface.class.php --- sccpManClasses/dbinterface.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 25fd292..60b7a0b 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -71,12 +71,12 @@ class dbinterface case 'phoneGrid': switch ($data['type']) { case "cisco-sip": - $stmts = $this->db->prepare("SELECT name, type, button, addon, description, 'not connected' AS status, '- -' AS address + $stmts = $this->db->prepare("SELECT name, type, button, addon, description, 'not connected' AS status, '- -' AS address, 'N' AS new_hw FROM sccpdeviceconfig WHERE type LIKE '%-sip' ORDER BY name"); break; case "sccp": // Fall through to default intentionally default: - $stmts = $this->db->prepare("SELECT name, type, button, addon, description, 'not connected' AS status, '- -' AS address + $stmts = $this->db->prepare("SELECT name, type, button, addon, description, 'not connected' AS status, '- -' AS address, 'N' AS new_hw FROM sccpdeviceconfig WHERE type not LIKE '%-sip' ORDER BY name"); break; } From 6567923ff1b80e2868ade4ce6f6f2c07618350bf Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 6 Aug 2021 08:24:53 +0200 Subject: [PATCH 157/181] Add chan-sccp build info to Sccp Info --- install.php | 2 +- sccpManClasses/aminterface.class.php | 4 ++-- views/server.info.php | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/install.php b/install.php index d0253ca..be1ea80 100644 --- a/install.php +++ b/install.php @@ -767,7 +767,7 @@ function createViewSccplineconfig() { sccpline.secondary_dialtone_tone, sccpline.musicclass, sccpline.language, sccpline.accountcode, sccpline.echocancel, sccpline.silencesuppression, sccpline.callgroup, sccpline.pickupgroup, sccpline.adhocNumber, sccpline.meetme, sccpline.meetmenum, sccpline.meetmeopts, sccpline.regexten, sccpline.directed_pickup, sccpline.directed_pickup_context, sccpline.pickup_modeanswer, sccpline.amaflags, sccpline.dnd, sccpline.setvar, - sccpline.namedcallgroup, sccpline.namedpickupgroup, sccpline.phonecodepage + sccpline.namedcallgroup, sccpline.namedpickupgroup, sccpline.phonecodepage, sccpline.videomode FROM sccpline"; $results = $db->query($sql); if (DB::IsError($results)) { diff --git a/sccpManClasses/aminterface.class.php b/sccpManClasses/aminterface.class.php index fbe2f26..93a3627 100644 --- a/sccpManClasses/aminterface.class.php +++ b/sccpManClasses/aminterface.class.php @@ -442,7 +442,7 @@ class aminterface function getSCCPVersion() { //Initialise result array - $result = array( 'RevisionHash' => '', 'vCode' => 0, 'RevisionNum' => 0, 'futures' => '', 'Version' => 0); + $result = array( 'RevisionHash' => '', 'vCode' => 0, 'RevisionNum' => 0, 'buildInfo' => '', 'Version' => 0); $metadata = $this->getSCCPConfigMetaData(); if (isset($metadata['Version'])) { @@ -477,7 +477,7 @@ class aminterface $result['RevisionNum'] = $metadata["RevisionNum"]; } if (isset($metadata['ConfigureEnabled'])) { - $result['futures'] = implode(';', $metadata['ConfigureEnabled']); + $result['buildInfo'] = implode(';', $metadata['ConfigureEnabled']); } } return $result; diff --git a/views/server.info.php b/views/server.info.php index 7d54fae..f46b094 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -37,6 +37,7 @@ $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']}"); +$info['chan-sccp build info'] = array('Version' => $core['Version'], 'about' => "{$core['buildInfo']}"); $info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about' => 'Asterisk.'); From 14215b64caf57d923d07c1feee677ea32b0e2f80 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 6 Aug 2021 08:42:39 +0200 Subject: [PATCH 158/181] Finalise chan-sccp build info --- sccpManClasses/aminterface.class.php | 2 +- views/server.info.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sccpManClasses/aminterface.class.php b/sccpManClasses/aminterface.class.php index 93a3627..341e359 100644 --- a/sccpManClasses/aminterface.class.php +++ b/sccpManClasses/aminterface.class.php @@ -477,7 +477,7 @@ class aminterface $result['RevisionNum'] = $metadata["RevisionNum"]; } if (isset($metadata['ConfigureEnabled'])) { - $result['buildInfo'] = implode(';', $metadata['ConfigureEnabled']); + $result['buildInfo'] = $metadata['ConfigureEnabled']; } } return $result; diff --git a/views/server.info.php b/views/server.info.php index f46b094..ff626cb 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -37,8 +37,10 @@ $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']}"); -$info['chan-sccp build info'] = array('Version' => $core['Version'], 'about' => "{$core['buildInfo']}"); +$capabilityArray = array( "park", "pickup", "realtime", "video", "conference", "dirtrfr", "feature_monitor", "functions", "manager_events", + "devicestate", "devstate_feature", "dynamic_speeddial", "dynamic_speeddial_cid", "experimental", "debug"); +$info['chan-sccp build info'] = array('Version' => $core['Version'], 'about' => 'Following options NOT built: ' . implode('; ',array_diff($capabilityArray, $core['buildInfo']))); $info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about' => 'Asterisk.'); if (!empty($this->sccpvalues['SccpDBmodel'])) { From 0f352eeb592e8746e736ba5fe6ed3b8f9081c337 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 7 Aug 2021 11:03:33 +0200 Subject: [PATCH 159/181] Fix addition of new device when not in db Partial fix for issue#29 Populate available fields Optimise code --- assets/js/sccp_manager.js | 3 +- module.xml | 2 +- sccpManClasses/dbinterface.class.php | 2 +- views/form.adddevice.php | 121 +++++++++++---------------- 4 files changed, 51 insertions(+), 77 deletions(-) diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 5f3e9ed..f318418 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -7,7 +7,7 @@ $(document).ready(function () { }, }); $('#ajaxcancel').on('click', function (e) { -// console.log('Calncel'); + console.log('Cancel'); if ($(this).data('hash') != null) { location.hash = $(this).data('hash'); } @@ -24,7 +24,6 @@ $(document).ready(function () { location.reload(); } }); - // ajaxsubmit2 is "Save and continue" - saves form data and stays on form $('#ajaxsubmit2').on('click', function (e) { var vdata = ''; diff --git a/module.xml b/module.xml index b0aeb58..8e060ab 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.4 + 14.3.0.5 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index 60b7a0b..f86b43b 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -115,7 +115,7 @@ class dbinterface } break; case 'get_columns_sccpdevice': - $stmts = $this->db->prepare('DESCRIBE sccpdevice'); + $stmtU = $this->db->prepare('DESCRIBE sccpdevice'); break; case 'get_columns_sccpuser': $stmts = $this->db->prepare('DESCRIBE sccpuser'); diff --git a/views/form.adddevice.php b/views/form.adddevice.php index 6626e6c..e05a403 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -6,10 +6,10 @@ */ $def_val = array(); $dev_id = null; -$dev_new = null; $device_warning= null; // Default value from Server setings - +//Get default values. Will use these for a new device, and modify for an existing. +$def_val = $this->getTableDefaults('sccpdevice'); $def_val['netlang'] = array("keyword" => 'netlang', "data" => $this->sccpvalues['netlang']['data'], "seq" => "99"); $def_val['devlang'] = array("keyword" => 'devlang', "data" => $this->sccpvalues['devlang']['data'], "seq" => "99"); $def_val['directed_pickup_context'] = array("keyword" => 'directed_pickup_context', "data" => $this->sccpvalues['directed_pickup_context']['data'], "seq" => "99"); @@ -17,66 +17,23 @@ $def_val['directed_pickup_context'] = array("keyword" => 'directed_pickup_conte if (!empty($_REQUEST['new_id'])) { // Adding device that is connected but not in database $dev_id = $_REQUEST['new_id']; - - // Get device defaults from db - $sccpDeviceDesc = $this->dbinterface->getSccpDeviceTableData('get_columns_sccpdevice'); - - foreach ($sccpDeviceDesc as $data) { - $key = (string) $data['Field']; - $def_val[$key] = array("keyword" => $key, "data" => $data['Default'], "seq" => "99"); - } - // Overwrite some specific defaults based on $_REQUEST - $val = str_replace(array('SEP','ATA','VG'), '', $dev_id); - $val = implode(':', sscanf($val, '%2s%2s%2s%2s%2s%2s')); // Convert to Cisco display Format - $def_val['mac'] = array("keyword" => 'mac', "data" => $val, "seq" => "99"); - $val = $_REQUEST['type']; - $def_val['type'] = array("keyword" => 'type', "data" => $val, "seq" => "99"); + $def_val['type'] = array("keyword" => 'type', "data" => $_REQUEST['type'], "seq" => "99"); if (!empty($_REQUEST['addon'])) { $def_val['addon'] = array("keyword" => 'type', "data" => $_REQUEST['addon'], "seq" => "99"); } } -//Get default values. Will use these for a new device, and modify for an existing. -$def_val = $this->getTableDefaults('sccpdevice'); if (!empty($_REQUEST['id'])) { // Editing an existing Device. Overwrite any defaults that are already set for this device. $dev_id = $_REQUEST['id']; - $dev_new = $dev_id; $db_res = $this->dbinterface->getSccpDeviceTableData('get_sccpdevice_byid', array("id" => $dev_id)); foreach ($db_res as $key => $val) { if (!empty($val)) { switch ($key) { - case 'type': - $tmp_raw = $this->getSccpModelInformation('byid', true, 'all', array('model'=>$val)); - if (!empty($tmp_raw[0])) { - $tmp_raw = $tmp_raw[0]; - } - if (!empty($tmp_raw['validate'])) { - $tmpar = explode(";", $tmp_raw['validate']); - if ($tmpar[0] != 'yes') { - $device_warning['Image'] = array('Device firmware not found : '.$tmp_raw['loadimage']); - } - if ($tmpar[1] != 'yes') { - $device_warning['Template'] = array('Missing device configuration template : '. $tmp_raw['nametemplate']); - } - } - $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); - break; - case 'name': - $key = 'mac'; //This is the key that formShow expects - $val = str_replace(array('SEP','ATA','VG'), '', $val); - $val = implode(':', sscanf($val, '%2s%2s%2s%2s%2s%2s')); // Convert to Cisco display Format - $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); - break; -// case 'permit': -// case 'deny': -// $def_val[$key . '_net'] = array("keyword" => $key, "data" => before('/', $val), "seq" => "99"); -// $key = $key . '_mask'; -// $val = after('/', $val); -// break; case 'phonepersonalization': - $def_val['phonepersonalization'] = array("keyword" => 'phonepersonalization', "data" => $val, "seq" => "99"); + $def_val['phonepersonalization'] = array("keyword" => 'phonepersonalization', "data" => $val, "seq" => "99"); + break; default: // Overwrite existing defaults after checking that data is still valid after schema updates // Do not strip underscores as these fields are new in the schema and so should be valid. @@ -86,7 +43,7 @@ if (!empty($_REQUEST['id'])) { // Quote value as enum values are quoted. if (in_array("'{$val}'", $enumFields[$key])) { // The value is valid so will keep - $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); + $def_val[$key] = array('keyword' => $key, 'data' => $val, 'seq' => 99); } // Do not store value and let defaults apply continue; @@ -100,40 +57,58 @@ if (!empty($_REQUEST['id'])) { } } -if (!empty($device_warning)) { - ?> -
    -
    -
    -

    Warning in the SCCP Device

    -
    - $value) { - echo '

    '.$key.'

    '; - if (is_array($value)) { - echo '
  • '._(implode('
  • ', $value)).'
  • '; - } else { - echo '
  • '. _($value).'
  • '; - } - } - ?> - +if (!empty($def_val['type'])) { + $tmp_raw = $this->getSccpModelInformation('byid', true, 'all', array('model'=>$def_val['type'])); + if (!empty($tmp_raw[0])) { + $tmp_raw = $tmp_raw[0]; + } + if (!empty($tmp_raw['validate'])) { + $tmpar = explode(";", $tmp_raw['validate']); + if ($tmpar[0] != 'yes') { + $device_warning['Image'] = array('Device firmware not found : '.$tmp_raw['loadimage']); + } + if ($tmpar[1] != 'yes') { + $device_warning['Template'] = array('Missing device configuration template : '. $tmp_raw['nametemplate']); + } + if (!empty($device_warning)) { + ?> +
    +
    +
    +

    Warning in the SCCP Device

    +
    +
    +                                 $value) {
    +                                    echo '

    '.$key.'

    '; + if (is_array($value)) { + echo '
  • '._(implode('
  • ', $value)).'
  • '; + } else { + echo '
  • '. _($value).'
  • '; + } + } + ?> +
    +
    +
    -
    -
    -
    - - +
    + '; } else { + $val = str_replace(array('SEP','ATA','VG'), '', $dev_id); + $val = implode(':', sscanf($val, '%2s%2s%2s%2s%2s%2s')); // Convert to Cisco display Format + $def_val['mac'] = array("keyword" => 'mac', "data" => $val, "seq" => "99"); echo ''; } if (empty($dev_id)) { From 31e8a48e12379580961323a4de171d98f05ae54e Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 7 Aug 2021 16:01:19 +0200 Subject: [PATCH 160/181] Add videomode select - dropped in earlier commit --- sccpManClasses/Sccp.class.php.v433 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 931de55..4cf7d9f 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -455,6 +455,13 @@ class Sccp extends \FreePBX\modules\Core\Driver { } } + $select[] = array('value' => 'off', 'text' => 'Off'); + $select[] = array('value' => 'user', 'text' => 'User'); + $select[] = array('value' => 'auto', 'text' => 'Auto'); + $tt = _("Automatic or Manual video mode. Valid values are 'auto', 'user' or 'off'. When set to 'auto', video will automatically start if both parties have a compatible code enabled. In 'user' mode the user needs to press the vidmode softkey before video will be tried. Default:'auto'"); + $tmparr['videomode'] = array('prompttext' => _('Video Mode '), 'value' => 'auto', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section_с, 'category' => $gn_category); + unset($select); + return $tmparr; } From b30340eab580ea00c4b06666eee51e7afb180b34 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 7 Aug 2021 16:07:18 +0200 Subject: [PATCH 161/181] Update ajaxHelper.php --- sccpManTraits/ajaxHelper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 6b55527..eee0b42 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -315,7 +315,7 @@ trait ajaxHelper { $dbDevices = array(); // Find all devices defined in the database. $dbDevices = $this->dbinterface->getSccpDeviceTableData('phoneGrid', array('type' => $request['type'])); - + // Return if only interested in SIP devices if ($request['type'] == 'cisco-sip') { return $dbDevices; //this may be empty @@ -338,7 +338,7 @@ trait ajaxHelper { if (!empty($activeDevices)) { // Have a device that is connected but is not currently in the database - // This device must have been configured by sccp.conf + // This device must have connected via hotline or config in sccp.conf. // Pass parameters to addDevice so that can be added to db. foreach ($activeDevices as $dev_ids) { $id_name = $dev_ids['name']; @@ -699,7 +699,7 @@ trait ajaxHelper { $save_settings = array(); $save_codec = array(); $name_dev = ''; - $db_field = $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_type = (empty($get_settings['sccp_device_typeid'])) ? 'sccpdevice' : $get_settings['sccp_device_typeid']; $update_hw = ($hw_id == 'new') ? 'add' : 'clear'; // Clear is delete + add From 8dc1175b371536289c5ea89eb8a448afb8f392d2 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 8 Aug 2021 09:03:05 +0200 Subject: [PATCH 162/181] Update installer to add parent extensions to sccpline if they exist Previously ignored sccp extensions in freepbx devices and so created 'orphans'. Now create rows for sccpline for devices that already exist as sccp extensions in devices. Remove dbug code --- Sccp_manager.class.php | 2 -- install.php | 57 ++++++++++++++++++++---------- module.xml | 2 +- sccpManClasses/Sccp.class.php.v433 | 1 - sccpManTraits/ajaxHelper.php | 2 -- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 3a2fd47..686b332 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -383,7 +383,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { function getPhoneButtons($get_settings, $ref_id = '', $ref_type = 'sccpdevice') { // get Model Buttons info - dbug($get_settings); $res = array(); $def_feature = array('parkinglot' => array('name' => 'P.slot', 'value' => 'default'), 'devstate' => array('name' => 'Coffee', 'value' => 'coffee'), @@ -494,7 +493,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } - dbug($res); return $res; } diff --git a/install.php b/install.php index be1ea80..16d5f1a 100644 --- a/install.php +++ b/install.php @@ -63,8 +63,8 @@ InstallDB_updateSchema($db_config); cleanUpSccpSettings(); InstallDB_createButtonConfigTrigger(); -InstallDB_CreateSccpDeviceConfigView($sccp_compatible); -createViewSccplineconfig(); +InstallDbCreateViews($sccp_compatible); +installDbPopulateSccpline(); InstallDB_updateDBVer($sccp_compatible); if ($chanSCCPWarning) { outn("
    "); @@ -323,7 +323,6 @@ function Get_DB_config($sccp_compatible) $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']); $db_config_v4['sccpsettings'] = $db_config_v5['sccpsettings']; - dbug($db_config_v4['sccpdevice']); } return $db_config_v4; } @@ -497,7 +496,6 @@ function InstallDB_updateSchema($db_config) if (!empty($sql_rename)) { outn("
  • " . _("Renaming table columns ") . $tabl_name ."
  • "); $sql_rename = "ALTER TABLE {$tabl_name} " . substr($sql_rename, 0, -2); - dbug($sql_rename); try { $check = $db->query($sql_rename); } catch (\Exception $e) { @@ -697,7 +695,7 @@ function InstallDB_updateDBVer($sccp_compatible) return true; } -function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) +function InstallDbCreateViews($sccp_compatible) { global $db; outn("
  • " . _("(Re)Create sccpdeviceconfig view") . "
  • "); @@ -746,16 +744,12 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_compatible) LEFT JOIN sccpuser sccpuser ON ( sccpuser.name = sccpdevice.loginname ) GROUP BY sccpdevice.name;"; } - - $results = $db->query($sql); - if (DB::IsError($results)) { + $stmt = $db->prepare($sql); + $stmt->execute(); + if (DB::IsError($stmt)) { die_freepbx(sprintf(_("Error updating sccpdeviceconfig view. Command was: %s; error was: %s "), $sql, $results->getMessage())); } - return true; -} -function createViewSccplineconfig() { - global $db; outn("
  • " . _("(Re)Create sccplineconfig view") . "
  • "); $sql = "DROP VIEW IF EXISTS sccplineconfig; @@ -769,13 +763,44 @@ function createViewSccplineconfig() { sccpline.directed_pickup, sccpline.directed_pickup_context, sccpline.pickup_modeanswer, sccpline.amaflags, sccpline.dnd, sccpline.setvar, sccpline.namedcallgroup, sccpline.namedpickupgroup, sccpline.phonecodepage, sccpline.videomode FROM sccpline"; - $results = $db->query($sql); - if (DB::IsError($results)) { + $stmt = $db->prepare($sql); + $stmt->execute(); + if (DB::IsError($stmt)) { die_freepbx(sprintf(_("Error updating sccplineconfig view. Command was: %s; error was: %s "), $sql, $results->getMessage())); } return true; } +function installDbPopulateSccpline() { + // Lines in Sccp_manager are devices in FreePbx. Need to ensure that these two tables are synchronised on install + global $db; + $freePbxExts = array (); + $sccpExts =array(); + $sql = "SELECT id AS name, user AS accountcode, description AS label FROM devices WHERE tech='sccp'"; + $stmt = $db->prepare($sql); + $stmt->execute(); + $freePbxExts = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); + + $sql = "SELECT name, accountcode, label FROM sccpline"; + $stmt = $db->prepare($sql); + $stmt->execute(); + $sccpExts = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); + $linesToCreate = array_diff_assoc($freePbxExts, $sccpExts); + + foreach ($linesToCreate as $key => $valArr) { + $stmt = $db->prepare("INSERT into sccpline (name, accountcode, description, label) VALUES (:name, :accountcode, :description, :label)"); + $stmt->bindParam(':name',$key,\PDO::PARAM_STR); + $description = "{$valArr['label']} <{$key}>"; + $stmt->bindParam(':accountcode',$valArr['accountcode'],\PDO::PARAM_STR); + $stmt->bindParam(':description',$description,\PDO::PARAM_STR); + $stmt->bindParam(':label',$valArr['label'],\PDO::PARAM_STR); + $stmt->execute(); + if (DB::IsError($stmt)) { + die_freepbx(sprintf(_("Error inserting into sccpline. Command was: %s; error was: %s "), $stmt, $stmt->getMessage())); + } + } +} + function createBackUpConfig() { global $amp_conf; @@ -1047,10 +1072,6 @@ function cleanUpSccpSettings() { } } */ - // TODO: It seems that DOCUMENT ROOT is not always set so maybe should switch to AMPWEBROOT. - // need to declare amp_conf global each time. - //global $amp_conf; - //dbug($amp_conf['AMPWEBROOT']); // Clean up sccpsettings to remove legacy values. $xml_vars = $amp_conf['AMPWEBROOT'] . "/admin/modules/sccp_manager/conf/sccpgeneral.xml.v{$sccp_compatible}"; $thisInstaller->xml_data = simplexml_load_file($xml_vars); diff --git a/module.xml b/module.xml index 8e060ab..bdd0e5a 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.5 + 14.3.0.6 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 4cf7d9f..f5d2517 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -111,7 +111,6 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function addDevice($id, $settings) { // This is actually save line and is used by add and edit. - dbug($settings); $add_fld = array ("name"=>'label',"outboundcid"=>'cid_num',"langcode"=>'language',"extdisplay"=>'description','devinfo_mailbox'=>'mailbox'); $settings['cid_num']['value'] = ''; $settings['cid_name']['value'] = ''; diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index eee0b42..4c37482 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -400,7 +400,6 @@ trait ajaxHelper { } function handleSubmit($request, $validateonly = false) { - dbug($request); $hdr_prefix = 'sccp_'; $hdr_arprefix = 'sccp-ar_'; $save_settings = array(); @@ -690,7 +689,6 @@ trait ajaxHelper { } function saveSccpDevice($get_settings, $validateonly = false) { - dbug($get_settings); $hdr_prefix = 'sccp_hw_'; $hdr_arprefix = 'sccp_hw-ar_'; $hdr_vendPrefix = 'sccp_hw_vendorconfig'; From 481c8929a90e920e3e0316b907bcc9b5900fe31b Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 8 Aug 2021 09:56:04 +0200 Subject: [PATCH 163/181] Correct handling of device vendor settings Prefix was incorrect following removal of _column names --- sccpManTraits/ajaxHelper.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 4c37482..e1d1bb6 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -691,7 +691,7 @@ trait ajaxHelper { function saveSccpDevice($get_settings, $validateonly = false) { $hdr_prefix = 'sccp_hw_'; $hdr_arprefix = 'sccp_hw-ar_'; - $hdr_vendPrefix = 'sccp_hw_vendorconfig'; + $hdr_vendPrefix = 'vendorconfig_'; $save_buttons = array(); $save_settings = array(); @@ -711,8 +711,9 @@ trait ajaxHelper { $hw_prefix = 'VG'; } } - foreach ($db_field as $data) { - $key = (string) $data['Field']; + dbug($get_settings); + dbug($db_field); + foreach ($db_field as $key) { $value = ""; switch ($key) { case 'name': @@ -792,15 +793,13 @@ trait ajaxHelper { // Now only have normal prefix if (!empty($get_settings["{$hdr_prefix}{$key}"])) { $value = $get_settings["{$hdr_prefix}{$key}"]; - } else if (!empty($get_settings["sccp_hw{$key}"])) { - //have an underscore db field - $value = $get_settings["sccp_hw{$key}"]; } } if (!empty($value)) { $save_settings[$key] = $value; } } + dbug($save_settings); // Save this device. $this->dbinterface->write('sccpdevice', $save_settings, 'replace'); // Retrieve the phone buttons from $_REQUEST ($get_settings) and write back to From 0b03d58c096bbea6eb7f1528c413000c6ab5fd75 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 8 Aug 2021 09:57:36 +0200 Subject: [PATCH 164/181] Remove debug code and update version --- module.xml | 2 +- sccpManTraits/ajaxHelper.php | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/module.xml b/module.xml index bdd0e5a..7376219 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.6 + 14.3.0.7 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index e1d1bb6..042515b 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -711,8 +711,6 @@ trait ajaxHelper { $hw_prefix = 'VG'; } } - dbug($get_settings); - dbug($db_field); foreach ($db_field as $key) { $value = ""; switch ($key) { @@ -799,7 +797,6 @@ trait ajaxHelper { $save_settings[$key] = $value; } } - dbug($save_settings); // Save this device. $this->dbinterface->write('sccpdevice', $save_settings, 'replace'); // Retrieve the phone buttons from $_REQUEST ($get_settings) and write back to From a40c110efeab144fdf51ba2471d2b9f909fc3829 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 8 Aug 2021 14:30:48 +0200 Subject: [PATCH 165/181] Update Defaults and correct site defaults to comply with new enum values Legacy values for site defaults in sccpsettings are now converted to be compliant with current enums, or reset to system defaults (cleared) --- Sccp_manager.class.php | 2 -- conf/sccpgeneral.xml.v433 | 16 +++++----- install.php | 64 +++++++++++++++++++++++++++++++-------- module.xml | 2 +- 4 files changed, 60 insertions(+), 24 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 686b332..fa54d43 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -569,8 +569,6 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { $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 getCodecs($type, $showDefaults = false) { diff --git a/conf/sccpgeneral.xml.v433 b/conf/sccpgeneral.xml.v433 index 8685df0..1350a3c 100644 --- a/conf/sccpgeneral.xml.v433 +++ b/conf/sccpgeneral.xml.v433 @@ -1148,18 +1148,18 @@ and open the template in the editor. Base Version before all crash :-) echocancel - off + yes - Echo Cancel: Echo Cancellation (On or Off). + Echo Cancel: Echo Cancellation (Yes or No). silencesuppression - off + no - Silence Suppression: Slience Suppression on the phone. + Silence Suppression: Silence Suppression on the phone. @@ -2060,15 +2060,15 @@ and open the template in the editor. Base Version before all crash :-) echocancel - off + yes - Echo Cancel: Echo Cancellation (On or Off). + Echo Cancel: Echo Cancellation (Yes or No). dnd - Reject + reject @@ -2081,7 +2081,7 @@ and open the template in the editor. Base Version before all crash :-) silencesuppression - off + no Silence Suppression: Silence Suppression on the phone. diff --git a/install.php b/install.php index 16d5f1a..b7f7a11 100644 --- a/install.php +++ b/install.php @@ -113,14 +113,14 @@ function Get_DB_config($sccp_compatible) 'permit' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL', 'modify' => "VARCHAR(100)"), 'backgroundImage' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), 'ringtone' => array('create' => 'VARCHAR(255) NULL DEFAULT NULL', 'modify' => "VARCHAR(255)"), - 'transfer' => array('create' => "enum('yes','no') NOT NULL default 'no'", 'modify' => "enum('yes','no')"), + 'transfer' => array('create' => "enum('no','yes') NOT NULL default 'no'", 'modify' => "enum('no','yes')"), 'cfwdall' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"), 'cfwdbusy' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"), 'cfwdnoanswer' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"), 'park' => array('create' => "enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), 'directrtp' => array('create' => "enum('no','yes') NOT NULL default 'no'", 'modify' => "enum('no','yes')"), - 'dndFeature' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), - 'earlyrtp' => array('create' => "ENUM('yes','no') NOT NULL default 'no'", 'modify' => "ENUM('yes','no')"), + 'dndFeature' => array('create' => "enum('off','on') NOT NULL default 'off'", 'modify' => "enum('off','on')"), + 'earlyrtp' => array('create' => "ENUM('yes','no') NOT NULL default 'yes'", 'modify' => "ENUM('yes','no')"), 'monitor' => array('create' => "enum('on','off') NOT NULL default 'off'", 'modify' => "enum('on','off')"), 'audio_tos' => array('create' => "VARCHAR(11) NOT NULL default '0xB8'",'modify' => "0xB8"), 'audio_cos' => array('create' => "VARCHAR(11) NOT NULL default '0x6'",'modify' => "0x6"), @@ -160,7 +160,7 @@ function Get_DB_config($sccp_compatible) 'audio_cos' => array('drop' => "yes"), 'video_tos' => array('drop' => "yes"), 'video_cos' => array('drop' => "yes"), - 'videomode' => array('create' => "enum('user','auto','off') NOT NULL default 'auto'", 'modify' => "enum('user','auto','off')"), + 'videomode' => array('create' => "enum('auto','user','off') NOT NULL default 'auto'", 'modify' => "enum('auto','user','off')"), 'incominglimit' => array('create' => "INT(11) DEFAULT '6'", 'modify' => 'INT(11)', 'def_modify' => "6"), 'transfer' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"), 'vmnum' => array('def_modify' => "*97"), @@ -169,15 +169,15 @@ function Get_DB_config($sccp_compatible) 'allow' => array('create' => "VARCHAR(255) NULL DEFAULT NULL"), 'id' => array('create' => 'MEDIUMINT(9) NOT NULL AUTO_INCREMENT, ADD UNIQUE(id);', 'modify' => "MEDIUMINT(9)", 'index' => 'id'), 'echocancel' => array('create' => "enum('yes','no') NOT NULL default 'yes'", 'modify' => "enum('yes','no')"), - 'silencesuppression' => array('create' => "enum('yes','no') NOT NULL default 'no'", 'modify' => "enum('yes','no')"), - 'dnd' => array('create' => "enum('off','reject','silent','user') NOT NULL default 'reject'", 'modify' => "enum('off','reject','silent','user')", 'def_modify' => "reject") + 'silencesuppression' => array('create' => "enum('no','yes') NOT NULL default 'no'", 'modify' => "enum('no','yes')"), + 'dnd' => array('create' => "enum('reject','off','silent','user') NOT NULL default 'reject'", 'modify' => "enum('reject','off','silent','user')", 'def_modify' => "reject") ), 'sccpuser' => array( 'name' => array('create' => "VARCHAR(20) NOT NULL", 'modify' => "VARCHAR(20)" ), 'pin' => array('create' => "VARCHAR(7) NOT NULL", 'modify' => "VARCHAR(7)" ), 'password' => array('create' => "VARCHAR(7) NOT NULL", 'modify' => "VARCHAR(7)" ), 'description' => array('create' => "VARCHAR(45) NOT NULL", 'modify' => "VARCHAR(45)" ), - 'roaminglogin' => array('create' => "ENUM('on','off','multi') NOT NULL DEFAULT 'off'", 'modify' => "ENUM('on','off','multi')" ), + 'roaminglogin' => array('create' => "ENUM('off','on','multi') NOT NULL DEFAULT 'off'", 'modify' => "ENUM('on','off','multi')" ), 'auto_logout' => array('create' => "ENUM('on','off') NOT NULL DEFAULT 'off'", 'modify' => "ENUM('on','off')" ), 'homedevice' => array('create' => "VARCHAR(20) NOT NULL", 'modify' => "VARCHAR(20)" ), 'devicegroup' => array('create' => "VARCHAR(7) NOT NULL", 'modify' => "VARCHAR(7)" ), @@ -326,10 +326,6 @@ function Get_DB_config($sccp_compatible) } return $db_config_v4; } - - // New values to add (these are currently unused) - - } function CheckSCCPManagerDBVersion() @@ -416,7 +412,7 @@ function InstallDB_updateSchema($db_config) } else { if (!empty($tab_modif[$fld_id]['def_modify'])) { // if a default has been modified, use it here and unset - $sql_modify .= "MODIFY COLUMN {$fld_id} {$tab_modif[$fld_id]['modify']} DEFAULT {$tab_modif[$fld_id]['def_modify']}, "; + $sql_modify .= "MODIFY COLUMN {$fld_id} {$tab_modif[$fld_id]['modify']} DEFAULT '{$tab_modif[$fld_id]['def_modify']}', "; // def_modify has been used so unset unset($tab_modif[$fld_id]['def_modify']); } else if (!empty($tab_modif[$fld_id]['create'])) { @@ -436,7 +432,7 @@ function InstallDB_updateSchema($db_config) // Defaults have not changed so unset unset($tab_modif[$fld_id]['def_modify']); } else { - $sql_modify .= "ALTER COLUMN {$row_fld} SET DEFAULT '{$tab_modif[$fld_id]['def_modify']}', "; + $sql_modify .= "ALTER COLUMN {$fld_id} SET DEFAULT '{$tab_modif[$fld_id]['def_modify']}', "; $count_modify ++; } } @@ -1136,6 +1132,48 @@ function cleanUpSccpSettings() { unset($sysConfiguration[$key]); } unset($sysConfiguration['Options']); + + // Update enums in sccpsettings - values have changed over versions so need to update values in db that are not compliant + outn("
  • " . _("Updating invalid enums in sccpsettings") . "
  • "); + $rowsToTest = array(); + $tablesToDescribe = array('sccpline', 'sccpdevice'); + foreach ($tablesToDescribe as $theTable) { + $stmt = $db->prepare("DESCRIBE {$theTable}"); + $stmt->execute(); + $tableDesc = $stmt->fetchAll(\PDO::FETCH_ASSOC|\PDO::FETCH_UNIQUE); + foreach ($tableDesc as $key => $valArr) { + if (strpos($valArr['Type'], 'enum') !== 0) { + continue; + } + $rowsToTest[$key] = explode(',',rtrim(str_replace('enum(', '',$valArr['Type']), ')')); + } + } + $count = 0; + foreach ($rowsToTest as $key => $valArr) { + if (empty($settingsFromDb[$key]['data'])) { + continue; + } + if (in_array("'{$settingsFromDb[$key]['data']}'", $valArr, true)) { + continue; + } + // clear site setting so that will return to system defaults. + // Try to convert based on change from on/off to yes/no. + if (in_array($settingsFromDb[$key]['data'], array('on','off'), true)) { + if (in_array("'yes'", $valArr, true)) { + $settingsFromDb[$key]['data'] = ($settingsFromDb[$key]['data'] = 'on') ? 'yes' : 'no'; + continue; + } + } + // Test for case + if (in_array("'" . strtolower($settingsFromDb[$key]['data']) . "'", $valArr, true)) { + $settingsFromDb[$key]['data'] = strtolower($settingsFromDb[$key]['data']); + continue; + } + // No easy choices so reset to system default + $settingsFromDb[$key]['data'] = ''; + $count++; + } + // Write settings back to db $sql = "TRUNCATE sccpsettings"; $results = $db->query($sql); diff --git a/module.xml b/module.xml index 7376219..1184b9a 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.7 + 14.3.0.8 setup SCCP Connectivity Steve Lad, Alex GP From 662e2a4aa3365bc572d9ada7d58c8f6a458770d1 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 9 Aug 2021 06:56:38 +0200 Subject: [PATCH 166/181] Update file extensions list to include .SBN and .LOADS Some firmware has upper case extensions --- Sccp_manager.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index fa54d43..5faa249 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1066,7 +1066,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } function getSccpModelInformation($get = "all", $validate = false, $format_list = "all", $filter = array()) { - $file_ext = array('.loads', '.sbn', '.bin', '.zup', '.sbin'); + $file_ext = array('.loads', '.sbn', '.bin', '.zup', '.sbin', '.SBN', '.LOADS'); $dir = $this->sccppath['tftp_firmware_path']; $search_mode = $this->sccpvalues['tftp_rewrite']['data']; From 91d6ad2f48bf331b61e5f69bc1e5dedb6b6a32a0 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 9 Aug 2021 09:23:00 +0200 Subject: [PATCH 167/181] Fix incompatibility with new Describe table --- sccpManClasses/dbinterface.class.php | 2 +- sccpManTraits/helperFunctions.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sccpManClasses/dbinterface.class.php b/sccpManClasses/dbinterface.class.php index f86b43b..4e3f45d 100644 --- a/sccpManClasses/dbinterface.class.php +++ b/sccpManClasses/dbinterface.class.php @@ -121,7 +121,7 @@ class dbinterface $stmts = $this->db->prepare('DESCRIBE sccpuser'); break; case 'get_columns_sccpline': - $stmts = $this->db->prepare('DESCRIBE sccpline'); + $stmtU = $this->db->prepare('DESCRIBE sccpline'); break; case 'get_sccpdevice_byid': $stmt = $this->db->prepare('SELECT t1.*, types.dns, types.buttons, types.loadimage, types.nametemplate as nametemplate, diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index f5cd640..97205d1 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -77,8 +77,7 @@ trait helperfunctions { return $this->sccpvalues; } $sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}"); - foreach ($sccpTableDesc as $data) { - $key = (string) $data['Field']; + foreach ($sccpTableDesc as $key => $data) { // function has 2 roles: return actual table keys (trim_underscore = false) // return sanitised keys to add defaults (trim_underscore = true) if ($trim_underscore) { From 031ef0087e9d17e2394d2158f1d8605225248823 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Mon, 9 Aug 2021 13:56:18 +0200 Subject: [PATCH 168/181] Compatibility update --- sccpManTraits/helperFunctions.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 97205d1..672ec3b 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -93,9 +93,7 @@ trait helperfunctions { private function getTableEnums($table, $trim_underscore = true) { $enumFields = array(); $sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}"); - - foreach ($sccpTableDesc as $data) { - $key = (string) $data['Field']; + foreach ($sccpTableDesc as $key = $data) { // function has 2 roles: return actual table keys (trim_underscore = false) // return sanitised keys to add defaults (trim_underscore = true) if ($trim_underscore) { From 90729f74aace8b0a9c92c6407215cdbb4a97b797 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 10 Aug 2021 07:08:10 +0200 Subject: [PATCH 169/181] Update for compatibility with PHP 7.4 PHP 7.4 gives warnings that are handled as exceptions --- sccpManClasses/Sccp.class.php.v433 | 1 + views/form.adddevice.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index f5d2517..cecbe41 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -217,6 +217,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function getDefaultDeviceSettings($id, $displayname, &$flag) { // FreePBX required method + $settings = array(); $settingsFields = array('mailbox', 'incominglimit', 'context', 'directed_pickup_context', 'callgroup', 'pickupgroup', 'namedcallgroup', 'namedpickupgroup', 'adhocNumber', 'secondary_dialtone_digits', 'secondary_dialtone_tone', 'directed_pickup', 'pickup_modeanswer', 'transfer', 'echocancel', 'dnd', 'silencesuppression', 'musicclass', 'pin', 'allow', 'disallow'); diff --git a/views/form.adddevice.php b/views/form.adddevice.php index e05a403..a1d46c9 100644 --- a/views/form.adddevice.php +++ b/views/form.adddevice.php @@ -46,7 +46,7 @@ if (!empty($_REQUEST['id'])) { $def_val[$key] = array('keyword' => $key, 'data' => $val, 'seq' => 99); } // Do not store value and let defaults apply - continue; + break; } $def_val[$key] = array("keyword" => $key, "data" => $val, "seq" => "99"); // Need to assign defaultLine as not set in the db. From b7d585164377af221132be88b3dbb97cee66819d Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 10 Aug 2021 08:06:36 +0200 Subject: [PATCH 170/181] Update helperFunctions.php --- sccpManTraits/helperFunctions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sccpManTraits/helperFunctions.php b/sccpManTraits/helperFunctions.php index 672ec3b..e6fa71b 100644 --- a/sccpManTraits/helperFunctions.php +++ b/sccpManTraits/helperFunctions.php @@ -93,7 +93,7 @@ trait helperfunctions { private function getTableEnums($table, $trim_underscore = true) { $enumFields = array(); $sccpTableDesc = $this->dbinterface->getSccpDeviceTableData("get_columns_{$table}"); - foreach ($sccpTableDesc as $key = $data) { + foreach ($sccpTableDesc as $key => $data) { // function has 2 roles: return actual table keys (trim_underscore = false) // return sanitised keys to add defaults (trim_underscore = true) if ($trim_underscore) { From fbb61be0f1a964730afa5330ab997288fa12412b Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 10 Aug 2021 08:10:30 +0200 Subject: [PATCH 171/181] Update Sccp.class.php.v433 --- sccpManClasses/Sccp.class.php.v433 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index cecbe41..a850afc 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -217,12 +217,11 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function getDefaultDeviceSettings($id, $displayname, &$flag) { // FreePBX required method - $settings = array(); $settingsFields = array('mailbox', 'incominglimit', 'context', 'directed_pickup_context', 'callgroup', 'pickupgroup', 'namedcallgroup', 'namedpickupgroup', 'adhocNumber', 'secondary_dialtone_digits', 'secondary_dialtone_tone', 'directed_pickup', 'pickup_modeanswer', 'transfer', 'echocancel', 'dnd', 'silencesuppression', 'musicclass', 'pin', 'allow', 'disallow'); foreach ($settingsFields as $key) { - $settings[$key] = array('value' => $this->line_defaults['$key'], 'flag' => $flag++); + $settings[$key] = array('value' => $this->line_defaults[$key], 'flag' => $flag++); } return array('dial' => 'SCCP', 'settings' => $settings); } From 3a1a89fdb85385df8879642f97427244425de0ff Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 10 Aug 2021 08:11:08 +0200 Subject: [PATCH 172/181] Update Sccp.class.php.v433 --- sccpManClasses/Sccp.class.php.v433 | 1 + 1 file changed, 1 insertion(+) diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index a850afc..0131878 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -217,6 +217,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function getDefaultDeviceSettings($id, $displayname, &$flag) { // FreePBX required method + $settings = array(); $settingsFields = array('mailbox', 'incominglimit', 'context', 'directed_pickup_context', 'callgroup', 'pickupgroup', 'namedcallgroup', 'namedpickupgroup', 'adhocNumber', 'secondary_dialtone_digits', 'secondary_dialtone_tone', 'directed_pickup', 'pickup_modeanswer', 'transfer', 'echocancel', 'dnd', 'silencesuppression', 'musicclass', 'pin', 'allow', 'disallow'); From c209932eb56d86739f584add11af9158bf44114d Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 10 Aug 2021 09:48:53 +0200 Subject: [PATCH 173/181] Get all chan-sccp settings Prior only included general section - now get from all sections Get all settings fields even if empty or SccpClass will raise an exception --- install.php | 35 ++++++++++++++++++------------ module.xml | 2 +- sccpManClasses/Sccp.class.php.v433 | 3 ++- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/install.php b/install.php index b7f7a11..15e0cc0 100644 --- a/install.php +++ b/install.php @@ -1085,12 +1085,20 @@ function cleanUpSccpSettings() { // get chan-sccp defaults - $sysConfiguration = $aminterface->getSCCPConfigMetaData('general'); - - foreach ($sysConfiguration['Options'] as $key => $valueArray) { - if ($valueArray['Flags'][0] == 'Obsolete' || $valueArray['Flags'][0] == 'Deprecated') { - continue; + foreach (array('general','line', 'device') as $section) { + $sysConfig = $aminterface->getSCCPConfigMetaData($section); + foreach ($sysConfig['Options'] as $valueArray) { + if ($valueArray['Flags'][0] == 'Obsolete' || $valueArray['Flags'][0] == 'Deprecated') { + continue; + } + if (isset($sysConfiguration[$valueArray['Name']])) { + continue; + } + $sysConfiguration[$valueArray['Name']] = $valueArray; } + } + unset($sysConfig); + foreach ($sysConfiguration as $key => $valueArray) { // 2 special cases deny|permit & disallow|allow where need to parse on |. $newKeyword = explode("|", $valueArray['Name'], 2); @@ -1110,19 +1118,18 @@ function cleanUpSccpSettings() { } $i++; } - if (array_key_exists($valueArray['Name'],$settingsFromDb)){ - unset($settingsFromDb[$valueArray['Name']]); + if (array_key_exists($key, $settingsFromDb)){ + unset($settingsFromDb[$key]); } } else { - ($sysConfiguration[$valueArray['Name']]['DefaultValue'] == '(null)') ? '' : $sysConfiguration[$valueArray['Name']]['DefaultValue']; - $sysConfiguration[$valueArray['Name']] = $valueArray; - if (array_key_exists($valueArray['Name'],$settingsFromDb)) { - if (!empty($sysConfiguration[$valueArray['Name']]['DefaultValue'])) { + ($sysConfiguration[$key]['DefaultValue'] == '(null)') ? '' : $sysConfiguration[$key]['DefaultValue']; + if (array_key_exists($key,$settingsFromDb)) { + if (!empty($sysConfiguration[$key2]['DefaultValue'])) { // Preserve sequence and type - $settingsFromDb[$valueArray['Name']]['systemdefault'] = $sysConfiguration[$valueArray['Name']]['DefaultValue']; + $settingsFromDb[$key]['systemdefault'] = $sysConfiguration[$key]['DefaultValue']; } } else { - $settingsFromDb[$valueArray['Name']] = array('keyword' => $valueArray['Name'], 'seq' => 0, 'type' => 0, 'data' => '', 'systemdefault' => $sysConfiguration[$valueArray['Name']]['DefaultValue']); + $settingsFromDb[$key] = array('keyword' => $key, 'seq' => 0, 'type' => 0, 'data' => '', 'systemdefault' => $sysConfiguration[$key]['DefaultValue']); } } // Override certain chan-sccp defaults as they are based on a non-FreePbx system @@ -1131,7 +1138,7 @@ function cleanUpSccpSettings() { unset($sysConfiguration[$key]); } - unset($sysConfiguration['Options']); + unset($sysConfiguration); // Update enums in sccpsettings - values have changed over versions so need to update values in db that are not compliant outn("
  • " . _("Updating invalid enums in sccpsettings") . "
  • "); diff --git a/module.xml b/module.xml index 1184b9a..fa67a9b 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.8 + 14.3.0.9 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManClasses/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433 index 0131878..f6e568c 100644 --- a/sccpManClasses/Sccp.class.php.v433 +++ b/sccpManClasses/Sccp.class.php.v433 @@ -78,7 +78,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { $this->freepbx = $parent_class; $this->database = $parent_class->Database(); // Get system defaults [systemdefault] and sitedefaults [data] from sccpsettings. - $stmt = $this->database->prepare("SELECT * FROM sccpsettings WHERE systemdefault !=''"); + $stmt = $this->database->prepare("SELECT * FROM sccpsettings"); $stmt->execute(); $raw_settings = $stmt->fetchAll(\PDO::FETCH_ASSOC); foreach ($raw_settings as $key => $valueArray) { @@ -218,6 +218,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function getDefaultDeviceSettings($id, $displayname, &$flag) { // FreePBX required method $settings = array(); + dbug($this->line_defaults); $settingsFields = array('mailbox', 'incominglimit', 'context', 'directed_pickup_context', 'callgroup', 'pickupgroup', 'namedcallgroup', 'namedpickupgroup', 'adhocNumber', 'secondary_dialtone_digits', 'secondary_dialtone_tone', 'directed_pickup', 'pickup_modeanswer', 'transfer', 'echocancel', 'dnd', 'silencesuppression', 'musicclass', 'pin', 'allow', 'disallow'); From 43677651dfa5b08daf76cbd3555dae427d4969a6 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 10 Aug 2021 11:52:17 +0200 Subject: [PATCH 174/181] Refinements to installer handling of sccpvalues --- install.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/install.php b/install.php index 15e0cc0..4aab536 100644 --- a/install.php +++ b/install.php @@ -1101,7 +1101,7 @@ function cleanUpSccpSettings() { foreach ($sysConfiguration as $key => $valueArray) { // 2 special cases deny|permit & disallow|allow where need to parse on |. - $newKeyword = explode("|", $valueArray['Name'], 2); + $newKeyword = explode("|", $key, 2); if (isset($newKeyword[1])) { // chan-sccp sets sysdef as comma separated list for sccp.conf, but expects ; separated list // when returned from db @@ -1124,10 +1124,8 @@ function cleanUpSccpSettings() { } else { ($sysConfiguration[$key]['DefaultValue'] == '(null)') ? '' : $sysConfiguration[$key]['DefaultValue']; if (array_key_exists($key,$settingsFromDb)) { - if (!empty($sysConfiguration[$key2]['DefaultValue'])) { - // Preserve sequence and type - $settingsFromDb[$key]['systemdefault'] = $sysConfiguration[$key]['DefaultValue']; - } + // Preserve sequence and type + $settingsFromDb[$key]['systemdefault'] = $sysConfiguration[$key]['DefaultValue']; } else { $settingsFromDb[$key] = array('keyword' => $key, 'seq' => 0, 'type' => 0, 'data' => '', 'systemdefault' => $sysConfiguration[$key]['DefaultValue']); } From 1bea598588aa0593db0a7cd72046ae949f294d7d Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 13 Aug 2021 07:01:16 +0200 Subject: [PATCH 175/181] Increase length of netlang and devlang fields Increased to 50 - 25 caused truncation of certain locales --- install.php | 4 ++-- module.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/install.php b/install.php index 4aab536..bd0a50d 100644 --- a/install.php +++ b/install.php @@ -254,8 +254,8 @@ function Get_DB_config($sccp_compatible) 'dialrules' => array('create' => "VARCHAR(255) NULL DEFAULT NULL"), 'description' => array('create' => "VARCHAR(45) NULL DEFAULT NULL"), '_hwlang' => array ('drop' => 'yes'), - 'devlang' => array('create' => "VARCHAR(25) NULL default NULL", 'modify' => "VARCHAR(25)"), - 'netlang' => array('create' => "VARCHAR(25) NULL default NULL", 'modify' => "VARCHAR(25)"), + 'devlang' => array('create' => "VARCHAR(50) NULL default NULL", 'modify' => "VARCHAR(50)"), + 'netlang' => array('create' => "VARCHAR(50) NULL default NULL", 'modify' => "VARCHAR(50)"), '_devlang' => array('rename' => "devlang"), '_netlang' => array('rename' => "netlang"), '_logserver' => array('rename' => 'logserver'), diff --git a/module.xml b/module.xml index fa67a9b..b6f815f 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.9 + 14.3.0.10 setup SCCP Connectivity Steve Lad, Alex GP From 570171bce0d6f87cc19eb303f118809cb192751e Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Fri, 13 Aug 2021 08:05:41 +0200 Subject: [PATCH 176/181] Remove chan-sccp (null) defaults --- install.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install.php b/install.php index bd0a50d..67f9eca 100644 --- a/install.php +++ b/install.php @@ -1122,7 +1122,8 @@ function cleanUpSccpSettings() { unset($settingsFromDb[$key]); } } else { - ($sysConfiguration[$key]['DefaultValue'] == '(null)') ? '' : $sysConfiguration[$key]['DefaultValue']; + dbug($sysConfiguration); + $sysConfiguration[$key]['DefaultValue'] = ($sysConfiguration[$key]['DefaultValue'] == '(null)') ? '' : $sysConfiguration[$key]['DefaultValue']; if (array_key_exists($key,$settingsFromDb)) { // Preserve sequence and type $settingsFromDb[$key]['systemdefault'] = $sysConfiguration[$key]['DefaultValue']; @@ -1130,6 +1131,7 @@ function cleanUpSccpSettings() { $settingsFromDb[$key] = array('keyword' => $key, 'seq' => 0, 'type' => 0, 'data' => '', 'systemdefault' => $sysConfiguration[$key]['DefaultValue']); } } + dbug($settingsFromDb); // Override certain chan-sccp defaults as they are based on a non-FreePbx system $settingsFromDb['context']['systemdefault'] = 'from-internal'; $settingsFromDb['directed_pickup']['systemdefault'] = 'no'; From 8f6c7be74e3f6a0d18f7d510d803dbc299dfadd8 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 15 Aug 2021 13:07:36 +0200 Subject: [PATCH 177/181] Optimise handle submit Change order of treatment of returned data Handle db calls outside of loops Optimise parsing --- Sccp_manager.class.php | 2 +- sccpManTraits/ajaxHelper.php | 152 +++++++++++++---------------------- views/server.url.php | 4 +- 3 files changed, 58 insertions(+), 100 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 5faa249..04b6474 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -390,7 +390,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { ); // $lines_list = $this->dbinterface->getSccpDeviceTableData('SccpExtension'); - $max_btn = ((!empty($get_settings['buttonscount']) ? $get_settings['buttonscount'] : 100)); + $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'])) { diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 042515b..9937ff8 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -407,56 +407,45 @@ trait ajaxHelper { $count_mods = 0; $dbSaveArray = array(); $errors = array(); - $i = 0; if (isset($request["{$hdr_prefix}createlangdir"]) && ($request["{$hdr_prefix}createlangdir"] == 'yes')) { $this->initializeTFtpLanguagePath(); } // if uncheck all codecs, audiocodecs key is missing so nothing changes in db. // Unsetting all codecs will now return to chan-sccp defaults. + // all codecs are currently treated as audiocodecs. To treat videocodecs separately name in video codec section of + // server.codec needs to be changed from audiocodecs to videocodecs. if (!isset($request['audiocodecs'])) { - $request['audiocodecs'] = array_fill_keys(explode(';',$this->sccpvalues['allow']['systemdefault']),true); + $save_settings['allow'] = $this->sccpvalues['allow']; + $save_settings['allow']['data'] = $this->sccpvalues['allow']['systemdefault']; + } else { + foreach ($request['audiocodecs'] as $keycodeс => $dumVal) { + $save_codec[] = $keycodeс; + } + $save_settings['allow'] = $this->sccpvalues['allow']; + $save_settings['allow']['data'] = implode(";", $save_codec); } - foreach ($request as $key => $value) { - // Originally saved all to sccpvalues. Now will save to db defaults if appropriate - // TODO: Need to verify the tables defined in showGroup - some options maybe - // device options, but if set by freePbx extensions, be in sccpline. - $key = (str_replace('sccpdevice_', '', $key, $count_mods)); - if ($count_mods) { - // 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->getTableDefaults('sccpdevice', false); - if (!array_key_exists($key, $dev_def)) { - // This key needs to be prefixed with underscore - $key = "_{$key}"; - } - if ((array_key_exists($key, $dev_def)) && (($dev_def[$key]['data'] == $value) || empty($dev_def[$key]['data']))) { - // Value unchanged or null so ignore and go to next key. - continue; - } - $dbSaveArray[$key] = array('table' => 'sccpdevice', 'field' => $key, 'Default' => $value); - continue; - } - $key = (str_replace('sccpline_', '', $key, $count_mods)); - if ($count_mods) { - // 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->getTableDefaults('sccpline', false); - if (!array_key_exists($key, $dev_def)) { - // This key needs to be prefixed with underscore - $key = "_{$key}"; - } - if ((array_key_exists($key, $dev_def)) && ($dev_def[$key]['data'] == $value)) { - // Value unchanged so ignore and get next key. - continue; - } - $dbSaveArray[$key] = array('table' => 'sccpline', 'field' => $key, 'Default' => $value); - unset($request[$key]); - continue; - } + unset($request['audiocodecs']); + if (isset($request[$hdr_prefix . 'ntp_timezone'])) { + $TZdata = $this->extconfigs->getExtConfig('sccp_timezone', $request[$hdr_prefix . 'ntp_timezone']); + if (!empty($TZdata)) { + $save_settings['tzoffset'] = array( + 'keyword' => 'tzoffset', + 'data' => $TZdata['offset']/60, + 'seq' => '98', + 'type' => '2', + 'systemdefault' => '' + ); + } + unset($request[$hdr_prefix . 'ntp_timezone']); + } + // Now handle remaining data. First get table defaults + $sccpdevice_def = (array)$this->getTableDefaults('sccpdevice', false); + $sccpline_def = (array)$this->getTableDefaults('sccpline', false); + + foreach ($request as $key => $value) { + // First handle any arrays as their prefix is part common with normal data $key = (str_replace($hdr_arprefix, '', $key, $count_mods)); if ($count_mods) { $arr_data = ''; @@ -483,69 +472,38 @@ trait ajaxHelper { } } if (!($this->sccpvalues[$key]['data'] == $arr_data)) { - $save_settings[$key] = array( - 'keyword' => $key, - 'data' => $arr_data, - 'seq' => $this->sccpvalues[$key]['seq'], - 'type' => $this->sccpvalues[$key]['type'], - 'systemdefault' => $this->sccpvalues[$key]['systemdefault'] - ); + $save_settings[$key] = $this->sccpvalues[$key]; + $save_settings[$key]['data'] = $array_data; } } + continue; } - - $key = (str_replace($hdr_prefix, '', $key, $count_mods)); - if ($count_mods) { - if (!empty($this->sccpvalues[$key]) && ($this->sccpvalues[$key]['data'] != $value)) { - $save_settings[$key] = array( - 'keyword' => $key, - 'data' => $value, - 'seq' => $this->sccpvalues[$key]['seq'], - 'type' => $this->sccpvalues[$key]['type'], - 'systemdefault' => $this->sccpvalues[$key]['systemdefault'] - ); + // Now handle any normal data - arrays will not match as already handled. + if (strpos($key, $hdr_prefix) === 0) { + $key = (str_replace($hdr_prefix, '', $key, $count_mods)); + if (($count_mods) && (!empty($this->sccpvalues[$key])) && ($this->sccpvalues[$key]['data'] != $value)) { + $save_settings[$key] = $this->sccpvalues[$key]; + $save_settings[$key]['data'] = $value; } - + continue; } - - switch ($key) { - case 'audiocodecs': - foreach ($value as $keycodeс => $valcodeс) { - $save_codec[$i] = $keycodeс; - $i++; - }; - $tmpv = implode(";", $save_codec); - if (!($this->sccpvalues['allow']['data'] == $tmpv)) { - $save_settings['allow'] = array( - 'keyword' => 'allow', - 'data' => $tmpv, - 'seq' => $this->sccpvalues['allow']['seq'], - 'type' => $this->sccpvalues['allow']['type'], - 'systemdefault' => $this->sccpvalues['allow']['systemdefault'] - ); + // Finally treat values to be saved to sccpdevice and sccpline defaults. + // TODO: Need to verify the tables defined in showGroup - some options maybe + // device options, but if set by freePbx extensions, be in sccpline. + foreach (array('sccpdevice', 'sccpline') as $tableName) { + $key = (str_replace("{$tableName}_", '', $key, $count_mods)); + if ($count_mods) { + // Have default to be saved to db table default + $tableName_def = "{$tableName}_def"; + if ((array_key_exists($key, ${$tableName_def})) && (${$tableName_def}[$key]['data'] == $value)) { + // Value unchanged so ignore + } else { + $dbSaveArray[$key] = array('table' => $tableName, 'field' => $key, 'Default' => $value); } - break; - case 'videocodecs': - // currently not used. To reach this case, name in video codec section of - // server.codec needs to be changed from audiocodecs to videocodecs. - break; - - case 'ntp_timezone': - $tz_id = $value; - $TZdata = $this->extconfigs->getExtConfig('sccp_timezone', $tz_id); - if (!empty($TZdata)) { - $value = $TZdata['offset']/60; - $save_settings['tzoffset'] = array( - 'keyword' => 'tzoffset', - 'data' => $value, - 'seq' => '98', - 'type' => '2', - 'systemdefault' => '' - ); - } - break; + // If have matched on device, cannot match on line + continue 2; + } } - } $extSettings = $this->extconfigs->updateTftpStructure(array_merge($this->sccpvalues, $save_settings)); diff --git a/views/server.url.php b/views/server.url.php index ceb8a1f..79cc7ec 100644 --- a/views/server.url.php +++ b/views/server.url.php @@ -9,6 +9,6 @@ showGroup('sccp_dev_url', 1); -?> + echo $this->showGroup('sccp_dev_url', 1,); +?> From 2dc613f063e38e06d3c9124a1eff465c956c4edf Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Tue, 21 Sep 2021 10:35:10 +0200 Subject: [PATCH 178/181] Fix variable name arr_data was mistyped --- module.xml | 2 +- sccpManTraits/ajaxHelper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module.xml b/module.xml index b6f815f..17ccd96 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.10 + 14.3.0.11 setup SCCP Connectivity Steve Lad, Alex GP diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 9937ff8..496d823 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -473,7 +473,7 @@ trait ajaxHelper { } if (!($this->sccpvalues[$key]['data'] == $arr_data)) { $save_settings[$key] = $this->sccpvalues[$key]; - $save_settings[$key]['data'] = $array_data; + $save_settings[$key]['data'] = $arr_data; } } continue; From 67f2a8b2a36eceafbc338cb195f6e2e1e15de722 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 14 Oct 2021 09:12:57 +0200 Subject: [PATCH 179/181] Quote device name in xpath request Xpath requires quotes if non numeric device name (eg 894x) --- sccpManTraits/ajaxHelper.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sccpManTraits/ajaxHelper.php b/sccpManTraits/ajaxHelper.php index 496d823..c7d7e05 100644 --- a/sccpManTraits/ajaxHelper.php +++ b/sccpManTraits/ajaxHelper.php @@ -566,9 +566,8 @@ trait ajaxHelper { switch ($request['type']) { case 'firmware': $device = $request['device']; - $firmwareDir = $tftpBootXml->xpath("//Directory[@name='firmware']"); - $result = $firmwareDir[0]->xpath("//Directory[@name={$device}]"); + $result = $firmwareDir[0]->xpath("//Directory[@name='{$device}']"); $filesToGet['firmware'] = (array)$result[0]->FileName; $totalFiles += count($filesToGet['firmware']); $srcDir['firmware'] = $provisionerUrl . (string)$result[0]->DirectoryPath; From 5bd1455e91595e5552a57aa561b80cb76862829a Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Thu, 14 Oct 2021 09:13:43 +0200 Subject: [PATCH 180/181] Update version --- module.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module.xml b/module.xml index 17ccd96..470d9a2 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.11 + 14.3.0.12 setup SCCP Connectivity Steve Lad, Alex GP From 48ace0574a26f3a81450022fb3c6cfd0e6a69661 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sat, 16 Oct 2021 15:32:53 +0200 Subject: [PATCH 181/181] Force installer to update sccpdevmodel Ensure changes in sccpdevmodel are implimented. Update number of burttons on 894X --- install.php | 274 ++++++++++++++++++++++++++-------------------------- module.xml | 2 +- 2 files changed, 140 insertions(+), 136 deletions(-) diff --git a/install.php b/install.php index 67f9eca..f033599 100644 --- a/install.php +++ b/install.php @@ -500,148 +500,152 @@ function InstallDB_updateSchema($db_config) } } outn("
  • " . _("Total modify count :") . $count_modify . "
  • "); - + /* $stmt = $db->prepare('SELECT CASE WHEN EXISTS(SELECT 1 FROM sccpdevmodel) THEN 0 ELSE 1 END AS IsEmpty;'); $stmt->execute(); $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); if (!$result[0]['IsEmpty']) { return; } else { - outn("Populating sccpdevmodel..."); - outn("
  • " . _("Fill sccpdevmodel") . "
  • "); - $sql = "REPLACE INTO sccpdevmodel (model, vendor, dns, buttons, loadimage, loadinformationid, enabled, nametemplate) VALUES - ('12 SP', 'CISCO', 1, 1, '', 'loadInformation3', 0, NULL), - ('12 SP+', 'CISCO', 1, 1, '', 'loadInformation2', 0, NULL), - ('30 SP+', 'CISCO', 1, 1, '', 'loadInformation1', 0, NULL), - ('30 VIP', 'CISCO', 1, 1, '', 'loadInformation5', 0, NULL), - ('3911', 'CISCO', 1, 1, '', 'loadInformation446', 0, NULL), - ('3951', 'CISCO', 1, 1, '', 'loadInformation412', 0, ''), - ('6901', 'CISCO', 1, 1, 'SCCP6901.9-2-1-a', 'loadInformation547', 0, NULL), - ('6911', 'CISCO', 1, 1, 'SCCP6911.9-2-1-a', 'loadInformation548', 0, NULL), - ('6921', 'CISCO', 1, 1, 'SCCP69xx.9-4-1-3SR3', 'loadInformation496', 0, NULL), - ('6941', 'CISCO', 1, 1, 'SCCP69xx.9-3-1-3', 'loadInformation495', 0, NULL), - ('6945', 'CISCO', 1, 1, 'SCCP6945.9-3-1-3', 'loadInformation564', 0, NULL), - ('6961', 'CISCO', 1, 1, 'SCCP69xx.9-2-1-0', 'loadInformation497', 0, NULL), - ('7902', 'CISCO', 1, 1, 'CP7902080002SCCP060817A', 'loadInformation30008', 0, NULL), - ('7905', 'CISCO', 1, 1, 'CP7905080003SCCP070409A', 'loadInformation20000', 0, NULL), - ('7906', 'CISCO', 1, 1, 'SCCP11.9-4-2SR3-1S', 'loadInformation369', 1, 'SEP0000000000.cnf.xml_791x_template'), - ('7910', 'CISCO', 1, 1, 'P00405000700', 'loadInformation6', 1, 'SEP0000000000.cnf.xml_791x_template'), - ('7911', 'CISCO', 1, 1, 'SCCP11.9-4-2SR3-1S', 'loadInformation307', 1, 'SEP0000000000.cnf.xml_791x_template'), - ('7912', 'CISCO', 1, 1, 'CP7912080004SCCP080108A', 'loadInformation30007', 0, NULL), - ('7914', 'CISCO', 0, 14, 'S00105000400', 'loadInformation124', 1, NULL), - ('7914;7914', 'CISCO', 0, 28, 'S00105000400', 'loadInformation124', 1, NULL), - ('7915', 'CISCO', 0, 24, 'B015-1-0-4-2', 'loadInformation227', 1, NULL), - ('7915;7915', 'CISCO', 0, 48, 'B015-1-0-4-2', 'loadInformation228', 1, NULL), - ('7916', 'CISCO', 0, 24, 'B016-1-0-4-2', 'loadInformation229', 1, NULL), - ('7916;7916', 'CISCO', 0, 48, 'B016-1-0-4-2', 'loadInformation230', 1, NULL), - ('7920', 'CISCO', 1, 1, 'cmterm_7920.4.0-03-02', 'loadInformation30002', 0, NULL), - ('7921', 'CISCO', 1, 1, 'CP7921G-1.4.6.3', 'loadInformation365', 0, NULL), - ('7925', 'CISCO', 1, 6, 'CP7925G-1.4.1SR1', 'loadInformation484', 0, 'SEP0000000000.cnf.xml_7925_template'), - ('7926', 'CISCO', 1, 1, 'CP7926G-1.4.1SR1', 'loadInformation557', 0, NULL), - ('7931', 'CISCO', 1, 34, 'SCCP31.9-2-1S', 'loadInformation348', 0, NULL), - ('7935', 'CISCO', 1, 2, 'P00503021900', 'loadInformation9', 0, NULL), - ('7936', 'CISCO', 1, 1, 'cmterm_7936.3-3-21-0', 'loadInformation30019', 0, NULL), - ('7937', 'CISCO', 1, 1, 'apps37sccp.1-4-5-7', 'loadInformation431', 0, 'SEP0000000000.cnf.xml_7937_template'), - ('7940', 'CISCO', 1, 2, 'P0030801SR02', 'loadInformation8', 1, 'SEP0000000000.cnf.xml_7940_template'), - ('7941', 'CISCO', 1, 2, 'SCCP41.9-4-2SR3-1S', 'loadInformation115', 0, 'SEP0000000000.cnf.xml_796x_template'), - ('7941G-GE', 'CISCO', 1, 2, 'SCCP41.9-4-2SR3-1S', 'loadInformation309', 0, 'SEP0000000000.cnf.xml_796x_template'), - ('7942', 'CISCO', 1, 2, 'SCCP42.9-4-2SR3-1S', 'loadInformation434', 0, 'SEP0000000000.cnf.xml_796x_template'), - ('7945', 'CISCO', 1, 2, 'SCCP45.9-3-1SR1-1S', 'loadInformation435', 0, 'SEP0000000000.cnf.xml_796x_template'), - ('7960', 'CISCO', 3, 6, 'P0030801SR02', 'loadInformation7', 1, 'SEP0000000000.cnf.xml_7940_template'), - ('7961', 'CISCO', 3, 6, 'SCCP41.9-4-2SR3-1S', 'loadInformation30018', 0, 'SEP0000000000.cnf.xml_796x_template'), - ('7961G-GE', 'CISCO', 3, 6, 'SCCP41.9-4-2SR3-1S', 'loadInformation308', 0, 'SEP0000000000.cnf.xml_796x_template'), - ('7962', 'CISCO', 3, 6, 'SCCP42.9-4-2SR3-1S', 'loadInformation404', 0, 'SEP0000000000.cnf.xml_796x_template'), - ('7965', 'CISCO', 3, 6, 'SCCP45.9-3-1SR1-1S', 'loadInformation436', 0, 'SEP0000000000.cnf.xml_796x_template'), - ('7970', 'CISCO', 3, 8, 'SCCP70.9-4-2SR3-1S', 'loadInformation30006', 0, 'SEP0000000000.cnf.xml_797x_template'), - ('7971', 'CISCO', 1, 2, 'SCCP70.9-4-2SR3-1S', 'loadInformation119', 0, 'SEP0000000000.cnf.xml_797x_template'), - ('7975', 'CISCO', 3, 8, 'SCCP75.9-4-2SR3-1S', 'loadInformation437', 0, 'SEP0000000000.cnf.xml_7975_template'), - ('7985', 'CISCO', 3, 8, 'cmterm_7985.4-1-7-0', 'loadInformation302', 0, NULL), - ('8941', 'CISCO', 1, 1, 'SCCP894x.9-2-2-0', 'loadInformation586', 0, NULL), - ('8945', 'CISCO', 1, 1, 'SCCP894x.9-2-2-0', 'loadInformation585', 0, NULL), - ('ATA 186', 'CISCO', 1, 1, 'ATA030204SCCP090202A', 'loadInformation12', 0, 'SEP0000000000.cnf.xml_ATA_template'), - ('ATA 187', 'CISCO', 1, 1, 'ATA187.9-2-3-1', 'loadInformation550', 0, 'SEP0000000000.cnf.xml_ATA_template'), - ('CN622', 'MOTOROLA', 1, 1, '', 'loadInformation335', 0, NULL), - ('Digital Access', 'CISCO', 1, 1, 'D001M022', 'loadInformation40', 0, NULL), - ('Digital Access+', 'CISCO', 1, 1, 'D00303010033', 'loadInformation42', 0, NULL), - ('E-Series', 'NOKIA', 1, 1, '', '', 0, NULL), - ('ICC', 'NOKIA', 1, 1, '', '', 0, NULL), - ('Analog Access', 'CISCO', 1, 1, 'A001C030', 'loadInformation30', 0, ''),('WS-X6608', 'CISCO', 1, 1, 'D00404000032', 'loadInformation43', 0, ''), - ('WS-X6624', 'CISCO', 1, 1, 'A00204000013', 'loadInformation43', 0, ''), - ('WS-X6608', 'CISCO', 1, 1, 'C00104000003', 'loadInformation51', 0, ''), - ('H.323 Phone', 'CISCO', 1, 1, '', 'loadInformation61', 0, ''), - ('Simulator', 'CISCO', 1, 1, '', 'loadInformation100', 0, ''), - ('MTP', 'CISCO', 1, 1, '', 'loadInformation111', 0, ''), - ('MGCP Station', 'CISCO', 1, 1, '', 'loadInformation120', 0, ''), - ('MGCP Trunk', 'CISCO', 1, 1, '', 'loadInformation121', 0, ''), - ('UPC', 'CISCO', 1, 1, '', 'loadInformation358', 0, ''), - ('TelePresence', 'TELEPRESENCE', 1, 1, '', 'loadInformation375', 0, ''), - ('1000', 'TELEPRESENCE', 1, 1, '', 'loadInformation478', 0, ''), - ('3000', 'TELEPRESENCE', 1, 1, '', 'loadInformation479', 0, ''), - ('3200', 'TELEPRESENCE', 1, 1, '', 'loadInformation480', 0, ''), - ('500-37', 'TELEPRESENCE', 1, 1, '', 'loadInformation481', 0, ''), - ('1300-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation505', 0, ''), - ('1100', 'TELEPRESENCE', 1, 1, '', 'loadInformation520', 0, ''), - ('200', 'TELEPRESENCE', 1, 1, '', 'loadInformation557', 0, ''), - ('400', 'TELEPRESENCE', 1, 1, '', 'loadInformation558', 0, ''), - ('EX90', 'TELEPRESENCE', 1, 1, '', 'loadInformation584', 0, ''), - ('500-32', 'TELEPRESENCE', 1, 1, '', 'loadInformation590', 0, ''), - ('1300-47', 'TELEPRESENCE', 1, 1, '', 'loadInformation591', 0, ''), - ('TX1310-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation596', 0, ''), - ('EX60', 'TELEPRESENCE', 1, 1, '', 'loadInformation604', 0, ''), - ('C90', 'TELEPRESENCE', 1, 1, '', 'loadInformation606', 0, ''), - ('C60', 'TELEPRESENCE', 1, 1, '', 'loadInformation607', 0, ''), - ('C40', 'TELEPRESENCE', 1, 1, '', 'loadInformation608', 0, ''), - ('C20', 'TELEPRESENCE', 1, 1, '', 'loadInformation609', 0, ''), - ('C20-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation610', 0, ''), - ('C60-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation611', 0, ''), - ('C40-52', 'TELEPRESENCE', 1, 1, '', 'loadInformation612', 0, ''), - ('C60-52', 'TELEPRESENCE', 1, 1, '', 'loadInformation613', 0, ''), - ('C60-52D', 'TELEPRESENCE', 1, 1, '', 'loadInformation614', 0, ''), - ('C60-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation615', 0, ''), - ('C90-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation616', 0, ''), - ('MX200', 'TELEPRESENCE', 1, 1, '', 'loadInformation617', 0, ''), - ('TX9000', 'TELEPRESENCE', 1, 1, '', 'loadInformation619', 0, ''), - ('TX9200', 'TELEPRESENCE', 1, 1, '', 'loadInformation620', 0, ''), - ('SX20', 'TELEPRESENCE', 1, 1, '', 'loadInformation626', 0, ''), - ('MX300', 'TELEPRESENCE', 1, 1, '', 'loadInformation627', 0, ''), - ('C40-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation633', 0, ''), - ('Jabber', 'CISCO', 1, 1, '', 'loadInformation652', 0, ''), - ('S60', 'NOKIA', 0, 1, '', 'loadInformation376', 0, ''), - ('9971', 'CISCO', 1, 1, '', 'loadInformation493', 0, ''), - ('9951', 'CISCO', 1, 1, '', 'loadInformation537', 0, ''), - ('8961', 'CISCO', 1, 1, '', 'loadInformation540', 0, ''), - ('Iphone', 'APPLE', 0, 1, '', 'loadInformation562', 0, ''), - ('Android', 'ANDROID', 0, 1, '', 'loadInformation575', 0, ''), - ('7926', 'CISCO', 1, 1, 'CP7926G-1.4.5.3', 'loadInformation577', 0, ''), - ('7821', 'CISCO', 1, 1, '', 'loadInformation621', 0, ''), - ('7841', 'CISCO', 1, 1, '', 'loadInformation622', 0, ''), - ('7861', 'CISCO', 1, 1, '', 'loadInformation623', 0, ''), - ('VXC 6215', 'CISCO', 1, 1, '', 'loadInformation634', 0, ''), - ('8831', 'CISCO', 1, 1, '', 'loadInformation659', 0, ''), - ('8841', 'CISCO', 1, 1, '', 'loadInformation683', 0, ''), - ('8851', 'CISCO', 1, 1, '', 'loadInformation684', 0, ''), - ('8861', 'CISCO', 1, 1, '', 'loadInformation685', 0, ''), - ('Analog', 'CISCO', 1, 1, '', 'loadInformation30027', 0, ''), - ('ISDN', 'CISCO', 1, 1, '', 'loadInformation30028', 0, ''), - ('SCCP GW', 'CISCO', 1, 1, '', 'loadInformation30032', 0, ''), - ('IP-STE', 'CISCO', 1, 1, '', 'loadInformation30035', 0, ''), - ('SPA 521S', 'CISCO', 1, 1, '', 'loadInformation80000', 0, ''), - ('SPA 502G', 'CISCO', 1, 1, '', 'loadInformation80003', 0, ''), - ('SPA 504G', 'CISCO', 1, 1, '', 'loadInformation80004', 0, ''), - ('SPA 525G', 'CISCO', 1, 1, '', 'loadInformation80005', 0, ''), - ('SPA 525G2', 'CISCO', 1, 1, '', 'loadInformation80009', 0, ''), - ('SPA 303G', 'CISCO', 1, 1, '', 'loadInformation80011', 0, ''), - ('IP Communicator', 'CISCO', 1, 1, '', 'loadInformation30016', 0, NULL), - ('Nokia E', 'Nokia', 1, 28, '', 'loadInformation275', 0, NULL), - ('VGC Phone', 'CISCO', 1, 1, '', 'loadInformation10', 0, NULL), - ('7911-sip', 'CISCO-SIP', 1, 1, 'SIP11.9-2-1S', 'loadInformation307', 1, 'SEP0000000000.cnf.xml_791x_sip_template'), - ('9951-sip', 'CISCO-SIP', 1, 1, 'sip9951.9-2-2SR1-9', 'loadinformation537', 1, 'SEP0000000000.cnf.xml_99xx_sip_template'), - ('VGC Virtual', 'CISCO', 1, 1, '', 'loadInformation11', 0, NULL);"; - $check = $db->query($sql); - if (DB::IsError($check)) { - die_freepbx("Can not create sccpdevmodel table, error:$check\n"); - } + + */ + + // Force update of sccp devmodel to ensure changes are taken into account + outn("Updating sccpdevmodel..."); + outn("
  • " . _("Fill sccpdevmodel") . "
  • "); + $sql = "REPLACE INTO sccpdevmodel (model, vendor, dns, buttons, loadimage, loadinformationid, enabled, nametemplate) VALUES + ('12 SP', 'CISCO', 1, 1, '', 'loadInformation3', 0, NULL), + ('12 SP+', 'CISCO', 1, 1, '', 'loadInformation2', 0, NULL), + ('30 SP+', 'CISCO', 1, 1, '', 'loadInformation1', 0, NULL), + ('30 VIP', 'CISCO', 1, 1, '', 'loadInformation5', 0, NULL), + ('3911', 'CISCO', 1, 1, '', 'loadInformation446', 0, NULL), + ('3951', 'CISCO', 1, 1, '', 'loadInformation412', 0, ''), + ('6901', 'CISCO', 1, 1, 'SCCP6901.9-2-1-a', 'loadInformation547', 0, NULL), + ('6911', 'CISCO', 1, 1, 'SCCP6911.9-2-1-a', 'loadInformation548', 0, NULL), + ('6921', 'CISCO', 1, 1, 'SCCP69xx.9-4-1-3SR3', 'loadInformation496', 0, NULL), + ('6941', 'CISCO', 1, 1, 'SCCP69xx.9-3-1-3', 'loadInformation495', 0, NULL), + ('6945', 'CISCO', 1, 1, 'SCCP6945.9-3-1-3', 'loadInformation564', 0, NULL), + ('6961', 'CISCO', 1, 1, 'SCCP69xx.9-2-1-0', 'loadInformation497', 0, NULL), + ('7902', 'CISCO', 1, 1, 'CP7902080002SCCP060817A', 'loadInformation30008', 0, NULL), + ('7905', 'CISCO', 1, 1, 'CP7905080003SCCP070409A', 'loadInformation20000', 0, NULL), + ('7906', 'CISCO', 1, 1, 'SCCP11.9-4-2SR3-1S', 'loadInformation369', 1, 'SEP0000000000.cnf.xml_791x_template'), + ('7910', 'CISCO', 1, 1, 'P00405000700', 'loadInformation6', 1, 'SEP0000000000.cnf.xml_791x_template'), + ('7911', 'CISCO', 1, 1, 'SCCP11.9-4-2SR3-1S', 'loadInformation307', 1, 'SEP0000000000.cnf.xml_791x_template'), + ('7912', 'CISCO', 1, 1, 'CP7912080004SCCP080108A', 'loadInformation30007', 0, NULL), + ('7914', 'CISCO', 0, 14, 'S00105000400', 'loadInformation124', 1, NULL), + ('7914;7914', 'CISCO', 0, 28, 'S00105000400', 'loadInformation124', 1, NULL), + ('7915', 'CISCO', 0, 24, 'B015-1-0-4-2', 'loadInformation227', 1, NULL), + ('7915;7915', 'CISCO', 0, 48, 'B015-1-0-4-2', 'loadInformation228', 1, NULL), + ('7916', 'CISCO', 0, 24, 'B016-1-0-4-2', 'loadInformation229', 1, NULL), + ('7916;7916', 'CISCO', 0, 48, 'B016-1-0-4-2', 'loadInformation230', 1, NULL), + ('7920', 'CISCO', 1, 1, 'cmterm_7920.4.0-03-02', 'loadInformation30002', 0, NULL), + ('7921', 'CISCO', 1, 1, 'CP7921G-1.4.6.3', 'loadInformation365', 0, NULL), + ('7925', 'CISCO', 1, 6, 'CP7925G-1.4.1SR1', 'loadInformation484', 0, 'SEP0000000000.cnf.xml_7925_template'), + ('7926', 'CISCO', 1, 1, 'CP7926G-1.4.1SR1', 'loadInformation557', 0, NULL), + ('7931', 'CISCO', 1, 34, 'SCCP31.9-2-1S', 'loadInformation348', 0, NULL), + ('7935', 'CISCO', 1, 2, 'P00503021900', 'loadInformation9', 0, NULL), + ('7936', 'CISCO', 1, 1, 'cmterm_7936.3-3-21-0', 'loadInformation30019', 0, NULL), + ('7937', 'CISCO', 1, 1, 'apps37sccp.1-4-5-7', 'loadInformation431', 0, 'SEP0000000000.cnf.xml_7937_template'), + ('7940', 'CISCO', 1, 2, 'P0030801SR02', 'loadInformation8', 1, 'SEP0000000000.cnf.xml_7940_template'), + ('7941', 'CISCO', 1, 2, 'SCCP41.9-4-2SR3-1S', 'loadInformation115', 0, 'SEP0000000000.cnf.xml_796x_template'), + ('7941G-GE', 'CISCO', 1, 2, 'SCCP41.9-4-2SR3-1S', 'loadInformation309', 0, 'SEP0000000000.cnf.xml_796x_template'), + ('7942', 'CISCO', 1, 2, 'SCCP42.9-4-2SR3-1S', 'loadInformation434', 0, 'SEP0000000000.cnf.xml_796x_template'), + ('7945', 'CISCO', 1, 2, 'SCCP45.9-3-1SR1-1S', 'loadInformation435', 0, 'SEP0000000000.cnf.xml_796x_template'), + ('7960', 'CISCO', 3, 6, 'P0030801SR02', 'loadInformation7', 1, 'SEP0000000000.cnf.xml_7940_template'), + ('7961', 'CISCO', 3, 6, 'SCCP41.9-4-2SR3-1S', 'loadInformation30018', 0, 'SEP0000000000.cnf.xml_796x_template'), + ('7961G-GE', 'CISCO', 3, 6, 'SCCP41.9-4-2SR3-1S', 'loadInformation308', 0, 'SEP0000000000.cnf.xml_796x_template'), + ('7962', 'CISCO', 3, 6, 'SCCP42.9-4-2SR3-1S', 'loadInformation404', 0, 'SEP0000000000.cnf.xml_796x_template'), + ('7965', 'CISCO', 3, 6, 'SCCP45.9-3-1SR1-1S', 'loadInformation436', 0, 'SEP0000000000.cnf.xml_796x_template'), + ('7970', 'CISCO', 3, 8, 'SCCP70.9-4-2SR3-1S', 'loadInformation30006', 0, 'SEP0000000000.cnf.xml_797x_template'), + ('7971', 'CISCO', 1, 2, 'SCCP70.9-4-2SR3-1S', 'loadInformation119', 0, 'SEP0000000000.cnf.xml_797x_template'), + ('7975', 'CISCO', 3, 8, 'SCCP75.9-4-2SR3-1S', 'loadInformation437', 0, 'SEP0000000000.cnf.xml_7975_template'), + ('7985', 'CISCO', 3, 8, 'cmterm_7985.4-1-7-0', 'loadInformation302', 0, NULL), + ('8941', 'CISCO', 1, 4, 'SCCP894x.9-4-2SR1-2', 'loadInformation586', 0, 'SEP0000000000.cnf.xml_797x_template'), + ('8945', 'CISCO', 1, 4, 'SCCP894x.9-4-2SR1-2', 'loadInformation585', 0, 'SEP0000000000.cnf.xml_7975_template'), + ('ATA 186', 'CISCO', 1, 1, 'ATA030204SCCP090202A', 'loadInformation12', 0, 'SEP0000000000.cnf.xml_ATA_template'), + ('ATA 187', 'CISCO', 1, 1, 'ATA187.9-2-3-1', 'loadInformation550', 0, 'SEP0000000000.cnf.xml_ATA_template'), + ('CN622', 'MOTOROLA', 1, 1, '', 'loadInformation335', 0, NULL), + ('Digital Access', 'CISCO', 1, 1, 'D001M022', 'loadInformation40', 0, NULL), + ('Digital Access+', 'CISCO', 1, 1, 'D00303010033', 'loadInformation42', 0, NULL), + ('E-Series', 'NOKIA', 1, 1, '', '', 0, NULL), + ('ICC', 'NOKIA', 1, 1, '', '', 0, NULL), + ('Analog Access', 'CISCO', 1, 1, 'A001C030', 'loadInformation30', 0, ''),('WS-X6608', 'CISCO', 1, 1, 'D00404000032', 'loadInformation43', 0, ''), + ('WS-X6624', 'CISCO', 1, 1, 'A00204000013', 'loadInformation43', 0, ''), + ('WS-X6608', 'CISCO', 1, 1, 'C00104000003', 'loadInformation51', 0, ''), + ('H.323 Phone', 'CISCO', 1, 1, '', 'loadInformation61', 0, ''), + ('Simulator', 'CISCO', 1, 1, '', 'loadInformation100', 0, ''), + ('MTP', 'CISCO', 1, 1, '', 'loadInformation111', 0, ''), + ('MGCP Station', 'CISCO', 1, 1, '', 'loadInformation120', 0, ''), + ('MGCP Trunk', 'CISCO', 1, 1, '', 'loadInformation121', 0, ''), + ('UPC', 'CISCO', 1, 1, '', 'loadInformation358', 0, ''), + ('TelePresence', 'TELEPRESENCE', 1, 1, '', 'loadInformation375', 0, ''), + ('1000', 'TELEPRESENCE', 1, 1, '', 'loadInformation478', 0, ''), + ('3000', 'TELEPRESENCE', 1, 1, '', 'loadInformation479', 0, ''), + ('3200', 'TELEPRESENCE', 1, 1, '', 'loadInformation480', 0, ''), + ('500-37', 'TELEPRESENCE', 1, 1, '', 'loadInformation481', 0, ''), + ('1300-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation505', 0, ''), + ('1100', 'TELEPRESENCE', 1, 1, '', 'loadInformation520', 0, ''), + ('200', 'TELEPRESENCE', 1, 1, '', 'loadInformation557', 0, ''), + ('400', 'TELEPRESENCE', 1, 1, '', 'loadInformation558', 0, ''), + ('EX90', 'TELEPRESENCE', 1, 1, '', 'loadInformation584', 0, ''), + ('500-32', 'TELEPRESENCE', 1, 1, '', 'loadInformation590', 0, ''), + ('1300-47', 'TELEPRESENCE', 1, 1, '', 'loadInformation591', 0, ''), + ('TX1310-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation596', 0, ''), + ('EX60', 'TELEPRESENCE', 1, 1, '', 'loadInformation604', 0, ''), + ('C90', 'TELEPRESENCE', 1, 1, '', 'loadInformation606', 0, ''), + ('C60', 'TELEPRESENCE', 1, 1, '', 'loadInformation607', 0, ''), + ('C40', 'TELEPRESENCE', 1, 1, '', 'loadInformation608', 0, ''), + ('C20', 'TELEPRESENCE', 1, 1, '', 'loadInformation609', 0, ''), + ('C20-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation610', 0, ''), + ('C60-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation611', 0, ''), + ('C40-52', 'TELEPRESENCE', 1, 1, '', 'loadInformation612', 0, ''), + ('C60-52', 'TELEPRESENCE', 1, 1, '', 'loadInformation613', 0, ''), + ('C60-52D', 'TELEPRESENCE', 1, 1, '', 'loadInformation614', 0, ''), + ('C60-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation615', 0, ''), + ('C90-65', 'TELEPRESENCE', 1, 1, '', 'loadInformation616', 0, ''), + ('MX200', 'TELEPRESENCE', 1, 1, '', 'loadInformation617', 0, ''), + ('TX9000', 'TELEPRESENCE', 1, 1, '', 'loadInformation619', 0, ''), + ('TX9200', 'TELEPRESENCE', 1, 1, '', 'loadInformation620', 0, ''), + ('SX20', 'TELEPRESENCE', 1, 1, '', 'loadInformation626', 0, ''), + ('MX300', 'TELEPRESENCE', 1, 1, '', 'loadInformation627', 0, ''), + ('C40-42', 'TELEPRESENCE', 1, 1, '', 'loadInformation633', 0, ''), + ('Jabber', 'CISCO', 1, 1, '', 'loadInformation652', 0, ''), + ('S60', 'NOKIA', 0, 1, '', 'loadInformation376', 0, ''), + ('9971', 'CISCO', 1, 1, '', 'loadInformation493', 0, ''), + ('9951', 'CISCO', 1, 1, '', 'loadInformation537', 0, ''), + ('8961', 'CISCO', 1, 1, '', 'loadInformation540', 0, ''), + ('Iphone', 'APPLE', 0, 1, '', 'loadInformation562', 0, ''), + ('Android', 'ANDROID', 0, 1, '', 'loadInformation575', 0, ''), + ('7926', 'CISCO', 1, 1, 'CP7926G-1.4.5.3', 'loadInformation577', 0, ''), + ('7821', 'CISCO', 1, 1, '', 'loadInformation621', 0, ''), + ('7841', 'CISCO', 1, 1, '', 'loadInformation622', 0, ''), + ('7861', 'CISCO', 1, 1, '', 'loadInformation623', 0, ''), + ('VXC 6215', 'CISCO', 1, 1, '', 'loadInformation634', 0, ''), + ('8831', 'CISCO', 1, 1, '', 'loadInformation659', 0, ''), + ('8841', 'CISCO', 1, 1, '', 'loadInformation683', 0, ''), + ('8851', 'CISCO', 1, 1, '', 'loadInformation684', 0, ''), + ('8861', 'CISCO', 1, 1, '', 'loadInformation685', 0, ''), + ('Analog', 'CISCO', 1, 1, '', 'loadInformation30027', 0, ''), + ('ISDN', 'CISCO', 1, 1, '', 'loadInformation30028', 0, ''), + ('SCCP GW', 'CISCO', 1, 1, '', 'loadInformation30032', 0, ''), + ('IP-STE', 'CISCO', 1, 1, '', 'loadInformation30035', 0, ''), + ('SPA 521S', 'CISCO', 1, 1, '', 'loadInformation80000', 0, ''), + ('SPA 502G', 'CISCO', 1, 1, '', 'loadInformation80003', 0, ''), + ('SPA 504G', 'CISCO', 1, 1, '', 'loadInformation80004', 0, ''), + ('SPA 525G', 'CISCO', 1, 1, '', 'loadInformation80005', 0, ''), + ('SPA 525G2', 'CISCO', 1, 1, '', 'loadInformation80009', 0, ''), + ('SPA 303G', 'CISCO', 1, 1, '', 'loadInformation80011', 0, ''), + ('IP Communicator', 'CISCO', 1, 1, '', 'loadInformation30016', 0, NULL), + ('Nokia E', 'Nokia', 1, 28, '', 'loadInformation275', 0, NULL), + ('VGC Phone', 'CISCO', 1, 1, '', 'loadInformation10', 0, NULL), + ('7911-sip', 'CISCO-SIP', 1, 1, 'SIP11.9-2-1S', 'loadInformation307', 1, 'SEP0000000000.cnf.xml_791x_sip_template'), + ('9951-sip', 'CISCO-SIP', 1, 1, 'sip9951.9-2-2SR1-9', 'loadinformation537', 1, 'SEP0000000000.cnf.xml_99xx_sip_template'), + ('VGC Virtual', 'CISCO', 1, 1, '', 'loadInformation11', 0, NULL);"; + $check = $db->query($sql); + if (DB::IsError($check)) { + die_freepbx("Can not create sccpdevmodel table, error:$check\n"); } + //} return; } diff --git a/module.xml b/module.xml index 470d9a2..ef81cb5 100644 --- a/module.xml +++ b/module.xml @@ -1,7 +1,7 @@ sccp_manager SCCP Manager - 14.3.0.12 + 14.3.0.13 setup SCCP Connectivity Steve Lad, Alex GP