Skip to content

Commit

Permalink
2.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
benkeen committed Dec 24, 2018
1 parent 63dc662 commit 293f105
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 108 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This module replaces the older Database Integrity module. It offers a few simple, quick tests to run on your Form Tools
installation: kind of like taking your car to get it serviced.


### Documentation

- [https://docs.formtools.org/modules/system_check/](https://docs.formtools.org/modules/system_check/)
Expand Down
38 changes: 19 additions & 19 deletions code/Module.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@

class Module extends FormToolsModule
{
protected $moduleName = "System Check";
protected $moduleDesc = "This module offers a few tests to analyze and repair your Form Tools installation.";
protected $author = "Ben Keen";
protected $authorEmail = "ben.keen@gmail.com";
protected $authorLink = "http://formtools.org";
protected $version = "2.1.3";
protected $date = "2017-12-20";
protected $originLanguage = "en_us";
protected $jsFiles = array("scripts/tests.js");
protected $cssFiles = array("css/styles.css");
protected $moduleName = "System Check";
protected $moduleDesc = "This module offers a few tests to analyze and repair your Form Tools installation.";
protected $author = "Ben Keen";
protected $authorEmail = "ben.keen@gmail.com";
protected $authorLink = "http://formtools.org";
protected $version = "2.1.4";
protected $date = "2018-12-23";
protected $originLanguage = "en_us";
protected $jsFiles = array("scripts/tests.js");
protected $cssFiles = array("css/styles.css");

protected $nav = array(
"module_name" => array("index.php", false),
"phrase_file_verification" => array("files.php", true),
"phrase_table_verification" => array("tables.php", true),
"phrase_hook_verification" => array("hooks.php", true),
"phrase_orphan_clean_up" => array("orphans.php", true),
"phrase_environment_info" => array("env.php", false),
"word_help" => array("help.php", false)
);
protected $nav = array(
"module_name" => array("index.php", false),
"phrase_file_verification" => array("files.php", true),
"phrase_table_verification" => array("tables.php", true),
"phrase_hook_verification" => array("hooks.php", true),
"phrase_orphan_clean_up" => array("orphans.php", true),
"phrase_environment_info" => array("env.php", false),
"word_help" => array("help.php", false)
);
}
2 changes: 1 addition & 1 deletion code/Tables.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private static function checkComponentTableColumns($component_info, $table_name)
$invalid_columns = array();

// get the actual content of the db table (should be moved to helper)
$db->query("SHOW COLUMNS FROM $table_name");
$db->query("SHOW COLUMNS FROM `$table_name`");
$db->execute();

$actual_column_info = array();
Expand Down
174 changes: 87 additions & 87 deletions code/actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,98 +25,98 @@
// the action to take and the ID of the page where it will be displayed (allows for
// multiple calls on same page to load content in unique areas)
$request = array_merge($_GET, $_POST);
$action = $request["action"];
$action = $request["action"];
$settings = Settings::get();
$root_dir = Core::getRootDir();

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("$root_dir/global/misc/config_core.php");
$tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE));
} else {
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
$tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"]));
}
echo json_encode(array("tables" => $tables));
break;

// Stage 2 of the Table Verification test: verifies the table structure
case "verify_table":
$component = $request["component"];
if ($component == "core") {
require_once("$root_dir/global/misc/config_core.php");
$info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]);
$info["table_name"] = $request["table_name"];
echo json_encode($info);
} else {
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
$info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]);
$info["table_name"] = $request["table_name"];
echo json_encode($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
case "verify_module_hooks":
$module_id = $request["module_id"];
$module_info = Modules::getModule($module_id);
$module_folder = $module_info["module_folder"];
$module_version = $module_info["version"];
list ($result, $extra_info) = Hooks::verifyModuleHooks($module_folder);

echo json_encode(array(
"module_id" => $module_id,
"module_folder" => $module_folder,
"module_name" => $module_info["module_name"],
"result" => $result,
"extra" => $extra_info
));
break;

case "verify_component_files":
$component = $request["component"];

$return_info = array("result" => "pass");
if ($component == "core") {
$missing_files = Files::checkCoreFiles();
$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 = Modules::getModule($module_id);
$missing_files = Files::checkModuleFiles($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 = Themes::getTheme($theme_id);
$missing_files = Files::checkThemeFiles($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 json_encode($return_info);
break;

case "find_table_orphans":
$remove_orphans = isset($request["remove_orphans"]) ? true : false;
$results = Orphans::findTableOrphans($request["table_name"], $remove_orphans);
echo json_encode($results);
break;
// 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("$root_dir/global/misc/config_core.php");
$tables = array_merge(array("FORM TOOLS CORE", "core"), Tables::getComponentTables($STRUCTURE));
} else {
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
$tables = array_merge(array($module_info["module_name"], $request["component"]), Tables::getComponentTables($module_config["tables"]));
}
echo json_encode(array("tables" => $tables));
break;

// Stage 2 of the Table Verification test: verifies the table structure
case "verify_table":
$component = $request["component"];
if ($component == "core") {
require_once("$root_dir/global/misc/config_core.php");
$info = Tables::checkComponentTable($STRUCTURE, $request["table_name"]);
$info["table_name"] = $request["table_name"];
echo json_encode($info);
} else {
$module_info = Modules::getModule($request["component"]); // $request["component"] is just the module ID
$module_config = General::getModuleConfigFileContents($module_info["module_folder"]);
$info = Tables::checkComponentTable($module_config["tables"], $request["table_name"]);
$info["table_name"] = $request["table_name"];
echo json_encode($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
case "verify_module_hooks":
$module_id = $request["module_id"];
$module_info = Modules::getModule($module_id);
$module_folder = $module_info["module_folder"];
$module_version = $module_info["version"];
list ($result, $extra_info) = Hooks::verifyModuleHooks($module_folder);

echo json_encode(array(
"module_id" => $module_id,
"module_folder" => $module_folder,
"module_name" => $module_info["module_name"],
"result" => $result,
"extra" => $extra_info
));
break;

case "verify_component_files":
$component = $request["component"];

$return_info = array("result" => "pass");
if ($component == "core") {
$missing_files = Files::checkCoreFiles();
$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 = Modules::getModule($module_id);
$missing_files = Files::checkModuleFiles($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 = Themes::getTheme($theme_id);
$missing_files = Files::checkThemeFiles($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 json_encode($return_info);
break;

case "find_table_orphans":
$remove_orphans = isset($request["remove_orphans"]) ? true : false;
$results = Orphans::findTableOrphans($request["table_name"], $remove_orphans);
echo json_encode($results);
break;
}


2 changes: 1 addition & 1 deletion lang/en_us.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
$L["text_help"] = "For more information on this module, please see the <a href=\"https://docs.formtools.org/modules/system_check/\" target=\"_blank\">help documentation</a> on the Form Tools site.";
$L["text_file_check"] = "This examines all compatible components (Core, modules and themes) to confirm that the component's files exist.";
$L["text_file_verification_intro"] = "This checks over your Core, modules and themes to confirm that all the necessary files have been uploaded properly. If any are missing, you will need to re-download the appropriate component and upload them to your server.";
$L["text_orphan_record_check_intro"] = "This is a house-keeping test to examine the Core database tables for any unwanted orphaned records and references. Orphaned records are database entries that are no longer needed and should have been deleted along with their \"parents\". For example, when you delete a form, any references to that form ID should also be deleted. Orphaned records shouldn't cause problems, but add unnecessary clutter to your database. <b>If this test finds anything, we'd appreciate it if you <a href=\"http://forums.formtools.org/\">report them in the forums</a>!</b>";
$L["text_orphan_record_check_intro"] = "This is a house-keeping test to examine the Core database tables for any unwanted orphaned records and references. Orphaned records are database entries that are no longer needed and should have been deleted along with their \"parents\". For example, when you delete a form, any references to that form ID should also be deleted. Orphaned records shouldn't cause problems, but add unnecessary clutter to your database. <b>If this test finds anything, we'd appreciate it if you <a href=\"https://github.com/formtools/core/issues\" target=\"_blank\">reported it on github</a>!</b>";
$L["text_orphan_desc_short"] = "A housekeeping test to identify and remove old database records and references that are no longer needed and should have been deleted.";
$L["text_environment_overview_summary"] = "This section below contains a report of key information about your Form Tools installation and environment, which can be helpful when reporting bugs.";
$L["text_ft3_compatibility"] = "Form Tools 3 has slightly difference server requirements than Form Tools 2. This page runs a couple of simple tests to confirm you will be able to run the newer version.";
Expand Down

0 comments on commit 293f105

Please sign in to comment.