From 20ce8a5a6b042b8a85d02ad63783a1c97e0077ed Mon Sep 17 00:00:00 2001 From: nmatuschek Date: Fri, 9 Aug 2024 09:13:53 +0200 Subject: [PATCH] Code improvement --- .../class.ilAuthLogoutPageEditorGUI.php | 33 ++++++------------- .../class.ilAuthLogoutPageEditorSettings.php | 2 ++ .../ILIAS/Init/classes/class.ilStartUpGUI.php | 8 +++++ 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/components/ILIAS/Authentication/classes/class.ilAuthLogoutPageEditorGUI.php b/components/ILIAS/Authentication/classes/class.ilAuthLogoutPageEditorGUI.php index 6618e21fcdf5..d9edb0457abb 100644 --- a/components/ILIAS/Authentication/classes/class.ilAuthLogoutPageEditorGUI.php +++ b/components/ILIAS/Authentication/classes/class.ilAuthLogoutPageEditorGUI.php @@ -75,7 +75,6 @@ public function __construct(int $a_ref_id) $query_wrapper = $DIC->http()->wrapper()->query(); $post_wrapper = $DIC->http()->wrapper()->post(); - $is_post_request = $DIC->http()->request()->getMethod() === 'POST'; $refinery = $DIC->refinery(); if ($query_wrapper->has('redirectSource')) { @@ -87,22 +86,6 @@ public function __construct(int $a_ref_id) } elseif ($query_wrapper->has('key')) { $this->key = $query_wrapper->retrieve('key', $refinery->kindlyTo()->int()); } - - if ($is_post_request) { - if ($post_wrapper->has('visible_languages')) { - $this->visible_languages = $post_wrapper->retrieve( - 'visible_languages', - $refinery->kindlyTo()->listOf($refinery->kindlyTo()->string()) - ); - } - - if ($post_wrapper->has('languages')) { - $this->languages = $post_wrapper->retrieve( - 'languages', - $refinery->kindlyTo()->listOf($refinery->kindlyTo()->string()) - ); - } - } } public function getSettings(): ilAuthLogoutPageEditorSettings @@ -208,14 +191,17 @@ private function handleLogoutPageActions(): void case 'deactivate': $this->deactivate(); break; + case 'activate': $this->activate(); break; + case 'edit': $this->ctrl->setParameter($this, 'logoutpage_languages_key', current($keys)); $this->ctrl->setParameter($this, 'key', ilLanguage::lookupId(current($keys))); $this->ctrl->redirectByClass(ilLogoutPageGUI::class, 'edit'); break; + default: $this->ctrl->redirect($this, 'show'); break; @@ -331,18 +317,19 @@ private function initLogoutForm(): void $def_language = $this->lng->getDefaultLanguage(); foreach ($this->setDefLangFirst($def_language, $languages) as $lang_key) { - $add = ""; + $add = ''; + if ($lang_key === $def_language) { - $add = " (" . $this->lng->txt("default") . ")"; + $add = ' (' . $this->lng->txt('default') . ')'; } $textarea = new ilTextAreaInputGUI( - $this->lng->txt("meta_l_" . $lang_key) . $add, + $this->lng->txt('meta_l_' . $lang_key) . $add, 'logout_message_' . $lang_key ); $textarea->setRows(10); - $msg_logout_lang = "logout_message_" . $lang_key; + $msg_logout_lang = 'logout_message_' . $lang_key; if (isset($logout_settings[$msg_logout_lang])) { $textarea->setValue($logout_settings[$msg_logout_lang]); @@ -350,14 +337,14 @@ private function initLogoutForm(): void $this->form->addItem($textarea); - unset($logout_settings["logout_message_" . $lang_key]); + unset($logout_settings['logout_message_' . $lang_key]); } foreach ($logout_settings as $key => $message) { $lang_key = substr($key, strrpos($key, "_") + 1, strlen($key) - strrpos($key, "_")); $textarea = new ilTextAreaInputGUI( - $this->lng->txt("meta_l_" . $lang_key), + $this->lng->txt('meta_l_' . $lang_key), 'logout_message_' . $lang_key ); diff --git a/components/ILIAS/Authentication/classes/class.ilAuthLogoutPageEditorSettings.php b/components/ILIAS/Authentication/classes/class.ilAuthLogoutPageEditorSettings.php index 572bdeb002ae..0ebd3ee71240 100644 --- a/components/ILIAS/Authentication/classes/class.ilAuthLogoutPageEditorSettings.php +++ b/components/ILIAS/Authentication/classes/class.ilAuthLogoutPageEditorSettings.php @@ -52,9 +52,11 @@ public function getIliasEditorLanguage(string $a_langkey): string if ($this->isIliasEditorEnabled($a_langkey)) { return $a_langkey; } + if ($this->isIliasEditorEnabled($this->lng->getDefaultLanguage())) { return $this->lng->getDefaultLanguage(); } + return ''; } diff --git a/components/ILIAS/Init/classes/class.ilStartUpGUI.php b/components/ILIAS/Init/classes/class.ilStartUpGUI.php index 71b5f40ce424..884335cb8f04 100755 --- a/components/ILIAS/Init/classes/class.ilStartUpGUI.php +++ b/components/ILIAS/Init/classes/class.ilStartUpGUI.php @@ -214,6 +214,7 @@ private function showLoginPageOrStartupPage(): void ] ); } + $this->logger->debug('Show login page'); if (isset($messages) && count($messages) > 0) { foreach ($messages as $type => $content) { @@ -247,15 +248,18 @@ private function showLoginPage(ILIAS\UI\Component\Input\Container\Form\Form $for 'ext_uid', $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always('')]) ); + $soapPw = $this->http->wrapper()->query()->retrieve( 'soap_pw', $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $this->refinery->always('')]) ); + $credentials = new ilAuthFrontendCredentialsSoap( $GLOBALS['DIC']->http()->request(), $this->ctrl, $this->setting ); + $credentials->setUsername($extUid); $credentials->setPassword($soapPw); $credentials->tryAuthenticationOnLoginPage(); @@ -294,6 +298,7 @@ private function showLoginPage(ILIAS\UI\Component\Input\Container\Form\Form $for $this->lng->txt($message_key) ); } + if ($page_editor_html !== '') { $tpl->setVariable('LPE', $page_editor_html); } @@ -1203,6 +1208,7 @@ private function doMigrationNewAccount(): void $credentials, [$provider] ); + if ($frontend->migrateAccountNew()) { ilInitialisation::redirectToStartingPage(); } @@ -1255,6 +1261,7 @@ private function doMigration(array $migration_request_data): void $credentials, [$provider] ); + if ($frontend->migrateAccount($GLOBALS['DIC']['ilAuthSession'])) { ilInitialisation::redirectToStartingPage(); } @@ -1795,6 +1802,7 @@ private function doSamlAuthentication(): void if (isset($params['target']) && !isset($params['returnTo'])) { $params['returnTo'] = $params['target']; } + if (isset($params['returnTo'])) { $auth->storeParam('target', $params['returnTo']); }