Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/environment.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00030 require_once('../config.php');
00031 require_once($CFG->libdir.'/adminlib.php');
00032 require_once($CFG->libdir.'/environmentlib.php');
00033 require_once($CFG->libdir.'/componentlib.class.php');
00034 
00035 // Parameters
00036 $action  = optional_param('action', '', PARAM_ACTION);
00037 $version = optional_param('version', '', PARAM_FILE); //
00038 
00039 $extraurlparams = array();
00040 if ($version) {
00041     $extraurlparams['version'] = $version;
00042 }
00043 admin_externalpage_setup('environment', '', $extraurlparams);
00044 
00045 // Handle the 'updatecomponent' action
00046 if ($action == 'updatecomponent' && confirm_sesskey()) {
00047     // Create component installer and execute it
00048     if ($cd = new component_installer('http://download.moodle.org',
00049                                       'environment',
00050                                       'environment.zip')) {
00051         $status = $cd->install(); //returns COMPONENT_(ERROR | UPTODATE | INSTALLED)
00052         switch ($status) {
00053             case COMPONENT_ERROR:
00054                 if ($cd->get_error() == 'remotedownloaderror') {
00055                     $a = new stdClass();
00056                     $a->url  = 'http://download.moodle.org/environment/environment.zip';
00057                     $a->dest = $CFG->dataroot . '/';
00058                     print_error($cd->get_error(), 'error', $PAGE->url, $a);
00059                     die();
00060 
00061                 } else {
00062                     print_error($cd->get_error(), 'error', $PAGE->url);
00063                     die();
00064                 }
00065 
00066             case COMPONENT_UPTODATE:
00067                 redirect($PAGE->url, get_string($cd->get_error(), 'error'));
00068                 die;
00069 
00070             case COMPONENT_INSTALLED:
00071                 redirect($PAGE->url, get_string('componentinstalled', 'admin'));
00072                 die;
00073         }
00074     }
00075 }
00076 
00077 // Get current Moodle version
00078 $current_version = $CFG->release;
00079 
00080 // Calculate list of versions
00081 $versions = array();
00082 if ($contents = load_environment_xml()) {
00083     if ($env_versions = get_list_of_environment_versions($contents)) {
00084         // Set the current version at the beginning
00085         $env_version = normalize_version($current_version); //We need this later (for the upwards)
00086         $versions[$env_version] = $current_version;
00087         // If no version has been previously selected, default to $current_version
00088         if (empty($version)) {
00089             $version =  $env_version;
00090         }
00091         //Iterate over each version, adding bigger than current
00092         foreach ($env_versions as $env_version) {
00093             if (version_compare(normalize_version($current_version), $env_version, '<')) {
00094                 $versions[$env_version] = $env_version;
00095             }
00096         }
00097         // Add 'upwards' to the last element
00098         $versions[$env_version] = $env_version.' '.get_string('upwards', 'admin');
00099     } else {
00100         $versions = array('error' => get_string('error'));
00101     }
00102 }
00103 
00104 // Get the results of the environment check.
00105 list($envstatus, $environment_results) = check_moodle_environment($version);
00106 
00107 // Display the page.
00108 $output = $PAGE->get_renderer('core', 'admin');
00109 echo $output->environment_check_page($versions, $version, $envstatus, $environment_results);
 All Data Structures Namespaces Files Functions Variables Enumerations