diff --git a/admin/index.php b/admin/index.php index 68fa429325e..b50c0e17a9c 100644 --- a/admin/index.php +++ b/admin/index.php @@ -378,8 +378,6 @@ if (!empty($CFG->maintenance_enabled)) { echo $OUTPUT->box(get_string('sitemaintenancewarning2', 'admin', "$CFG->wwwroot/$CFG->admin/settings.php?section=maintenancemode"), 'generalbox adminwarning'); } -echo $OUTPUT->single_button(new moodle_url('/admin/purgecaches.php'), get_string('purgecaches', 'admin'), 'post'); - ////////////////////////////////////////////////////////////////////////////////////////////////// //// IT IS ILLEGAL AND A VIOLATION OF THE GPL TO HIDE, REMOVE OR MODIFY THIS COPYRIGHT NOTICE /// $copyrighttext = 'Moodle '. diff --git a/admin/purgecaches.php b/admin/purgecaches.php index e240bf72e8b..bddb5478f17 100644 --- a/admin/purgecaches.php +++ b/admin/purgecaches.php @@ -24,15 +24,26 @@ */ require_once('../config.php'); +require_once($CFG->libdir.'/adminlib.php'); $confirm = optional_param('confirm', 0, PARAM_BOOL); -$PAGE->set_url('/admin/purgecaches.php'); +admin_externalpage_setup('purgecaches'); require_login(); require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); -require_sesskey(); -purge_all_caches(); +if ($confirm) { + require_sesskey(); + purge_all_caches(); + redirect($_SERVER['HTTP_REFERER'], get_string('purgecachesfinished', 'admin')); +} else { + echo $OUTPUT->header(); + echo $OUTPUT->heading(get_string('purgecaches', 'admin')); -redirect(new moodle_url('/admin/index.php'), get_string('purgecachesfinished', 'admin')); + $url = new moodle_url('/admin/purgecaches.php', array('sesskey'=>sesskey(), 'confirm'=>1)); + $return = $_SERVER['HTTP_REFERER']; + echo $OUTPUT->confirm(get_string('purgecachesconfirm', 'admin'), $url, $return); + + echo $OUTPUT->footer(); +} diff --git a/admin/settings/development.php b/admin/settings/development.php index 068b6fac43b..b7ac470620d 100644 --- a/admin/settings/development.php +++ b/admin/settings/development.php @@ -44,4 +44,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page if ($CFG->mnet_dispatcher_mode !== 'off') { $ADMIN->add('development', new admin_externalpage('mnettestclient', get_string('testclient', 'mnet'), "$CFG->wwwroot/$CFG->admin/mnet/testclient.php")); } + + $ADMIN->add('development', new admin_externalpage('purgecaches', get_string('purgecaches','admin'), "$CFG->wwwroot/$CFG->admin/purgecaches.php")); } // end of speedup diff --git a/lang/en/admin.php b/lang/en/admin.php index f2a0976f4ea..cb532b13b06 100755 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -830,6 +830,7 @@ $string['requiredtemplate'] = 'Required. You may use template syntax here (%l = $string['requiremodintro'] = 'Require activity description'; $string['requires'] = 'Requires'; $string['purgecaches']= 'Purge all caches'; +$string['purgecachesconfirm']= 'Moodle can cache themes, javascript, language strings, filtered text, rss feeds and many other pieces of calculated data. Purging these caches will delete that data from the server and force browsers to refetch data, so that you can be sure you are seeing the most up-to-date values produced by the current code. There is no danger in purging caches, but your site may appear slower for a while until the server and clients calculate new information and cache it.'; $string['purgecachesfinished']= 'All caches were purged.'; $string['restrictbydefault'] = 'Restrict modules by default'; $string['restrictmodulesfor'] = 'Restrict modules for'; diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php index 096983dbe96..9d5f3ba12ce 100644 --- a/lib/outputrenderers.php +++ b/lib/outputrenderers.php @@ -354,6 +354,9 @@ class core_renderer extends renderer_base { if (!empty($CFG->debugpageinfo)) { $output .= '
This page is: ' . $this->page->debug_summary() . '
'; } + if (debugging(null, DEBUG_DEVELOPER)) { // Only in developer mode + $output .= '
'.get_string('purgecaches', 'admin').'
'; + } if (!empty($CFG->debugvalidators)) { $output .= '