Ejemplo n.º 1
0
 function updateObject()
 {
     $form = $this->initEditForm();
     $form->checkInput();
     $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
     $this->object->setDescription(ilUtil::stripSlashes($_POST['desc']));
     /*
     $archive_start = $this->loadDate('archive_start');
     $archive_end = $this->loadDate('archive_end');				 
     */
     $period = $form->getItemByPostVar("access_period");
     $sub_period = $form->getItemByPostVar("subscription_period");
     if ((int) $_POST['activation_type']) {
         $this->object->setActivationType(IL_CRS_ACTIVATION_LIMITED);
     } else {
         $this->object->setActivationType(IL_CRS_ACTIVATION_UNLIMITED);
     }
     $this->object->setOfflineStatus(!(bool) $_POST['activation_online']);
     $this->object->setActivationStart($period->getStart()->get(IL_CAL_UNIX));
     $this->object->setActivationEnd($period->getEnd()->get(IL_CAL_UNIX));
     $this->object->setActivationVisibility((int) $_POST['activation_visibility']);
     $sub_type = (int) $_POST['subscription_type'];
     if ($sub_type != IL_CRS_SUBSCRIPTION_DEACTIVATED) {
         $this->object->setSubscriptionType($sub_type);
         if ((int) $_POST['subscription_limitation_type']) {
             $this->object->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_LIMITED);
         } else {
             $this->object->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_UNLIMITED);
         }
     } else {
         $this->object->setSubscriptionType(IL_CRS_SUBSCRIPTION_DIRECT);
         // see ilObjCourse::__createDefaultSettings()
         $this->object->setSubscriptionLimitationType(IL_CRS_SUBSCRIPTION_DEACTIVATED);
     }
     // save subitems anyways
     $this->object->setSubscriptionPassword(ilUtil::stripSlashes($_POST['subscription_password']));
     $this->object->setSubscriptionStart($sub_period->getStart()->get(IL_CAL_UNIX));
     $this->object->setSubscriptionEnd($sub_period->getEnd()->get(IL_CAL_UNIX));
     $this->object->enableSubscriptionMembershipLimitation((int) $_POST['subscription_membership_limitation']);
     $this->object->setSubscriptionMaxMembers((int) $_POST['subscription_max']);
     $this->object->enableRegistrationAccessCode((int) $_POST['reg_code_enabled']);
     $this->object->setRegistrationAccessCode(ilUtil::stripSlashes($_POST['reg_code']));
     $this->object->enableWaitingList((int) $_POST['waiting_list']);
     #$this->object->setSubscriptionNotify((int) $_POST['subscription_notification']);
     $this->object->setViewMode((int) $_POST['view_mode']);
     if ($this->object->getViewMode() == IL_CRS_VIEW_TIMING) {
         $this->object->setOrderType(ilContainer::SORT_ACTIVATION);
     } else {
         $this->object->setOrderType($form->getInput('sorting'));
     }
     $this->saveSortingSettings($form);
     /*
     		$this->object->setArchiveStart($archive_start->get(IL_CAL_UNIX));
     		$this->object->setArchiveEnd($archive_end->get(IL_CAL_UNIX));		
     		$this->object->setArchiveType($_POST['archive_type']);
     */
     $this->object->setAboStatus((int) $_POST['abo']);
     $this->object->setShowMembers((int) $_POST['show_members']);
     $this->object->setMailToMembersType((int) $_POST['mail_type']);
     $this->object->enableSessionLimit((int) $_POST['sl']);
     $this->object->setNumberOfPreviousSessions(is_numeric($_POST['sp']) ? (int) $_POST['sp'] : -1);
     $this->object->setNumberOfnextSessions(is_numeric($_POST['sn']) ? (int) $_POST['sn'] : -1);
     $this->object->setAutoNotification($_POST['auto_notification'] == 1 ? true : false);
     $show_lp_sync_confirmation = false;
     // could be hidden in form
     if (isset($_POST['status_dt'])) {
         if ($this->object->getStatusDetermination() != ilObjCourse::STATUS_DETERMINATION_LP && (int) $_POST['status_dt'] == ilObjCourse::STATUS_DETERMINATION_LP) {
             $show_lp_sync_confirmation = true;
         } else {
             $this->object->setStatusDetermination((int) $_POST['status_dt']);
         }
     }
     if ($this->object->validate()) {
         $this->object->update();
         // BEGIN ChangeEvent: Record write event
         require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
         global $ilUser;
         ilChangeEvent::_recordWriteEvent($this->object->getId(), $ilUser->getId(), 'update');
         ilChangeEvent::_catchupWriteEvents($this->object->getId(), $ilUser->getId());
         // END ChangeEvent: Record write event
         include_once './Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
         ilObjectServiceSettingsGUI::updateServiceSettingsForm($this->object->getId(), $form, array(ilObjectServiceSettingsGUI::CALENDAR_VISIBILITY, ilObjectServiceSettingsGUI::NEWS_VISIBILITY, ilObjectServiceSettingsGUI::AUTO_RATING_NEW_OBJECTS, ilObjectServiceSettingsGUI::TAG_CLOUD));
         // Update ecs export settings
         include_once 'Modules/Course/classes/class.ilECSCourseSettings.php';
         $ecs = new ilECSCourseSettings($this->object);
         if (!$ecs->handleSettingsUpdate()) {
             $this->editObject();
             return false;
         }
         if ($show_lp_sync_confirmation) {
             return $this->confirmLPSync();
         }
         return $this->afterUpdate();
     } else {
         ilUtil::sendFailure($this->object->getMessage());
         $this->editObject();
         return false;
     }
 }