]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10168 improvements to display of results from environment checks
authorjamiesensei <jamiesensei>
Tue, 19 Jun 2007 15:52:19 +0000 (15:52 +0000)
committerjamiesensei <jamiesensei>
Tue, 19 Jun 2007 15:52:19 +0000 (15:52 +0000)
lang/en_utf8/admin.php
lib/environmentlib.php
theme/standard/styles_color.css

index e1caeb60e4bb96e7a4f07f0260898b1bc01fa4ee..0b2cd4ae320782dd513dd0f432015a9127794723 100644 (file)
@@ -1,7 +1,5 @@
-<?PHP // $Id$ 
+<?PHP // $Id$
       // admin.php - created with Moodle 1.7 beta + (2006101003)
-
-
 $string['accessdenied'] = 'Access denied';
 $string['accounts'] = 'Accounts';
 $string['adminseesall'] = 'Admins See All';
@@ -200,7 +198,7 @@ $string['configstatsmaxruntime'] = 'Stats processing can be quite intensive, so
 $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.';
@@ -223,6 +221,7 @@ $string['cronerrorpassword'] = 'Sorry, you have not provided a valid password to
 $string['cronremotepassword'] = 'Cron password for remote access';
 $string['cronwarning'] = 'The <a href=\"cron.php\">cron.php maintenance script</a> has not been run for at least 24 hours.';
 $string['curlrecommended'] = 'Installing the optional Curl library is highly recommended in order to enable Moodle Networking functionality.';
+$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.';
@@ -524,6 +523,7 @@ $string['searchinsettings'] = 'Search in settings';
 $string['secureforms'] = 'Use additional form security';
 $string['security'] = 'Security';
 $string['server'] = 'Server';
+$string['serverchecks'] = 'Server Checks';
 $string['serverlimit'] = 'Server Limit';
 $string['sessioncookie'] = 'Cookie prefix';
 $string['sessioncookiepath'] = 'Cookie path';
index 6f59e64848ea0fab741674d8883b28d30388cd63..1428256bc41c78af9a4386c9aa14e07e0f0bac64 100644 (file)
@@ -58,8 +58,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) {
@@ -114,14 +115,13 @@ 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)
  * @param array environment_results array of results gathered
  */
 function print_moodle_environment($result, $environment_results) {
-
 /// Get some strings
     $strname = get_string('name');
     $strinfo = get_string('info');
@@ -133,18 +133,26 @@ function print_moodle_environment($result, $environment_results) {
     $strbypassed = get_string('bypassed');
     $strrestricted = get_string('restricted');
     $strenvironmenterrortodo = get_string('environmenterrortodo', 'admin');
-
-/// Here we'll store all the feedback found
-    $feedbacktext = '';
-
-/// Table header
-    $table = new stdClass;
-    $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';
+/// 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());
 
 /// Iterate over each environment_result
     $continue = true;
@@ -205,46 +213,67 @@ 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%', '', '', 'environmentbox generalbox');
+/// 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
@@ -277,7 +306,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
@@ -289,7 +318,7 @@ function load_environment_xml() {
 /// First of all, take a look inside $CFG->dataroot/environment/environment.xml
     $file = $CFG->dataroot.'/environment/environment.xml';
     $internalfile = $CFG->dirroot.'/'.$CFG->admin.'/environment.xml';
-    if (!is_file($file) || !is_readable($file) || filemtime($file) < filemtime($internalfile) || 
+    if (!is_file($file) || !is_readable($file) || filemtime($file) < filemtime($internalfile) ||
         !$contents = file_get_contents($file)) {
     /// Fallback to fixed $CFG->admin/environment.xml
         if (!is_file($internalfile) || !is_readable($internalfile) || !$contents = file_get_contents($internalfile)) {
@@ -363,12 +392,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);
 
@@ -389,12 +418,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
@@ -534,7 +563,7 @@ function environment_custom_checks($version) {
         if (!is_null($result)) {
         /// Do any actions defined in the XML file.
             process_environment_result($check, $result);
-    
+
         /// Add the result to the array of results
             $results[] = $result;
         }
@@ -587,7 +616,7 @@ function environment_check_php($version) {
     } else {
         $result->setStatus(false);
     }
-    $result->setLevel($level);   
+    $result->setLevel($level);
     $result->setCurrentVersion($current_version);
     $result->setNeededVersion($needed_version);
 
@@ -722,7 +751,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);
@@ -837,7 +866,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)
  */
@@ -920,7 +949,7 @@ class environment_results {
     function setInfo($info) {
         $this->info=$info;
     }
-    
+
     /**
      * Set the feedback string
      * @param string the feedback string
@@ -970,7 +999,7 @@ class environment_results {
     }
 
     /**
-     * Get the current version 
+     * Get the current version
      * @return string current version
      */
     function getCurrentVersion() {
@@ -1050,7 +1079,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
  *
index 8db64941485b8a8fe6f00ae44ba40fddeed2839d..6b3453202f4a942da0c5ca9e0d373d2419bf9a60 100644 (file)
@@ -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;
 }
 
 
@@ -256,13 +256,13 @@ table.formtable tbody th {
  ***/
 
 .admin .generalbox {
-  border-color:#BBBBBB; 
-  background-color:#EEEEEE; 
+  border-color:#BBBBBB;
+  background-color:#EEEEEE;
 }
 
 .admin .informationbox {
-  border-color:#BBBBBB; 
-  background-color:#FFFFFF; 
+  border-color:#BBBBBB;
+  background-color:#FFFFFF;
 }
 
 body#admin-index .c0 {
@@ -361,6 +361,18 @@ table.flexible .r1 {
   background-color: #aaffaa;
 }
 
+body#admin-environment .error {
+    background-color : red;
+    color : inherit;
+}
+
+body#admin-environment .warn {
+    background-color : yellow;
+}
+
+body#admin-environment .ok {
+    background-color : lightgreen;
+}
 
 /***
  *** Blocks
@@ -807,7 +819,7 @@ table.message_search_results td {
 }
 
 #mod-chat-view #chatcurrentusers .idletime {
-  color: #888888;   
+  color: #888888;
 }
 
 /***
@@ -828,7 +840,7 @@ table.message_search_results td {
 }
 
 .forumpost .left {
-  background:#EEEEEE; 
+  background:#EEEEEE;
 }
 
 .forumpost .topic {
@@ -836,11 +848,11 @@ table.message_search_results td {
 }
 
 .forumpost .starter {
-  background:#DDDDDD; 
+  background:#DDDDDD;
 }
 
 .forumheaderlist .discussion .starter {
-  background:#DDDDDD; 
+  background:#DDDDDD;
 }
 
 .forumheaderlist td {
@@ -859,11 +871,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 {
 }