Skip to content

Commit

Permalink
Merge pull request #4757 from schmitz-ilias/bt_21972_dtpl_sessions
Browse files Browse the repository at this point in the history
fixes 21972 by adding adding didactic templates to session settings
  • Loading branch information
smeyer-ilias authored Jul 12, 2022
2 parents b441323 + 0b4ffa7 commit b1119f1
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 23 deletions.
111 changes: 88 additions & 23 deletions Modules/Session/classes/class.ilObjSessionGUI.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
<?php
/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

use ILIAS\DI\HTTPServices;

include_once('./Services/Object/classes/class.ilObjectGUI.php');
include_once('./Modules/Session/classes/class.ilObjSession.php');
Expand All @@ -23,7 +40,10 @@ class ilObjSessionGUI extends ilObjectGUI implements ilDesktopItemHandling
* @var ilLogger
*/
protected $logger = null;

/**
* @var HTTPServices
*/
protected $http;

public $lng;
public $ctrl;
Expand Down Expand Up @@ -60,8 +80,9 @@ public function __construct($a_data, $a_id, $a_call_by_reference, $a_prepare_out

$this->tpl = $tpl;
$this->ctrl = $ilCtrl;

$this->logger = $GLOBALS['DIC']->logger()->sess();

$this->http = $DIC->http();
$this->logger = $DIC->logger()->sess();
}


Expand Down Expand Up @@ -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');
Expand All @@ -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()
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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;

Expand All @@ -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';
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 4 additions & 0 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -15226,6 +15226,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
Expand Down
4 changes: 4 additions & 0 deletions lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -15272,6 +15272,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
Expand Down

0 comments on commit b1119f1

Please sign in to comment.