Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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.
13
//
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/>.
16
 
17
/**
18
 * This script triggers a full purging of system caches,
19
 * this is useful mostly for developers who did not disable the caching.
20
 *
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
24
 */
25
 
1441 ariadna 26
define('IGNORE_COMPONENT_CACHE', true);
27
 
1 efrain 28
require_once('../config.php');
29
require_once($CFG->libdir.'/adminlib.php');
30
 
31
$confirm = optional_param('confirm', 0, PARAM_BOOL);
32
$returnurl = optional_param('returnurl', '/admin/purgecaches.php', PARAM_LOCALURL);
33
$returnurl = new moodle_url($returnurl);
34
 
35
admin_externalpage_setup('purgecaches');
36
 
37
$form = new core_admin\form\purge_caches(null, ['returnurl' => $returnurl]);
38
 
39
// If we have got here as a confirmed aciton, do it.
40
if ($data = $form->get_data()) {
41
 
42
    // Valid request. Purge, and redirect the user back to where they came from.
43
    if (isset($data->all)) {
44
        purge_caches();
45
        $message = get_string('purgecachesfinished', 'admin');
46
    } else {
1441 ariadna 47
        // When passing selected options, ensure each is cast to boolean for strict comparison.
48
        purge_caches(array_map(
49
            fn($option) => (bool) $option,
50
            $data->purgeselectedoptions,
51
        ));
1 efrain 52
        $message = get_string('purgeselectedcachesfinished', 'admin');
53
    }
54
 
55
} else if ($confirm && confirm_sesskey()) {
56
    purge_caches();
57
    $message = get_string('purgecachesfinished', 'admin');
58
}
59
 
60
// Redirect and/or show notification message confirming cache(s) were purged.
61
if (isset($message)) {
62
    if (!$PAGE->url->compare($returnurl, URL_MATCH_BASE)) {
63
        redirect($returnurl, $message);
64
    }
65
 
66
    // We are already on the purge caches page, add the notification.
67
    \core\notification::add($message, \core\output\notification::NOTIFY_INFO);
68
}
69
 
70
// Otherwise, show a form to actually purge the caches.
71
 
72
echo $OUTPUT->header();
73
echo $OUTPUT->heading(get_string('purgecachespage', 'admin'));
74
 
75
echo $OUTPUT->box_start('generalbox', 'notice');
76
echo html_writer::tag('p', get_string('purgecachesconfirm', 'admin'));
77
echo $form->render();
78
echo $OUTPUT->box_end();
79
 
80
echo $OUTPUT->footer();