mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-30478 - wiki - Fixing up group problems when viewing and creating wiki pages.
Thanks to Matt Kolb for his contribution.
This commit is contained in:
parent
ead4f180a0
commit
5dedd64d58
4 changed files with 69 additions and 19 deletions
|
@ -81,7 +81,7 @@ if ($id) {
|
|||
|
||||
// Getting current group id
|
||||
$currentgroup = groups_get_activity_group($cm);
|
||||
$currentgroup = !empty($currentgroup) ? $currentgroup : 0;
|
||||
|
||||
// Getting current user id
|
||||
if ($wiki->wikimode == 'individual') {
|
||||
$userid = $USER->id;
|
||||
|
@ -91,7 +91,7 @@ if ($id) {
|
|||
|
||||
// Getting subwiki. If it does not exists, redirecting to create page
|
||||
if (!$subwiki = wiki_get_subwiki_by_group($wiki->id, $currentgroup, $userid)) {
|
||||
$params = array('wid' => $wiki->id, 'gid' => $currentgroup, 'uid' => $userid, 'title' => $wiki->firstpagetitle);
|
||||
$params = array('wid' => $wiki->id, 'group' => $currentgroup, 'uid' => $userid, 'title' => $wiki->firstpagetitle);
|
||||
$url = new moodle_url('/mod/wiki/create.php', $params);
|
||||
redirect($url);
|
||||
}
|
||||
|
@ -133,6 +133,8 @@ if ($id) {
|
|||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
$currentgroup = $subwiki->groupid;
|
||||
|
||||
// Checking course instance
|
||||
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
|
||||
|
||||
|
@ -169,10 +171,6 @@ if ($id) {
|
|||
}
|
||||
|
||||
$groupmode = groups_get_activity_groupmode($cm);
|
||||
if (empty($currentgroup)) {
|
||||
$currentgroup = groups_get_activity_group($cm);
|
||||
$currentgroup = !empty($currentgroup) ? $currentgroup : 0;
|
||||
}
|
||||
|
||||
if ($wiki->wikimode == 'individual' && ($groupmode == SEPARATEGROUPS || $groupmode == VISIBLEGROUPS)) {
|
||||
list($gid, $uid) = explode('-', $groupanduser);
|
||||
|
@ -202,15 +200,20 @@ if ($id) {
|
|||
print_error('nocontent','wiki');
|
||||
}
|
||||
|
||||
$params = array('wid' => $wiki->id, 'gid' => $gid, 'uid' => $uid, 'title' => $title);
|
||||
$params = array('wid' => $wiki->id, 'group' => $gid, 'uid' => $uid, 'title' => $title);
|
||||
$url = new moodle_url('/mod/wiki/create.php', $params);
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
// Checking is there is a page with this title. If it does not exists, redirect to first page
|
||||
if (!$page = wiki_get_page_by_title($subwiki->id, $title)) {
|
||||
$params = array('wid' => $wiki->id, 'gid' => $gid, 'uid' => $uid, 'title' => $wiki->firstpagetitle);
|
||||
$url = new moodle_url('/mod/wiki/view.php', $params);
|
||||
$params = array('wid' => $wiki->id, 'group' => $gid, 'uid' => $uid, 'title' => $wiki->firstpagetitle);
|
||||
// Check to see if the first page has been created
|
||||
if (!wiki_get_page_by_title($subwiki->id, $wiki->firstpagetitle)) {
|
||||
$url = new moodle_url('/mod/wiki/create.php', $params);
|
||||
} else {
|
||||
$url = new moodle_url('/mod/wiki/view.php', $params);
|
||||
}
|
||||
redirect($url);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue