Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-34695 Wiki Module: add prevention to create new record when useri…

…d is 0
  • Loading branch information...
commit a8f5d3814d7e413881c2a9a1089ed150c78c08af 1 parent f2ce3d0
hqhoang hqhoang authored rwijaya committed
5 mod/wiki/files.php
@@ -49,11 +49,6 @@
49 49 print_error('incorrectwikiid', 'wiki');
50 50 }
51 51 if (!$subwiki = wiki_get_subwiki_by_group($wiki->id, $currentgroup, $userid)) {
52   - // trap anomalous parameters that would lead to a shared subwiki being created for an individual user
53   - if ($wiki->wikimode == 'individual' && $userid == 0) {
54   - throw new coding_exception('Tried creating a shared subwiki in \'individual\' mode. This shouldn\'t happen.');
55   - }
56   -
57 52 // create subwiki if doesn't exist
58 53 $subwikiid = wiki_add_subwiki($wiki->id, $currentgroup, $userid);
59 54 $subwiki = wiki_get_subwiki($subwikiid);
5 mod/wiki/pagelib.php
@@ -947,11 +947,6 @@ function create_page($pagetitle) {
947 947 $groupid = '0';
948 948 }
949 949 if (empty($this->subwiki)) {
950   - // trap anomalous parameters that would lead to a shared subwiki being created for an individual user
951   - if ($PAGE->activityrecord->wikimode == 'individual' && $this->uid == 0) {
952   - throw new coding_exception('Tried creating a shared subwiki in \'individual\' mode. This shouldn\'t happen.');
953   - }
954   -
955 950 // If subwiki is not set then try find one and set else create one.
956 951 if (!$this->subwiki = wiki_get_subwiki_by_group($this->wid, $groupid, $this->uid)) {
957 952 $swid = wiki_add_subwiki($PAGE->activityrecord->id, $groupid, $this->uid);
10 mod/wiki/view.php
@@ -68,6 +68,8 @@
68 68 // Checking course instance
69 69 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
70 70
  71 + require_login($course, true, $cm);
  72 +
71 73 // Checking wiki instance
72 74 if (!$wiki = wiki_get_wiki($cm->instance)) {
73 75 print_error('incorrectwikiid', 'wiki');
@@ -138,6 +140,7 @@
138 140 // Checking course instance
139 141 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
140 142
  143 + require_login($course, true, $cm);
141 144 /*
142 145 * Case 2:
143 146 *
@@ -166,9 +169,9 @@
166 169 }
167 170
168 171 // Checking course instance
169   - if (!$course = $DB->get_record("course", array("id" => $cm->course))) {
170   - print_error('coursemisconf');
171   - }
  172 + $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
  173 +
  174 + require_login($course, true, $cm);
172 175
173 176 $groupmode = groups_get_activity_groupmode($cm);
174 177
@@ -267,7 +270,6 @@
267 270 } else {
268 271 print_error('incorrectparameters');
269 272 }
270   -require_login($course, true, $cm);
271 273
272 274 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
273 275 require_capability('mod/wiki:viewpage', $context);

0 comments on commit a8f5d38

Please sign in to comment.
Something went wrong with that request. Please try again.