public function save() { $isnew = empty($this->id); parent::save(); // TO-DO: not sure how much of code from old data_update_record() is needed here if (!$isnew && !empty($this->properties)) { $record = new stdClass(); foreach ($this->properties as $prop => $type) { if (!isset($this->{$prop})) { continue; } if ($prop == 'timemodified') { $record->{$prop} = time(); } else { switch ($type) { case 'int': $record->{$prop} = $this->_db->clean_int($this->{$prop}); break; case 'string': $record->{$prop} = $this->_db->clean_text($this->{$prop}); break; case 'html': $record->{$prop} = $this->_db->clean_html($this->{$prop}); break; } } } $this->_db->update_record($this->table, $record); } }
/** * Save the record to the database. This method is used to both create a * new record, and to update an existing record. */ public function save() { $trigger = false; if (!isset($this->id)) { $trigger = true; } parent::save(); if ($trigger) { $usass = new stdClass(); $usass->userid = $this->userid; $usass->clusterid = $this->clusterid; events_trigger('cluster_assigned', $usass); } }
/** * Save a record, plus all its custom fields. */ public function save() { parent::save(); //ELIS-6114 - this seems to fix issues related to the default value of a //multi-valued custom field not being saved $this->to_object(); $this->_load_context(); $contextlevel = $this->_context->contextlevel; // only save the custom field data that has been changed foreach ($this->_field_changed as $name => $changed) { if ($changed) { $field = self::$_fields[$contextlevel][$name]; if (isset($this->_field_data[$name])) { field_data::set_for_context_and_field($this->_context, $field, $this->_field_data[$name]); } else { // field data was unset, so delete values $fielddatatype = "field_data_{$field->data_type()}"; $fieldatatype::delete_records(array(new field_filter('contextid', $this->_context->id), new field_filter('fieldid', $field->id))); } } unset($this->_field_changed[$name]); } }
function save() { // ELIS-3722 -- We need to prevent duplicate records when adding new student LO grade records if ($this->_dbfield_id !== parent::$_unset || $this->_dbfield_id == parent::$_unset && !$this->duplicate_check()) { parent::save(); } else { //debugging('student_grade::save() - LO grade already saved!', DEBUG_DEVELOPER); } }
/** * Perform parent add */ public function save() { parent::save(); }
/** * Saves (inserts or updates) a workflow data record to the database. */ public function save() { $this->timemodified = time(); parent::save(); }
/** * Assign a class to a track, this function also creates * and assigns the class to the curriculum default track * * @return TODO: add meaningful return value */ function save() { //add() if (empty($this->courseid)) { $this->courseid = $this->_db->get_field(pmclass::TABLE, 'courseid', array('id' => $this->classid)); } if ((empty($this->trackid) or empty($this->classid) or empty($this->courseid)) and empty(elis::$config->local_elisprogram->userdefinedtrack)) { cm_error('trackid and classid have not been properly initialized'); return false; } else { if ((empty($this->courseid) or empty($this->classid)) and elis::$config->local_elisprogram->userdefinedtrack) { cm_error('courseid has not been properly initialized'); } } if (!isset($this->id) && $this->is_class_assigned_to_track()) { //trying to re-add an existing association return; } // Determine whether class is required $curcrsobj = new curriculumcourse(array('curriculumid' => $this->track->curid, 'courseid' => $this->courseid)); // TBV: was $this->classid // insert assignment record parent::save(); //updated for ELIS2 from $this->data_insert_record() if ($this->autoenrol && $this->is_autoenrollable()) { // autoenrol all users in the track // ELIS-7582 @set_time_limit(0); $users = usertrack::get_users($this->trackid); foreach ($users as $user) { // ELIS-3460: Must check pre-requisites ... if (!$curcrsobj->prerequisites_satisfied($user->userid)) { //error_log("/local/elisprogram/lib/data/track.class.php:trackassignment::save(); pre-requisites NOT satisfied for course: {$this->courseid}, curriculum: {$this->track->curid}"); continue; } $now = time(); $stu_record = new object(); $stu_record->userid = $user->userid; $stu_record->user_idnumber = $user->idnumber; $stu_record->classid = $this->classid; $stu_record->enrolmenttime = $now; $enrolment = new student($stu_record); // check enrolment limits try { $enrolment->save(); } catch (pmclass_enrolment_limit_validation_exception $e) { // autoenrol into waitlist $wait_record = new object(); $wait_record->userid = $user->userid; $wait_record->classid = $this->classid; $wait_record->enrolmenttime = $now; $wait_record->timecreated = $now; $wait_record->position = 0; $wait_list = new waitlist($wait_record); $wait_list->save(); } catch (Exception $e) { $param = array('message' => $e->getMessage()); echo cm_error(get_string('record_not_created_reason', 'local_elisprogram', $param)); } } } events_trigger('pm_track_class_associated', $this); }
/** * Perform parent add and trigger assigned event. */ public function save() { parent::save(); events_trigger('crlm_instructor_assigned', $this); }
public function save() { $isnew = empty($this->id); $now = time(); if ($isnew) { $this->timecreated = $now; if (!empty(elis::$config->local_elisprogram->enable_curriculum_expiration) && elis::$config->local_elisprogram->curriculum_expiration_start == CURR_EXPIRE_ENROL_START && $this->_db->get_field(curriculum::TABLE, 'frequency', array('id' => $this->curriculumid))) { // We need to load this record from the DB fresh so we don't accidentally overwrite legitimate // values with something empty when we update the record. $this->timecreated = time(); $timeexpired = calculate_curriculum_expiry($this); if ($timeexpired > 0) { $this->timeexpired = $timeexpired; } } } $this->timemodified = $now; parent::save(); }
/** * */ public function save() { $new = false; try { validation_helper::is_unique_userid_classid($this); } catch (Exception $e) { // already on waitlist return true; } if (!isset($this->id)) { $new = true; if (empty($this->position)) { $max = $this->_db->get_field(waitlist::TABLE, 'MAX(position)', array('classid' => $this->classid)); $this->position = $max + 1; } } parent::save(); $sendnotification = !empty(elis::$config->local_elisprogram->notify_addedtowaitlist_user) ? true : false; if ($new && $sendnotification === true) { $subject = get_string('waitlist', self::LANG_FILE); $pmclass = new pmclass($this->classid); $sparam = new stdClass(); $sparam->idnumber = $pmclass->idnumber; $message = get_string('added_to_waitlist_message', self::LANG_FILE, $sparam); $cuser = new user($this->userid); $cuser->load(); $from = get_admin(); notification::notify($message, $cuser, $from); //email_to_user($user, $from, $subject, $message); // *TBD* } }
public function save() { parent::save(); events_trigger('crlm_curriculum_course_associated', $this); }