diff --git a/modules/settings/_includes.php b/modules/settings/_includes.php index b7d8bff4..7c6bc812 100644 --- a/modules/settings/_includes.php +++ b/modules/settings/_includes.php @@ -6,6 +6,8 @@ $includePath = $_EnginePath . 'modules/settings/'; + include($includePath . './components/LoginHistoryEntry/LoginHistoryEntry.component.php'); + include($includePath . './utils/content/prepareChangeProcessEmails.content.php'); include($includePath . './utils/errorMappers/tryDeleteUserIgnoreEntries.errorMapper.php'); diff --git a/modules/settings/components/LoginHistoryEntry/LoginHistoryEntry.component.php b/modules/settings/components/LoginHistoryEntry/LoginHistoryEntry.component.php new file mode 100644 index 00000000..298acff2 --- /dev/null +++ b/modules/settings/components/LoginHistoryEntry/LoginHistoryEntry.component.php @@ -0,0 +1,110 @@ + $localTemplateLoader('body'), + ]; + + $isSuccessfulLogin = ($entryData['State'] === true); + $isSameIpAsLastSeen = ($entryData['IP'] == $userLastIp); + + $dateColorClassNames = Collections\compact([ + ( + ( + !$isSuccessfulLogin && + !$isSameIpAsLastSeen + ) ? + 'red' : + null + ) + ]); + $ipColorClassNames = Collections\compact([ + ( + $isSuccessfulLogin ? + 'lime' : + null + ), + ( + ( + !$isSuccessfulLogin && + !$isSameIpAsLastSeen + ) ? + 'red' : + null + ) + ]); + $stateColorClassNames = Collections\compact([ + ( + ( + !$isSuccessfulLogin && + !$isSameIpAsLastSeen + ) ? + 'red' : + null + ), + ( + ( + !$isSuccessfulLogin && + $isSameIpAsLastSeen + ) ? + 'orange' : + null + ) + ]); + + $dateColorClassName = reset($dateColorClassNames); + $ipColorClassName = reset($ipColorClassNames); + $stateColorClassName = reset($stateColorClassNames); + + $componentTplData = [ + 'inject_dateColorClass' => $dateColorClassName, + 'inject_ipColorClass' => $ipColorClassName, + 'inject_stateColorClass' => $stateColorClassName, + 'data_loginTimeAbsolute' => prettyDate('d m Y, H:i:s', $entryData['Time'], 1), + 'data_loginTimeRelative' => implode( + ' ', + [ + pretty_time($currentTimestamp - $entryData['Time'], true, 'D'), + $_Lang['Logons_ago'] + ] + ), + 'data_ip' => $entryData['IP'], + 'data_stateLabel' => ( + $isSuccessfulLogin ? + $_Lang['Logons_Success'] : + $_Lang['Logons_Failed'] + ), + ]; + + $componentHTML = parsetemplate( + $tplBodyCache['body'], + $componentTplData + ); + + return [ + 'componentHTML' => $componentHTML + ]; +} + +?> diff --git a/modules/settings/components/LoginHistoryEntry/body.tpl b/modules/settings/components/LoginHistoryEntry/body.tpl new file mode 100644 index 00000000..e1c4757d --- /dev/null +++ b/modules/settings/components/LoginHistoryEntry/body.tpl @@ -0,0 +1,14 @@ +