Petr's patch for MDL-7327 to modify require_capability login a bit
[moodle.git] / admin / maintenance.php
blob9b4f2d9bb76117bc0e13757b9ca52a367280198b
1 <?php // $Id$
2 // Enables/disables maintenance mode
4 require('../config.php');
5 require_once($CFG->libdir.'/adminlib.php');
7 $action = optional_param('action', '', PARAM_ALPHA);
9 $adminroot = admin_get_root();
10 admin_externalpage_setup('maintenancemode', $adminroot);
12 //Check folder exists
13 if (! make_upload_directory(SITEID)) { // Site folder
14 error("Could not create site folder. The site administrator needs to fix the file permissions");
17 $filename = $CFG->dataroot.'/'.SITEID.'/maintenance.html';
19 if ($form = data_submitted()) {
20 if (confirm_sesskey()) {
21 if ($form->action == "disable") {
22 unlink($filename);
23 redirect('maintenance.php', get_string('sitemaintenanceoff','admin'));
24 } else {
25 $file = fopen($filename, 'w');
26 fwrite($file, stripslashes($form->text));
27 fclose($file);
28 redirect('maintenance.php', get_string('sitemaintenanceon', 'admin'));
33 /// Print the header stuff
35 admin_externalpage_print_header($adminroot);
37 /// Print the appropriate form
39 if (file_exists($filename)) { // We are in maintenance mode
40 echo '<center>';
41 echo '<form action="maintenance.php" method="post">';
42 echo '<input type="hidden" name="action" value="disable">';
43 echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
44 echo '<p><input type="submit" value="'.get_string('disable').'"></p>';
45 echo '</form>';
46 echo '</center>';
47 } else { // We are not in maintenance mode
48 $usehtmleditor = can_use_html_editor();
50 echo '<center>';
51 echo '<form action="maintenance.php" method="post">';
52 echo '<input type="hidden" name="action" value="enable">';
53 echo '<input type="hidden" name="sesskey" value="'.sesskey().'">';
54 echo '<p><input type="submit" value="'.get_string('enable').'"></p>';
55 echo '<p>'.get_string('optionalmaintenancemessage', 'admin').':</p>';
56 echo '<table><tr><td>';
57 print_textarea($usehtmleditor, 20, 50, 600, 400, "text");
58 echo '</td></tr></table>';
59 echo '</form>';
60 echo '</center>';
62 if ($usehtmleditor) {
63 use_html_editor();
67 admin_externalpage_print_footer($adminroot);