fixing multilingual issues: display languages in native names and fix initialition point of plugins

This commit is contained in:
Stephan Brunker 2019-10-20 16:22:10 +02:00 committed by onli
parent f9d43d20a3
commit 5c4c11f0b4
3 changed files with 46 additions and 39 deletions

View File

@ -400,7 +400,7 @@ function serendipity_login($use_external = true) {
$user = $serendipity['COOKIE']['author_username'];
$valid_logintoken = serendipity_checkAutologin($user);
if ($valid_logintoken === true) {
// if we do not tie down the session gere it will be recreated on every page reload, which will fuck op the form token system. That's why we need to load all data that makes the session stick. That's why we call setAuthorToken here.
// if we do not tie down the session here it will be recreated on every page reload, which will fuck op the form token system. That's why we need to load all data that makes the session stick. That's why we call setAuthorToken here.
serendipity_setAuthorToken();
serendipity_load_userdata($user);
return true;
@ -412,7 +412,7 @@ function serendipity_login($use_external = true) {
}
$data = array('ext' => $use_external, 'mode' => 2, 'user' => $serendipity['POST']['user'], 'pass' => $serendipity['POST']['pass']);
serendipity_plugin_api::hook_event('backend_loginfail', $data);
if ($use_external) serendipity_plugin_api::hook_event('backend_loginfail', $data);
}
/**
@ -542,16 +542,12 @@ function serendipity_authenticate_author($username = '', $password = '', $is_has
if ($debug) fwrite($fp, date('Y-m-d H:i') . ' - Login ext check' . "\n");
$is_authenticated = false;
serendipity_plugin_api::hook_event('backend_login', $is_authenticated, NULL);
if ($is_authenticated) {
return true;
}
if ($use_external) serendipity_plugin_api::hook_event('backend_login', $is_authenticated, NULL);
if ($is_authenticated) return true;
if ($debug) fwrite($fp, date('Y-m-d H:i') . ' - Login username check:' . $username . "\n");
if (!empty($username) && is_string($username)) {
if ($use_external) {
serendipity_plugin_api::hook_event('backend_auth', $is_hashed, array('username' => $username, 'password' => $password));
}
if ($use_external) serendipity_plugin_api::hook_event('backend_auth', $is_hashed, array('username' => $username, 'password' => $password));
$query = "SELECT DISTINCT
email, password, realname, authorid, userlevel, right_publish, hashtype

View File

@ -32,6 +32,12 @@ if (isset($serendipity['GET']['adminModule']) && $serendipity['GET']['adminModul
if (!serendipity_userLoggedIn()) {
// Try again to log in, this time with enabled external authentication event hook
serendipity_login(true);
if (serendipity_userLoggedIn()) {
// login with external authentication - reload page to set language settings correct for user
include_once S9Y_INCLUDE_PATH . 'include/functions_routing.inc.php';
gotoAdmin();
return true;
}
}
}
}

View File

@ -156,42 +156,44 @@ if (!isset($serendipity['dashboardEntriesLimit'])) {
// Available languages
if (!isset($serendipity['languages'])) {
$serendipity['languages'] = array('en' => 'English',
'de' => 'German',
'da' => 'Danish',
'es' => 'Spanish',
'fr' => 'French',
'fi' => 'Finnish',
'cs' => 'Czech (Win-1250)',
'cz' => 'Czech (ISO-8859-2)',
'sk' => 'Slovak',
'nl' => 'Dutch',
'is' => 'Icelandic',
'tr' => 'Turkish',
'se' => 'Swedish',
'pt' => 'Portuguese Brazilian',
'pt_PT' => 'Portuguese European',
'bg' => 'Bulgarian',
'hu' => 'Hungarian',
'no' => 'Norwegian',
'pl' => 'Polish',
'ro' => 'Romanian',
'it' => 'Italian',
'ru' => 'Russian',
'fa' => 'Persian',
'tw' => 'Traditional Chinese (Big5)',
'tn' => 'Traditional Chinese (UTF-8)',
'zh' => 'Simplified Chinese (GB2312)',
'cn' => 'Simplified Chinese (UTF-8)',
'ja' => 'Japanese',
'ko' => 'Korean',
'sa' => 'Arabic',
'ta' => 'Tamil');
'de' => 'Deutsch',
'da' => 'Dansk',
'es' => 'Español',
'fr' => 'Français',
'fi' => 'Suomalainen',
'cs' => 'čeština (Win-1250)',
'cz' => 'čeština (ISO-8859-2)',
'sk' => 'Slovenský',
'nl' => 'Nederlands',
'is' => 'Íslensku',
'tr' => 'Türk',
'se' => 'svenska',
'pt' => 'português brasileiro',
'pt_PT' => 'português europeu',
'bg' => 'Български',
'hu' => 'magyar',
'no' => 'norsk',
'pl' => 'polski',
'ro' => 'limba română',
'it' => 'italiano',
'ru' => 'Русский язык',
'fa' => 'Fārsī',
'tw' => '正體字/繁體字 (Big5)',
'tn' => '正體字/繁體字 (UTF-8)',
'zh' => '简化字 (GB2312)',
'cn' => '简化字 (UTF-8)',
'ja' => '日本語',
'ko' => '한국어, 조선말',
'sa' => 'العربية',
'ta' => 'தமிழ்');
}
// Available Calendars
$serendipity['calendars'] = array('gregorian' => 'Gregorian',
'persian-utf8' => 'Persian (utf8)');
// Load main language file
// if installed === false language autodetect or 'en', else nothing happens
// because serendipity['lang'] is not defined yet
include($serendipity['serendipityPath'] . 'include/lang.inc.php');
$serendipity['charsets'] = array(
@ -373,6 +375,9 @@ if (IS_installed === true && php_sapi_name() !== 'cli') {
if (isset($_SESSION['serendipityAuthorid'])) {
serendipity_load_configuration($_SESSION['serendipityAuthorid']);
// load_configuration overwrites $serendipity['lang'], so roll back if another language was detected
// in the backend should always the user language be shown
// in the frontend logged in same as any other user, exept with fallback to user instead of default
$serendipity['lang'] = serendipity_getPostAuthSessionLanguage();
}