From 80ecc2593bf92d20f98a7dd72e2799c59f296c04 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Thu, 19 Dec 2013 11:43:03 +0100 Subject: [PATCH] MDL-42995 mod_assign: Remove files from calendar event description --- mod/assign/locallib.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index b3afe7a0b9880..b99ae1bef38d7 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -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 {