Skip to content

Commit 1a5dd86

Browse files
committed
1.0.0
1 parent b972726 commit 1a5dd86

37 files changed

+165
-2443
lines changed
File renamed without changes.

system_check/global/code/actions.php renamed to global/code/actions.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
case "verify_component_files":
7878
$component = $request["component"];
7979

80-
$return_info = array("result" => "pass", "bah" => "stupid");
80+
$return_info = array("result" => "pass");
8181
if ($component == "core")
8282
{
8383
$missing_files = sc_check_core_files();
@@ -108,12 +108,6 @@
108108
}
109109
echo ft_convert_to_json($return_info);
110110
break;
111-
112-
case "find_table_orphans":
113-
$remove_orphans = isset($request["remove_orphans"]) ? true : false;
114-
$results = sc_find_table_orphans($request["table_name"], $remove_orphans);
115-
echo ft_convert_to_json($results);
116-
break;
117111
}
118112

119113

File renamed without changes.

global/code/general.php

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?php
2+
3+
4+
/**
5+
* Figures out which (if any) of the installed modules are available for a particular test.
6+
*
7+
* @param string $test "tables", "hooks" or "files"
8+
* @return array all compatible modules (not the module_config.php info).
9+
*/
10+
function sc_get_compatible_modules($test)
11+
{
12+
global $g_root_dir;
13+
14+
$module_list = ft_get_modules();
15+
16+
$compatible_modules = array();
17+
foreach ($module_list as $module_info)
18+
{
19+
$module_folder = $module_info["module_folder"];
20+
if ($module_info["is_installed"] != "yes")
21+
continue;
22+
23+
$module_config = sc_get_module_config_file_contents($module_folder);
24+
if (!$module_config["is_compatible"])
25+
continue;
26+
27+
$relevant = false;
28+
switch ($test)
29+
{
30+
case "tables":
31+
if ($module_config["includes_table_info"])
32+
$relevant = true;
33+
break;
34+
case "hooks":
35+
if ($module_config["includes_hook_info"])
36+
$relevant = true;
37+
break;
38+
case "files":
39+
if ($module_config["includes_file_info"])
40+
$relevant = true;
41+
break;
42+
}
43+
44+
$module_info["module_config"] = $module_config;
45+
46+
if ($relevant)
47+
$compatible_modules[] = $module_info;
48+
}
49+
50+
return $compatible_modules;
51+
}
52+
53+
54+
/**
55+
* This is the one entry point for getting data from a module config file.
56+
*
57+
* This function returns all config info about a module that can be used by the System Check module.
58+
* It's compatible with the old Database Integrity module, which required a database_integrity.php file
59+
* defined in the module root. The new System Check module requires a module_config.php file to be
60+
* defined in the module root.
61+
*
62+
* The module_config.php can define any of the following globals:
63+
* $STRUCTURE - which contains the database structure of all module tables. If there's no database,
64+
* it (should) define an empty array.
65+
* $FILES - a list of files for this module
66+
* $HOOKS - the list of hook calls that the module uses - or an empty array if none.
67+
*
68+
* @param string $module_folder
69+
* @return array
70+
*/
71+
function sc_get_module_config_file_contents($module_folder)
72+
{
73+
global $g_root_dir;
74+
75+
// Database Integrity compatibility
76+
$is_compatible = false;
77+
78+
// if the module is sporting compatibility with the new System Check module, use that file. Otherwise, use
79+
// the older Database Integrity module file
80+
if (is_file("$g_root_dir/modules/$module_folder/module_config.php"))
81+
{
82+
$is_compatible = true;
83+
require("$g_root_dir/modules/$module_folder/module_config.php");
84+
}
85+
86+
else if (is_file("$g_root_dir/modules/$module_folder/database_integrity.php"))
87+
{
88+
$is_compatible = true;
89+
require("$g_root_dir/modules/$module_folder/database_integrity.php");
90+
}
91+
92+
$return_info = array(
93+
"is_compatible" => $is_compatible,
94+
"includes_table_info" => false,
95+
"includes_hook_info" => false,
96+
"includes_file_info" => false
97+
);
98+
99+
// if data is available for the module, tack it all together and return the result
100+
if ($is_compatible)
101+
{
102+
$includes_table_info = isset($STRUCTURE) ? true : false;
103+
$tables = array();
104+
if ($includes_table_info)
105+
{
106+
$return_info["includes_table_info"] = $includes_table_info;
107+
$return_info["tables"] = $STRUCTURE;
108+
}
109+
110+
$includes_hook_info = isset($HOOKS) ? true : false;
111+
$hooks = array();
112+
if ($includes_hook_info)
113+
{
114+
$return_info["includes_hook_info"] = $includes_hook_info;
115+
$return_info["hooks"] = $HOOKS;
116+
}
117+
118+
$includes_file_info = isset($FILES) ? true : false;
119+
$files = array();
120+
if ($includes_file_info)
121+
{
122+
$return_info["includes_file_info"] = $includes_file_info;
123+
$return_info["files"] = $FILES;
124+
}
125+
}
126+
127+
return $return_info;
128+
}
129+
File renamed without changes.
File renamed without changes.
File renamed without changes.

system_check/global/css/styles.css renamed to global/css/styles.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ table.log_table .full_log_heading {
1313
color: white;
1414
font-weight: bold;
1515
font-size: 8pt;
16-
padding-left: 3px;
1716
}
1817
table.log_table .error_log_heading {
1918
background-color: #990000;
2019
color: white;
2120
font-weight: bold;
2221
font-size: 8pt;
23-
padding-left: 3px;
2422
}
2523
table.log_table td {
2624
background-color: #efefef;
File renamed without changes.
File renamed without changes.

system_check/global/scripts/tests.js renamed to global/scripts/tests.js

Lines changed: 6 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
/**
2-
* This file contains all the client-side code for all tests in the module.
2+
* This file contains all the client-side code for the three tests: file, table and hook verification. It's arranged
3+
* into general functions first, then test-specific functions below, grouped under the appropriate heading.
4+
*
35
*/
46

57
var sc_ns = {
68

7-
// common vars (used for all, or most tests)
9+
// common vars (used for all tests)
810
is_processing: false, // any time a test is running
911
component_list: [], // contains "core" and/or any module IDs, depending on what's selected for the test
1012
current_component: null, // core / module ID
1113
current_component_name: null, // for display purposes
1214

1315

1416
/**
15-
* This initiates the test process for any of the tests, called from the individual test pages. It
16-
* does the following:
17-
*
17+
* This initiates the test process for any of the 3 tests. This does the following:
1818
* 1. Clears the logs already outputted
1919
* 2. marks the test as having begun (is_processing = true)
2020
* 3. stores the list of components (module IDs + core) that the user selected
21-
* 4. Calls the appropriate init test function
21+
* 4. Calls the
2222
*/
2323
start: function(start_test_func) {
2424
sc_ns.clear_logs();
2525
sc_ns.is_processing = true;
2626
sc_ns.component_list = [];
2727
sc_ns.file_verification_problems = null;
28-
sc_ns.total_orphan_tests_run = 0;
29-
sc_ns.total_num_orphans_found = 0;
3028

3129
$(".components:checked").each(function() {
3230
sc_ns.component_list.push(this.value);
@@ -345,114 +343,6 @@ var sc_ns = {
345343
}
346344
return;
347345
}
348-
},
349-
350-
351-
// ----------------------------------------------------------------------------------------------
352-
353-
// Orphan Record Check
354-
355-
total_orphan_tests_run: 0,
356-
total_num_orphans_found: 0,
357-
358-
/**
359-
* Called for each component on the Table Verification page. This method returns all tables
360-
* for the component, which are passed to sc_ns.verify_component_tables which does the actual
361-
* verification.
362-
*/
363-
init_orphan_record_test: function() {
364-
$("#result__" + sc_ns.current_component).html("<img src=\"images/loading.gif\" />");
365-
$.ajax({
366-
url: g.root_url + "/modules/system_check/global/code/actions.php",
367-
data: { action: "get_component_tables", component: "core" },
368-
type: "POST",
369-
dataType: "json",
370-
success: sc_ns.find_orphan_records
371-
});
372-
},
373-
374-
find_orphan_records: function(core_info) {
375-
sc_ns.current_component_name = core_info.tables.shift();
376-
sc_ns.current_component = core_info.tables.shift();
377-
sc_ns.current_component_tables = core_info.tables;
378-
sc_ns.current_component_table = core_info.tables[0];
379-
380-
// update the log section
381-
var log = g.messages["word_testing_c"] + sc_ns.current_component_name + "\n"
382-
+ "------------------------------------------\n";
383-
384-
// if this isn't the first thing outputted to the log, add some visual padding
385-
if ($("#full_log").val() != "")
386-
log = "\n\n" + log;
387-
388-
sc_ns.log_message(log);
389-
390-
// now start processing this component's tables
391-
sc_ns.find_next_table_orphans();
392-
},
393-
394-
find_next_table_orphans: function() {
395-
$.ajax({
396-
url: g.root_url + "/modules/system_check/global/code/actions.php",
397-
data: { action: "find_table_orphans", table_name: sc_ns.current_component_table },
398-
type: "POST",
399-
dataType: "json",
400-
success: sc_ns.display_orphan_test_results
401-
});
402-
},
403-
404-
display_orphan_test_results: function(results) {
405-
var log = "TABLE: " + results.table_name + "\n";
406-
if (results.has_test) {
407-
log += "Test description:\n" + results.test_descriptions + "\n"
408-
+ "Results:\n"
409-
+ "- num tests: " + results.num_tests + "\n"
410-
+ "- num orphans: " + results.num_orphans;
411-
412-
sc_ns.total_orphan_tests_run += results.num_tests;
413-
sc_ns.total_num_orphans_found += results.num_orphans;
414-
} else {
415-
log += "- No test";
416-
}
417-
sc_ns.log_message(log);
418-
sc_ns.log_message("_______________________\n");
419-
420-
if (results.num_orphans > 0) {
421-
var log = "TABLE: " + results.table_name + "\n"
422-
+ "- num orphans: " + results.num_orphans + "\n"
423-
+ "- error description: \n";
424-
for (var i=1; i<=results.problems.length; i++) {
425-
log += i + ". " + results.problems[i-1] + "\n";
426-
}
427-
sc_ns.log_error(log + "_______________________\n");
428-
}
429-
430-
var next_table = null;
431-
for (var i=0; i<sc_ns.current_component_tables.length-1; i++) {
432-
if (sc_ns.current_component_tables[i] == sc_ns.current_component_table) {
433-
next_table = sc_ns.current_component_tables[i+1];
434-
break;
435-
}
436-
}
437-
438-
if (next_table != null) {
439-
sc_ns.current_component_table = next_table;
440-
sc_ns.find_next_table_orphans();
441-
} else {
442-
var message = "Number of tests run: <b>" + sc_ns.total_orphan_tests_run + "</b>, "
443-
+ "total number of orphans found: <b>" + sc_ns.total_num_orphans_found + "</b>";
444-
445-
var error_type = 1;
446-
if (sc_ns.total_num_orphans_found > 0) {
447-
error_type = 0;
448-
message += ". <a href=\"orphans.php?clean\">Click here</a> to delete all the orphaned records / references.";
449-
} else {
450-
message += ". Passed!";
451-
}
452-
453-
ft.display_message("ft_message", error_type, message);
454-
return;
455-
}
456346
}
457347

458348
};
File renamed without changes.

system_check/hooks.php renamed to hooks.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111

1212
// example
13-
//sc_generate_module_hook_array("module_hooks_manager_rules", "1.1.4");
13+
//sc_generate_module_hook_array("form_backup", "1.1.4");
1414
//exit;
1515

1616
$word_testing_uc = mb_strtoupper($L["word_untested"]);
File renamed without changes.
File renamed without changes.
File renamed without changes.

system_check/lang/en_us.php renamed to lang/en_us.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
$L["word_passed"] = "Passed";
1212
$L["word_failed"] = "Failed";
1313
$L["word_result"] = "Result";
14-
$L["word_summary"] = "Summary";
15-
$L["word_installed"] = "Installed";
16-
$L["word_available"] = "Available";
1714

1815
$L["phrase_missing_table_c"] = "missing table: ";
1916
$L["phrase_missing_column_c"] = "missing column: ";
@@ -29,30 +26,16 @@
2926
$L["phrase_uses_hooks_q"] = "Uses Hooks?";
3027
$L["phrase_nothing_to_test"] = "nothing to test";
3128
$L["phrase_has_tables_q"] = "Has Tables?";
32-
$L["phrase_orphan_clean_up"] = "Orphan Clean-up";
33-
$L["phrase_run_test"] = "Run Test";
34-
$L["phrase_form_integrity_check"] = "Form Integrity Check";
35-
$L["phrase_environment_info"] = "Environment Info";
36-
$L["phrase_not_installed"] = "Not Installed";
37-
$L["phrase_not_available"] = "Not Available";
38-
$L["phrase_environment_overview"] = "Environment Overview";
39-
$L["phrase_php_sessions"] = "PHP Sessions";
40-
$L["phrase_suhosin_extension"] = "Suhosin Extension";
41-
$L["phrase_curl_extension"] = "Curl Extension";
42-
$L["phrase_simplexml_extension"] = "SimpleXML Extension";
4329

4430
$L["text_tables_test"] = "The following tables will be tested to confirm they exist, and that the column information is valid.";
45-
$L["text_module_intro"] = "This module lets you run tests on your Form Tools installation to look for potential problems. Choose one of the tests below.";
31+
$L["text_module_intro"] = "This module lets you run tests on your Form Tools installation to verify the structure and files. Choose one of the tests below.";
4632
$L["text_table_verification_intro"] = "This examines and verifies the existence and structure of your Core database tables and any compatible modules.";
4733
$L["text_hook_verification_intro"] = "Modules interact with the Core script through <i>hooks</i>. They attach their own functionality to act at particular junctions in the code. If this gets corrupted, it can prevent the module from working properly. This test examines your database to confirm that the hooks for all your modules are configured properly.";
4834
$L["text_problems_identified_and_fixed"] = "Problems are both identified and fixed.";
4935
$L["text_problems_identified_not_fixed"] = "Problems are only identified, not fixed.";
5036
$L["text_help"] = "For more information on this module, please see the <a href=\"http://modules.formtools.org/system_check/\" target=\"_blank\">help documentation</a> on the Form Tools site.";
5137
$L["text_file_check"] = "This examines all compatible components (Core, modules and themes) to confirm that the component's files exist.";
5238
$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.";
53-
$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>";
54-
$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.";
55-
$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.";
5639

5740
$L["notify_test_complete_problems"] = "The test is complete. We found a problem with one or more of your installed components.";
5841
$L["notify_test_complete_no_problems"] = "The test is complete. No problems were found.";

system_check/library.php renamed to library.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
require_once(dirname(__FILE__) . "/global/code/general.php");
55
require_once(dirname(__FILE__) . "/global/code/generation.php");
66
require_once(dirname(__FILE__) . "/global/code/hooks.php");
7-
require_once(dirname(__FILE__) . "/global/code/orphans.php");
87
require_once(dirname(__FILE__) . "/global/code/tables.php");

0 commit comments

Comments
 (0)