MDL-31708 wiki: Wiki 2.0 non-group member can see edit option in navigation block

This commit is contained in:
Gilles-Philippe Leblanc
2012-10-18 08:34:09 -04:00
parent 10c3c372b9
commit d0d121acb7
4 changed files with 6 additions and 11 deletions
+2
View File
@@ -22,8 +22,10 @@ $string['backoldversion'] = 'Back to old version';
$string['backpage'] = 'Back to page';
$string['backtomapmenu'] = 'Back to map menu';
$string['changerate'] = 'Do you wish to change it?';
$string['cannoteditpage'] = 'You can not edit this page.';
$string['cannotmanagefiles'] = 'You don\'t have permission to manage the wiki files.';
$string['cannotviewfiles'] = 'You don\'t have permission to view the wiki files.';
$string['cannotviewpage'] = 'You can not view this page.';
$string['comparesel'] = 'Compare selected';
$string['comments'] = 'Comments';
$string['commentscount'] = 'Comments ({$a})';
+1 -1
View File
@@ -536,7 +536,7 @@ function wiki_extend_navigation(navigation_node $navref, $course, $module, $cm)
$node = $navref->add(get_string('view', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:editpage', $context)) {
if (wiki_user_can_edit($subwiki)) {
$link = new moodle_url('/mod/wiki/edit.php', array('pageid' => $pageid));
$node = $navref->add(get_string('edit', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
+1 -1
View File
@@ -766,7 +766,7 @@ function wiki_user_can_view($subwiki) {
// Each person owns a wiki.
if ($wiki->wikimode == 'collaborative' || $wiki->wikimode == 'individual') {
// Only members of subwiki group could view that wiki
if ($subwiki->groupid == groups_get_activity_group($cm)) {
if (groups_is_member($subwiki->groupid)) {
// Only view capability needed
return has_capability('mod/wiki:viewpage', $context);
+2 -9
View File
@@ -172,13 +172,8 @@ abstract class page_wiki {
if (!$manage and !($edit and groups_is_member($currentgroup))) {
unset($this->tabs['edit']);
}
} else {
if (!has_capability('mod/wiki:editpage', $PAGE->context)) {
unset($this->tabs['edit']);
}
}
if (empty($options)) {
$this->tabs_options = array('activetab' => substr(get_class($this), 10));
} else {
@@ -326,8 +321,7 @@ class page_wiki_view extends page_wiki {
}
}
} else {
// @TODO: Tranlate it
echo "You can not view this page";
echo get_string('cannotviewpage', 'wiki');
}
}
@@ -420,8 +414,7 @@ class page_wiki_edit extends page_wiki {
if (wiki_user_can_edit($this->subwiki)) {
$this->print_edit();
} else {
// @TODO: Translate it
echo "You can not edit this page";
echo get_string('cannoteditpage', 'wiki');
}
}