Skip to content

Commit

Permalink
MDL-36115 cache: Fixed up requirements check in cache admin interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Oct 19, 2012
1 parent 7e8ae12 commit 7e7e108
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cache/admin.php
Expand Up @@ -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()) {
Expand Down
4 changes: 2 additions & 2 deletions cache/locallib.php
Expand Up @@ -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())
);
}

Expand Down Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions lang/en/cache.php
Expand Up @@ -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';
Expand Down

0 comments on commit 7e7e108

Please sign in to comment.