Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'MDL-30731-23' of git://github.com/FMCorz/moodle into MO…

…ODLE_23_STABLE
  • Loading branch information...
commit a91c6103f3de7d6af41244242058242065eac976 2 parents 0299d83 + ac247b4
@danpoltawski danpoltawski authored
Showing with 14 additions and 11 deletions.
  1. +9 −5 calendar/lib.php
  2. +5 −6 lib/filelib.php
View
14 calendar/lib.php
@@ -2080,24 +2080,22 @@ public function update($data, $checkcapability=true) {
if ($usingeditor) {
switch ($this->properties->eventtype) {
case 'user':
- $this->editorcontext = $this->properties->context;
$this->properties->courseid = 0;
+ $this->properties->course = 0;
$this->properties->groupid = 0;
$this->properties->userid = $USER->id;
break;
case 'site':
- $this->editorcontext = $this->properties->context;
$this->properties->courseid = SITEID;
+ $this->properties->course = SITEID;
$this->properties->groupid = 0;
$this->properties->userid = $USER->id;
break;
case 'course':
- $this->editorcontext = $this->properties->context;
$this->properties->groupid = 0;
$this->properties->userid = $USER->id;
break;
case 'group':
- $this->editorcontext = $this->properties->context;
$this->properties->userid = $USER->id;
break;
default:
@@ -2107,6 +2105,13 @@ public function update($data, $checkcapability=true) {
break;
}
+ // If we are actually using the editor, we recalculate the context because some default values
+ // were set when calculate_context() was called from the constructor.
+ if ($usingeditor) {
+ $this->properties->context = $this->calculate_context($this->properties);
+ $this->editorcontext = $this->properties->context;
+ }
+
$editor = $this->properties->description;
$this->properties->format = $this->properties->description['format'];
$this->properties->description = $this->properties->description['text'];
@@ -2125,7 +2130,6 @@ public function update($data, $checkcapability=true) {
$this->editoroptions,
$editor['text'],
$this->editoroptions['forcehttps']);
-
$DB->set_field('event', 'description', $this->properties->description, array('id'=>$this->properties->id));
}
View
11 lib/filelib.php
@@ -3649,7 +3649,6 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null) {
if (!$event = $DB->get_record('event', array('id'=>(int)$eventid, 'eventtype'=>'site'))) {
send_file_not_found();
}
- // Check that we got an event and that it's userid is that of the user
// Get the file and serve if successful
$filename = array_pop($args);
@@ -3697,8 +3696,8 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null) {
require_login($course);
}
- // Must be able to at least view the course
- if (!is_enrolled($context) and !is_viewing($context)) {
+ // Must be able to at least view the course. This does not apply to the front page.
+ if ($course->id != SITEID && (!is_enrolled($context)) && (!is_viewing($context))) {
//TODO: hmm, do we really want to block guests here?
send_file_not_found();
}
@@ -3719,10 +3718,10 @@ function file_pluginfile($relativepath, $forcedownload, $preview = null) {
if (!has_capability('moodle/site:accessallgroups', $context) && !groups_is_member($event->groupid, $USER->id)) {
send_file_not_found();
}
- } else if ($event->eventtype === 'course') {
- //ok
+ } else if ($event->eventtype === 'course' || $event->eventtype === 'site') {
+ // Ok. Please note that the event type 'site' still uses a course context.
} else {
- // some other type
+ // Some other type.
send_file_not_found();
}
Please sign in to comment.
Something went wrong with that request. Please try again.