Skip to content
Browse files

MDL-10168 improvements to display of results from environment checks

  • Loading branch information...
1 parent 416622f commit 2685a2eee174ee5c73e086c91fe96d4b1535c4f8 jamiesensei committed
Showing with 155 additions and 66 deletions.
  1. +1 −0 .cvsignore
  2. +17 −0 .project
  3. +25 −0 config.php
  4. +4 −2 lang/en_utf8/admin.php
  5. +74 −42 lib/environmentlib.php
  6. +34 −22 theme/standard/styles_color.css
View
1 .cvsignore
@@ -0,0 +1 @@
+moodledata
View
17 .project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>moodle-MOODLE_17_STABLE</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>net.sourceforge.phpeclipse.parserbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>net.sourceforge.phpeclipse.phpnature</nature>
+ </natures>
+</projectDescription>
View
25 config.php
@@ -0,0 +1,25 @@
+<?php /// Moodle Configuration File
+
+unset($CFG);
+
+$CFG->dbtype = 'mysql';
+$CFG->dbhost = 'localhost';
+$CFG->dbname = 'mdl_stable_17';
+$CFG->dbuser = 'root';
+$CFG->dbpass = '';
+$CFG->dbpersist = false;
+$CFG->prefix = 'mdl_';
+
+$CFG->wwwroot = 'http://localhost/moodle-MOODLE_17_STABLE';
+$CFG->dirroot = 'C:\sites\moodle-MOODLE_17_STABLE';
+$CFG->dataroot = 'C:\sites\moodle-MOODLE_17_STABLE\moodledata';
+$CFG->admin = 'admin';
+
+$CFG->directorypermissions = 00777; // try 02777 on a server in Safe Mode
+
+$CFG->unicodedb = true; // Database is utf8
+
+require_once("$CFG->dirroot/lib/setup.php");
+// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
+// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
+?>
View
6 lang/en_utf8/admin.php
@@ -1,4 +1,4 @@
-<?PHP // $Id$
+<?PHP // $Id$
// admin.php - created with Moodle 1.7 beta + (2006101003)
@@ -167,7 +167,7 @@
$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 (all roles) 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['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.';
$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.';
@@ -184,6 +184,7 @@
$string['courses'] = 'Courses';
$string['coursesperpage'] = 'Courses per page';
$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['dbmigrate'] = 'Moodle Database Migration';
$string['dbmigrateconnecerror'] = 'Could not connect to the database specified.';
@@ -390,6 +391,7 @@
$string['secureforms'] = 'Use additional form security';
$string['security'] = 'Security';
$string['server'] = 'Server';
+$string['serverchecks'] = 'Server Checks';
$string['sessioncookie'] = 'Cookie prefix';
$string['sessioncookiepath'] = 'Cookie path';
$string['sessionhandling'] = 'Session Handling';
View
116 lib/environmentlib.php
@@ -55,8 +55,9 @@
* The function looks for the best version to compare and
* everything. This is the only function that should be called
* 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 boolean true/false, whether to print the table or just return results array
* @return boolean true/false, depending of results
*/
function check_moodle_environment($version, &$environment_results, $print_table=true) {
@@ -111,7 +112,7 @@ function check_moodle_environment($version, &$environment_results, $print_table=
return ($result && $status);
}
-/**
+/**
* This function will print one beautiful table with all the environmental
* configuration and how it suits Moodle needs.
* @param boolean final result of the check (true/false)
@@ -131,16 +132,27 @@ function print_moodle_environment($result, $environment_results) {
$strrestricted = get_string('restricted');
$strenvironmenterrortodo = get_string('environmenterrortodo', 'admin');
-/// Here we'll store all the feedback found
- $feedbacktext = '';
+/// Table headers
+ $servertable = new stdClass;//table for server checks
+ $servertable->head = array ($strname, $strinfo, $strreport, $strstatus);
+ $servertable->align = array ('center', 'center', 'left', 'center');
+ $servertable->wrap = array ('nowrap', '', '', 'nowrap');
+ $servertable->size = array ('10', 10, '100%', '10');
+ $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());
-/// Table header
- $table->head = array ($strname, $strinfo, $strreport, $strstatus);
- $table->align = array ('center', 'center', 'left', 'center');
- $table->wrap = array ('nowrap', '', '', 'nowrap');
- $table->size = array ('10', 10, '100%', '10');
- $table->width = '90%';
- $table->class = 'environmenttable generaltable';
/// Iterate over each environment_result
$continue = true;
@@ -195,46 +207,66 @@ function print_moodle_environment($result, $environment_results) {
$status = $strcheck;
$warningline = true;
} else { //Handle error result (error)
- $status = $strcheck;
+ $status = $strcheck;
$errorline = true;
}
}
}
}
-
+
/// 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
if ($errorline || $warningline) {
- $styletoapply = $errorline? 'error':'warn';
- $type = '<span class="'.$styletoapply.'">'.$type.'</span>';
- $info = '<span class="'.$styletoapply.'">'.$info.'</span>';
- $report = '<span class="'.$styletoapply.'">'.$report.'</span>';
- $status = '<span class="'.$styletoapply.'">'.$status.'</span>';
+ $messagetype = $errorline? 'error':'warn';
+ } else {
+ $messagetype = 'ok';
}
- /// Add the row to the table
- $table->data[] = array ($type, $info, $report, $status);
- ///Process the feedback if necessary
+ $status = '<span class="'.$messagetype.'">'.$status.'</span>';
+ /// Here we'll store all the feedback found
+ $feedbacktext = '';
+ ///Process the feedback if necessary
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
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
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);
}
}
}
-
-/// Print table
- print_table($table);
+ //put errors first in
+ $servertable->data = array_merge($serverdata['error'], $serverdata['warn'], $serverdata['ok']);
+ $othertable->data = array_merge($otherdata['error'], $otherdata['warn'], $otherdata['ok']);
-/// And feedback accumulated text
- if ($feedbacktext) {
- print_simple_box('<ul>'.$feedbacktext.'</ul>', 'center', '90%');
+/// Print table
+ print_heading(get_string('serverchecks', 'admin'));
+ 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
@@ -267,7 +299,7 @@ function normalize_version($version) {
* @return mixed the xmlized structure or false on error
*/
function load_environment_xml() {
-
+
global $CFG;
static $data; //Only load and xmlize once by request
@@ -352,12 +384,12 @@ function get_latest_version_available ($version) {
}
-/**
+/**
* This function will return the xmlized data belonging to one Moodle version
* @return mixed the xmlized structure or false on error
*/
function get_environment_for_version($version) {
-
+
/// Normalize the version requested
$version = normalize_version($version);
@@ -378,12 +410,12 @@ function get_environment_for_version($version) {
/// We now we have it. Extract from full contents.
$fl_arr = array_flip($versions);
-
+
return $contents['COMPATIBILITY_MATRIX']['#']['MOODLE'][$fl_arr[$version]];
}
-/**
+/**
* This function will check for everything (DB, PHP and PHP extensions for now)
* returning an array of environment_result objects.
* @param string $version xml version we are going to use to test this server
@@ -524,7 +556,7 @@ function environment_check_php($version) {
} else {
$result->setStatus(false);
}
- $result->setLevel($level);
+ $result->setLevel($level);
$result->setCurrentVersion($current_version);
$result->setNeededVersion($needed_version);
/// Process messages, modifying the $result if needed.
@@ -684,7 +716,7 @@ function environment_check_database($version) {
} else {
$result->setStatus(false);
}
- $result->setLevel($level);
+ $result->setLevel($level);
$result->setCurrentVersion($current_version);
$result->setNeededVersion($needed_version);
$result->setInfo($current_vendor);
@@ -803,7 +835,7 @@ function process_environment_messages($xml, &$result) {
//--- Helper Class to return results to caller ---//
-/**
+/**
* This class is used to return the results of the environment
* main functions (environment_check_xxxx)
*/
@@ -886,7 +918,7 @@ function setNeededVersion($needed_version) {
function setInfo($info) {
$this->info=$info;
}
-
+
/**
* Set the feedback string
* @param string the feedback string
@@ -936,7 +968,7 @@ function getLevel() {
}
/**
- * Get the current version
+ * Get the current version
* @return string current version
*/
function getCurrentVersion() {
@@ -1016,7 +1048,7 @@ function bypass_mysql416_reqs ($result) {
/// checker. All those functions will receive the result object and will
/// return it modified as needed (status and bypass string)
-/**
+/**
* This function will restrict PHP reqs if:
* - We are using PHP 5.0.x, informing about the buggy version
*
View
56 theme/standard/styles_color.css
@@ -1,7 +1,7 @@
/*******************************************************************
styles_color.css
-
- This CSS file contains all color definitions like
+
+ This CSS file contains all color definitions like
background-color, font-color, border-color etc.
Styles are organised into the following sections:
@@ -91,11 +91,11 @@ table.formtable tbody th {
}
/* Alternate rows even */
-.r0 {
+.r0 {
}
/* Alternate rows odd */
-.r1 {
+.r1 {
}
/* notification messages (can be good or bad) */
@@ -114,20 +114,20 @@ table.formtable tbody th {
}
.generalbox {
- border-color:#DDDDDD;
+ border-color:#DDDDDD;
}
.informationbox {
- border-color:#DDDDDD;
+ border-color:#DDDDDD;
}
.feedbackbox {
- border-color: #888888;
+ border-color: #888888;
}
.feedbackby {
background-color:#BBBBBB;
}
.noticebox {
- border-color:#DDDDDD;
+ border-color:#DDDDDD;
}
.errorbox {
@@ -162,7 +162,7 @@ table.formtable tbody th {
.unread {
background: #FFD991;
-}
+}
.censoredtext {
color:#000000;
@@ -185,11 +185,11 @@ table.formtable tbody th {
.generaltable .cell {
background-color:#FFFFFF;
- border-color:#EEEEEE;
+ border-color:#EEEEEE;
}
.generaltable {
- border-color:#EEEEEE;
+ border-color:#EEEEEE;
}
@@ -244,16 +244,16 @@ table.formtable tbody th {
***/
.admin .generalboxcontent {
- background-color:#EEEEEE;
+ background-color:#EEEEEE;
}
.admin .generalbox {
- border-color:#BBBBBB;
+ border-color:#BBBBBB;
}
.admin .informationbox {
- border-color:#BBBBBB;
- background-color:#FFFFFF;
+ border-color:#BBBBBB;
+ background-color:#FFFFFF;
}
body#admin-index .c0 {
@@ -324,6 +324,18 @@ table.flexible .r1 {
background-color:#EEEEEE;
}
+body#admin-environment .error {
+ background-color : red;
+ color : inherit;
+}
+
+body#admin-environment .warn {
+ background-color : yellow;
+}
+
+body#admin-environment .ok {
+ background-color : lightgreen;
+}
/***
*** Blocks
***/
@@ -665,7 +677,7 @@ table.message_search_results td {
}
.que .feedback {
border-color: #DDD;
-}
+}
.que.multianswer .incorrect {
background-color: #faa;
}
@@ -779,7 +791,7 @@ table.message_search_results td {
}
.forumpost .left {
- background:#EEEEEE;
+ background:#EEEEEE;
}
.forumpost .topic {
@@ -787,11 +799,11 @@ table.message_search_results td {
}
.forumpost .starter {
- background:#DDDDDD;
+ background:#DDDDDD;
}
.forumheaderlist .discussion .starter {
- background:#DDDDDD;
+ background:#DDDDDD;
}
.forumheaderlist td {
@@ -810,11 +822,11 @@ table.message_search_results td {
}
#mod-forum-discuss .forumpost.unread .content {
- border-color: #FFD991;
-}
+ border-color: #FFD991;
+}
#mod-forum-discuss .forumthread .unread {
-}
+}
#mod-forum-index .unread {
}

0 comments on commit 2685a2e

Please sign in to comment.
Something went wrong with that request. Please try again.