2009-11-01 10:57:00 +00:00
|
|
|
<?php
|
2006-01-16 19:32:14 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// //
|
|
|
|
// NOTICE OF COPYRIGHT //
|
|
|
|
// //
|
|
|
|
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
|
|
|
// http://moodle.com //
|
|
|
|
// //
|
2007-12-31 01:10:54 +00:00
|
|
|
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
|
2006-01-16 19:32:14 +00:00
|
|
|
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License for more details: //
|
|
|
|
// //
|
|
|
|
// http://www.gnu.org/copyleft/gpl.html //
|
|
|
|
// //
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-01-16 23:31:05 +00:00
|
|
|
// This file is the admin frontend to execute all the checks available
|
|
|
|
// in the environment.xml file. It includes database, php and
|
|
|
|
// php_extensions. Also, it's possible to update the xml file
|
|
|
|
// from moodle.org be able to check more and more versions.
|
2006-01-16 19:32:14 +00:00
|
|
|
|
2006-01-18 00:23:57 +00:00
|
|
|
require_once('../config.php');
|
2006-09-02 13:14:57 +00:00
|
|
|
require_once($CFG->libdir.'/adminlib.php');
|
2006-01-18 00:23:57 +00:00
|
|
|
require_once($CFG->libdir.'/environmentlib.php');
|
2006-01-31 14:53:05 +00:00
|
|
|
require_once($CFG->libdir.'/componentlib.class.php');
|
2006-01-18 00:23:57 +00:00
|
|
|
|
2007-04-30 17:08:34 +00:00
|
|
|
admin_externalpage_setup('environment');
|
2006-01-18 00:23:57 +00:00
|
|
|
|
|
|
|
/// Parameters
|
2006-03-06 10:02:59 +00:00
|
|
|
$action = optional_param('action', '', PARAM_ACTION);
|
|
|
|
$version = optional_param('version', '', PARAM_FILE); //
|
2006-01-18 00:23:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
/// Get some strings
|
|
|
|
$stradmin = get_string('administration');
|
|
|
|
$stradminhelpenvironment = get_string("adminhelpenvironment");
|
|
|
|
$strenvironment = get_string('environment', 'admin');
|
|
|
|
$strerror = get_string('error');
|
|
|
|
$strmoodleversion = get_string('moodleversion');
|
2006-01-31 14:53:05 +00:00
|
|
|
$strupdate = get_string('updatecomponent', 'admin');
|
2006-01-18 00:23:57 +00:00
|
|
|
$strupwards = get_string('upwards', 'admin');
|
2006-06-30 13:06:31 +00:00
|
|
|
$strmisc = get_string('miscellaneous');
|
2006-01-18 00:23:57 +00:00
|
|
|
|
|
|
|
/// Print the header stuff
|
2007-04-30 17:08:34 +00:00
|
|
|
admin_externalpage_print_header();
|
2006-01-18 00:23:57 +00:00
|
|
|
|
2006-01-31 14:53:05 +00:00
|
|
|
/// Print the component download link
|
2009-01-02 10:36:25 +00:00
|
|
|
echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&sesskey='.sesskey().'">'.$strupdate.'</a></div>';
|
2006-01-31 14:53:05 +00:00
|
|
|
|
2009-08-06 08:17:12 +00:00
|
|
|
echo $OUTPUT->heading($strenvironment);
|
2006-01-18 00:23:57 +00:00
|
|
|
|
2006-01-31 14:53:05 +00:00
|
|
|
/// Handle the 'updatecomponent' action
|
|
|
|
if ($action == 'updatecomponent' && confirm_sesskey()) {
|
|
|
|
/// Create component installer and execute it
|
|
|
|
if ($cd = new component_installer('http://download.moodle.org',
|
|
|
|
'environment',
|
2006-01-31 15:03:52 +00:00
|
|
|
'environment.zip')) {
|
2007-12-31 01:10:54 +00:00
|
|
|
$status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
|
2006-01-31 14:53:05 +00:00
|
|
|
switch ($status) {
|
2007-12-31 01:10:54 +00:00
|
|
|
case COMPONENT_ERROR:
|
2007-12-30 22:19:36 +00:00
|
|
|
if ($cd->get_error() == 'remotedownloaderror') {
|
2006-01-31 14:53:05 +00:00
|
|
|
$a = new stdClass();
|
|
|
|
$a->url = 'http://download.moodle.org/environment/environment.zip';
|
|
|
|
$a->dest= $CFG->dataroot.'/';
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box(get_string($cd->get_error(), 'error', $a), 'errorbox');
|
2006-01-31 14:53:05 +00:00
|
|
|
} else {
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box(get_string($cd->get_error(), 'error'), 'errorbox');
|
2006-01-31 14:53:05 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-12-31 01:10:54 +00:00
|
|
|
case COMPONENT_UPTODATE:
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box(get_string($cd->get_error(), 'error'));
|
2006-01-31 14:53:05 +00:00
|
|
|
break;
|
2007-12-31 01:10:54 +00:00
|
|
|
case COMPONENT_INSTALLED:
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box(get_string('componentinstalled', 'admin'));
|
2006-01-31 14:53:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-18 00:23:57 +00:00
|
|
|
/// Start of main box
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box_start();
|
2006-01-18 23:05:07 +00:00
|
|
|
|
2007-02-06 08:24:37 +00:00
|
|
|
echo "<div style=\"text-align:center\">".$stradminhelpenvironment."</div><br />";
|
2006-01-18 00:23:57 +00:00
|
|
|
|
|
|
|
/// Get current Moodle version
|
|
|
|
$current_version = $CFG->release;
|
|
|
|
|
|
|
|
/// Calculate list of versions
|
|
|
|
$versions = array();
|
|
|
|
if ($contents = load_environment_xml()) {
|
|
|
|
if ($env_versions = get_list_of_environment_versions($contents)) {
|
|
|
|
/// Set the current version at the beginning
|
|
|
|
$env_version = normalize_version($current_version); //We need this later (for the upwards)
|
|
|
|
$versions[$env_version] = $current_version;
|
|
|
|
/// If no version has been previously selected, default to $current_version
|
|
|
|
if (empty($version)) {
|
|
|
|
$version = $env_version;
|
|
|
|
}
|
|
|
|
///Iterate over each version, adding bigged than current
|
|
|
|
foreach ($env_versions as $env_version) {
|
|
|
|
if (version_compare(normalize_version($current_version), $env_version, '<')) {
|
|
|
|
$versions[$env_version] = $env_version;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// Add 'upwards' to the last element
|
|
|
|
$versions[$env_version] = $env_version.' '.$strupwards;
|
|
|
|
} else {
|
|
|
|
$versions = array('error' => $strerror);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Print form and popup menu
|
2007-02-06 08:24:37 +00:00
|
|
|
echo '<div style="text-align:center">'.$strmoodleversion.' ';
|
2009-08-10 08:38:45 +00:00
|
|
|
$select = html_select::make_popup_form("$CFG->wwwroot/$CFG->admin/environment.php", 'version', $versions, 'selectversion', $version);
|
2009-08-10 03:35:38 +00:00
|
|
|
$select->nothinglabel = false;
|
|
|
|
echo $OUTPUT->select($select);
|
2006-11-20 09:44:11 +00:00
|
|
|
echo '</div>';
|
|
|
|
|
2006-01-18 00:23:57 +00:00
|
|
|
/// End of main box
|
2009-08-18 04:28:40 +00:00
|
|
|
echo $OUTPUT->box_end();
|
2006-01-18 00:23:57 +00:00
|
|
|
|
2006-01-18 23:05:07 +00:00
|
|
|
/// Gather and show results
|
|
|
|
$status = check_moodle_environment($version, $environment_results);
|
|
|
|
|
2006-01-18 00:23:57 +00:00
|
|
|
/// Print footer
|
2009-08-06 14:12:46 +00:00
|
|
|
echo $OUTPUT->footer();
|
2009-11-01 10:57:00 +00:00
|
|
|
|