From 758206164582b41339c0240814ca9863b4fc319c Mon Sep 17 00:00:00 2001 From: PhantomVl Date: Mon, 25 Mar 2019 18:16:17 +0300 Subject: [PATCH] Initial add of feature mobility user table: - Add extra user fields and sccp_config entries - Create new buttonconfig table - Add PhoneCodepages like cp1251 - Add BackUp Config before Install --- install.php | 34 +++++++--------------------------- uninstall.php | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/install.php b/install.php index 692b13d..f31ca9e 100644 --- a/install.php +++ b/install.php @@ -714,7 +714,8 @@ DELIMITER ;";*/ if (DB::IsError($check)) { die_freepbx("Can not modify sccpdevice table\n"); } - outn("
  • " . $sql . "
  • "); + outn("
  • " . _("(Re)Create trigger Ok") . "
  • "); +// outn("
  • " . $sql . "
  • "); return true; } function InstallDB_updateDBVer($sccp_compatible) { @@ -797,13 +798,9 @@ function CreateBackUpConfig() { global $amp_conf; outn("
  • " . _("Create Config BackUp") . "
  • "); $cnf_int = \FreePBX::Config(); - $backup_files = array('extensions','extconfig','res_mysql', 'res_config_mysql','sccp','sccp_hardware','sccp_extensions'); + $backup_files = array('extconfig','extconfig','res_mysql', 'res_config_mysql','sccp'); $backup_ext = array('_custom.conf', '.conf'); $dir = $cnf_int->get('ASTETCDIR'); - - $fsql = $dir.'/sccp_backup_'.date("Ymd").'.sql'; - $result = exec('mysqldump '.$amp_conf['AMPDBNAME'].' --password='.$amp_conf['AMPDBPASS'].' --user='.$amp_conf['AMPDBUSER'].' --single-transaction >'.$fsql ,$output); - $zip = new \ZipArchive(); $filename = $dir . "/sccp_instal_backup" . date("Ymd"). ".zip"; if ($zip->open($filename, \ZIPARCHIVE::CREATE)) { @@ -814,33 +811,13 @@ function CreateBackUpConfig() { } } } - if (file_exists($fsql)) { - $zip->addFile($fsql); - } $zip->close(); } else { outn("
  • " . _("Error Create BackUp: ") . $filename ."
  • "); } - unlink($fsql); outn("
  • " . _("Create Config BackUp: ") . $filename ."
  • "); } -function RenameConfig() { - global $amp_conf; - outn("
  • " . _("Move Old Config") . "
  • "); - $cnf_int = \FreePBX::Config(); - $rename_files = array('sccp_hardware','sccp_extensions'); - $rename_ext = array('_custom.conf', '.conf'); - $dir = $cnf_int->get('ASTETCDIR'); - foreach ($rename_files as $file) { - foreach ($rename_ext as $b_ext) { - if (file_exists($dir . '/'.$file . $b_ext)) { - rename($dir . '/'.$file . $b_ext, $dir . '/'.$file . $b_ext.'.old'); - } - } - } -} - function Setup_RealTime() { global $amp_conf; outn("
  • " . _("Pre config RealTime") . "
  • "); @@ -852,7 +829,7 @@ function Setup_RealTime() { $def_config = array('sccpdevice' => 'mysql,sccp,sccpdeviceconfig', 'sccpline' => ' mysql,sccp,sccpline'); $def_bd_config = array('dbhost' => $amp_conf['AMPDBHOST'], 'dbname' => $amp_conf['AMPDBNAME'], 'dbuser' => $amp_conf['AMPDBUSER'], 'dbpass' => $amp_conf['AMPDBPASS'], - 'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock', 'dbcharset'=>'utf8'); + 'dbport' => '3306', 'dbsock' => '/var/lib/mysql/mysql.sock','dbcharset'=>'utf8'); $def_bd_sec = 'sccp'; $dir = $cnf_int->get('ASTETCDIR'); @@ -929,6 +906,9 @@ if ($sccp_compatible == 0) { $db_config = Get_DB_config($sccp_compatible); $sccp_db_ver = CheckSCCPManagerDBVersion(); +// BackUp Old config +CreateBackUpConfig(); + InstallDB_sccpusers(); InstallDB_Buttons(); InstallDB_sccpsettings(); diff --git a/uninstall.php b/uninstall.php index 340e7dd..6090e0f 100644 --- a/uninstall.php +++ b/uninstall.php @@ -5,6 +5,31 @@ /* !TODO!: This would require the install.php to make a note of all the actions that were skipped and/or performed */ /* !TODO!: Might be a good idea to create a backup of the database before removing anything */ // !TODO!: -TODO-: I remove only that which is related to the Manager, it is in my opinion not a critical configuration information. This information is partially present in other files. +/* +function CreateBackUpConfig() { + global $amp_conf; + outn("
  • " . _("Create Config BackUp") . "
  • "); + $cnf_int = \FreePBX::Config(); + $backup_files = array('extconfig','extconfig','res_mysql', 'res_config_mysql','sccp'); + $backup_ext = array('_custom.conf', '.conf'); + $dir = $cnf_int->get('ASTETCDIR'); + $zip = new \ZipArchive(); + $filename = $dir . "/sccp_uninstall_backup" . date("Ymd"). ".zip"; + if ($zip->open($filename, \ZIPARCHIVE::CREATE)) { + foreach ($backup_files as $file) { + foreach ($backup_ext as $b_ext) { + if (file_exists($dir . '/'.$file . $b_ext)) { + $zip->addFile($dir . '/'.$file . $b_ext); + } + } + } + $zip->close(); + } else { + outn("
  • " . _("Error Create BackUp: ") . $filename ."
  • "); + } + outn("
  • " . _("Create Config BackUp: ") . $filename ."
  • "); +} +*/ if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } global $db;