Merge branch 'm22_MDL-33053_AICC_flattened_TOC' of git://github.com/scara/moodle...
[moodle.git] / admin / purgecaches.php
blobf437e8ac8a759c6fa65825fae036b34d875d02b1
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * This script triggers a full purging of system caches,
19 * this is useful mostly for developers who did not disable the caching.
21 * @package core
22 * @copyright 2010 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 require_once('../config.php');
27 require_once($CFG->libdir.'/adminlib.php');
29 $confirm = optional_param('confirm', 0, PARAM_BOOL);
31 admin_externalpage_setup('purgecaches');
33 require_login();
34 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
36 if ($confirm) {
37 require_sesskey();
39 // Valid request. Purge, and redisplay the form so it is easy to purge again
40 // in the near future.
41 purge_all_caches();
42 redirect(new moodle_url('/admin/purgecaches.php'), get_string('purgecachesfinished', 'admin'));
44 } else {
45 // Show a confirm form.
46 echo $OUTPUT->header();
47 echo $OUTPUT->heading(get_string('purgecaches', 'admin'));
49 $url = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1));
50 $button = new single_button($url, get_string('purgecaches','admin'), 'post');
52 // Cancel button takes them back to the page the were on, if possible,
53 // otherwise to the site home page.
54 $return = new moodle_url('/');
55 if (isset($_SERVER['HTTP_REFERER']) and !empty($_SERVER['HTTP_REFERER'])) {
56 if ($_SERVER['HTTP_REFERER'] !== "$CFG->wwwroot/$CFG->admin/purgecaches.php") {
57 $return = $_SERVER['HTTP_REFERER'];
61 echo $OUTPUT->confirm(get_string('purgecachesconfirm', 'admin'), $button, $return);
62 echo $OUTPUT->footer();