Skip to content

Commit

Permalink
MDL-10168 improvements to display of results from environment checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiesensei committed Jun 19, 2007
1 parent 52f79e8 commit 9d8453b
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 71 deletions.
11 changes: 11 additions & 0 deletions .project
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>moodle-MOODLE_16_STABLE</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
8 changes: 5 additions & 3 deletions lang/en_utf8/admin.php
@@ -1,4 +1,4 @@
<?PHP // $Id$ <?PHP // $Id$
// admin.php - created with Moodle 1.6 development (2005053000) // admin.php - created with Moodle 1.6 development (2005053000)




Expand Down Expand Up @@ -50,7 +50,7 @@
$string['configerrorlevel'] = 'Choose the amount of PHP warnings that you want to be displayed. Normal is usually the best choice.'; $string['configerrorlevel'] = 'Choose the amount of PHP warnings that you want to be displayed. Normal is usually the best choice.';
$string['configextendedusernamechars'] = 'Enable this setting to allow students to use any characters in their usernames (note this does not affect their actual names). The default is \"false\" which restricts usernames to be alphanumeric characters only'; $string['configextendedusernamechars'] = 'Enable this setting to allow students to use any characters in their usernames (note this does not affect their actual names). The default is \"false\" which restricts usernames to be alphanumeric characters only';
$string['configfilterall'] = 'Filter all strings, including headings, titles, navigation bar and so on. This is mostly useful when using the multilang filter, otherwise it will just create extra load on your site for little gain.'; $string['configfilterall'] = 'Filter all strings, including headings, titles, navigation bar and so on. This is mostly useful when using the multilang filter, otherwise it will just create extra load on your site for little gain.';
$string['configfiltermatchoneperpage'] = 'Automatic linking filters will only generate a single link for the first matching text instance found on the complete page. All others are ignored.'; $string['configfiltermatchoneperpage'] = 'Automatic linking filters will only generate a single link for the first matching text instance found on the complete page. All others are ignored.';
$string['configfiltermatchonepertext'] = 'Automatic linking filters will only generate a single link for the first matching text instance found in each item of text (e.g., resource, block) on the page. All others are ignored. This setting is ignored if the one per page setting is <i>yes</i>.'; $string['configfiltermatchonepertext'] = 'Automatic linking filters will only generate a single link for the first matching text instance found in each item of text (e.g., resource, block) on the page. All others are ignored. This setting is ignored if the one per page setting is <i>yes</i>.';
$string['configfilteruploadedfiles'] = 'Process all uploaded HTML and text files with the filters before displaying them, only uploaded HTML files or none at all.'; $string['configfilteruploadedfiles'] = 'Process all uploaded HTML and text files with the filters before displaying them, only uploaded HTML files or none at all.';
$string['configforcelogin'] = 'Normally, the front page of the site and the course listings (but not courses) can be read by people without logging in to the site. If you want to force people to log in before they do ANYTHING on the site, then you should enable this setting.'; $string['configforcelogin'] = 'Normally, the front page of the site and the course listings (but not courses) can be read by people without logging in to the site. If you want to force people to log in before they do ANYTHING on the site, then you should enable this setting.';
Expand Down Expand Up @@ -121,7 +121,7 @@
$string['configstatsruntimestart'] = 'What time should the cronjob that does the stats processing <b>start</b>?'; $string['configstatsruntimestart'] = 'What time should the cronjob that does the stats processing <b>start</b>?';
$string['configstatsuserthreshold'] = 'If you enter a non-zero, non numeric value here, for ranking courses, courses with less than this number of enrolled users (students + teachers) will be ignored'; $string['configstatsuserthreshold'] = 'If you enter a non-zero, non numeric value here, for ranking courses, courses with less than this number of enrolled users (students + teachers) will be ignored';
$string['configteacherassignteachers'] = 'Should ordinary teachers be allowed to assign other teachers within courses they teach? If \'No\', then only course creators and admins can assign teachers.'; $string['configteacherassignteachers'] = 'Should ordinary teachers be allowed to assign other teachers within courses they teach? If \'No\', then only course creators and admins can assign teachers.';
$string['configthemelist'] = 'Leave this blank to allow any valid theme to be used. If you want to shorten the theme menu, you can specify a comma-separated list of names here (Don\'t use spaces!). $string['configthemelist'] = 'Leave this blank to allow any valid theme to be used. If you want to shorten the theme menu, you can specify a comma-separated list of names here (Don\'t use spaces!).
For example: standard,orangewhite.'; For example: standard,orangewhite.';
$string['configtimezone'] = 'You can set the default timezone here. This is the only the DEFAULT timezone for displaying dates - each user can override this by setting their own in their profile. \"Server time\" here will make Moodle default to the server\'s operating system setting, but \"Server time\" in the user profile will make the user default to this timezone setting. Cronjobs that depend on a time of day to run will use this timezone.'; $string['configtimezone'] = 'You can set the default timezone here. This is the only the DEFAULT timezone for displaying dates - each user can override this by setting their own in their profile. \"Server time\" here will make Moodle default to the server\'s operating system setting, but \"Server time\" in the user profile will make the user default to this timezone setting. Cronjobs that depend on a time of day to run will use this timezone.';
$string['configunzip'] = 'Indicate the location of your unzip program (Unix only, optional). If specified, this will be used to unpack zip archives on the server. If you leave this blank, then Moodle will use internal routines.'; $string['configunzip'] = 'Indicate the location of your unzip program (Unix only, optional). If specified, this will be used to unpack zip archives on the server. If you leave this blank, then Moodle will use internal routines.';
Expand All @@ -131,6 +131,7 @@
$string['confirmation'] = 'Confirmation'; $string['confirmation'] = 'Confirmation';
$string['confirminstall'] = 'You are about to install language pack ($a), are you sure?'; $string['confirminstall'] = 'You are about to install language pack ($a), are you sure?';
$string['cronwarning'] = 'The <a href=\"cron.php\">cron.php maintenance script</a> has not been run for at least 24 hours.'; $string['cronwarning'] = 'The <a href=\"cron.php\">cron.php maintenance script</a> has not been run for at least 24 hours.';
$string['customcheck'] = 'Other Checks';
$string['datarootsecuritywarning'] = 'Your site configuration might not be secure. Please make sure that your dataroot directory ($a) is not directly accessible via web.'; $string['datarootsecuritywarning'] = 'Your site configuration might not be secure. Please make sure that your dataroot directory ($a) is not directly accessible via web.';
$string['dbmigrate'] = 'Moodle Database Migration'; $string['dbmigrate'] = 'Moodle Database Migration';
$string['dbmigrationdeprecateddb'] = '<font color=\"#ff0000\">This database is migrated to a new UTF8 database and deprecated. Please edit your config.php and use the new database for this moodle.</font>'; $string['dbmigrationdeprecateddb'] = '<font color=\"#ff0000\">This database is migrated to a new UTF8 database and deprecated. Please edit your config.php and use the new database for this moodle.</font>';
Expand Down Expand Up @@ -220,6 +221,7 @@
$string['pgclusterdescription'] = 'PostgreSQL version/cluster parameter for command line operations. If you only have one postgresql on your system or you are not sure what this is, leave this blank.'; $string['pgclusterdescription'] = 'PostgreSQL version/cluster parameter for command line operations. If you only have one postgresql on your system or you are not sure what this is, leave this blank.';
$string['php50restricted'] = 'PHP 5.0.x has a number of known problems, please upgrade to 5.1.x or downgrade to 4.3.x or 4.4.x'; $string['php50restricted'] = 'PHP 5.0.x has a number of known problems, please upgrade to 5.1.x or downgrade to 4.3.x or 4.4.x';
$string['remotelangnotavailable'] = 'Because Moodle can not connect to download.moodle.org, we are unable to do language pack installation automatically. Please download the appropriate zip file(s) from the list below, copy them to your $a directory and unzip them manually.'; $string['remotelangnotavailable'] = 'Because Moodle can not connect to download.moodle.org, we are unable to do language pack installation automatically. Please download the appropriate zip file(s) from the list below, copy them to your $a directory and unzip them manually.';
$string['serverchecks'] = 'Server Checks';
$string['sitelangchanged'] = 'Site language setting changed successfully'; $string['sitelangchanged'] = 'Site language setting changed successfully';
$string['sitemaintenance'] = 'The site is undergoing maintenance and is currently not available'; $string['sitemaintenance'] = 'The site is undergoing maintenance and is currently not available';
$string['sitemaintenancemode'] = 'Maintenance mode'; $string['sitemaintenancemode'] = 'Maintenance mode';
Expand Down
117 changes: 75 additions & 42 deletions lib/environmentlib.php
Expand Up @@ -54,8 +54,9 @@
* The function looks for the best version to compare and * The function looks for the best version to compare and
* everything. This is the only function that should be called * everything. This is the only function that should be called
* ever from the rest of Moodle. * ever from the rest of Moodle.
* @param string version version to check. * @param string version version to check.
* @param array results array of results checked. * @param array results array of results checked.
* @param boolean true/false, whether to print the table or just return results array
* @return boolean true/false, depending of results * @return boolean true/false, depending of results
*/ */
function check_moodle_environment($version, &$environment_results, $print_table=true) { function check_moodle_environment($version, &$environment_results, $print_table=true) {
Expand Down Expand Up @@ -110,7 +111,7 @@ function check_moodle_environment($version, &$environment_results, $print_table=
return ($result && $status); return ($result && $status);
} }


/** /**
* This function will print one beautiful table with all the environmental * This function will print one beautiful table with all the environmental
* configuration and how it suits Moodle needs. * configuration and how it suits Moodle needs.
* @param boolean final result of the check (true/false) * @param boolean final result of the check (true/false)
Expand All @@ -130,16 +131,28 @@ function print_moodle_environment($result, $environment_results) {
$strrestricted = get_string('restricted'); $strrestricted = get_string('restricted');
$strenvironmenterrortodo = get_string('environmenterrortodo', 'admin'); $strenvironmenterrortodo = get_string('environmenterrortodo', 'admin');


/// Here we'll store all the feedback found
$feedbacktext = '';


/// Table header /// Table headers
$table->head = array ($strname, $strinfo, $strreport, $strstatus); $servertable = new stdClass;//table for server checks
$table->align = array ('center', 'center', 'left', 'center'); $servertable->head = array ($strname, $strinfo, $strreport, $strstatus);
$table->wrap = array ('nowrap', '', '', 'nowrap'); $servertable->align = array ('center', 'center', 'left', 'center');
$table->size = array ('10', 10, '100%', '10'); $servertable->wrap = array ('nowrap', '', '', 'nowrap');
$table->width = '90%'; $servertable->size = array ('10', 10, '100%', '10');
$table->class = 'environmenttable generaltable'; $servertable->width = '90%';
$servertable->class = 'environmenttable generaltable';

$serverdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());

$othertable = new stdClass;//table for custom checks
$othertable->head = array ($strinfo, $strreport, $strstatus);
$othertable->align = array ('center', 'left', 'center');
$othertable->wrap = array ('', '', 'nowrap');
$othertable->size = array (10, '100%', '10');
$othertable->width = '90%';
$othertable->class = 'environmenttable generaltable';

$otherdata = array('ok'=>array(), 'warn'=>array(), 'error'=>array());



/// Iterate over each environment_result /// Iterate over each environment_result
$continue = true; $continue = true;
Expand Down Expand Up @@ -194,46 +207,66 @@ function print_moodle_environment($result, $environment_results) {
$status = $strcheck; $status = $strcheck;
$warningline = true; $warningline = true;
} else { //Handle error result (error) } else { //Handle error result (error)
$status = $strcheck; $status = $strcheck;
$errorline = true; $errorline = true;
} }
} }
} }
} }

/// Build the text /// Build the text
$report = get_string($stringtouse, 'admin', $rec); $linkparts = array();
$linkparts[] = 'admin/environment';
$linkparts[] = $type;
if (!empty($info)){
$linkparts[] = $info;
}
$report = doc_link(join($linkparts, '/'), get_string($stringtouse, 'admin', $rec));

/// Format error or warning line /// Format error or warning line
if ($errorline || $warningline) { if ($errorline || $warningline) {
$styletoapply = $errorline? 'error':'warn'; $messagetype = $errorline? 'error':'warn';
$type = '<span class="'.$styletoapply.'">'.$type.'</span>'; } else {
$info = '<span class="'.$styletoapply.'">'.$info.'</span>'; $messagetype = 'ok';
$report = '<span class="'.$styletoapply.'">'.$report.'</span>';
$status = '<span class="'.$styletoapply.'">'.$status.'</span>';
} }
/// Add the row to the table $status = '<span class="'.$messagetype.'">'.$status.'</span>';
$table->data[] = array ($type, $info, $report, $status); /// Here we'll store all the feedback found
///Process the feedback if necessary $feedbacktext = '';
///Process the feedback if necessary
if ($feedbackstr = $environment_result->getFeedbackStr()) { if ($feedbackstr = $environment_result->getFeedbackStr()) {
$feedbacktext .= '<li class="environmenttable">'.get_string($feedbackstr, 'admin').'</li>'; $feedbacktext .= '<p class="'.$messagetype.'">'.get_string($feedbackstr, 'admin').'</p>';
} }
///Process the bypass if necessary ///Process the bypass if necessary
if ($bypassstr = $environment_result->getBypassStr()) { if ($bypassstr = $environment_result->getBypassStr()) {
$feedbacktext .= '<li class="environmenttable">'.get_string($bypassstr, 'admin').'</li>'; $feedbacktext .= '<p class="warn">'.get_string($bypassstr, 'admin').'</p>';
} }
///Process the restrict if necessary ///Process the restrict if necessary
if ($restrictstr = $environment_result->getRestrictStr()) { if ($restrictstr = $environment_result->getRestrictStr()) {
$feedbacktext .= '<li class="environmenttable">'.get_string($restrictstr, 'admin').'</li>'; $feedbacktext .= '<p class="error">'.get_string($restrictstr, 'admin').'</p>';
}
if ($feedbacktext) {
$report = $report .$feedbacktext;
}
/// Add the row to the table

if ($environment_result->getPart() == 'custom_check'){
$otherdata[$messagetype][] = array ($info, $report, $status);

} else {
$serverdata[$messagetype][] = array ($type, $info, $report, $status);
} }
} }
} }

//put errors first in
/// Print table $servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
print_table($table); $othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);


/// And feedback accumulated text /// Print table
if ($feedbacktext) { print_heading(get_string('serverchecks', 'admin'));
print_simple_box('<ul>'.$feedbacktext.'</ul>', 'center', '90%'); print_table($servertable);
if (count($othertable->data)){
print_heading(get_string('customcheck', 'admin'));
print_table($othertable);
} }


/// Finally, if any error has happened, print the summary box /// Finally, if any error has happened, print the summary box
Expand Down Expand Up @@ -266,7 +299,7 @@ function normalize_version($version) {
* @return mixed the xmlized structure or false on error * @return mixed the xmlized structure or false on error
*/ */
function load_environment_xml() { function load_environment_xml() {

global $CFG; global $CFG;


static $data; //Only load and xmlize once by request static $data; //Only load and xmlize once by request
Expand Down Expand Up @@ -351,12 +384,12 @@ function get_latest_version_available ($version) {
} }




/** /**
* This function will return the xmlized data belonging to one Moodle version * This function will return the xmlized data belonging to one Moodle version
* @return mixed the xmlized structure or false on error * @return mixed the xmlized structure or false on error
*/ */
function get_environment_for_version($version) { function get_environment_for_version($version) {

/// Normalize the version requested /// Normalize the version requested
$version = normalize_version($version); $version = normalize_version($version);


Expand All @@ -377,12 +410,12 @@ function get_environment_for_version($version) {


/// We now we have it. Extract from full contents. /// We now we have it. Extract from full contents.
$fl_arr = array_flip($versions); $fl_arr = array_flip($versions);

return $contents['COMPATIBILITY_MATRIX']['#']['MOODLE'][$fl_arr[$version]]; return $contents['COMPATIBILITY_MATRIX']['#']['MOODLE'][$fl_arr[$version]];
} }




/** /**
* This function will check for everything (DB, PHP and PHP extensions for now) * This function will check for everything (DB, PHP and PHP extensions for now)
* returning an array of environment_result objects. * returning an array of environment_result objects.
* @param string $version xml version we are going to use to test this server * @param string $version xml version we are going to use to test this server
Expand Down Expand Up @@ -522,7 +555,7 @@ function environment_check_php($version) {
} else { } else {
$result->setStatus(false); $result->setStatus(false);
} }
$result->setLevel($level); $result->setLevel($level);
$result->setCurrentVersion($current_version); $result->setCurrentVersion($current_version);
$result->setNeededVersion($needed_version); $result->setNeededVersion($needed_version);
/// Process messages, modifying the $result if needed. /// Process messages, modifying the $result if needed.
Expand Down Expand Up @@ -626,7 +659,7 @@ function environment_check_database($version) {
} else { } else {
$result->setStatus(false); $result->setStatus(false);
} }
$result->setLevel($level); $result->setLevel($level);
$result->setCurrentVersion($current_version); $result->setCurrentVersion($current_version);
$result->setNeededVersion($needed_version); $result->setNeededVersion($needed_version);
$result->setInfo($current_vendor); $result->setInfo($current_vendor);
Expand Down Expand Up @@ -745,7 +778,7 @@ function process_environment_messages($xml, &$result) {
//--- Helper Class to return results to caller ---// //--- Helper Class to return results to caller ---//




/** /**
* This class is used to return the results of the environment * This class is used to return the results of the environment
* main functions (environment_check_xxxx) * main functions (environment_check_xxxx)
*/ */
Expand Down Expand Up @@ -828,7 +861,7 @@ function setNeededVersion($needed_version) {
function setInfo($info) { function setInfo($info) {
$this->info=$info; $this->info=$info;
} }

/** /**
* Set the feedback string * Set the feedback string
* @param string the feedback string * @param string the feedback string
Expand Down Expand Up @@ -878,7 +911,7 @@ function getLevel() {
} }


/** /**
* Get the current version * Get the current version
* @return string current version * @return string current version
*/ */
function getCurrentVersion() { function getCurrentVersion() {
Expand Down Expand Up @@ -958,7 +991,7 @@ function bypass_mysql416_reqs ($result) {
/// checker. All those functions will receive the result object and will /// checker. All those functions will receive the result object and will
/// return it modified as needed (status and bypass string) /// return it modified as needed (status and bypass string)


/** /**
* This function will restrict PHP reqs if: * This function will restrict PHP reqs if:
* - We are using PHP 5.0.x, informing about the buggy version * - We are using PHP 5.0.x, informing about the buggy version
* *
Expand Down

0 comments on commit 9d8453b

Please sign in to comment.