Skip to content

Commit

Permalink
MDL-42995 mod_assign: Remove files from calendar event description
Browse files Browse the repository at this point in the history
  • Loading branch information
FMCorz committed Jan 6, 2014
1 parent d6f428b commit 80ecc25
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions mod/assign/locallib.php
Expand Up @@ -786,30 +786,37 @@ public function update_calendar($coursemoduleid) {
$event = new stdClass();

$params = array('modulename'=>'assign', 'instance'=>$instance->id);
$event->id = $DB->get_field('event',
'id',
$params);
$event->id = $DB->get_field('event', 'id', $params);
$event->name = $instance->name;
$event->timestart = $instance->duedate;

// Convert the links to pluginfile. It is a bit hacky but at this stage the files
// might not have been saved in the module area yet.
$intro = $instance->intro;
if ($draftid = file_get_submitted_draft_itemid('introeditor')) {
$intro = file_rewrite_urls_to_pluginfile($intro, $draftid);
}

// We need to remove the links to files as the calendar is not ready
// to support module events with file areas.
$intro = strip_pluginfile_content($intro);
$event->description = array(
'text' => $intro,
'format' => $instance->introformat
);

if ($event->id) {
$event->name = $instance->name;
$event->description = format_module_intro('assign', $instance, $coursemoduleid);
$event->timestart = $instance->duedate;

$calendarevent = calendar_event::load($event->id);
$calendarevent->update($event);
} else {
$event = new stdClass();
$event->name = $instance->name;
$event->description = format_module_intro('assign', $instance, $coursemoduleid);
unset($event->id);
$event->courseid = $instance->course;
$event->groupid = 0;
$event->userid = 0;
$event->modulename = 'assign';
$event->instance = $instance->id;
$event->eventtype = 'due';
$event->timestart = $instance->duedate;
$event->timeduration = 0;

calendar_event::create($event);
}
} else {
Expand Down

0 comments on commit 80ecc25

Please sign in to comment.