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()) {
'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())
);
}
*/
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(
$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';