diff --git a/app/modules/app_defaults.php b/app/modules/app_defaults.php
index 84dfe431ed..ca82a621af 100644
--- a/app/modules/app_defaults.php
+++ b/app/modules/app_defaults.php
@@ -34,15 +34,13 @@
//use the module class to get the list of modules from the db and add any missing modules
if (isset($_SESSION['switch']['mod']['dir'])) {
- $mod = new modules;
- $mod->db = $db;
- $mod->dir = $_SESSION['switch']['mod']['dir'];
- $mod->get_modules();
- $mod->synch();
- $msg = $mod->msg;
-
- //save the modules.conf
- save_module_xml();
+ $module = new modules;
+ $module->db = $db;
+ $module->dir = $_SESSION['switch']['mod']['dir'];
+ $module->get_modules();
+ $module->synch();
+ $module->xml();
+ $msg = $module->msg;
}
}
diff --git a/app/modules/module_edit.php b/app/modules/module_edit.php
index ce87f739ca..37685be3cc 100644
--- a/app/modules/module_edit.php
+++ b/app/modules/module_edit.php
@@ -114,7 +114,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$db->exec(check_sql($sql));
unset($sql);
- save_module_xml();
+ $module new modules;;
+ $module->xml();
$_SESSION["message"] = $text['message-add'];
header("Location: modules.php");
@@ -134,7 +135,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$db->exec(check_sql($sql));
unset($sql);
- save_module_xml();
+ $module new modules;;
+ $module->xml();
$_SESSION["message"] = $text['message-update'];
header("Location: modules.php");
diff --git a/app/modules/modules.php b/app/modules/modules.php
index 6b5317d1b1..62cd2a2cdb 100644
--- a/app/modules/modules.php
+++ b/app/modules/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
- $mod = new modules;
- $mod->db = $db;
- $mod->dir = $_SESSION['switch']['mod']['dir'];
- $mod->get_modules();
- $result = $mod->modules;
+ $module = new modules;
+ $module->db = $db;
+ $module->dir = $_SESSION['switch']['mod']['dir'];
+ $module->get_modules();
+ $result = $module->modules;
$module_count = count($result);
- $mod->synch();
- $msg = $mod->msg;
+ $module->synch();
+ $module->xml();
+ $msg = $module->msg;
//show the msg
if ($msg) {
- save_module_xml();
echo "
\n";
echo "
\n";
echo "\n";
diff --git a/app/modules/resources/classes/modules.php b/app/modules/resources/classes/modules.php
index 8f8e0569d1..91a5788534 100644
--- a/app/modules/resources/classes/modules.php
+++ b/app/modules/resources/classes/modules.php
@@ -736,7 +736,6 @@ include "root.php";
}
closedir($handle);
if ($module_found) {
- //save_module_xml();
$msg = "Added New Modules:
\n";
$msg .= "\n";
$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 = "\n";
+ $xml .= " \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 \n";
+ }
+ if ($row['module_enabled'] == "true"){
+ $xml .= " \n";
+ }
+ $prev_module_cat = $row['module_category'];
+ }
+ $xml .= "\n";
+ $xml .= " \n";
+ $xml .= "";
+
+ $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
//add the database structure
diff --git a/resources/switch.php b/resources/switch.php
index a9c0811dae..dfd0893c51 100644
--- a/resources/switch.php
+++ b/resources/switch.php
@@ -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 .= "\n";
- $xml .= " \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 \n";
- }
- if ($row['module_enabled'] == "true"){
- $xml .= " \n";
- }
- $prev_module_cat = $row['module_category'];
- }
- $xml .= "\n";
- $xml .= " \n";
- $xml .= "";
-
- $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() {
global $config, $domain_uuid;
@@ -1478,7 +1432,8 @@ if (!function_exists('save_switch_xml')) {
save_setting_xml();
}
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")) {
save_var_xml();