/** * handle user input **/ public function entry_specific_process_data($reportfield_id, $entry_id, $data) { global $CFG; /* * parent method is fine for simple form element types * dd types will need something more elaborate to handle the intermediate * items table and foreign key */ $fieldname = $reportfield_id . "_field"; $report = $this->dbc->get_report_by_id($data->report_id); $title = !empty($report) ? $report->name . " " . get_string('deadline', 'block_ilp') : get_string('deadline', 'block_ilp'); $event = $this->dbc->get_calendar_event($entry_id, $reportfield_id); if (empty($event)) { $event = new stdClass(); $event->name = $title; //link to ilp has been removed due to moodle encoding html and outputing it. $event->description = $title; $event->format = 0; $event->courseid = 0; $event->groupid = 0; $event->userid = $data->user_id; $event->modulename = '0'; $event->instance = 0; $event->eventtype = 'due'; $event->timestart = $data->{$fieldname}; $event->timeduration = time(); $event->id = $this->dbc->save_event($event); $record = new stdClass(); $record->entry_id = $entry_id; $record->reportfield_id = $reportfield_id; $record->event_id = $event->id; $record->timemodified = time(); $record->timecreated = time(); //create the calendar cross reference record $this->dbc->create_event_cross_reference($record); } else { $event = $this->dbc->get_calendar_event($entry_id, $reportfield_id); if (!empty($event)) { $event->timestart = $data->{$fieldname}; $event->timemodified = time(); $event->modulename = '0'; $event->uuid = 0; $this->dbc->update_event($event); } } //before saving save a event in the users calendar for this report //Add Calendar event //if () { //} //$data->user_id //data->report_id - for report name //call the parent entry_process_data function to handle saving the field value return parent::entry_process_data($reportfield_id, $entry_id, $data); }