From 2861da85c065bbf63b6c83cb030af2c7ce570d5b Mon Sep 17 00:00:00 2001 From: PhantomVl Date: Wed, 18 Oct 2017 14:39:53 +0300 Subject: [PATCH] Begin resample Sccp_manager DB convert Use ENUM --- Sccp_manager.class.php | 4 +- Sccp_manager.inc/dbinterface.class.php | 3 +- conf/Sccp.class.php | 6 +- conf/Sccp.class.php.v11 | 36 ++-- conf/sccpgeneral.xml | 52 +++--- conf/sccpgeneral.xml.v11 | 212 ++++++++++++------------ install.php | 217 +++++++++++++++++-------- views/advserver.model.php | 2 +- 8 files changed, 310 insertions(+), 222 deletions(-) diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 8ce4b99..92b7eaa 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -71,6 +71,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { private $sccp_driver_ver = '11.2'; private $tftpLang = array(); private $hint_context = '@ext-local'; /// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Get it from Config !!! + private $val_null = 'NONE'; /// REPLACE to null Field + public $sccp_model_list = array(); private $cnf_wr = null; public $sccppath = array(); @@ -636,7 +638,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { if (!empty($request[$value])) { $save_settings[$value] = $request[$value]; } else { - $save_settings[$value] = 'none'; + $save_settings[$value] = $val_null; // null } } $this->dbinterface->sccp_save_db('sccpdevmodel', $save_settings, $upd_mode, "model"); diff --git a/Sccp_manager.inc/dbinterface.class.php b/Sccp_manager.inc/dbinterface.class.php index fc1aa11..89c62f7 100644 --- a/Sccp_manager.inc/dbinterface.class.php +++ b/Sccp_manager.inc/dbinterface.class.php @@ -8,6 +8,7 @@ namespace FreePBX\modules\Sccp_manager; class dbinterface { + private $val_null = 'NONE'; /// REPLACE to null Field public function __construct() { } @@ -160,7 +161,7 @@ class dbinterface { if (!empty($sql_var)) { $sql_var .= ', '; } - if ($data === 'none') { + if ($data === $this->val_null) { $sql_var .= '`' . $key_v . '`=NULL'; } else { $sql_var .= '`' . $key_v . '`="' . $data . '"'; diff --git a/conf/Sccp.class.php b/conf/Sccp.class.php index 1896bc1..af13a09 100644 --- a/conf/Sccp.class.php +++ b/conf/Sccp.class.php @@ -52,8 +52,8 @@ class Sccp extends \FreePBX\modules\Core\Driver { if (empty($settings['cid_num']['value'])) { $settings['cid_num']['value']= $id; } - $sql = 'INSERT INTO sccpline (name, id'; - $sqlv = 'values ("'.$id.'", "'.$id.'"'; + $sql = 'INSERT INTO sccpline (name'; + $sqlv = 'values ("'.$id.'"'; foreach($this->data_fld as $key => $val) { if (!empty($settings[$val]) ) { if (!empty($settings[$val]['value'])){ @@ -78,7 +78,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function getDevice($id) { $sccp_line = array(); - $sql = "SELECT name as id"; + $sql = "SELECT name as id, name as name"; foreach($this->data_fld as $key => $val) { $sql .= ',`'. $key .'` as '.$val; } diff --git a/conf/Sccp.class.php.v11 b/conf/Sccp.class.php.v11 index 2a2418e..67a55f3 100644 --- a/conf/Sccp.class.php.v11 +++ b/conf/Sccp.class.php.v11 @@ -68,8 +68,8 @@ class Sccp extends \FreePBX\modules\Core\Driver { // die(print_r($settings)); - $sql = 'REPLACE INTO sccpline (name, id'; - $sqlv = 'values ("'.$id.'", "'.$id.'"'; + $sql = 'REPLACE INTO sccpline (name'; + $sqlv = 'values ("'.$id.'"'; foreach($this->data_fld as $key => $val) { switch ($key) { case 'secondary_dialtone_digits': @@ -111,7 +111,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { public function getDevice($id) { $sccp_line = array(); - $sql = "SELECT name as id"; + $sql = "SELECT name as id, name as name "; foreach($this->data_fld as $key => $val) { $sql .= ',`'. $key .'` as '.$val; } @@ -203,11 +203,11 @@ class Sccp extends \FreePBX\modules\Core\Driver { "flag" => $flag++ ), "transfer" => array( - "value" => "yes", + "value" => "on", "flag" => $flag++ ), "echocancel" => array( - "value" => "yes", + "value" => "on", "flag" => $flag++ ), "dnd" => array( @@ -215,7 +215,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { "flag" => $flag++ ), "silencesuppression" => array( - "value" => "no", + "value" => "off", "flag" => $flag++ ), "musicclass" => array( @@ -339,34 +339,34 @@ class Sccp extends \FreePBX\modules\Core\Driver { unset($select); - $select[] = array('value' => 'yes', 'text' => 'Yes'); - $select[] = array('value' => 'no', 'text' => 'No'); + $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' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); + $tmparr['transfer'] = array('prompttext' => _('Call Transfer'), 'value' => 'on', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); unset($select); - $select[] = array('value' => 'yes', 'text' => 'Yes'); - $select[] = array('value' => 'no', 'text' => 'No'); + $select[] = array('value' => 'on', 'text' => 'Yes'); + $select[] = array('value' => 'off', 'text' => 'No'); $tt = _("Echo cancel"); - $tmparr['echocancel'] = array('prompttext' => _('Echo cancel'), 'value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); + $tmparr['echocancel'] = array('prompttext' => _('Echo cancel'), 'value' => 'on', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); unset($select); $select[] = array('value' => 'off', 'text' => 'Off'); $select[] = array('value' => 'reject', 'text' => 'Reject'); $select[] = array('value' => 'silent', 'text' => 'Silent'); - $select[] = array('value' => '', 'text' => 'Cycle'); + $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)"); - $tmparr['dnd'] = array('prompttext' => _('DND'), 'value' => '', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); + $tmparr['dnd'] = array('prompttext' => _('DND'), 'value' => 'reject', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); unset($select); - $select[] = array('value' => 'yes', 'text' => 'Yes'); - $select[] = array('value' => 'no', 'text' => 'No'); + $select[] = array('value' => 'on', 'text' => 'Yes'); + $select[] = array('value' => 'off', 'text' => 'No'); $tt = _("Silence Suppression. Asterisk Not suported"); - $tmparr['silencesuppression'] = array('prompttext' => _('Silence Suppression'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); + $tmparr['silencesuppression'] = array('prompttext' => _('Silence Suppression'), 'value' => 'off', 'tt' => $tt, 'select' => $select, 'level' => 1, 'type' => 'radio', 'section' => $section); unset($select); $select[] = array('value' => 'default', 'text' => _('default')); @@ -380,7 +380,7 @@ class Sccp extends \FreePBX\modules\Core\Driver { } $tt = _("Music on hold"); - $tmparr['musicclass'] = array('prompttext' => _('Music on hold'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1, 'section' => $section); + $tmparr['musicclass'] = array('prompttext' => _('Music on hold'), 'value' => '', 'tt' => $tt, 'select' => $select, 'level' => 1, 'section' => $section); $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); diff --git a/conf/sccpgeneral.xml b/conf/sccpgeneral.xml index a697f54..d2cc65a 100644 --- a/conf/sccpgeneral.xml +++ b/conf/sccpgeneral.xml @@ -74,8 +74,8 @@ and open the template in the editor. Base Version before all crash :-) Time between Keep Alive checks. Valid range is 60-300 seconds. After much trial-and-error, the minimum (60) seems to work just fine. debug - none - + NONE + @@ -88,8 +88,8 @@ and open the template in the editor. Base Version before all crash :-) permit 0.0.0.0/0.0.0.0 - - + + Allow network settings. Blank fields will be ignored, use Network 0.0.0.0. @@ -98,8 +98,8 @@ and open the template in the editor. Base Version before all crash :-) deny 0.0.0.0/0.0.0.0 - - + + All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'. @@ -108,8 +108,8 @@ and open the template in the editor. Base Version before all crash :-) localnet 0.0.0.0/0.0.0.0 - - + + Local network settings. Blank fields will be ignored used Network 0.0.0.0. @@ -477,14 +477,14 @@ and open the template in the editor. Base Version before all crash :-) musicclass - none + NONE form-control Music Class: Available MOH Classes. These are the MOH classes listed in your current server. dial_template - none + NONE sccp-custom Help. @@ -586,7 +586,7 @@ and open the template in the editor. Base Version before all crash :-) addon - none + 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. @@ -628,7 +628,7 @@ and open the template in the editor. Base Version before all crash :-) addon - none + NONE sccp-custom @@ -836,8 +836,8 @@ and open the template in the editor. Base Version before all crash :-) permit / - - + + Allow network settings. Blank fields will be ignored used Network 0.0.0.0. @@ -846,8 +846,8 @@ and open the template in the editor. Base Version before all crash :-) deny / - - + + All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'. @@ -875,8 +875,8 @@ 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. + + The audio stream will be open in the progress and connected state. Valid options: NONE, progress, offhook, dial, ringout. Default may be Progress. @@ -896,11 +896,11 @@ and open the template in the editor. Base Version before all crash :-) dialtemplate */10/* title - - + + text1 - - + + empty Bellcore-Alerting @@ -986,8 +986,8 @@ and open the template in the editor. Base Version before all crash :-) srst_ip 3 / - - + + @@ -996,8 +996,8 @@ and open the template in the editor. Base Version before all crash :-) srst_sip 3 / - - + + diff --git a/conf/sccpgeneral.xml.v11 b/conf/sccpgeneral.xml.v11 index 54b124b..ebb3637 100644 --- a/conf/sccpgeneral.xml.v11 +++ b/conf/sccpgeneral.xml.v11 @@ -75,8 +75,8 @@ and open the template in the editor. Base Version before all crash :-) Time between Keep Alive checks. Valid range is 60-300 seconds. After much trial-and-error, the minimum (60) seems to work just fine. debug - none - + NONE + @@ -89,8 +89,8 @@ and open the template in the editor. Base Version before all crash :-) permit 0.0.0.0/0.0.0.0 - - + + Alow network settings. Blank fields will be ignored used Network 0.0.0.0. @@ -99,8 +99,8 @@ and open the template in the editor. Base Version before all crash :-) deny 0.0.0.0/0.0.0.0 - - + + All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'. @@ -109,8 +109,8 @@ and open the template in the editor. Base Version before all crash :-) localnet 0.0.0.0/0.0.0.0 - - + + Local network settings. Blank fields will be ignored used Network 0.0.0.0. @@ -201,27 +201,27 @@ and open the template in the editor. Base Version before all crash :-) 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. echocancel - no - - + off + + Echo Cancel: Echo Cancellation (On or Off). silencesuppression - no - - + off + + Silence Suppression: Slience Suppression on the phone. private - yes - - + 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. directed_pickup_modeanswer - no - - + off + + Directed Pickup Mode (Answer): If a call is sent with the "directed pickup" flag, the phone will answer when set to "Yes". callanswerorder @@ -240,9 +240,9 @@ and open the template in the editor. Base Version before all crash :-) Set the MWI lamp style when MWI active to on, off, wink, flash or blink mwioncall - no - - + off + + Set the MWI on call. @@ -250,9 +250,9 @@ and open the template in the editor. Base Version before all crash :-) ntp_config_enabled - no - - + off + + Enabling NTP settings in device configuration. @@ -310,7 +310,7 @@ and open the template in the editor. Base Version before all crash :-) srst_Option - no + off @@ -343,8 +343,8 @@ and open the template in the editor. Base Version before all crash :-) srst_ip 3 / - - + + Help. @@ -353,8 +353,8 @@ and open the template in the editor. Base Version before all crash :-) srst_sip 3 / - - + + Help. @@ -502,9 +502,9 @@ and open the template in the editor. Base Version before all crash :-) hotline_enabled - no - - + off + + Hotline Enabled: This allows unregistered extensions to connect to the system and dial the number listed below. @@ -549,14 +549,14 @@ and open the template in the editor. Base Version before all crash :-) musicclass - none + NONE form-control Music Class: Available MOH Classes. These are the MOH classes listed in your current server. dial_template - none + NONE sccp-custom Help. @@ -564,15 +564,15 @@ and open the template in the editor. Base Version before all crash :-) autoselectline_enabled - no - - + off + + Enables and disables auto line selection. meetme - no - - + off + + enable/disable conferencing via meetme (on/off), make sure you have one of the meetme apps mentioned below activated in module.conf @@ -587,15 +587,15 @@ and open the template in the editor. Base Version before all crash :-) autocall_select - no - - + off + + backgroundImageAccess - no - - + off + + 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. @@ -629,9 +629,9 @@ and open the template in the editor. Base Version before all crash :-) createlangdir - no - - + off + + Say 'yes' if you need to create cisco default language directory in tftp path. @@ -658,7 +658,7 @@ and open the template in the editor. Base Version before all crash :-) addon - none + 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. @@ -700,7 +700,7 @@ and open the template in the editor. Base Version before all crash :-) addon - none + NONE sccp-custom @@ -774,44 +774,44 @@ and open the template in the editor. Base Version before all crash :-) transfer - no - - + off + + Transfer allowed cfwdall - no - - + off + + Activate the callforward softkeys. Default is On cfwdbusy - no - - + off + + Activate the callforward busy softkeys. Default is On - DND + dndFeature - On + on Do Not Disturb. Default is Off directed_pickup - yes + on no - - + + Enable Pickup function to direct pickup an extension. Default is On conf_allow - yes + on no - - + + Allow the use of conference @@ -827,9 +827,9 @@ and open the template in the editor. Base Version before all crash :-) Context where direct pickup search for extensions. if not set current contect will be use. directed_pickup_modeanswer - yes - - + 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' ?????? @@ -838,13 +838,13 @@ and open the template in the editor. Base Version before all crash :-) useRedialMenu - no - - + 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. - + dtmfmode outofband @@ -871,33 +871,33 @@ and open the template in the editor. Base Version before all crash :-) conf_play_general_announce - yes - - + on + + Playback General Announcements (like: 'You are Entering/Leaving the conference') conf_play_part_announce - yes - - + on + + Playback Personal/Participant Announcements, (like: 'You have been muted / You have been kicked') conf_mute_on_entry - no - - + off + + Mute new participants from the start conf_show_conflist - yes - - + on + + Automatically show conference list to the moderator @@ -916,8 +916,8 @@ and open the template in the editor. Base Version before all crash :-) permit / - - + + Alow network settings. Blank fields will be ignored used Network 0.0.0.0. @@ -926,16 +926,16 @@ and open the template in the editor. Base Version before all crash :-) deny / - - + + All RFC 1918 addresses are local networks. Should always be at least '0.0.0.0/0.0.0.0'. nat - none - + auto + Device NAT support (default Auto) @@ -944,8 +944,8 @@ and open the template in the editor. Base Version before all crash :-) directrtp - none - + NONE + This option allow devices to do direct RTP sessions (default Off) @@ -954,13 +954,13 @@ and open the template in the editor. Base Version before all crash :-) 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 strem will be open in the progress and connected state. Valid options: NONE, progress, offhook, dial, ringout. Default may be Progress. @@ -1004,11 +1004,11 @@ and open the template in the editor. Base Version before all crash :-) dialtemplate */10/* title - - + + text1 - - + + empty Bellcore-Alerting diff --git a/install.php b/install.php index 733d163..f896ca5 100644 --- a/install.php +++ b/install.php @@ -41,6 +41,7 @@ function astman_retrieveJSFromMetaData($astman, $segment = "") { } } +function Get_DB_config($sccp_comatable) { $db_config_v0 = array( 'sccpdevmodel' => array( 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), @@ -94,7 +95,7 @@ $db_config_v0 = array( ) ); -$db_config_v3 = array( +$db_config_v5 = array( 'sccpdevmodel' => array( 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'), @@ -161,13 +162,98 @@ $db_config_v3 = array( ) ); +$db_config_v3 = array( + 'sccpdevmodel' => array( + 'enabled' => array('create' => "INT(2) NULL DEFAULT '0'"), + 'nametemplate' => array('create' => 'VARCHAR(50) NULL DEFAULT NULL'), + 'loadinformationid' => array('create' => "VARCHAR(30) NULL DEFAULT NULL" ) + ), + 'sccpdevice' => array( + 'pickupexten' => array('rename' => "directed_pickup"), + 'directed_pickup' => array('create' => " enum('on','off') NOT NULL default 'on'", 'modify' => "enum('on','off')"), + 'pickupcontext' => array('rename' => "directed_pickup_context"), + 'directed_pickup_context' => array('create' => "VARCHAR(100) NULL DEFAULT NULL"), + 'pickupmodeanswer' => array('rename' => "directed_pickup_modeanswer"), + 'directed_pickup_modeanswer' => array('create' => "VARCHAR(5) NULL DEFAULT 'yes'"), + 'hwlang' => array('rename' => "_hwlang"), + '_hwlang' => array('create' => 'varchar(12) NULL DEFAULT NULL'), + 'useRedialMenu' => array('create' => "VARCHAR(5) NULL DEFAULT 'no' AFTER `_hwlang`"), + + //'dtmfmode' => array('create' => "VARCHAR(10) default 'outofband'", 'modify' => "VARCHAR(10)", 'def_modify'=> 'outofband'), + 'dtmfmode' => array('drop' => "yes"), + + 'deny' => array('create' => 'VARCHAR(100) NULL DEFAULT NULL','modify' => "VARCHAR(100)"), + '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('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), + 'cfwdall' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), + 'cfwdbusy' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), + 'directrtp' =>array('create' => "enum('on','off') NULL default 'off'",'modify' => "enum('on','off')"), + 'dndFeature' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), + 'earlyrtp' =>array('create' => "enum('immediate','offHook','dialing','ringout','progress','none') NOT NULL default 'progress'",'modify' => "enum('immediate','offHook','dialing','ringout','progress','none')"), + 'audio_tos'=>array('def_modify' => "0xB8"), + 'audio_cos'=>array('def_modify' => "6"), + 'video_tos'=>array('def_modify' => "0x88"), + 'video_cos'=>array('def_modify' => "5"), + 'trustphoneip'=>array('drop' => "yes"), + + 'mwilamp' =>array('create' => "enum('on','off','wink','flash','blink') default 'on'",'modify' => "enum('on','off','wink','flash','blink')"), + 'mwioncall' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), + 'private' =>array('create' => "enum('on','off') NOT NULL default 'off'",'modify' => "enum('on','off')"), + 'privacy' =>array('create' => "enum('full','on','off') NOT NULL default 'full'",'modify' => "enum('full','on','off')"), + 'nat' =>array('create' => "enum('on','off','auto') NOT NULL default 'auto'",'modify' => "enum('on','off','auto')"), + 'conf_allow' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), + 'conf_play_part_announce' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), + 'conf_mute_on_entry' =>array('create' => "enum('on','off') NOT NULL default 'off'",'modify' => "enum('on','off')"), + 'conf_show_conflist' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), + + 'type' =>array('create' => 'VARCHAR(15) NULL DEFAULT NULL','modify' => "VARCHAR(15)"), + 'imageversion' =>array('create' => 'VARCHAR(31) NULL DEFAULT NULL','modify' => "VARCHAR(31)"), + + 'softkeyset' =>array('def_modify' => "softkeyset") + ), + 'sccpline' => array( + 'namedcallgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `setvar`", 'modify' => "VARCHAR(100)"), + 'namedpickupgroup' =>array('create' => "VARCHAR(100) NULL DEFAULT NULL AFTER `namedcallgroup`", 'modify' => "VARCHAR(100)"), + 'adhocNumber' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `namedpickupgroup`"), + 'meetme' =>array('create' => "VARCHAR(5) NULL DEFAULT NULL AFTER `adhocNumber`"), + 'meetmenum' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetme`"), + 'meetmeopts' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmenum`"), + 'regexten' =>array('create' => "VARCHAR(45) NULL DEFAULT NULL AFTER `meetmeopts`"), + 'rtptos' => array('drop' => "yes"), + 'audio_tos' => array('drop' => "yes"), + 'audio_cos' => array('drop' => "yes"), + 'video_tos' => array('drop' => "yes"), + 'video_cos' => array('drop' => "yes"), + 'incominglimit' =>array('def_modify' => "2"), + 'transfer' =>array('create' => "enum('on','off') NOT NULL default 'on'",'modify' => "enum('on','off')"), + 'vmnum' =>array('def_modify' => "*97"), + 'musicclass' =>array('def_modify' => "default"), + 'id' =>array('create' => 'MEDIUMINT(9) NOT NULL AUTO_INCREMENT, ADD UNIQUE(id);', 'modify' => "MEDIUMINT(9)",'index' =>'id'), +// 'id' =>array('create' => 'VARCHAR( 20 ) NULL DEFAULT NULL', 'modify' => "VARCHAR(20)", 'def_modify' =>"NULL"), + + 'echocancel' =>array('create' => "enum('on','off') NOT NULL default 'off'",'modify' => "enum('on','off')"), + 'silencesuppression' =>array('create' => "enum('on','off') NOT NULL default 'off'",'modify' => "enum('on','off')"), + 'dnd' => array('create' => "enum('off','reject','silent','user') NOT NULL default 'reject'", 'modify' => "enum('off','reject','silent','user')", 'def_modify' =>"reject") + ) +); + if ($sccp_comatable >= 11) { + return $db_config_v3; + } else { + return $db_config_v0; + } +} + $autoincrement = (($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3")) ? "AUTOINCREMENT" : "AUTO_INCREMENT"; $table_req = array('sccpdevice', 'sccpline', 'buttonconfig'); $ss = FreePBX::create()->Sccp_manager; $astman = FreePBX::create()->astman; -$sccp_ver = 0; -$db_config = $db_config_v0; +$sccp_comatable = 0; +//$db_config = $db_config_v0; +$db_config = ''; function CheckSCCPManagerDBTables($table_req) { global $db; @@ -210,69 +296,16 @@ function CheckAsteriskVersion() { return $ver_compatible; } -function CheckChanSCCPVersion() { - global $db_config, $db_config_v0, $db_config_v3, $srvinterface,$astman; +function CheckChanSCCPСomatable() { + global $srvinterface,$astman; if (!$astman) { ie_freepbx('No asterisk manager connection provided!. Installation Failed'); } - $sccp_ver = $srvinterface->get_comatable_sccp(); - outn("
  • " . _("Sccp model Version : ") . $sccp_ver . "
  • "); - if ($sccp_ver >= 11) { - $db_config = $db_config_v3; - } else { - $db_config = $db_config_v0; - } - return $sccp_ver; + $sccp_comatable = $srvinterface->get_comatable_sccp(); + outn("
  • " . _("Sccp model Compatable code : ") . $sccp_comatable . "
  • "); + return $sccp_comatable; } -/* -function CheckChanSCCPVersion() { - global $db_config, $db_config_v0, $db_config_v3, $astman; - if (!$astman) { - ie_freepbx('No asterisk manager connection provided!. Installation Failed'); - } - $metadata = astman_retrieveJSFromMetaData($astman, ""); - // example metadata: - // {"Name":"Chan-sccp-b","Branch":"develop","Version":"4.3.0","RevisionHash":"d3f4482","RevisionNum":"10403","Tag":"v4.2.3-574-gd3f44824","VersioningType":"git","ConfigRevision":"0", - // "ConfigureEnabled": ["park","pickup","realtime","video","conferenence","dirtrfr","feature_monitor","functions","manager_events","devstate_feature","dynamic_speeddial","dynamic_speeddial_cid","experimental","debug"], - // "Segments":["general","device","line","softkey"]} - - if ($metadata && array_key_exists("Version",$metadata)) { - $version_parts=explode(".", $metadata["Version"]); - - # not sure about this sccp_ver numbering. Might be better to just check "Version" and Revision - if ($version_parts[0] == "4") { - $sccp_ver = 400; - $db_config = $db_config_v0; - if ($version_parts[1] == "1") { - $sccp_ver = 410; - } else - if ($version_parts[1] == "2") { - $sccp_ver = 420; - } else - if ($version_parts[1] >= "3") { - $sccp_ver = 430; - } - } - if (array_key_exists("Revision",$metadata)) { // old method - if (base_convert($metadata["Revision"],16,10) == base_convert('702487a',16,10)) { // hash values are random, not incrementa - $sccp_ver = 431; - $db_config = $db_config_v3; - } - } - if (array_key_exists("RevisionNum",$metadata)) { - if ($metadata["RevisionNum"] >= "10403") { // new method, RevisionNum is incremental - $sccp_ver = 432; - $db_config = $db_config_v3; - } - } - } else { - die_freepbx("Version information could not be retrieved from chan-sccp, via astman::SCCPConfigMetaData"); - } - outn("
  • " . _("Sccp Version : ") . $sccp_ver . "
  • "); - return $sccp_ver; -} -*/ function InstallDB_sccpsettings() { global $db; @@ -313,11 +346,55 @@ function InstallDB_sccpdevmodel() { return true; } +/* +function InstallDB_updateEnums($db_config) { + global $db; + if (!$db_config) { + die_freepbx("No db_config provided"); + } + $count_modify = 0; + outn("
  • " . _("Update Database Enums") . "
  • "); + foreach ($db_config as $tabl_name => &$tab_modify) { + $sql = ""; + $sql_r = array(); + foreach ($tab_modify as $row_fld => $row_data){ + if (!empty($row_data['crate'])) { + if (strpos($row_data['crate'], 'enum') !== false) { + $sql_r[] = $row_fld; + } + } + } + $sql = "SELECT " . implode(',', $sql_r) . " from ".$tabl_name; + $db_result= $db->getAll($sql); + if (DB::IsError($db_result)) { + die_freepbx("Can not add get informations from ".$tabl_name." table\n"); + } + $sql_table = ''; + $enum_data = array('true'=>'on','false'=>'off','yes'=>'on','no'=>'off'); + foreach ($db_result as $tabl_data){ + $sql = ""; + foreach( $tabl_data as $row => $col_val){ + $val= strtolower($col_val); + if (isset($enum_data[$val])) { + $sql .= $row.'="'.$enum_data[$val].'",'; + } + } + if (!empty($sql)){ + } + } + + } + +} + +*/ + function InstallDB_updateSchema($db_config) { global $db; if (!$db_config) { die_freepbx("No db_config provided"); } + $count_modify = 0; outn("
  • " . _("Modify Database schema") . "
  • "); foreach ($db_config as $tabl_name => &$tab_modify) { // 0 - name 1-type 4- default @@ -334,6 +411,8 @@ function InstallDB_updateSchema($db_config) { if (strtoupper($tab_modify[$fld_id]['def_modify']) == strtoupper($tabl_data[4])) { $db_config[$tabl_name][$fld_id]['def_mod_stat'] = 'no'; } + } + if (!empty($tab_modify[$fld_id]['modify'])) { if ( strtoupper ($tab_modify[$fld_id]['modify']) == strtoupper($tabl_data[1])) { $db_config[$tabl_name][$fld_id]['mod_stat'] = 'no'; } @@ -352,11 +431,12 @@ function InstallDB_updateSchema($db_config) { if (empty($row_data['status'])) { if (!empty($row_data['create'])) { $sql_create .='ADD COLUMN `'.$row_fld.'` '. $row_data['create'].', '; + $count_modify ++; } } else { if (!empty($row_data['rename'])) { $sql_modify .= 'CHANGE COLUMN `'.$row_fld.'` `'. $row_data['rename'].'` '.$row_data['create'].', '; - + $count_modify ++; } if (!empty($row_data['modify'])) { if (empty($row_data['mod_stat'])) { @@ -366,15 +446,18 @@ function InstallDB_updateSchema($db_config) { $sql_modify .= "CHANGE COLUMN `".$row_fld."` `".$row_fld."` ".$row_data['modify']." DEFAULT '".$row_data['def_modify']."', "; } $row_data['def_mod_stat'] = 'no'; + $count_modify ++; } } if (!empty($row_data['def_modify'])) { if (empty($row_data['def_mod_stat'])) { $sql_modify .= "ALTER COLUMN `".$row_fld."` SET DEFAULT '".$row_data['def_modify']."', "; + $count_modify ++; } } if (!empty($row_data['drop'])) { $sql_create .='DROP COLUMN `'.$row_fld.'`, '; + $count_modify ++; } } @@ -397,6 +480,7 @@ function InstallDB_updateSchema($db_config) { } } } + outn("
  • " . _("Modify count :") .$count_modify. "
  • "); return true; } @@ -452,11 +536,11 @@ function InstallDB_createButtonConfigTrigger() { return true; } -function InstallDB_CreateSccpDeviceConfigView($sccp_ver) { +function InstallDB_CreateSccpDeviceConfigView($sccp_comatable) { global $db; outn("
  • " . _("(Re)Create sccpdeviceconfig view") . "
  • "); $sql = ""; - if ($sccp_ver < 430) { + if ($sccp_comatable < 11) { $sql= " CREATE OR REPLACE ALGORITHM = MERGE @@ -501,14 +585,15 @@ function InstallDB_CreateSccpDeviceConfigView($sccp_ver) { CheckSCCPManagerDBTables($table_req); CheckPermissions(); CheckAsteriskVersion(); -$sccp_ver = CheckChanSCCPVersion(); +$sccp_comatable = CheckChanSCCPСomatable(); +$db_config = Get_DB_config($sccp_comatable); InstallDB_sccpsettings(); InstallDB_sccpdevmodel(); InstallDB_updateSchema($db_config); InstallDB_fillsccpdevmodel(); InstallDB_updateSccpDevice(); InstallDB_createButtonConfigTrigger(); -InstallDB_CreateSccpDeviceConfigView($sccp_ver); +InstallDB_CreateSccpDeviceConfigView($sccp_comatable); outn("
    "); // $ss->save_submit($request); diff --git a/views/advserver.model.php b/views/advserver.model.php index a742931..3830902 100644 --- a/views/advserver.model.php +++ b/views/advserver.model.php @@ -207,7 +207,7 @@ return (value === '1') ? '">' : '">'; } function DisplayDnsFormatter(value, row, index) { - var exp_model = ['Expansion Module', 'No awalable', 'One ExpModule', 'Tow ExpModule']; + var exp_model = ['Expansion Module', 'Not Available', 'One ExpModule', 'Two ExpModule']; return exp_model[value]; }