From e2694e9dd6089856a14b62ddebc1a0de5b06783d Mon Sep 17 00:00:00 2001 From: Gilles-Philippe Leblanc Date: Thu, 18 Oct 2012 08:51:51 -0400 Subject: [PATCH] MDL-31708 wiki: Wiki 2.0 non-group member can see edit option in navigation block --- mod/wiki/lang/en/wiki.php | 2 ++ mod/wiki/lib.php | 2 +- mod/wiki/locallib.php | 2 +- mod/wiki/pagelib.php | 11 ++--------- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/mod/wiki/lang/en/wiki.php b/mod/wiki/lang/en/wiki.php index 80fbdf4561267..d332563b2b5f9 100644 --- a/mod/wiki/lang/en/wiki.php +++ b/mod/wiki/lang/en/wiki.php @@ -22,8 +22,10 @@ $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})'; diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php index 133178a58db80..974c46ddab6ec 100644 --- a/mod/wiki/lib.php +++ b/mod/wiki/lib.php @@ -531,7 +531,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); } diff --git a/mod/wiki/locallib.php b/mod/wiki/locallib.php index ff3b67a9d37c3..079ce2ab4af21 100644 --- a/mod/wiki/locallib.php +++ b/mod/wiki/locallib.php @@ -767,7 +767,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); diff --git a/mod/wiki/pagelib.php b/mod/wiki/pagelib.php index 4fe9d50d20722..511f48f7f18bf 100644 --- a/mod/wiki/pagelib.php +++ b/mod/wiki/pagelib.php @@ -172,13 +172,8 @@ protected function setup_tabs($options = array()) { 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 @@ function print_content() { } } } else { - // @TODO: Tranlate it - echo "You can not view this page"; + echo get_string('cannotviewpage', 'wiki'); } } @@ -420,8 +414,7 @@ function print_content() { 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'); } }