Skip to content

Commit

Permalink
Code improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
nmatuschek committed Aug 9, 2024
1 parent 0dd3532 commit 20ce8a5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -331,33 +317,34 @@ 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]);
}

$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
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}

Expand Down
8 changes: 8 additions & 0 deletions components/ILIAS/Init/classes/class.ilStartUpGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -1203,6 +1208,7 @@ private function doMigrationNewAccount(): void
$credentials,
[$provider]
);

if ($frontend->migrateAccountNew()) {
ilInitialisation::redirectToStartingPage();
}
Expand Down Expand Up @@ -1255,6 +1261,7 @@ private function doMigration(array $migration_request_data): void
$credentials,
[$provider]
);

if ($frontend->migrateAccount($GLOBALS['DIC']['ilAuthSession'])) {
ilInitialisation::redirectToStartingPage();
}
Expand Down Expand Up @@ -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']);
}
Expand Down

0 comments on commit 20ce8a5

Please sign in to comment.