Skip to content

Commit

Permalink
MDL-52013 assign: Allow subplugins to add calendar events
Browse files Browse the repository at this point in the history
  • Loading branch information
micaherne committed Nov 26, 2015
1 parent c18acb8 commit 72797e6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,10 +889,12 @@ public function update_calendar($coursemoduleid) {
// Special case for add_instance as the coursemodule has not been set yet.
$instance = $this->get_instance();

$eventtype = 'due';

if ($instance->duedate) {
$event = new stdClass();

$params = array('modulename'=>'assign', 'instance'=>$instance->id);
$params = array('modulename' => 'assign', 'instance' => $instance->id, 'eventtype' => $eventtype);
$event->id = $DB->get_field('event', 'id', $params);
$event->name = $instance->name;
$event->timestart = $instance->duedate;
Expand Down Expand Up @@ -929,12 +931,12 @@ public function update_calendar($coursemoduleid) {
$event->userid = 0;
$event->modulename = 'assign';
$event->instance = $instance->id;
$event->eventtype = 'due';
$event->eventtype = $eventtype;
$event->timeduration = 0;
calendar_event::create($event);
}
} else {
$DB->delete_records('event', array('modulename'=>'assign', 'instance'=>$instance->id));
$DB->delete_records('event', array('modulename' => 'assign', 'instance' => $instance->id, 'eventtype' => $eventtype));
}
}

Expand Down

0 comments on commit 72797e6

Please sign in to comment.