Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…d is 0
  • Loading branch information...
commit e8c07ff705680417ee63aa2b56ee6713607f6eab 1 parent 70a9f27
@hqhoang hqhoang authored rwijaya committed
Showing with 6 additions and 14 deletions.
  1. +0 −5 mod/wiki/files.php
  2. +0 −5 mod/wiki/pagelib.php
  3. +6 −4 mod/wiki/view.php
View
5 mod/wiki/files.php
@@ -49,11 +49,6 @@
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
5 mod/wiki/pagelib.php
@@ -946,11 +946,6 @@ 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, $this->uid)) {
$swid = wiki_add_subwiki($PAGE->activityrecord->id, $groupid, $this->uid);
View
10 mod/wiki/view.php
@@ -68,6 +68,8 @@
// Checking course instance
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ require_login($course, true, $cm);
+
// Checking wiki instance
if (!$wiki = wiki_get_wiki($cm->instance)) {
print_error('incorrectwikiid', 'wiki');
@@ -138,6 +140,7 @@
// Checking course instance
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ require_login($course, true, $cm);
/*
* Case 2:
*
@@ -166,9 +169,9 @@
}
// Checking course instance
- if (!$course = $DB->get_record("course", array("id" => $cm->course))) {
- print_error('coursemisconf');
- }
+ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+
+ require_login($course, true, $cm);
$groupmode = groups_get_activity_groupmode($cm);
@@ -267,7 +270,6 @@
} else {
print_error('incorrectparameters');
}
-require_login($course, true, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/wiki:viewpage', $context);

0 comments on commit e8c07ff

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