/** * Saves the given course set to database. * * @param String $coursesetId the course set to save or empty if it is a * new course set */ public function save_action($coursesetId = '') { if (!$this->instant_course_set_view && (!Request::submitted('submit') || !Request::get('name') || !Request::getArray('institutes'))) { $this->flash['name'] = Request::get('name'); $this->flash['institutes'] = Request::getArray('institutes'); $this->flash['courses'] = Request::getArray('courses'); $this->flash['rules'] = Request::getArray('rules'); $this->flash['userlists'] = Request::getArray('userlists'); $this->flash['infotext'] = Request::get('infotext'); $this->flash['private'] = (bool) Request::get('private'); if (Request::submitted('add_institute')) { $this->flash['institutes'] = array_merge($this->flash['institutes'], array(Request::option('institute_id'))); } else { $this->flash['institute_id'] = Request::get('institute_id'); $this->flash['institute_id_parameter'] = Request::get('institute_id_parameter'); } if (!Request::submitted('add_institute') && !Request::option('name')) { $this->flash['error'] = _('Bitte geben Sie einen Namen für das Anmeldeset an!'); } if (!Request::submitted('add_institute') && !Request::getArray('institutes')) { $this->flash['error'] = _('Bitte geben Sie mindestens eine Einrichtung an, zu der das Anmeldeset gehört!'); } $this->redirect($this->url_for('admission/courseset/configure', $coursesetId)); } else { $courseset = new CourseSet($coursesetId); if (!$courseset->getUserId()) { $courseset->setUserId($GLOBALS['user']->id); } $courseset->setName(Request::get('name')); if (Request::submitted('institutes')) { $courseset->setInstitutes(Request::getArray('institutes')); } if (Request::submitted('semester')) { $courseset->setCourses(Request::getArray('courses')); } if (Request::submitted('userlists')) { $courseset->setUserLists(Request::getArray('userlists')); } if (!$this->instant_course_set_view && $courseset->isUserAllowedToEdit($GLOBALS['user']->id)) { $courseset->setPrivate((bool) Request::get('private')); } if (Request::submitted('infotext')) { $courseset->setInfoText(Request::get('infotext')); } $courseset->clearAdmissionRules(); foreach (Request::getArray('rules') as $serialized) { $rule = unserialize($serialized); $courseset->addAdmissionRule($rule); } $courseset->store(); PageLayout::postMessage(MessageBox::success(sprintf(_("Das Anmeldeset: %s wurde gespeichert"), htmlReady($courseset->getName())))); if ($this->instant_course_set_view) { $this->redirect($this->url_for('course/admission')); } else { $this->redirect($this->url_for('admission/courseset/configure', $courseset->getId())); } } }