From 5d725b4e134030b390739680c0b45cc1fe8a14ae Mon Sep 17 00:00:00 2001 From: PhantomVl Date: Tue, 17 Apr 2018 15:59:18 +0300 Subject: [PATCH] In the install script, added the mysql parameter search. Added the ability to read the configuration of the "tftp-rewrite" from external config file --- README.md | 8 ++ Sccp_manager.class.php | 59 +++++++++++-- Sccp_manager.inc/extconfigs.class.php | 119 ++++++++++++++++++++++++++ assets/js/sccp_manager.js | 27 ++++++ conf/sccpgeneral.xml.v431 | 36 +++++++- install.php | 7 +- module.xml | 5 +- views/formShow.php | 34 ++++++-- views/server.info.php | 12 +++ 9 files changed, 292 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index ac69537..8126c1f 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ This module will suit you if you are planing the to migrate from CallManager to You can control phone buttons (depending on the phone model) assigning multiple lines, speeddials and BLF’s. And you can use the driver functions "sccp_chain" from the GUI module. +### Wiki +You can find more information and documentation on our [![Wiki](https://img.shields.io/badge/Wiki-new-blue.svg)](https://github.com/PhantomVl/sccp_manager/wiki) ### Prerequisites Make sure you have the following installed on your system: @@ -77,6 +79,12 @@ Make sure you have the following installed on your system: 8. Close Status window. 9. Apply Config to FreePBX. +### Module update to latest state +1. Goto to module into your local system. (/var/www/html/admin/module/sccp_manager/) + cd /var/www/html/admin/module/sccp_manager/ + git fetch + git pull + ### IMPORTANT NOTES: - This system assumes/requires that you are using the Asterisk realtime database. If you are not yet using the realtime database, you will have to set it up for this module to work ([See](https://github.com/chan-sccp/chan-sccp/wiki/Realtime-Configuration)). diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php index 2d1defc..1c7bc51 100644 --- a/Sccp_manager.class.php +++ b/Sccp_manager.class.php @@ -1520,7 +1520,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { */ // !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 init_sccp_path() { global $db; global $amp_conf; @@ -1534,6 +1534,52 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } + $driver = $this->FreePBX->Core->getAllDriversInfo(); + $sccp_driver_replace= ''; + if (empty($driver['sccp'])) { + $sccp_driver_replace = 'yes'; + } else { + if (empty($driver['sccp']['Version'])) { + $sccp_driver_replace = 'yes'; + } else { + if ($driver['sccp']['Version'] != $this->sccp_driver_ver) { + $sccp_driver_replace = 'yes'; + } + } + } + + $this->sccpvalues['sccp_compatible'] = array('keyword' => 'compatible', 'data' => $this->srvinterface->get_compatible_sccp(), 'type' => '1', 'seq' => '99'); +// $this->sccpvalues['sccp_compatible'] = '11'; + + $this->sccppath = $this->extconfigs->validate_init_path($confDir, $this->sccpvalues, $sccp_driver_replace); + + $driver = $this->FreePBX->Core->getAllDriversInfo(); // ?????? + + $read_config = $this->cnf_read->getConfig('sccp.conf'); + $this->sccp_conf_init['general'] = $read_config['general']; + foreach ($read_config as $key => $value) { + if (isset($read_config[$key]['type'])) { // copy soft key + if ($read_config[$key]['type'] == 'softkeyset') { + $this->sccp_conf_init[$key] = $read_config[$key]; + } + } + } + + } +/* OLD INI + function init_sccp_path1() { + global $db; + global $amp_conf; + + $confDir = $amp_conf["ASTETCDIR"]; + if (empty($this->sccppath["asterisk"])) { + if (strlen($confDir) < 1) { + $this->sccppath["asterisk"] = "/etc/asterisk"; + } else { + $this->sccppath["asterisk"] = $confDir; + } + } + if (empty($this->sccppath["sccp_conf"])) { $this->sccppath["sccp_conf"] = $this->sccppath["asterisk"] . "/sccp.conf"; } @@ -1599,7 +1645,7 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } -/* if (!empty($this->sccppath["tftp_path"])) { + if (!empty($this->sccppath["tftp_path"])) { $this->sccppath["tftp_DP"] = $this->sccppath["tftp_path"] . '/Dialplan'; if (!file_exists($this->sccppath["tftp_DP"])) { if (!mkdir($this->sccppath["tftp_DP"], 0777, true)) { @@ -1607,7 +1653,8 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } -*/ + + if (empty($_SERVER['DOCUMENT_ROOT'])) { return; } @@ -1666,10 +1713,10 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO { } } } - -// $this->sccp_conf_init = @parse_ini_file($this->sccppath["sccp_conf"], true); + + // $this->sccp_conf_init = @parse_ini_file($this->sccppath["sccp_conf"], true); } - +*/ /* * DialPlan * diff --git a/Sccp_manager.inc/extconfigs.class.php b/Sccp_manager.inc/extconfigs.class.php index 38b3cd7..ba13b07 100644 --- a/Sccp_manager.inc/extconfigs.class.php +++ b/Sccp_manager.inc/extconfigs.class.php @@ -211,4 +211,123 @@ class extconfigs { 'New Zealand' => array('offset' => '720', 'daylight' => 'Daylight') ); + + public function validate_init_path($confDir = '', $db_vars, $sccp_driver_replace='') { +// global $db; +// global $amp_conf; +// *** Setings for Provision Sccp + $adv_config = Array('tftproot' => '', 'firmware' => 'firmware', 'settings' => 'settings', + 'locales' => 'locales', 'languages' => 'languages', 'templates' => 'templates'); + $adv_tree['pro'] = Array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales'); + $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'tftproot'); +//* **************------ **** + $base_tree = Array('tftp_templates' => 'templates', 'tftp_path_store' => 'settings', 'tftp_lang_path' => 'languages', 'tftp_firmware_path'=>'firmware'); + + + if (empty($confDir)) { + return array('error' => 'empty СonfDir' ); + } + + $base_config = Array( 'asterisk' => $confDir, 'sccp_conf' => $confDir . '/sccp.conf', 'tftp_path' => ''); + + + 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"])) { + return array('error' => 'empty tftp_path' ); + } + 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 = 'pro'; + } + foreach ($adv_tree[$adv_tree_mode] as $key => $value) { + if (!empty($adv_config[$key])) { + if (substr($adv_config[$key],0,1) != "/") { + $adv_config[$key] = $adv_config[$value].'/'.$adv_config[$key]; + } + } + } + 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]); + } + } + } + +// $base_config['External_ini'] = $adv_config; +// $base_config['External_mode'] = $adv_tree_mode; + +/* + if (!empty($this->sccppath["tftp_path"])) { + $this->sccppath["tftp_DP"] = $this->sccppath["tftp_path"] . '/Dialplan'; + if (!file_exists($this->sccppath["tftp_DP"])) { + if (!mkdir($this->sccppath["tftp_DP"], 0777, true)) { + die('Error creating DialPlan template dir'); + } + } + } +*/ + // TFTP -REWrite double model + if (empty($_SERVER['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)); + } + } + + + $dst = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/core/functions.inc/drivers/Sccp.class.php'; + if (!file_exists($dst) || $sccp_driver_replace == 'yes') { + $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst) . '.v' . $this->sccpvalues['sccp_compatible']['data']; + if (file_exists($src_path)) { + copy($src_path, $dst); + } else { + $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst); + copy($src_path, $dst); + } + } + + if (!file_exists($base_config["sccp_conf"])) { // System re Config + $sccpfile = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/sccp.conf'); + file_put_contents($base_config["sccp_conf"], $sccpfile); + } + + return $base_config; + } } + diff --git a/assets/js/sccp_manager.js b/assets/js/sccp_manager.js index 632a140..54811a3 100644 --- a/assets/js/sccp_manager.js +++ b/assets/js/sccp_manager.js @@ -323,6 +323,19 @@ $(document).ready(function () { } }); } + + dev_id = $(this).data('vshow'); + if (dev_state == 'checked'){ + dev_class = $(this).data('clshow'); + $(dev_class).each(function () { + if (dev_val == dev_id) { + $(this).removeClass('hidden'); + $(this).removeAttr('hidden') + } else { + $(this).addClass('hidden'); + } + }); + } }); $('.sccp_button_hide').on('click', function (e) { var dev_id = $(this).data('vhide'); @@ -339,6 +352,20 @@ $(document).ready(function () { $(this).addClass('hidden'); } }); + + dev_id = $(this).data('vshow'); + if (dev_id !== ''){ + dev_class = $(this).data('clshow'); + $(dev_class).each(function () { + if (dev_val == dev_id) { + $(this).removeClass('hidden'); + $(this).removeAttr('hidden') + } else { + $(this).addClass('hidden'); + } + }); + } + }); $('.sccp_button_disabled').each(function () { // On page create !! diff --git a/conf/sccpgeneral.xml.v431 b/conf/sccpgeneral.xml.v431 index 1b92055..a7331c9 100644 --- a/conf/sccpgeneral.xml.v431 +++ b/conf/sccpgeneral.xml.v431 @@ -3,6 +3,23 @@ To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. Base Version before all crash :-) + * IE - Text Input + * IED - Text Input Dynamic + * ITED- Input Dynamic Table + * IS - Radio box + * SL - Select element + * SLA - Select element (from - data ) + * Input element Select SLD - Date format + * SLZ - Time Zone + * SLZN - Time Zone List + * SLT - TFTP Lang + * SLM - Music on hold + * SLK - System KeySet + * * Input element Select SLS - System Language + * Input element Select SDM - Model List + * SDE - Extension List + * Help elemen HLP - Help Element + --> @@ -817,6 +834,7 @@ and open the template in the editor. Base Version before all crash :-) + provision_hide tftp_path /tftpboot @@ -824,15 +842,29 @@ and open the template in the editor. Base Version before all crash :-) 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 + + Support the use of regular-expression-based filename remapping - + devicetable diff --git a/install.php b/install.php index 64a41f4..cc617f4 100644 --- a/install.php +++ b/install.php @@ -547,13 +547,18 @@ function Setup_RealTime() { $def_bd_sec = 'sccp'; $dir = $cnf_int->get('ASTETCDIR'); - + $res_conf_sql = ini_get('pdo_mysql.default_socket'); $res_conf_old = ''; $res_conf = ''; $ext_conf = ''; if (file_exists($dir . '/extconfig.conf')) { $ext_conf = $cnf_read->getConfig('extconfig.conf'); } + if (!empty($res_conf_sql)) { + if (!file_exists($res_conf_sql)) { + $def_bd_config['dbsock'] = $res_conf_sql; + } + } if (!empty($ext_conf)) { $tmp = array(); diff --git a/module.xml b/module.xml index 1e4405f..4c607b7 100644 --- a/module.xml +++ b/module.xml @@ -5,6 +5,7 @@ setup SCCP Connectivity Alex GP + extended SCCP Phone and Extension Manager Server Config @@ -18,6 +19,8 @@ 13.0.0.1 - + + https://github.com/PhantomVl/sccp_manager + GPL diff --git a/views/formShow.php b/views/formShow.php index 31a64f1..6f10a10 100644 --- a/views/formShow.php +++ b/views/formShow.php @@ -83,6 +83,12 @@ foreach ($items as $child) { $res_input = ''; $res_name = ''; $res_id = $npref.$child->input[0]->name; + // --- Add Hiden option + $res_sec_class =''; + if (!empty($child ->class)){ + $res_sec_class = (string)$child ->class; + } + if (empty($child->nameseparator)) { $child->nameseparator = ' / '; } @@ -92,7 +98,7 @@ foreach ($items as $child) { ?>
-
+
@@ -206,7 +212,14 @@ foreach ($items as $child) { 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'].'" '; @@ -287,11 +300,16 @@ foreach ($items as $child) { if ($child['type'] == 'IS') { $res_n = (string)$child->name; $res_id = $npref.$child->name; - + // --- Add Hiden option + $res_sec_class =''; + if (!empty($child ->class)){ + $res_sec_class = (string)$child ->class; + } + echo ''; ?>
-
+
@@ -315,8 +333,14 @@ foreach ($items as $child) { } } if (!empty($child->option_hide)) { - $opt_hide = ' class="sccp_button_hide" data-vhide="'.$child->option_hide.'" data-clhide="'.$child->option_hide['class'].'" '; + $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 = (string)$value[@value]; if ($val_check == '' || $val_check == 'NONE' || $val_check == 'none' ) { diff --git a/views/server.info.php b/views/server.info.php index f186d0f..2c07915 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -19,9 +19,21 @@ $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['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about'=> 'Asterisk.'); +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'); + } +} $info['Сompatible'] = array('Version' => $this->srvinterface->get_compatible_sccp(), 'about'=> ''); //print_r($this->dbinterface->info()); +//print(""); + //print_r("
Request:
");
+ //$asss = $this->extconfigs->validate_init_path($this->sccppath["asterisk"],$this->sccpvalues,$driver_ver);
+ //print_r($asss);
+ //print("
"); // $lang_arr = $this->extconfigs->getextConfig('sccp_lang','sk_SK'); // print_r('
');