/** * Stores the given values to the given course. * * @param Course $course the course to store values for * @param Array $values values to set * @return Course The course object with updated values. */ public function storeValues($course, $values) { // We only need our own stored values here. $values = $values[__CLASS__]; $course->study_areas = SimpleORMapCollection::createFromArray(StudipStudyArea::findMany($values['studyareas'])); if ($course->store()) { return $course; } else { return false; } }
public function assign() { if ($this->course->study_areas) { foreach ($this->course->study_areas as $area) { $assigned[] = $area->sem_tree_id; } foreach (array_keys(Request::getArray('assign')) as $new) { if (!in_array($new, $assigned)) { $assigned[] = $new; } } } $this->course->study_areas = SimpleORMapCollection::createFromArray(StudipStudyArea::findMany($assigned)); try { $msg = null; $this->course->store(); } catch (UnexpectedValueException $e) { $msg = $e->getMessage(); } return $msg; }