From 6810caae47787689d6f316c5bdd62e3722b363bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 14 Dec 2010 06:10:00 +0000 Subject: [PATCH] Performance hacks, encapsulation and more EL code usage: - Performance hack in SQL_QUERY() to save some expensive str_replace() and other function calls - Encapsulation of admin session data - Some more usage of EL code in admin welcome templates - TODOs.txt updated --- DOCS/TODOs.txt | 47 +++++++------- inc/db/lib-mysql3.php | 58 +++++++++-------- inc/extensions/ext-admins.php | 2 +- inc/filters.php | 6 +- inc/libs/admins_functions.php | 16 +++-- inc/modules/admin.php | 4 +- inc/modules/admin/admin-inc.php | 13 ++-- inc/modules/admin/what-config_admins.php | 6 +- inc/modules/admin/what-list_rallyes.php | 7 -- inc/modules/admin/what-list_unconfirmed.php | 5 +- inc/mysql-manager.php | 7 +- inc/pool/pool-bonus.php | 2 +- inc/session-functions.php | 10 +-- inc/template-functions.php | 6 +- inc/wrapper-functions.php | 65 ++++++++++++++++++- templates/de/html/admin/admin_welcome.tpl | 2 +- .../de/html/admin/admin_welcome_admins.tpl | 2 +- 17 files changed, 166 insertions(+), 92 deletions(-) diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index cdaf36a4e3..f293a25ce3 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -59,7 +59,7 @@ ./inc/language/rallye_de.php:13: * @TODO Naming convention not applied for language strings * ./inc/language/refback_de.php:44:// @TODO Rewrite these constants to one ./inc/language/sponsor_de.php:117:// @TODO Rewrite these four constants to one and use sprintf() -./inc/libs/admins_functions.php:433: // @TODO This can be, somehow, rewritten +./inc/libs/admins_functions.php:435: // @TODO This can be, somehow, rewritten ./inc/libs/beg_functions.php:55: // @TODO Try to rewrite the following unset() ./inc/libs/bonus_functions.php:199: // @TODO Move this HTML to a template ./inc/libs/bonus_functions.php:287: // @TODO This query isn't right, it will only update if the user was for a longer time away! @@ -95,11 +95,12 @@ ./inc/loader/load_cache-extension.php:13: * @TODO Rewrite this whole file to load_cache-extensions.php * ./inc/module-functions.php:267: // @TODO Nothing helped??? ./inc/module-functions.php:308: // @TODO Rewrite this to a filter -./inc/modules/admin/admin-inc.php:262: // @TODO Rewrite this to $content = SQL_FETCHARRAY() -./inc/modules/admin/admin-inc.php:267: // @TODO ACL is 'allow'... hmmm -./inc/modules/admin/admin-inc.php:333: // @TODO Rewrite this to $content = SQL_FETCHARRAY() -./inc/modules/admin/admin-inc.php:339: // @TODO ACL is 'allow'... hmmm -./inc/modules/admin/admin-inc.php:439:// @TODO Try to rewrite this to adminAddMenuSelectionBox() +./inc/modules/admin/admin-inc.php:170: // @TODO This and the next getCurrentAdminId() call might be moved into the templates? +./inc/modules/admin/admin-inc.php:259: // @TODO Rewrite this to $content = SQL_FETCHARRAY() +./inc/modules/admin/admin-inc.php:264: // @TODO ACL is 'allow'... hmmm +./inc/modules/admin/admin-inc.php:330: // @TODO Rewrite this to $content = SQL_FETCHARRAY() +./inc/modules/admin/admin-inc.php:336: // @TODO ACL is 'allow'... hmmm +./inc/modules/admin/admin-inc.php:436:// @TODO Try to rewrite this to adminAddMenuSelectionBox() ./inc/modules/admin/overview-inc.php:162: // @TODO Rewrite this to a filter ./inc/modules/admin/overview-inc.php:275: // @TODO Rewrite this to something with include files and/or filter ./inc/modules/admin/overview-inc.php:309: // @TODO This may also be rewritten to include files @@ -136,8 +137,8 @@ ./inc/modules/admin/what-list_links.php:85: // @TODO Find a way to rewrite this. See some lines above for different queries ./inc/modules/admin/what-list_links.php:94: // @TODO Rewrite this to includes/filter ./inc/modules/admin/what-list_refs.php:107: // @TODO Try to rewrite some to EL -./inc/modules/admin/what-list_unconfirmed.php:77: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); -./inc/modules/admin/what-list_unconfirmed.php:96: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus +./inc/modules/admin/what-list_unconfirmed.php:80: // @TODO This constant might be unused? define('__LIST_UNCON_TITLE', '{--ADMIN_LIST_UNCONFIRMED_BONUS_LINKS--}'); +./inc/modules/admin/what-list_unconfirmed.php:99: // @TODO "Please do not call me directly." Should be rewritten to a nice selection depending on ext-bonus ./inc/modules/admin/what-list_user.php:149: // @TODO Rewrite these to filters ./inc/modules/admin/what-list_user.php:255: // @TODO Rewrite this into a filter ./inc/modules/admin/what-list_user.php:295: // @TODO Rewrite this into a filter @@ -176,25 +177,25 @@ ./inc/modules/order.php:74: // @TODO Unused: 2,4 ./inc/monthly/monthly_bonus.php:67: // @TODO Rewrite this to a filter ./inc/mysql-manager.php:1183: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1438: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1544: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1915: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1959:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1441: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1547: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1918: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1962:// @TODO Fix inconsistency between last_module and getWhat() ./inc/mysql-manager.php:368: // @TODO Try to rewrite this to one or more functions ./inc/mysql-manager.php:44:// @TODO Can we cache this? ./inc/reset/reset_beg.php:52:// @TODO This should be converted in a daily beg rallye ./inc/reset/reset_birthday.php:92: // @TODO 4 is hard-coded here, should we move it out in config? ./inc/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array' -./inc/template-functions.php:1041: // @TODO Deprecate this thing -./inc/template-functions.php:1052: // @TODO Deprecate this thing -./inc/template-functions.php:1139: // @TODO This can be easily moved out after the merge from EL branch to this is complete -./inc/template-functions.php:1172: // @TODO Add a little more infos here -./inc/template-functions.php:1460:// @TODO Lame description for this function -./inc/template-functions.php:1482: // @TODO Move this in a filter -./inc/template-functions.php:187: * @TODO On some pages this is buggy -./inc/template-functions.php:263: // @TODO Remove this sanity-check if all is fine -./inc/template-functions.php:576:// @TODO $simple/$constants are deprecated -./inc/template-functions.php:600: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates +./inc/template-functions.php:1043: // @TODO Deprecate this thing +./inc/template-functions.php:1054: // @TODO Deprecate this thing +./inc/template-functions.php:1141: // @TODO This can be easily moved out after the merge from EL branch to this is complete +./inc/template-functions.php:1174: // @TODO Add a little more infos here +./inc/template-functions.php:1462:// @TODO Lame description for this function +./inc/template-functions.php:1484: // @TODO Move this in a filter +./inc/template-functions.php:189: * @TODO On some pages this is buggy +./inc/template-functions.php:265: // @TODO Remove this sanity-check if all is fine +./inc/template-functions.php:578:// @TODO $simple/$constants are deprecated +./inc/template-functions.php:602: // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates ./inc/wrapper-functions.php:130:// @TODO Implement $compress ./inc/wrapper-functions.php:137:// @TODO Implement $decompress ./inc/wrapper-functions.php:452:// @TODO Do some more sanity check here @@ -232,7 +233,7 @@ ./templates/de/html/member/member_unconfirmed_table_nopoints.tpl:11: ./templates/de/html/surfbar/surfbar_frame_textlinks.tpl:5: ### ### DEPRECATION FOLLOWS: ### ### -./inc/modules/admin/admin-inc.php:440:// @DEPRECATED +./inc/modules/admin/admin-inc.php:437:// @DEPRECATED ### ### template-warnings.log follows: ### ### Warning: Not parsing JavaScript templates/de/html/js/js_order_send.tpl. Warning: Not parsing JavaScript templates/de/html/js/js_cookies_disabled.tpl. diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 7f1d99dc8a..e982d87793 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -42,36 +42,42 @@ if (!defined('__SECURITY')) { // SQL queries function SQL_QUERY ($sqlString, $F, $L, $enableCodes = true) { - // Trim SQL string - $sqlString = trim($sqlString); - - // Link is up? - if (!SQL_IS_LINK_UP()) { - // We should not quietly ignore this! - debug_report_bug(__FUNCTION__, __LINE__, sprintf("Cannot query database: sqlString=%s,file=%s,line=%s", - $sqlString, - basename($F), - $L - )); + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__][$sqlString])) { + // Trim SQL string + $sqlStringModified = trim($sqlString); + + // Empty query string or link is not up? + if (empty($sqlStringModified)) { + // Empty SQL string! + debug_report_bug(__FUNCTION__, __LINE__, sprintf("SQL string is empty. Please fix this. file=%s, line=%s", + basename($F), + $L + )); + } elseif (!SQL_IS_LINK_UP()) { + // We should not quietly ignore this + debug_report_bug(__FUNCTION__, __LINE__, sprintf("Cannot query database: sqlString=%s,file=%s,line=%s", + $sqlStringModified, + basename($F), + $L + )); + } - // Return 'false' because it has failed - return false; - } elseif (empty($sqlString)) { - // Empty SQL string! - debug_report_bug(__FUNCTION__, __LINE__, sprintf("SQL string is empty. Please fix this. file=%s, line=%s", - basename($F), - $L - )); + // Remove \t, \n and \r from queries they may confuse some MySQL versions + $sqlStringModified = str_replace("\t", ' ', str_replace("\n", ' ', str_replace("\r", ' ', $sqlStringModified))); - // This is invalid, of course - return false; - } + // Compile config entries out + $sqlStringModified = SQL_PREPARE_SQL_STRING($sqlStringModified, $enableCodes); - // Remove \t, \n and \r from queries they may confuse some MySQL versions - $sqlString = str_replace("\t", ' ', str_replace("\n", ' ', str_replace("\r", ' ', $sqlString))); + // Cache it and remember as last SQL query + $GLOBALS[__FUNCTION__][$sqlString] = $sqlStringModified; + $GLOBALS['last_sql'] = $sqlStringModified; + } else { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Cache used!'); - // Compile config entries out - $GLOBALS['last_sql'] = SQL_PREPARE_SQL_STRING($sqlString, $enableCodes); + // Use cache (to save a lot function calls + $sqlString = $GLOBALS[__FUNCTION__][$sqlString]; + } // Starting time $querytimeBefore = microtime(true); diff --git a/inc/extensions/ext-admins.php b/inc/extensions/ext-admins.php index dc8c2a62e9..510ebf7dbf 100644 --- a/inc/extensions/ext-admins.php +++ b/inc/extensions/ext-admins.php @@ -101,7 +101,7 @@ switch (getExtensionMode()) { addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admins` ADD default_acl ENUM('deny','allow') NOT NULL DEFAULT 'deny'"); // But allow current admin everything (THIS SHALL BE YOU!) - addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `default_acl`='allow' WHERE `id`=".bigintval(getSession('admin_id'))." LIMIT 1"); + addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admins` SET `default_acl`='allow' WHERE `id`=".bigintval(getCurrentAdminId())." LIMIT 1"); addExtensionSql('DROP TABLE IF EXISTS `{?_MYSQL_PREFIX?}_admins_acls`'); addExtensionSql("CREATE TABLE `{?_MYSQL_PREFIX?}_admins_acls` ( `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, diff --git a/inc/filters.php b/inc/filters.php index c079bd698b..a75f8dd0c9 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -959,11 +959,11 @@ LIMIT 1", function FILTER_DO_LOGIN_ADMIN ($data) { // Now set all session variables and store the result for later processing $GLOBALS['admin_login_success'] = (( - setSession('admin_md5', encodeHashForCookie($data['pass_hash'])) + setAdminMd5(encodeHashForCookie($data['pass_hash'])) ) && ( - setSession('admin_id', $data['id']) + setAdminId($data['id']) ) && ( - setSession('admin_last', time()) + setAdminLast(time()) )); // Return the data for further processing diff --git a/inc/libs/admins_functions.php b/inc/libs/admins_functions.php index 2f084b8d37..3e650a1f5a 100644 --- a/inc/libs/admins_functions.php +++ b/inc/libs/admins_functions.php @@ -187,17 +187,19 @@ function adminsChangeAdminAccount ($postData, $element = '') { // Rewrite cookie when it's own account if ($adminId == $id) { // Set timeout cookie - setSession('admin_last', time()); + setAdminLast(time()); - if ($adminId != getSession('admin_id')) { + if ($adminId != getCurrentAdminId()) { // Update login cookie - setSession('admin_id', $adminId); + setAdminId($adminId); // Update password cookie as well? - if (!empty($add)) setSession('admin_md5', $hash); - } elseif (generateHash($postData['pass1'][$id], $salt) != getSession('admin_md5')) { + if (!empty($add)) { + setAdminMd5($hash); + } // END - if + } elseif (generateHash($postData['pass1'][$id], $salt) != getAdminMd5()) { // Update password cookie - setSession('admin_md5', $hash); + setAdminMd5($hash); } } // END - if @@ -689,7 +691,7 @@ function FILTER_REHASH_ADMINS_PASSWORD ($data) { adminsChangeAdminAccount($postData); // Update cookie/session and data array - setSession('admin_md5', encodeHashForCookie($newHash)); + setAdminMd5(encodeHashForCookie($newHash)); $data['pass_hash'] = $newHash; // Always make sure the cache is destroyed diff --git a/inc/modules/admin.php b/inc/modules/admin.php index 63334d631a..284e3dd9fb 100644 --- a/inc/modules/admin.php +++ b/inc/modules/admin.php @@ -354,7 +354,7 @@ if (!isAdminRegistered()) { } } else { // Maybe an Admin want's to login? - $ret = ifAdminCookiesAreValid(getSession('admin_id'), getSession('admin_md5')); + $ret = ifAdminCookiesAreValid(getCurrentAdminId(), getAdminMd5()); // Check status switch ($ret) { @@ -384,7 +384,7 @@ if (!isAdminRegistered()) { case '404': // Administrator login not found setPostRequestParameter('ok', $ret); - loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_ACCOUNT_404', getSession('admin_id'))); + loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_ACCOUNT_404', getCurrentAdminId())); destroyAdminSession(); break; diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 78d2469e4b..bce95acae4 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -165,15 +165,12 @@ function doAdminAction () { // Get action value $action = getActionFromModuleWhat(getModule(), $what); - // Define admin login name and id number - $content['login'] = getAdminLogin(getSession('admin_id')); - $content['id'] = getCurrentAdminId(); - - // Preload templates + // Load welcome template if (isExtensionActive('admins')) { - $content['welcome'] = loadTemplate('admin_welcome_admins', true, $content); + // @TODO This and the next getCurrentAdminId() call might be moved into the templates? + $content['welcome'] = loadTemplate('admin_welcome_admins', true, getCurrentAdminId()); } else { - $content['welcome'] = loadTemplate('admin_welcome', true, $content); + $content['welcome'] = loadTemplate('admin_welcome', true, getCurrentAdminId()); } // Load header, footer, render menu @@ -1312,7 +1309,7 @@ function doVerifyExpertSettings () { // Is the element set, then we need to change the admin if (isPostRequestParameterSet('expert_settings')) { // Get it and prepare final post data array - $postData['login'][getCurrentAdminId()] = getAdminLogin(getCurrentAdminId()); + $postData['login'][getCurrentAdminId()] = getCurrentAdminLogin(); $postData['expert_warning'][getCurrentAdminId()] = 'N'; // Change it in the admin diff --git a/inc/modules/admin/what-config_admins.php b/inc/modules/admin/what-config_admins.php index 48a768ba98..3599a1a6f4 100644 --- a/inc/modules/admin/what-config_admins.php +++ b/inc/modules/admin/what-config_admins.php @@ -153,7 +153,11 @@ if ((isFormSent('edit')) && (ifPostContainsSelections())) { if (((isPostRequestParameterSet('action_menu')) || (isPostRequestParameterSet('what_menu'))) && ($BOTH === false)) { // Main or sub menu selected $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_admins_acls` WHERE `admin_id`=%s AND `action_menu`='%s' AND `what_menu`='%s' LIMIT 1", - array(bigintval(postRequestParameter('admin_id')), postRequestParameter('action_menu'), postRequestParameter('what_menu')), __FILE__, __LINE__); + array( + bigintval(postRequestParameter('admin_id')), + postRequestParameter('action_menu'), + postRequestParameter('what_menu') + ), __FILE__, __LINE__); if (SQL_HASZERONUMS($result)) { // Finally add the new ACL SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_admins_acls` (`admin_id`, `action_menu`, `what_menu`, `access_mode`) diff --git a/inc/modules/admin/what-list_rallyes.php b/inc/modules/admin/what-list_rallyes.php index e7965982d6..fda9a05b29 100644 --- a/inc/modules/admin/what-list_rallyes.php +++ b/inc/modules/admin/what-list_rallyes.php @@ -300,9 +300,6 @@ ORDER BY // List found rallyes $OUT = ''; while ($data = SQL_FETCHARRAY($result)) { - // Load admin login - $data['login'] = getAdminLogin($data['admin_id']); - // Count joined userids $users = countSumTotalData($data['id'], 'rallye_users', 'id', 'rallye_id', true); @@ -312,14 +309,10 @@ ORDER BY $users = '' . $users . ''; } // END - if - // Alter some variables - if (empty($data['login'])) $data['login'] = '???'; - // Transfer data into array for the template $row = array( 'select' => '', 'admin_id' => $data['admin_id'], - 'login' => $data['login'], 'id' => $data['id'], 'title' => $data['title'], 'template' => $data['template'], diff --git a/inc/modules/admin/what-list_unconfirmed.php b/inc/modules/admin/what-list_unconfirmed.php index a68fe3b08b..2d57bc6715 100644 --- a/inc/modules/admin/what-list_unconfirmed.php +++ b/inc/modules/admin/what-list_unconfirmed.php @@ -51,6 +51,9 @@ if (!isExtensionActive('mailid')) { // Don't load the admin_list_unconfirmed template by default $listed = false; +// Init query +$sql = ''; + // List confirmation links from normal or bonus mails if (isGetRequestParameterSet('mid')) { // SQL query for mail data @@ -98,7 +101,7 @@ LIMIT 1", } // Shall I display links or not? -if ($listed === true) { +if (($listed === true) && (!empty($sql))) { // Load mail data $result_master = SQL_QUERY($sql, __FILE__, __LINE__); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 6a20170870..bf1a9baec9 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -522,8 +522,8 @@ function isAdmin () { // If admin login is not given take current from cookies... if ((isSessionVariableSet('admin_id')) && (isSessionVariableSet('admin_md5'))) { // Get admin login and password from session/cookies - $adminId = getSession('admin_id'); - $passCookie = getSession('admin_md5'); + $adminId = getCurrentAdminId(); + $passCookie = getAdminMd5(); } // END - if //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminId.'/'.$passCookie); @@ -1235,6 +1235,9 @@ function getAdminId ($adminLogin) { // "Getter" for current admin id function getCurrentAdminId () { + // Log debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!'); + // Do we have cache? if (!isset($GLOBALS['current_admin_id'])) { // Get the admin login from session diff --git a/inc/pool/pool-bonus.php b/inc/pool/pool-bonus.php index 5d3678158e..dc07cfdb2a 100644 --- a/inc/pool/pool-bonus.php +++ b/inc/pool/pool-bonus.php @@ -38,7 +38,7 @@ // Some security stuff... if (!defined('__SECURITY')) { die(); -} +} // END - if // Don't run on daily reset if (isResetModeEnabled()) { diff --git a/inc/session-functions.php b/inc/session-functions.php index 226cad9134..71f67ca303 100644 --- a/inc/session-functions.php +++ b/inc/session-functions.php @@ -117,12 +117,12 @@ function destroyMemberSession () { // Destroys the admin session function destroyAdminSession ($destroy = true) { // Kill maybe existing session variables including array elements - setSession('admin_id' , ''); - setSession('admin_md5' , ''); - setSession('admin_last', ''); + setAdminId(''); + setAdminMd5(''); + setAdminLast(''); - // Destroy session and return status - if ($destroy) { + // Destroy session if requested and return status + if ($destroy === true) { return session_destroy(); } // END - if diff --git a/inc/template-functions.php b/inc/template-functions.php index c4d47e673c..f5f1c25965 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -74,7 +74,9 @@ function fixEmptyContentToDashes ($str) { $str = trim($str); // Is the string empty? - if (empty($str)) $str = '---'; + if (empty($str)) { + $str = '---'; + } // END - if // Return string return $str; @@ -279,7 +281,7 @@ function loadTemplate ($template, $return = false, $content = array()) { // Base directory $basePath = sprintf("%stemplates/%s/html/", getPath(), getLanguage()); - $extraPath = detectExtraTemplatePath($template);; + $extraPath = detectExtraTemplatePath($template); // Generate FQFN $FQFN = $basePath . $extraPath . $template . '.tpl'; diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 4bfcad28f2..4a6e0e0dc9 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -771,7 +771,7 @@ function isDemoModeActive () { // Is cache set? if (!isset($GLOBALS[__FUNCTION__])) { // Simply check it - $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getAdminLogin(getSession('admin_id')) == 'demo')); + $GLOBALS[__FUNCTION__] = ((isExtensionActive('demo')) && (getCurrentAdminLogin() == 'demo')); } // END - if // Return it @@ -800,6 +800,69 @@ function setAdminHash ($adminId, $hash) { $GLOBALS['cache_array']['admin']['password'][$adminId] = $hash; } +// Getter for current admin login +function getCurrentAdminLogin () { + // Log debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!'); + + // Do we have cache? + if (!isset($GLOBALS[__FUNCTION__])) { + // Determine it + $GLOBALS[__FUNCTION__] = getAdminLogin(getCurrentAdminId()); + } // END - if + + // Return it + return $GLOBALS[__FUNCTION__]; +} + +// Setter for admin id (and current) +function setAdminId ($adminId) { + // Log debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminId=' . $adminId); + + // Set session + $status = setSession('admin_id', bigintval($adminId)); + + // Set current id + setCurrentAdminId($adminId); + + // Return status + return $status; +} + +// Setter for admin_last +function setAdminLast ($adminLast) { + // Log debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminLast=' . $adminLast); + + // Set session + $status = setSession('admin_last', $adminLast); + + // Return status + return $status; +} + +// Setter for admin_md5 +function setAdminMd5 ($adminMd5) { + // Log debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'adminMd5=' . $adminMd5); + + // Set session + $status = setSession('admin_md5', $adminMd5); + + // Return status + return $status; +} + +// Getter for admin_md5 +function getAdminMd5 () { + // Log debug message + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!'); + + // Get session + return getSession('admin_md5'); +} + // Init user data array function initUserData () { // User id should not be zero diff --git a/templates/de/html/admin/admin_welcome.tpl b/templates/de/html/admin/admin_welcome.tpl index e9914b79cd..205290ac86 100644 --- a/templates/de/html/admin/admin_welcome.tpl +++ b/templates/de/html/admin/admin_welcome.tpl @@ -8,7 +8,7 @@ Aktueller Admin: - [$content[login]] + [{%pipe,getAdminLogin=$content[id]%}] Ausloggen diff --git a/templates/de/html/admin/admin_welcome_admins.tpl b/templates/de/html/admin/admin_welcome_admins.tpl index f52cc61a37..177f91986f 100644 --- a/templates/de/html/admin/admin_welcome_admins.tpl +++ b/templates/de/html/admin/admin_welcome_admins.tpl @@ -8,7 +8,7 @@ Aktueller Admin: - [$content[login]] + [{%pipe,getAdminLogin=$content%}] Ausloggen -- 2.30.2