Skip to content

Commit

Permalink
MDL-27037, wiki does not support visiblegroups functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankgupta committed Apr 8, 2011
1 parent 408612d commit 95fa6fd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mod/wiki/locallib.php
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
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
13 changes: 13 additions & 0 deletions mod/wiki/view.php
Expand Up @@ -189,6 +189,19 @@

// Getting subwiki instance. If it does not exists, redirect to create page
if (!$subwiki = wiki_get_subwiki_by_group($wiki->id, $gid, $uid)) {
$context = get_context_instance(CONTEXT_MODULE, $cm->id);

$modeanduser = $wiki->wikimode == 'individual' && $uid != $USER->id;
$modeandgroupmember = $wiki->wikimode == 'collaborative' && !groups_is_member($gid);

$manage = has_capability('mod/wiki:managewiki', $context);
$edit = has_capability('mod/wiki:editpage', $context);
$manageandedit = $manage && $edit;

if ($groupmode == VISIBLEGROUPS and ($modeanduser || $modeandgroupmember) and !$manageandedit) {
print_error('nocontent','wiki');
}

$params = array('wid' => $wiki->id, 'gid' => $gid, 'uid' => $uid, 'title' => $title);
$url = new moodle_url('/mod/wiki/create.php', $params);
redirect($url);
Expand Down

0 comments on commit 95fa6fd

Please sign in to comment.