-<?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';
$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.';
$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.';
$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';
* 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) {
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');
$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;
$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
* @return mixed the xmlized structure or false on error
*/
function load_environment_xml() {
-
+
global $CFG;
static $data; //Only load and xmlize once by request
/// 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)) {
}
-/**
+/**
* 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);
/// 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
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;
}
} else {
$result->setStatus(false);
}
- $result->setLevel($level);
+ $result->setLevel($level);
$result->setCurrentVersion($current_version);
$result->setNeededVersion($needed_version);
} else {
$result->setStatus(false);
}
- $result->setLevel($level);
+ $result->setLevel($level);
$result->setCurrentVersion($current_version);
$result->setNeededVersion($needed_version);
$result->setInfo($current_vendor);
//--- Helper Class to return results to caller ---//
-/**
+/**
* This class is used to return the results of the environment
* main functions (environment_check_xxxx)
*/
function setInfo($info) {
$this->info=$info;
}
-
+
/**
* Set the feedback string
* @param string the feedback string
}
/**
- * Get the current version
+ * Get the current version
* @return string current version
*/
function getCurrentVersion() {
/// 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
*