|
Moodle
2.2.1
http://www.collinsharper.com
|
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 00026 require_once('../config.php'); 00027 require_once($CFG->libdir.'/adminlib.php'); 00028 00029 $confirm = optional_param('confirm', 0, PARAM_BOOL); 00030 00031 admin_externalpage_setup('purgecaches'); 00032 00033 require_login(); 00034 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); 00035 00036 if ($confirm) { 00037 require_sesskey(); 00038 00039 // Valid request. Purge, and redisplay the form so it is easy to purge again 00040 // in the near future. 00041 purge_all_caches(); 00042 redirect(new moodle_url('/admin/purgecaches.php'), get_string('purgecachesfinished', 'admin')); 00043 00044 } else { 00045 // Show a confirm form. 00046 echo $OUTPUT->header(); 00047 echo $OUTPUT->heading(get_string('purgecaches', 'admin')); 00048 00049 $url = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1)); 00050 $button = new single_button($url, get_string('purgecaches','admin'), 'post'); 00051 00052 // Cancel button takes them back to the page the were on, if possible, 00053 // otherwise to the site home page. 00054 $return = new moodle_url('/'); 00055 if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) { 00056 if ($_SERVER['HTTP_REFERER'] !== "$CFG->wwwroot/$CFG->admin/purgecaches.php") { 00057 $return = $_SERVER['HTTP_REFERER']; 00058 } 00059 } 00060 00061 echo $OUTPUT->confirm(get_string('purgecachesconfirm', 'admin'), $button, $return); 00062 echo $OUTPUT->footer(); 00063 }