mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-27037, wiki does not support visiblegroups functionality
This commit is contained in:
parent
d48dae7507
commit
dc0cabb488
3 changed files with 28 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -155,6 +155,7 @@ abstract class page_wiki {
|
|||
*/
|
||||
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 @@ abstract class page_wiki {
|
|||
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));
|
||||
|
|
|
@ -189,6 +189,19 @@ if ($id) {
|
|||
|
||||
// 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue