Skip to content
Browse files

MDL-30731 calendar: Fixed display of images in event descriptions

  • Loading branch information...
1 parent b969895 commit 3135254d8f27782439e390c75d8b1f72da0ea8b2 @FMCorz FMCorz committed Nov 2, 2012
Showing with 14 additions and 11 deletions.
  1. +9 −5 calendar/lib.php
  2. +5 −6 lib/filelib.php
View
14 calendar/lib.php
@@ -1931,24 +1931,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:
@@ -1958,6 +1956,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'];
@@ -1976,7 +1981,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
@@ -3362,7 +3362,6 @@ function file_pluginfile($relativepath, $forcedownload) {
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);
@@ -3410,8 +3409,8 @@ function file_pluginfile($relativepath, $forcedownload) {
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();
}
@@ -3432,10 +3431,10 @@ function file_pluginfile($relativepath, $forcedownload) {
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();
}

0 comments on commit 3135254

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