public function save() { //add parent::save(); //add if ($this->autocreate) { $this->track_auto_create(); } $status = field_data::set_for_context_from_datarecord(CONTEXT_ELIS_TRACK, $this); return $status; }
/** * Save the record to the database. This method is used to both create a * new record, and to update an existing record. * * @param boolean $strict_match Whether we should use the association table rather * than just check idnumbers when comparing to Moodle users */ public function save($strict_match = true) { $isnew = empty($this->id); $now = time(); if ($isnew) { $this->timecreated = $now; } else { $this->timemodified = $now; } parent::save(); /// Synchronize Moodle data with this data. $this->synchronize_moodle_user(true, $isnew, $strict_match); }
public function save() { parent::save(); if (isset($this->curriculum)) { $this->add_course_to_curricula($this->curriculum); } // Add moodle course template if (isset($this->location)) { $template = $this->coursetemplate->current(); $template->location = $this->location; $template->templateclass = $this->templateclass; $template->courseid = $this->id; $template->save(); } else { coursetemplate::delete_records(new field_filter('courseid', $this->id)); } field_data::set_for_context_from_datarecord(CONTEXT_ELIS_COURSE, $this); }
public function save() { $isnew = empty($this->id); parent::save(); if (!$isnew) { // If this setting is changed, we need to update the existing curriclum expiration values (ELIS-1172) if ($rs = $this->_db->get_recordset_select(curriculumstudent::TABLE, "timecompleted = 0 AND curriculumid = {$this->id}", null, 'id, userid')) { $timenow = time(); foreach ($rs as $rec) { $update = new stdClass(); $update->id = $rec->id; $update->timeexpired = calculate_curriculum_expiry(NULL, $this->id, $rec->userid); $update->timemodified = $timenow; $this->_db->update_record(curriculumstudent::TABLE, $update); } $rs->close(); } } field_data::set_for_context_from_datarecord(CONTEXT_ELIS_PROGRAM, $this); }
/** * Add param fields to the form object */ public function to_object() { $obj = parent::to_object(); $prof_fields = $this->_db->get_records(userset_profile::TABLE, array('clusterid' => $this->id), '', '*', 0, 2); if (!empty($prof_fields)) { foreach (range(1, 2) as $i) { $profile = pos($prof_fields); if (!empty($profile)) { $field = 'profile_field' . $i; $value = 'profile_value' . $i; $obj->{$field} = $profile->fieldid; $obj->{$value} = $profile->value; } next($prof_fields); } } return $obj; }
public function save() { $isnew = empty($this->id); parent::save(); if (isset($this->track) && is_array($this->track)) { $param['classid'] = $this->id; $param['courseid'] = $this->courseid; foreach ($this->track as $t) { if (trackassignment::exists(array(new field_filter('classid', $this->id), new field_filter('trackid', $t)))) { continue; } $param['trackid'] = $t; $trackassignobj = new trackassignment($param); $trackassignobj->save(); } } if (isset($this->unlink_attached_course) && isset($this->moodlecourseid)) { // process unlink moodle course id request $return = moodle_detach_class($this->id, $this->moodlecourseid); $this->moodlecourseid = 0; } if ($this->moodlecourseid || $this->autocreate) { moodle_attach_class($this->id, $this->moodlecourseid, '', true, true, $this->autocreate); } if (!$isnew) { if (!empty($this->oldmax) && (!$this->maxstudents || $this->oldmax < $this->maxstudents) && ($waiting = waitlist::count_records($this->id)) > 0) { $start = student_count_records($this->id); $max = $this->maxstudents ? $this->maxstudents : $start + $waiting + 1; //error_log("pmclass.class.php::save() oldmax = {$this->oldmax}, start = {$start}, newmax = {$this->maxstudents}, waiting = {$waiting} ... max = {$max}"); for ($i = $start; $i < $max; $i++) { $next_student = waitlist::get_next($this->id); if (empty($next_student)) { break; } $next_student->enrol(); } } } field_data::set_for_context_from_datarecord(CONTEXT_ELIS_CLASS, $this); }