From 0b4ffa7231563fe9c5d49e1e53908008e098bcc5 Mon Sep 17 00:00:00 2001 From: Tim Schmitz Date: Tue, 12 Jul 2022 15:33:44 +0200 Subject: [PATCH] fixes 21972 by adding adding didactic templates to session settings --- .../Session/classes/class.ilObjSessionGUI.php | 111 ++++++++++++++---- lang/ilias_de.lang | 4 + lang/ilias_en.lang | 4 + 3 files changed, 96 insertions(+), 23 deletions(-) diff --git a/Modules/Session/classes/class.ilObjSessionGUI.php b/Modules/Session/classes/class.ilObjSessionGUI.php index e5bf9da79ae4..54b2f6d7573b 100644 --- a/Modules/Session/classes/class.ilObjSessionGUI.php +++ b/Modules/Session/classes/class.ilObjSessionGUI.php @@ -1,5 +1,22 @@ tpl = $tpl; $this->ctrl = $ilCtrl; - - $this->logger = $GLOBALS['DIC']->logger()->sess(); + + $this->http = $DIC->http(); + $this->logger = $DIC->logger()->sess(); } @@ -1043,17 +1064,13 @@ public function editObject() /** * update object - * - * @access protected - * @param - * @return */ - public function updateObject() + public function updateObject() : bool { global $DIC; $ilErr = $DIC['ilErr']; - + $old_autofill = $this->object->hasWaitingListAutoFill(); $form = $this->initForm('edit'); @@ -1065,6 +1082,19 @@ public function updateObject() return false; } + //Mantis 21972: Choose didactic template on settings screen + $old_type = ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId()); + + $modified = false; + $new_type_info = $form->getInput('didactic_type'); + if ($new_type_info) { + $new_type = explode('_', $form->getInput('didactic_type')); + $new_type = $new_type[1]; + + $modified = ($new_type != $old_type); + $this->logger->info('Switched group type from ' . $old_type . ' to ' . $new_type); + } + if ( $this->record_gui instanceof \ilAdvancedMDRecordGUI && !$this->record_gui->importEditFormPostValues() @@ -1105,14 +1135,53 @@ public function updateObject() $this->object->hasWaitingListAutoFill()) { $this->object->handleAutoFill(); } - - ilUtil::sendSuccess($this->lng->txt('event_updated'), true); + + //Mantis 21972: Choose didactic template on settings screen + if ($modified) { + if ($new_type == 0) { + $new_type_txt = $this->lng->txt('il_sess_status_open'); + } else { + $dtpl = new ilDidacticTemplateSetting($new_type); + $new_type_txt = $dtpl->getPresentationTitle($this->lng->getLangKey()); + } + $this->tabs_gui->activateTab('settings'); + + ilUtil::sendQuestion($this->lng->txt('sess_warn_sess_type_changed')); + $confirm = new ilConfirmationGUI(); + $confirm->setFormAction($this->ctrl->getFormAction($this)); + $confirm->addItem( + 'sess_type', + $new_type, + $this->lng->txt('sess_info_new_sess_type') . ': ' . $new_type_txt + ); + $confirm->addButton($this->lng->txt('sess_change_type'), 'updateSessionType'); + $confirm->setCancel($this->lng->txt('cancel'), 'edit'); + + $this->tpl->setContent($confirm->getHTML()); + return true; + } else { + ilUtil::sendSuccess($this->lng->txt('event_updated'), true); + $this->ctrl->redirect($this, 'edit'); + #$this->object->initFiles(); + #$this->editObject(); + return true; + } + } + + /** + * change session type + */ + public function updateSessionTypeObject() : void + { + ilDidacticTemplateUtils::switchTemplate( + $this->object->getRefId(), + $this->http->request()->getParsedBody()['sess_type'] + ); + + ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); $this->ctrl->redirect($this, 'edit'); - #$this->object->initFiles(); - #$this->editObject(); - return true; } - + /** * confirm delete files * @@ -1572,10 +1641,8 @@ public function eventsListObject() /** * Init Form - * - * @access protected */ - protected function initForm($a_mode) + protected function initForm(string $a_mode) : ilPropertyFormGUI { global $DIC; @@ -1598,9 +1665,7 @@ protected function initForm($a_mode) $this->form->setFormAction($this->ctrl->getFormAction($this)); $this->form->setMultipart(true); - if ($a_mode == 'create') { - $this->form = $this->initDidacticTemplate($this->form); - } + $this->form = $this->initDidacticTemplate($this->form); $this->lng->loadLanguageModule('dateplaner'); include_once './Services/Form/classes/class.ilDateDurationInputGUI.php'; @@ -1757,7 +1822,7 @@ protected function initForm($a_mode) array( ilObjectServiceSettingsGUI::CUSTOM_METADATA ) - ); + ); $gallery = new ilCheckboxInputGUI($this->lng->txt('sess_show_members'), 'show_members'); $gallery->setChecked($this->object->getShowMembers()); diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 46674b05177b..377643ca36e4 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -15224,6 +15224,10 @@ sess#:#sess_mail_all#:#Für alle Teilnehmer sess#:#sess_mail_all_info#:#Alle Teilnehmer können die Funktion "Mail an Teilnehmer" im Reiter Teilnehmer nutzen. sess#:#sess_contact#:#Kontakt sess#:#sess_mem_contacts#:#Tutorielle Betreuung +sess#:#sess_warn_sess_type_changed#:#Sind Sie sicher, dass Sie die Sitzungsart ändern möchten? Die Rechteeinstellungen dieser Sitzung werden überschrieben und an die neue Art der Sitzung angepasst. +sess#:#sess_info_new_sess_type#:#Neue Sitzungsart +sess#:#il_sess_status_open#:#Offene Sitzung +sess#:#sess_change_type#:#Sitzungsart ändern dateplaner#:#cal_calendar_subscription_modal_title#:#Kalender abonnieren sess#:#sess_members#:#Teilnehmer grp#:#grp_contact#:#Betreuung diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 0e71c2e13fbd..985dacd5a823 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -15270,6 +15270,10 @@ sess#:#sess_mail_all#:#For all Participants sess#:#sess_mail_all_info#:#All participants can use the feature ‘Mail to Participants’ in the ‘Participants’ tab. sess#:#sess_contact#:#Contact sess#:#sess_mem_contacts#:#Tutorial Support +sess#:#sess_warn_sess_type_changed#:#Do you really want to change the session type? All permission settings will be reset. +sess#:#sess_info_new_sess_type#:#New Session Type +sess#:#il_sess_status_open#:#Open Session +sess#:#sess_change_type#:#Change Session Type dateplaner#:#cal_calendar_subscription_modal_title#:#Calendar Subscription sess#:#sess_members#:#Participants grp#:#grp_contact#:#Support