From 7e7e108f9376db5334bc188adcc3de2dd9b43f2c Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Thu, 18 Oct 2012 14:40:51 +0800 Subject: [PATCH] MDL-36115 cache: Fixed up requirements check in cache admin interfaces --- cache/admin.php | 3 +++ cache/locallib.php | 4 ++-- lang/en/cache.php | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cache/admin.php b/cache/admin.php index aeed928e8636f..ce26856927392 100644 --- a/cache/admin.php +++ b/cache/admin.php @@ -54,6 +54,9 @@ break; case 'addstore' : // Add the requested store. $plugin = required_param('plugin', PARAM_PLUGIN); + if (!$plugins[$plugin]['canaddinstance']) { + print_error('ex_unmetstorerequirements', 'cache'); + } $mform = cache_administration_helper::get_add_store_form($plugin); $title = get_string('addstore', 'cache', $plugins[$plugin]['name']); if ($mform->is_cancelled()) { diff --git a/cache/locallib.php b/cache/locallib.php index 08a3ca9da1ac1..8b6c3ab6f8b17 100644 --- a/cache/locallib.php +++ b/cache/locallib.php @@ -566,7 +566,7 @@ public static function get_store_plugin_summaries() { 'nativelocking' => (in_array('cache_is_lockable', class_implements($class))), 'keyawareness' => (array_key_exists('cache_is_key_aware', class_implements($class))), ), - 'canaddinstance' => ($class::can_add_instance()) + 'canaddinstance' => ($class::can_add_instance() && $class::are_requirements_met()) ); } @@ -702,7 +702,7 @@ public static function get_store_instance_actions($name, array $storedetails) { */ public static function get_store_plugin_actions($name, array $plugindetails) { $actions = array(); - if (has_capability('moodle/site:config', get_system_context())) { + if (has_capability('moodle/site:config', context_system::instance())) { if (!empty($plugindetails['canaddinstance'])) { $url = new moodle_url('/cache/admin.php', array('action' => 'addstore', 'plugin' => $name, 'sesskey' => sesskey())); $actions[] = array( diff --git a/lang/en/cache.php b/lang/en/cache.php index 75383e8e7a29b..aab4e50e89b69 100644 --- a/lang/en/cache.php +++ b/lang/en/cache.php @@ -63,6 +63,7 @@ $string['ex_configcannotsave'] = 'Unable to save the cache config to file.'; $string['ex_nodefaultlock'] = 'Unable to find a default lock instance.'; $string['ex_unabletolock'] = 'Unable to acquire a lock for caching.'; +$string['ex_unmetstorerequirements'] = 'You are unable to use this store at the present time. Please refer to the documentation to determine its requirements.'; $string['gethit'] = 'Get - Hit'; $string['getmiss'] = 'Get - Miss'; $string['invalidplugin'] = 'Invalid plugin';