/** * Figures out which (if any) of the installed modules are available for a particular test. * * @param string $test "tables", "hooks" or "files" * @return array all compatible modules (not the module_config.php info). */ function sc_get_compatible_modules($test) { global $g_root_dir; $module_list = ft_get_modules(); $compatible_modules = array(); foreach ($module_list as $module_info) { $module_folder = $module_info["module_folder"]; if ($module_info["is_installed"] != "yes") { continue; } $module_config = sc_get_module_config_file_contents($module_folder); if (!$module_config["is_compatible"]) { continue; } $relevant = false; switch ($test) { case "tables": if ($module_config["includes_table_info"]) { $relevant = true; } break; case "hooks": if ($module_config["includes_hook_info"]) { $relevant = true; } break; case "files": if ($module_config["includes_file_info"]) { $relevant = true; } break; } $module_info["module_config"] = $module_config; if ($relevant) { $compatible_modules[] = $module_info; } } return $compatible_modules; }
/** * This explicitly empties and reloads any module's hook calls. * * @param array $module_ids */ function sc_reset_module_hook_calls($module_ids) { global $g_table_prefix, $L; $problems = false; foreach ($module_ids as $module_id) { if (!is_numeric($module_id)) { continue; } $module_info = ft_get_module($module_id); if (empty($module_info)) { continue; } $module_folder = $module_info["module_folder"]; $module_version = $module_info["version"]; $module_config = sc_get_module_config_file_contents($module_folder); $desired_hooks = isset($module_config["hooks"][$module_version]) ? $module_config["hooks"][$module_version] : $module_config["hooks"]; if (empty($desired_hooks)) { continue; } mysql_query("DELETE FROM {$g_table_prefix}hook_calls WHERE module_folder = '{$module_folder}'"); foreach ($desired_hooks as $hook_info) { $hook_type = $hook_info["hook_type"]; $action_location = $hook_info["action_location"]; $function_name = $hook_info["function_name"]; $hook_function = $hook_info["hook_function"]; $priority = $hook_info["priority"]; $query = mysql_query("\n \t INSERT INTO {$g_table_prefix}hook_calls (hook_type, action_location, module_folder, function_name, hook_function, priority)\n \t VALUES ('{$hook_type}', '{$action_location}', '{$module_folder}', '{$function_name}', '{$hook_function}', {$priority})\n \t"); if (!$query) { $problems = true; } } } if ($problems) { return array(true, $L["notify_problems_resetting_module_hooks"]); } else { return array(true, $L["notify_module_hooks_reset"]); } }
} 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 $module_config = sc_get_module_config_file_contents($module_info["module_folder"]); $info = sc_check_component_table($module_config["tables"], $request["table_name"]); $info["table_name"] = $request["table_name"]; echo ft_convert_to_json($info); } break; // verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks // in a single step and returns the result // verifies the hooks for a particular module. This is much simpler than the table test. It just examines each module's hooks // in a single step and returns the result case "verify_module_hooks": $module_id = $request["module_id"]; $module_info = ft_get_module($module_id); $module_folder = $module_info["module_folder"]; $module_version = $module_info["version"]; $result = sc_verify_module_hooks($module_folder, $module_version);