Permalink
Browse files

MDL-36115 cache: Fixed up requirements check in cache admin interfaces

  • Loading branch information...
1 parent 7e8ae12 commit 7e7e108f9376db5334bc188adcc3de2dd9b43f2c Sam Hemelryk committed Oct 18, 2012
Showing with 6 additions and 2 deletions.
  1. +3 −0 cache/admin.php
  2. +2 −2 cache/locallib.php
  3. +1 −0 lang/en/cache.php
View
@@ -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()) {
View
@@ -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(
View
@@ -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';

0 comments on commit 7e7e108

Please sign in to comment.