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

This commit is contained in:
Frederic Massart 2012-11-02 13:08:07 +08:00
parent 2d7c5eeeea
commit f19d57e514
2 changed files with 14 additions and 11 deletions

View File

@ -2112,24 +2112,22 @@ class calendar_event {
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:
@ -2139,6 +2137,13 @@ class calendar_event {
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'];
@ -2157,7 +2162,6 @@ class calendar_event {
$this->editoroptions,
$editor['text'],
$this->editoroptions['forcehttps']);
$DB->set_field('event', 'description', $this->properties->description, array('id'=>$this->properties->id));
}

View File

@ -3685,7 +3685,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);
@ -3733,8 +3732,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();
}
@ -3755,10 +3754,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();
}