From 55285cf62594fb3cea36ff54f51d51e65a61554c Mon Sep 17 00:00:00 2001
From: steve-lad <72376554+steve-lad@users.noreply.github.com>
Date: Sun, 20 Jun 2021 08:54:23 +0200
Subject: [PATCH] Move install functions from sccp_manager to installer
Change core driver to be an include
Move driver to sccpManClasses to improve maintainability and eliminate possible version issues
Add driver in installer (remove
from extConfigs)
Create sccp.conf in installer if it does not exist (remove from extconfigs)
Update extconfigs.class.php
Update Sccp.class.php.v433
---
Sccp_manager.class.php | 15 +--
install.php | 16 +++
module.xml | 2 +-
{conf => sccpManClasses}/Sccp.class.php.v433 | 9 +-
sccpManClasses/extconfigs.class.php | 100 ++++++++-----------
5 files changed, 65 insertions(+), 77 deletions(-)
rename {conf => sccpManClasses}/Sccp.class.php.v433 (98%)
diff --git a/Sccp_manager.class.php b/Sccp_manager.class.php
index ed7000a..c1de6b0 100644
--- a/Sccp_manager.class.php
+++ b/Sccp_manager.class.php
@@ -976,22 +976,9 @@ class Sccp_manager extends \FreePBX_Helpers implements \BMO {
}
$driver = $this->FreePBX->Core->getAllDriversInfo();
- // Below is always set to replace; good for Develop, but needs to be updated for release
- $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 . $driver_revision[$ver_id]) {
- $sccp_driver_replace = 'yes';
- }
- }
- }
$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, $sccp_driver_replace);
+ $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 f80a411..174545a 100644
--- a/install.php
+++ b/install.php
@@ -65,6 +65,7 @@ if ($chanSCCPWarning) {
outn("Error: installed version of chan-sccp is not compatible. Please upgrade chan-sccp");
}
Setup_RealTime();
+addDriver($sccp_compatible);
outn("
");
outn("Install Complete !");
outn("
");
@@ -851,4 +852,19 @@ function Setup_RealTime()
}
}
+function addDriver($sccp_compatible) {
+ outn("
" . _("Adding driver ...") . "");
+ $file = "/var/www/html/admin/modules/core/functions.inc/drivers/Sccp.class.php";
+ $contents = "";
+ file_put_contents($file, $contents);
+
+ $cnf_int = \FreePBX::Config();
+ $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');
+ file_put_contents("{$dir}/sccp.conf", $sccpfile);
+ }
+}
+
?>
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/conf/Sccp.class.php.v433 b/sccpManClasses/Sccp.class.php.v433
similarity index 98%
rename from conf/Sccp.class.php.v433
rename to sccpManClasses/Sccp.class.php.v433
index e2377ca..1c80f4b 100644
--- a/conf/Sccp.class.php.v433
+++ b/sccpManClasses/Sccp.class.php.v433
@@ -2,9 +2,12 @@
// vim: set ai ts=4 sw=4 ft=php:
// Version for SCCP Manager 13.0.X
//
-// Template for Sccp Driver
-/*
- * Required Functions for Core Drivers
+/* This is the driver for Sccp_manager in FreePBX.
+ It is loaded via an include, written by the installer, at
+ modules/core/functions.inc/drivers
+ and provides the following required methods. it provides the interface between
+ FreePBX extensions and sccp_manager lines
+ *
* getInfo
* addDevice
* delDevice
diff --git a/sccpManClasses/extconfigs.class.php b/sccpManClasses/extconfigs.class.php
index c969263..e2cc40d 100644
--- a/sccpManClasses/extconfigs.class.php
+++ b/sccpManClasses/extconfigs.class.php
@@ -15,9 +15,9 @@ class extconfigs
}
public function info() {
- $Ver = '13.1.1';
+ $Ver = '13.2.0';
return array('Version' => $Ver,
- 'about' => 'Default Setings and Enums ver: ' . $Ver);
+ 'about' => 'Default Settings and Enums ver: ' . $Ver);
}
public function getextConfig($id = '', $index = '') {
@@ -216,36 +216,50 @@ class extconfigs
'New Zealand' => array('offset' => '720', 'daylight' => true)
);
- 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', 'dialplan' => 'dialplan', 'softkey' => 'softkey');
-// 'pro' /tftpboot - root dir
-// /tftpboot/locales/locales/%Languge_name%
-// /tftpboot/settings/XMLdefault.cnf.xml
-// /tftpboot/settings/SEP[MAC].cnf.xml
-// /tftpboot/firmware/79xx/SCCPxxxx.loads
- $adv_tree['pro'] = array('templates' => 'tftproot', 'settings' => 'tftproot', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'locales', 'dialplan' => 'tftproot', 'softkey' => 'tftproot');
+ 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'
+ );
-// 'def' /tftpboot - root dir
-// /tftpboot/languages/%Languge_name%
-// /tftpboot/XMLdefault.cnf.xml
-// /tftpboot/SEP[MAC].cnf.xml
-// /tftpboot/SCCPxxxx.loads
- $adv_tree['def'] = array('templates' => 'tftproot', 'settings' => '', 'locales' => '', 'firmware' => '', 'languages' => 'tftproot', 'dialplan' => '', 'softkey' => '');
-// $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => '');
-// $adv_tree['def'] = Array('templates' => 'tftproot', 'settings' => '', 'locales' => 'tftproot', 'firmware' => 'tftproot', 'languages' => 'tftproot');
-//* **************------ ****
- $base_tree = array('tftp_templates' => 'templates', 'tftp_path_store' => 'settings', 'tftp_lang_path' => 'languages', 'tftp_firmware_path' => 'firmware', 'tftp_dialplan' => 'dialplan', 'tftp_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' => '');
+ $base_config = array('asterisk' => $confDir,
+ 'sccp_conf' => "$confDir/sccp.conf",
+ 'tftp_path' => '');
// Test Base dir (/tftproot)
if (!empty($db_vars["tftp_path"])) {
@@ -314,21 +328,7 @@ class extconfigs
}
}
}
- print_r($base_config, 1);
-// die(print_r($base_config,1));
-// $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'])) {
if (!empty($this->paren_class)) {
@@ -345,27 +345,9 @@ class extconfigs
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' . $db_vars['sccp_compatible']['data'];
- if (file_exists($src_path)) {
- copy($src_path, $dst);
- } else {
- // Set new default
- $src_path = $_SERVER['DOCUMENT_ROOT'] . '/admin/modules/sccp_manager/conf/' . basename($dst) . '.v433';
- 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;
}
- // Type declaration in below function is incompatible with PHP 5
+
public function validate_RealTime( $connector )
{
// This method only checks that asterisk is correctly configured for Realtime