Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/admin/cli/maintenance.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00027 define('CLI_SCRIPT', true);
00028 
00029 require(dirname(dirname(dirname(__FILE__))).'/config.php');
00030 require_once($CFG->libdir.'/clilib.php');      // cli only functions
00031 
00032 
00033 // now get cli options
00034 list($options, $unrecognized) = cli_get_params(array('enable'=>false, 'disable'=>false, 'help'=>false),
00035                                                array('h'=>'help'));
00036 
00037 if ($unrecognized) {
00038     $unrecognized = implode("\n  ", $unrecognized);
00039     cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
00040 }
00041 
00042 if ($options['help']) {
00043     $help =
00044 "Maintenance mode settings.
00045 Current status displayed if not option specified.
00046 
00047 Options:
00048 --enable              Enable maintenance mode
00049 --disable             Disable maintenance mode
00050 -h, --help            Print out this help
00051 
00052 Example:
00053 \$sudo -u www-data /usr/bin/php admin/cli/maintenance.php
00054 "; //TODO: localize - to be translated later when everything is finished
00055 
00056     echo $help;
00057     die;
00058 }
00059 
00060 cli_heading(get_string('sitemaintenancemode', 'admin')." ($CFG->wwwroot)");
00061 
00062 if ($options['enable']) {
00063     set_config('maintenance_enabled', 1);
00064     echo get_string('sitemaintenanceon', 'admin')."\n";
00065     exit(0);
00066 } else if ($options['disable']) {
00067     set_config('maintenance_enabled', 0);
00068     echo get_string('sitemaintenanceoff', 'admin')."\n";
00069     exit(0);
00070 }
00071 
00072 if (!empty($CFG->maintenance_enabled)) {
00073     echo get_string('clistatusenabled', 'admin')."\n";
00074 } else {
00075     echo get_string('clistatusdisabled', 'admin')."\n";
00076 }
 All Data Structures Namespaces Files Functions Variables Enumerations