Permalink
Browse files

Merge branch 'wip-MDL-39554-m25' of git://github.com/samhemelryk/moodle

  • Loading branch information...
2 parents 5df9bc3 + 5451933 commit 2fd46e12b8db398d55009f30e531e1609ad39165 @stronk7 stronk7 committed May 8, 2013
Showing with 40 additions and 30 deletions.
  1. +1 −1 cache/admin.php
  2. +20 −12 cache/classes/config.php
  3. +17 −15 cache/locallib.php
  4. +2 −2 cache/renderer.php
View
@@ -296,7 +296,7 @@
} else {
echo $renderer->store_plugin_summaries($plugins);
echo $renderer->store_instance_summariers($stores, $plugins);
- echo $renderer->definition_summaries($definitions, cache_administration_helper::get_definition_actions($context));
+ echo $renderer->definition_summaries($definitions, $context);
echo $renderer->lock_summaries($locks);
$applicationstore = join(', ', $defaultmodestores[cache_store::MODE_APPLICATION]);
View
@@ -231,20 +231,28 @@ public function load($configuration = false) {
// Invalid cache mode used for the definition.
continue;
}
- // Default the sharing option as it was added for 2.5.
- // This can be removed sometime after 2.5 is the minimum version someone can upgrade from.
- if (!isset($conf['sharingoptions'])) {
- $conf['sharingoptions'] = cache_definition::SHARING_DEFAULTOPTIONS;
- }
- // Default the selected sharing option as it was added for 2.5.
- // This can be removed sometime after 2.5 is the minimum version someone can upgrade from.
- if (!isset($conf['selectedsharingoption'])) {
+ if ($conf['mode'] === cache_store::MODE_SESSION || $conf['mode'] === cache_store::MODE_REQUEST) {
+ // We force this for session and request caches.
+ // They are only allowed to use the default as we don't want people changing them.
+ $conf['sharingoptions'] = cache_definition::SHARING_DEFAULT;
$conf['selectedsharingoption'] = cache_definition::SHARING_DEFAULT;
- }
- // Default the user input sharing key as it was added for 2.5.
- // This can be removed sometime after 2.5 is the minimum version someone can upgrade from.
- if (!isset($conf['userinputsharingkey'])) {
$conf['userinputsharingkey'] = '';
+ } else {
+ // Default the sharing option as it was added for 2.5.
+ // This can be removed sometime after 2.5 is the minimum version someone can upgrade from.
+ if (!isset($conf['sharingoptions'])) {
+ $conf['sharingoptions'] = cache_definition::SHARING_DEFAULTOPTIONS;
+ }
+ // Default the selected sharing option as it was added for 2.5.
+ // This can be removed sometime after 2.5 is the minimum version someone can upgrade from.
+ if (!isset($conf['selectedsharingoption'])) {
+ $conf['selectedsharingoption'] = cache_definition::SHARING_DEFAULT;
+ }
+ // Default the user input sharing key as it was added for 2.5.
+ // This can be removed sometime after 2.5 is the minimum version someone can upgrade from.
+ if (!isset($conf['userinputsharingkey'])) {
+ $conf['userinputsharingkey'] = '';
+ }
}
$this->configdefinitions[$id] = $conf;
}
View
@@ -866,25 +866,27 @@ public static function get_definition_sharing_options($sharingoption, $isselecte
* @param context $context
* @return array
*/
- public static function get_definition_actions(context $context) {
+ public static function get_definition_actions(context $context, array $definition) {
if (has_capability('moodle/site:config', $context)) {
- return array(
- // Edit mappings.
- array(
- 'text' => get_string('editmappings', 'cache'),
- 'url' => new moodle_url('/cache/admin.php', array('action' => 'editdefinitionmapping', 'sesskey' => sesskey()))
- ),
- // Edit sharing.
- array(
+ $actions = array();
+ // Edit mappings.
+ $actions[] = array(
+ 'text' => get_string('editmappings', 'cache'),
+ 'url' => new moodle_url('/cache/admin.php', array('action' => 'editdefinitionmapping', 'sesskey' => sesskey()))
+ );
+ // Edit sharing.
+ if (count($definition['sharingoptions']) > 1) {
+ $actions[] = array(
'text' => get_string('editsharing', 'cache'),
'url' => new moodle_url('/cache/admin.php', array('action' => 'editdefinitionsharing', 'sesskey' => sesskey()))
- ),
- // Purge.
- array(
- 'text' => get_string('purge', 'cache'),
- 'url' => new moodle_url('/cache/admin.php', array('action' => 'purgedefinition', 'sesskey' => sesskey()))
- )
+ );
+ }
+ // Purge.
+ $actions[] = array(
+ 'text' => get_string('purge', 'cache'),
+ 'url' => new moodle_url('/cache/admin.php', array('action' => 'purgedefinition', 'sesskey' => sesskey()))
);
+ return $actions;
}
return array();
}
View
@@ -211,10 +211,9 @@ public function store_plugin_summaries(array $plugins) {
* Displays definition summaries
*
* @param array $definitions
- * @param array $actions
* @return string HTML
*/
- public function definition_summaries(array $definitions, array $actions) {
+ public function definition_summaries(array $definitions, context $context) {
$table = new html_table();
$table->head = array(
get_string('definition', 'cache'),
@@ -238,6 +237,7 @@ public function definition_summaries(array $definitions, array $actions) {
$none = new lang_string('none', 'cache');
foreach ($definitions as $id => $definition) {
+ $actions = cache_administration_helper::get_definition_actions($context, $definition);
$htmlactions = array();
foreach ($actions as $action) {
$action['url']->param('definition', $id);

0 comments on commit 2fd46e1

Please sign in to comment.