$request = array_merge($_GET, $_POST); $action = $request["action"]; $settings = ft_get_settings(); switch ($action) { // Stage 1 of the Table Verification test: returns a list of tables to test for a particular component case "get_component_tables": $component = $request["component"]; // N.B. from 2.1.5 onwards, the Core stores its own DB structure if ($component == "core") { require_once "{$g_root_dir}/global/misc/config_core.php"; $tables = array_merge(array("FORM TOOLS CORE", "core"), sc_get_component_tables($STRUCTURE)); } else { $module_info = ft_get_module($request["component"]); // $request["component"] is just the module ID $module_config = sc_get_module_config_file_contents($module_info["module_folder"]); $tables = array_merge(array($module_info["module_name"], $request["component"]), sc_get_component_tables($module_config["tables"])); } echo "{ \"tables\": " . ft_convert_to_json($tables) . " }"; break; // Stage 2 of the Table Verification test: verifies the table structure // Stage 2 of the Table Verification test: verifies the table structure case "verify_table": $component = $request["component"]; if ($component == "core") { require_once "{$g_root_dir}/global/misc/config_core.php"; $info = sc_check_component_table($STRUCTURE, $request["table_name"]); $info["table_name"] = $request["table_name"]; echo ft_convert_to_json($info); } else { $module_info = ft_get_module($request["component"]); // $request["component"] is just the module ID
function sc_clean_orphans() { global $g_root_dir; require_once "{$g_root_dir}/global/misc/config_core.php"; $tables = sc_get_component_tables($STRUCTURE); $problems = array(); foreach ($tables as $table_name) { $response = sc_find_table_orphans($table_name, true); if (!empty($response["clean_up_problems"])) { $problems[] = $response["clean_up_problems"]; } } $message = "The orphaned records / references have been cleaned up."; if (!empty($problems)) { $problem_list = array(); foreach ($problems as $p) { foreach ($p as $p2) { $problem_list[] = "• " . $p2; } } $message = "The orphaned results were cleaned up, however the following problems were encountered:<br />" . implode("<br />", $problem_list); } return array(true, $message); }