Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-34695 wiki: ensure the correct individual subwiki is used/created…

… for a user
  • Loading branch information...
commit f2ce3d0239663ed3a96dc68b91b01399131ff0ab 1 parent 67ba008
@jonof jonof authored rwijaya committed
Showing with 11 additions and 1 deletion.
  1. +5 −0 mod/wiki/files.php
  2. +6 −1 mod/wiki/pagelib.php
View
5 mod/wiki/files.php
@@ -49,6 +49,11 @@
print_error('incorrectwikiid', 'wiki');
}
if (!$subwiki = wiki_get_subwiki_by_group($wiki->id, $currentgroup, $userid)) {
+ // trap anomalous parameters that would lead to a shared subwiki being created for an individual user
+ if ($wiki->wikimode == 'individual' && $userid == 0) {
+ throw new coding_exception('Tried creating a shared subwiki in \'individual\' mode. This shouldn\'t happen.');
+ }
+
// create subwiki if doesn't exist
$subwikiid = wiki_add_subwiki($wiki->id, $currentgroup, $userid);
$subwiki = wiki_get_subwiki($subwikiid);
View
7 mod/wiki/pagelib.php
@@ -947,8 +947,13 @@ function create_page($pagetitle) {
$groupid = '0';
}
if (empty($this->subwiki)) {
+ // trap anomalous parameters that would lead to a shared subwiki being created for an individual user
+ if ($PAGE->activityrecord->wikimode == 'individual' && $this->uid == 0) {
+ throw new coding_exception('Tried creating a shared subwiki in \'individual\' mode. This shouldn\'t happen.');
+ }
+
// If subwiki is not set then try find one and set else create one.
- if (!$this->subwiki = wiki_get_subwiki_by_group($this->wid, $groupid)) {
+ if (!$this->subwiki = wiki_get_subwiki_by_group($this->wid, $groupid, $this->uid)) {
$swid = wiki_add_subwiki($PAGE->activityrecord->id, $groupid, $this->uid);
$this->subwiki = wiki_get_subwiki($swid);
}
Please sign in to comment.
Something went wrong with that request. Please try again.