Remove save_module_xml() function and move it it into the modules class as the xml method. Eventual goal move everything out of switch.php.
This commit is contained in:
parent
db697b8342
commit
c92606353e
|
|
@ -34,15 +34,13 @@
|
||||||
|
|
||||||
//use the module class to get the list of modules from the db and add any missing modules
|
//use the module class to get the list of modules from the db and add any missing modules
|
||||||
if (isset($_SESSION['switch']['mod']['dir'])) {
|
if (isset($_SESSION['switch']['mod']['dir'])) {
|
||||||
$mod = new modules;
|
$module = new modules;
|
||||||
$mod->db = $db;
|
$module->db = $db;
|
||||||
$mod->dir = $_SESSION['switch']['mod']['dir'];
|
$module->dir = $_SESSION['switch']['mod']['dir'];
|
||||||
$mod->get_modules();
|
$module->get_modules();
|
||||||
$mod->synch();
|
$module->synch();
|
||||||
$msg = $mod->msg;
|
$module->xml();
|
||||||
|
$msg = $module->msg;
|
||||||
//save the modules.conf
|
|
||||||
save_module_xml();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||||
$db->exec(check_sql($sql));
|
$db->exec(check_sql($sql));
|
||||||
unset($sql);
|
unset($sql);
|
||||||
|
|
||||||
save_module_xml();
|
$module new modules;;
|
||||||
|
$module->xml();
|
||||||
|
|
||||||
$_SESSION["message"] = $text['message-add'];
|
$_SESSION["message"] = $text['message-add'];
|
||||||
header("Location: modules.php");
|
header("Location: modules.php");
|
||||||
|
|
@ -134,7 +135,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
||||||
$db->exec(check_sql($sql));
|
$db->exec(check_sql($sql));
|
||||||
unset($sql);
|
unset($sql);
|
||||||
|
|
||||||
save_module_xml();
|
$module new modules;;
|
||||||
|
$module->xml();
|
||||||
|
|
||||||
$_SESSION["message"] = $text['message-update'];
|
$_SESSION["message"] = $text['message-update'];
|
||||||
header("Location: modules.php");
|
header("Location: modules.php");
|
||||||
|
|
|
||||||
|
|
@ -89,18 +89,18 @@ if($fp){
|
||||||
}
|
}
|
||||||
|
|
||||||
//use the module class to get the list of modules from the db and add any missing modules
|
//use the module class to get the list of modules from the db and add any missing modules
|
||||||
$mod = new modules;
|
$module = new modules;
|
||||||
$mod->db = $db;
|
$module->db = $db;
|
||||||
$mod->dir = $_SESSION['switch']['mod']['dir'];
|
$module->dir = $_SESSION['switch']['mod']['dir'];
|
||||||
$mod->get_modules();
|
$module->get_modules();
|
||||||
$result = $mod->modules;
|
$result = $module->modules;
|
||||||
$module_count = count($result);
|
$module_count = count($result);
|
||||||
$mod->synch();
|
$module->synch();
|
||||||
$msg = $mod->msg;
|
$module->xml();
|
||||||
|
$msg = $module->msg;
|
||||||
|
|
||||||
//show the msg
|
//show the msg
|
||||||
if ($msg) {
|
if ($msg) {
|
||||||
save_module_xml();
|
|
||||||
echo "<div align='center'>\n";
|
echo "<div align='center'>\n";
|
||||||
echo "<table width='40%'>\n";
|
echo "<table width='40%'>\n";
|
||||||
echo "<tr>\n";
|
echo "<tr>\n";
|
||||||
|
|
|
||||||
|
|
@ -736,7 +736,6 @@ include "root.php";
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
if ($module_found) {
|
if ($module_found) {
|
||||||
//save_module_xml();
|
|
||||||
$msg = "<strong>Added New Modules:</strong><br />\n";
|
$msg = "<strong>Added New Modules:</strong><br />\n";
|
||||||
$msg .= "<ul>\n";
|
$msg .= "<ul>\n";
|
||||||
$msg .= $modules_new;
|
$msg .= $modules_new;
|
||||||
|
|
@ -745,6 +744,50 @@ include "root.php";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//save the modules.conf.xml file
|
||||||
|
function xml() {
|
||||||
|
//set the globals
|
||||||
|
global $config, $domain_uuid;
|
||||||
|
|
||||||
|
//get the database connection
|
||||||
|
require_once "resources/classes/database.php";
|
||||||
|
$database = new database;
|
||||||
|
$database->connect();
|
||||||
|
$db = $database->db;
|
||||||
|
|
||||||
|
$xml = "<configuration name=\"modules.conf\" description=\"Modules\">\n";
|
||||||
|
$xml .= " <modules>\n";
|
||||||
|
|
||||||
|
$sql = "select * from v_modules ";
|
||||||
|
$sql .= "order by module_order ASC, ";
|
||||||
|
$sql .= "module_category ASC";
|
||||||
|
$prep_statement = $db->prepare(check_sql($sql));
|
||||||
|
$prep_statement->execute();
|
||||||
|
$prev_module_cat = '';
|
||||||
|
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
foreach ($result as $row) {
|
||||||
|
if ($prev_module_cat != $row['module_category']) {
|
||||||
|
$xml .= "\n <!-- ".$row['module_category']." -->\n";
|
||||||
|
}
|
||||||
|
if ($row['module_enabled'] == "true"){
|
||||||
|
$xml .= " <load module=\"".$row['module_name']."\"/>\n";
|
||||||
|
}
|
||||||
|
$prev_module_cat = $row['module_category'];
|
||||||
|
}
|
||||||
|
$xml .= "\n";
|
||||||
|
$xml .= " </modules>\n";
|
||||||
|
$xml .= "</configuration>";
|
||||||
|
|
||||||
|
$fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/modules.conf.xml","w");
|
||||||
|
fwrite($fout, $xml);
|
||||||
|
unset($xml);
|
||||||
|
fclose($fout);
|
||||||
|
|
||||||
|
//apply settings
|
||||||
|
$_SESSION["reload_xml"] = true;
|
||||||
|
|
||||||
|
}
|
||||||
} //class
|
} //class
|
||||||
|
|
||||||
//add the database structure
|
//add the database structure
|
||||||
|
|
|
||||||
|
|
@ -378,52 +378,6 @@ function save_gateway_xml() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function save_module_xml() {
|
|
||||||
global $config, $domain_uuid;
|
|
||||||
|
|
||||||
//get the database connection
|
|
||||||
require_once "resources/classes/database.php";
|
|
||||||
$database = new database;
|
|
||||||
$database->connect();
|
|
||||||
$db = $database->db;
|
|
||||||
|
|
||||||
$xml = "";
|
|
||||||
$xml .= "<configuration name=\"modules.conf\" description=\"Modules\">\n";
|
|
||||||
$xml .= " <modules>\n";
|
|
||||||
|
|
||||||
$sql = "select * from v_modules ";
|
|
||||||
$sql .= "order by module_order ASC, ";
|
|
||||||
$sql .= "module_category ASC";
|
|
||||||
$prep_statement = $db->prepare(check_sql($sql));
|
|
||||||
$prep_statement->execute();
|
|
||||||
$prev_module_cat = '';
|
|
||||||
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
foreach ($result as $row) {
|
|
||||||
if ($prev_module_cat != $row['module_category']) {
|
|
||||||
$xml .= "\n <!-- ".$row['module_category']." -->\n";
|
|
||||||
}
|
|
||||||
if ($row['module_enabled'] == "true"){
|
|
||||||
$xml .= " <load module=\"".$row['module_name']."\"/>\n";
|
|
||||||
}
|
|
||||||
$prev_module_cat = $row['module_category'];
|
|
||||||
}
|
|
||||||
$xml .= "\n";
|
|
||||||
$xml .= " </modules>\n";
|
|
||||||
$xml .= "</configuration>";
|
|
||||||
|
|
||||||
$fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/modules.conf.xml","w");
|
|
||||||
fwrite($fout, $xml);
|
|
||||||
unset($xml);
|
|
||||||
fclose($fout);
|
|
||||||
|
|
||||||
//apply settings
|
|
||||||
$_SESSION["reload_xml"] = true;
|
|
||||||
|
|
||||||
//$cmd = "api reloadxml";
|
|
||||||
//event_socket_request_cmd($cmd);
|
|
||||||
//unset($cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
function save_var_xml() {
|
function save_var_xml() {
|
||||||
global $config, $domain_uuid;
|
global $config, $domain_uuid;
|
||||||
|
|
||||||
|
|
@ -1478,7 +1432,8 @@ if (!function_exists('save_switch_xml')) {
|
||||||
save_setting_xml();
|
save_setting_xml();
|
||||||
}
|
}
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/modules/app_config.php")) {
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/modules/app_config.php")) {
|
||||||
save_module_xml();
|
$module new modules;;
|
||||||
|
$module->xml();
|
||||||
}
|
}
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/vars/app_config.php")) {
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/vars/app_config.php")) {
|
||||||
save_var_xml();
|
save_var_xml();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue