3 ///////////////////////////////////////////////////////////////////////////
5 // NOTICE OF COPYRIGHT //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // http://moodle.com //
10 // Copyright (C) 2001-3001 Martin Dougiamas http://dougiamas.com //
11 // (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
13 // This program is free software; you can redistribute it and/or modify //
14 // it under the terms of the GNU General Public License as published by //
15 // the Free Software Foundation; either version 2 of the License, or //
16 // (at your option) any later version. //
18 // This program is distributed in the hope that it will be useful, //
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
21 // GNU General Public License for more details: //
23 // http://www.gnu.org/copyleft/gpl.html //
25 ///////////////////////////////////////////////////////////////////////////
27 // This file is the admin frontend to execute all the checks available
28 // in the environment.xml file. It includes database, php and
29 // php_extensions. Also, it's possible to update the xml file
30 // from moodle.org be able to check more and more versions.
32 require_once('../config.php');
33 require_once($CFG->libdir
.'/adminlib.php');
34 require_once($CFG->libdir
.'/environmentlib.php');
35 require_once($CFG->libdir
.'/componentlib.class.php');
37 admin_externalpage_setup('environment');
40 $action = optional_param('action', '', PARAM_ACTION
);
41 $version = optional_param('version', '', PARAM_FILE
); //
45 $stradmin = get_string('administration');
46 $stradminhelpenvironment = get_string("adminhelpenvironment");
47 $strenvironment = get_string('environment', 'admin');
48 $strerror = get_string('error');
49 $strmoodleversion = get_string('moodleversion');
50 $strupdate = get_string('updatecomponent', 'admin');
51 $strupwards = get_string('upwards', 'admin');
52 $strmisc = get_string('miscellaneous');
54 /// Print the header stuff
55 admin_externalpage_print_header();
57 /// Print the component download link
58 echo '<div class="reportlink"><a href="environment.php?action=updatecomponent&sesskey='.$USER->sesskey
.'">'.$strupdate.'</a></div>';
60 print_heading($strenvironment);
62 /// Handle the 'updatecomponent' action
63 if ($action == 'updatecomponent' && confirm_sesskey()) {
64 /// Create component installer and execute it
65 if ($cd = new component_installer('http://download.moodle.org',
68 $status = $cd->install(); //returns ERROR | UPTODATE | INSTALLED
71 if ($cd->get_error() == 'remotedownloadnotallowed') {
73 $a->url
= 'http://download.moodle.org/environment/environment.zip';
74 $a->dest
= $CFG->dataroot
.'/';
75 print_simple_box(get_string($cd->get_error(), 'error', $a), 'center', '', '', 5, 'errorbox');
77 print_simple_box(get_string($cd->get_error(), 'error'), 'center', '', '', 5, 'errorbox');
81 print_simple_box(get_string($cd->get_error(), 'error'), 'center');
84 print_simple_box(get_string('componentinstalled', 'admin'), 'center');
91 print_simple_box_start('center');
93 echo "<div style=\"text-align:center\">".$stradminhelpenvironment."</div><br />";
95 /// Get current Moodle version
96 $current_version = $CFG->release
;
98 /// Calculate list of versions
100 if ($contents = load_environment_xml()) {
101 if ($env_versions = get_list_of_environment_versions($contents)) {
102 /// Set the current version at the beginning
103 $env_version = normalize_version($current_version); //We need this later (for the upwards)
104 $versions[$env_version] = $current_version;
105 /// If no version has been previously selected, default to $current_version
106 if (empty($version)) {
107 $version = $env_version;
109 ///Iterate over each version, adding bigged than current
110 foreach ($env_versions as $env_version) {
111 if (version_compare(normalize_version($current_version), $env_version, '<')) {
112 $versions[$env_version] = $env_version;
115 /// Add 'upwards' to the last element
116 $versions[$env_version] = $env_version.' '.$strupwards;
118 $versions = array('error' => $strerror);
122 /// Print form and popup menu
123 echo '<div style="text-align:center">'.$strmoodleversion.' ';
124 popup_form("$CFG->wwwroot/$CFG->admin/environment.php?version=",
125 $versions, 'selectversion', $version, '');
129 print_simple_box_end();
131 /// Gather and show results
132 $status = check_moodle_environment($version, $environment_results);
135 admin_externalpage_print_footer();