if ($component == "core") { $missing_files = sc_check_core_files(); $return_info["component_type"] = "core"; $return_info["component_name"] = "Form Tools Core"; } if (preg_match("/^module_/", $component)) { $module_id = preg_replace("/^module_/", "", $component); $module_info = ft_get_module($module_id); $missing_files = sc_check_module_files($module_info["module_folder"]); $return_info["component_type"] = "module"; $return_info["component_name"] = $module_info["module_name"]; } if (preg_match("/^theme_/", $component)) { $theme_id = preg_replace("/^theme_/", "", $component); $theme_info = ft_get_theme($theme_id); $missing_files = sc_check_theme_files($theme_info["theme_folder"]); $return_info["component_type"] = "theme"; $return_info["component_name"] = $theme_info["theme_name"]; } if (!empty($missing_files)) { $return_info["result"] = "fail"; $return_info["missing_files"] = $missing_files; } echo ft_convert_to_json($return_info); break; case "find_table_orphans": $remove_orphans = isset($request["remove_orphans"]) ? true : false; $results = sc_find_table_orphans($request["table_name"], $remove_orphans); echo ft_convert_to_json($results); break; }
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); }