|
25 | 25 | // the action to take and the ID of the page where it will be displayed (allows for |
26 | 26 | // multiple calls on same page to load content in unique areas) |
27 | 27 | $request = array_merge($_GET, $_POST); |
28 | | -$action = $request["action"]; |
| 28 | +$action = $request["action"]; |
29 | 29 | $settings = Settings::get(); |
30 | 30 | $root_dir = Core::getRootDir(); |
31 | 31 |
|
32 | 32 | switch ($action) { |
33 | 33 |
|
34 | | - // Stage 1 of the Table Verification test: returns a list of tables to test for a particular component |
35 | | - case "get_component_tables": |
36 | | - $component = $request["component"]; |
37 | | - |
38 | | - // N.B. from 2.1.5 onwards, the Core stores its own DB structure |
39 | | - if ($component == "core") { |
40 | | - require_once("$root_dir/global/misc/config_core.php"); |
41 | | - $tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE)); |
42 | | - } else { |
43 | | - $module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID |
44 | | - $module_config = General::getModuleConfigFileContents($module_info["module_folder"]); |
45 | | - $tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"])); |
46 | | - } |
47 | | - echo json_encode(array("tables" => $tables)); |
48 | | - break; |
49 | | - |
50 | | - // Stage 2 of the Table Verification test: verifies the table structure |
51 | | - case "verify_table": |
52 | | - $component = $request["component"]; |
53 | | - if ($component == "core") { |
54 | | - require_once("$root_dir/global/misc/config_core.php"); |
55 | | - $info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]); |
56 | | - $info["table_name"] = $request["table_name"]; |
57 | | - echo json_encode($info); |
58 | | - } else { |
59 | | - $module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID |
60 | | - $module_config = General::getModuleConfigFileContents($module_info["module_folder"]); |
61 | | - $info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]); |
62 | | - $info["table_name"] = $request["table_name"]; |
63 | | - echo json_encode($info); |
64 | | - } |
65 | | - break; |
66 | | - |
67 | | - // verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks |
68 | | - // in a single step and returns the result |
69 | | - case "verify_module_hooks": |
70 | | - $module_id = $request["module_id"]; |
71 | | - $module_info = Modules::getModule($module_id); |
72 | | - $module_folder = $module_info["module_folder"]; |
73 | | - $module_version = $module_info["version"]; |
74 | | - list ($result, $extra_info) = Hooks::verifyModuleHooks($module_folder); |
75 | | - |
76 | | - echo json_encode(array( |
77 | | - "module_id" => $module_id, |
78 | | - "module_folder" => $module_folder, |
79 | | - "module_name" => $module_info["module_name"], |
80 | | - "result" => $result, |
81 | | - "extra" => $extra_info |
82 | | - )); |
83 | | - break; |
84 | | - |
85 | | - case "verify_component_files": |
86 | | - $component = $request["component"]; |
87 | | - |
88 | | - $return_info = array("result" => "pass"); |
89 | | - if ($component == "core") { |
90 | | - $missing_files = Files::checkCoreFiles(); |
91 | | - $return_info["component_type"] = "core"; |
92 | | - $return_info["component_name"] = "Form Tools Core"; |
93 | | - } |
94 | | - if (preg_match("/^module_/", $component)) { |
95 | | - $module_id = preg_replace("/^module_/", "", $component); |
96 | | - $module_info = Modules::getModule($module_id); |
97 | | - $missing_files = Files::checkModuleFiles($module_info["module_folder"]); |
98 | | - $return_info["component_type"] = "module"; |
99 | | - $return_info["component_name"] = $module_info["module_name"]; |
100 | | - } |
101 | | - if (preg_match("/^theme_/", $component)) { |
102 | | - $theme_id = preg_replace("/^theme_/", "", $component); |
103 | | - $theme_info = Themes::getTheme($theme_id); |
104 | | - $missing_files = Files::checkThemeFiles($theme_info["theme_folder"]); |
105 | | - $return_info["component_type"] = "theme"; |
106 | | - $return_info["component_name"] = $theme_info["theme_name"]; |
107 | | - } |
108 | | - if (!empty($missing_files)) { |
109 | | - $return_info["result"] = "fail"; |
110 | | - $return_info["missing_files"] = $missing_files; |
111 | | - } |
112 | | - echo json_encode($return_info); |
113 | | - break; |
114 | | - |
115 | | - case "find_table_orphans": |
116 | | - $remove_orphans = isset($request["remove_orphans"]) ? true : false; |
117 | | - $results = Orphans::findTableOrphans($request["table_name"], $remove_orphans); |
118 | | - echo json_encode($results); |
119 | | - break; |
| 34 | + // Stage 1 of the Table Verification test: returns a list of tables to test for a particular component |
| 35 | + case "get_component_tables": |
| 36 | + $component = $request["component"]; |
| 37 | + |
| 38 | + // N.B. from 2.1.5 onwards, the Core stores its own DB structure |
| 39 | + if ($component == "core") { |
| 40 | + require_once("$root_dir/global/misc/config_core.php"); |
| 41 | + $tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE)); |
| 42 | + } else { |
| 43 | + $module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID |
| 44 | + $module_config = General::getModuleConfigFileContents($module_info["module_folder"]); |
| 45 | + $tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"])); |
| 46 | + } |
| 47 | + echo json_encode(array("tables" => $tables)); |
| 48 | + break; |
| 49 | + |
| 50 | + // Stage 2 of the Table Verification test: verifies the table structure |
| 51 | + case "verify_table": |
| 52 | + $component = $request["component"]; |
| 53 | + if ($component == "core") { |
| 54 | + require_once("$root_dir/global/misc/config_core.php"); |
| 55 | + $info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]); |
| 56 | + $info["table_name"] = $request["table_name"]; |
| 57 | + echo json_encode($info); |
| 58 | + } else { |
| 59 | + $module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID |
| 60 | + $module_config = General::getModuleConfigFileContents($module_info["module_folder"]); |
| 61 | + $info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]); |
| 62 | + $info["table_name"] = $request["table_name"]; |
| 63 | + echo json_encode($info); |
| 64 | + } |
| 65 | + break; |
| 66 | + |
| 67 | + // verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks |
| 68 | + // in a single step and returns the result |
| 69 | + case "verify_module_hooks": |
| 70 | + $module_id = $request["module_id"]; |
| 71 | + $module_info = Modules::getModule($module_id); |
| 72 | + $module_folder = $module_info["module_folder"]; |
| 73 | + $module_version = $module_info["version"]; |
| 74 | + list ($result, $extra_info) = Hooks::verifyModuleHooks($module_folder); |
| 75 | + |
| 76 | + echo json_encode(array( |
| 77 | + "module_id" => $module_id, |
| 78 | + "module_folder" => $module_folder, |
| 79 | + "module_name" => $module_info["module_name"], |
| 80 | + "result" => $result, |
| 81 | + "extra" => $extra_info |
| 82 | + )); |
| 83 | + break; |
| 84 | + |
| 85 | + case "verify_component_files": |
| 86 | + $component = $request["component"]; |
| 87 | + |
| 88 | + $return_info = array("result" => "pass"); |
| 89 | + if ($component == "core") { |
| 90 | + $missing_files = Files::checkCoreFiles(); |
| 91 | + $return_info["component_type"] = "core"; |
| 92 | + $return_info["component_name"] = "Form Tools Core"; |
| 93 | + } |
| 94 | + if (preg_match("/^module_/", $component)) { |
| 95 | + $module_id = preg_replace("/^module_/", "", $component); |
| 96 | + $module_info = Modules::getModule($module_id); |
| 97 | + $missing_files = Files::checkModuleFiles($module_info["module_folder"]); |
| 98 | + $return_info["component_type"] = "module"; |
| 99 | + $return_info["component_name"] = $module_info["module_name"]; |
| 100 | + } |
| 101 | + if (preg_match("/^theme_/", $component)) { |
| 102 | + $theme_id = preg_replace("/^theme_/", "", $component); |
| 103 | + $theme_info = Themes::getTheme($theme_id); |
| 104 | + $missing_files = Files::checkThemeFiles($theme_info["theme_folder"]); |
| 105 | + $return_info["component_type"] = "theme"; |
| 106 | + $return_info["component_name"] = $theme_info["theme_name"]; |
| 107 | + } |
| 108 | + if (!empty($missing_files)) { |
| 109 | + $return_info["result"] = "fail"; |
| 110 | + $return_info["missing_files"] = $missing_files; |
| 111 | + } |
| 112 | + echo json_encode($return_info); |
| 113 | + break; |
| 114 | + |
| 115 | + case "find_table_orphans": |
| 116 | + $remove_orphans = isset($request["remove_orphans"]) ? true : false; |
| 117 | + $results = Orphans::findTableOrphans($request["table_name"], $remove_orphans); |
| 118 | + echo json_encode($results); |
| 119 | + break; |
120 | 120 | } |
121 | 121 |
|
122 | 122 |
|
0 commit comments