Skip to content

Commit

Permalink
MDL-27037, wiki editable in visiblegroups *edit disabled when not edi…
Browse files Browse the repository at this point in the history
…table
  • Loading branch information
mayankgupta committed Apr 6, 2011
1 parent 408612d commit 2eaf4b3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mod/wiki/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ function wiki_user_can_edit($subwiki) {
// There is one wiki per group.
//
// Only members of subwiki group could edit that wiki
if ($subwiki->groupid == groups_get_activity_group($cm)) {
if (groups_is_member($subwiki->groupid)) {
// Only edit capability needed
return has_capability('mod/wiki:editpage', $context);
} else { // User is not part of that group
Expand Down
14 changes: 14 additions & 0 deletions mod/wiki/pagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ protected function print_pagetitle() {
*/
protected function setup_tabs($options = array()) {
global $CFG, $PAGE;
$groupmode = groups_get_activity_groupmode($PAGE->cm);

if (empty($CFG->usecomments) || !has_capability('mod/wiki:viewcomment', $PAGE->context)){
unset($this->tabs['comments']);
Expand All @@ -164,6 +165,19 @@ protected function setup_tabs($options = array()) {
unset($this->tabs['edit']);
}

if ($groupmode and $groupmode == VISIBLEGROUPS){
$currentgroup = groups_get_activity_group($PAGE->cm);
$manage = has_capability('mod/wiki:managewiki', $PAGE->cm->context);
$edit = has_capability('mod/wiki:editpage', $PAGE->context);
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));
Expand Down

0 comments on commit 2eaf4b3

Please sign in to comment.