Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'm20_MDL-27037_wiki_visiblegroups_functionality' of http…

  • Loading branch information...
commit 7ba8da8a13cfc8a3be733d2d8aeb54ef09aaa29c 2 parents 4342686 + 95fa6fd
@nebgor nebgor authored
View
2  mod/wiki/locallib.php
@@ -899,7 +899,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
View
14 mod/wiki/pagelib.php
@@ -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']);
@@ -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));
View
13 mod/wiki/view.php
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.