Skip to content

Commit

Permalink
MDL-39554 cache: sharing link only shown in multiple options are avai…
Browse files Browse the repository at this point in the history
…lable
  • Loading branch information
Sam Hemelryk committed May 7, 2013
1 parent bd12f74 commit 5451933
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cache/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
32 changes: 17 additions & 15 deletions cache/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions cache/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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);
Expand Down

0 comments on commit 5451933

Please sign in to comment.