From: Roland Häder Date: Sat, 25 Jun 2011 02:09:37 +0000 (+0000) Subject: Introduced template call-back function 'doTemplateAdminListUserTitle': X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=766fcb898d34d42249d75f6097d85296aa5f9196;p=mailer.git Introduced template call-back function 'doTemplateAdminListUserTitle': - Introduced template call-back function doTemplateAdminListUserTitle() which encapsulates some nasty code into a small function - Several minor cleanups/rewrites - TODOs.txt updated --- diff --git a/DOCS/TODOs.txt b/DOCS/TODOs.txt index 9a3bc1d708..270d5e6bcc 100644 --- a/DOCS/TODOs.txt +++ b/DOCS/TODOs.txt @@ -56,9 +56,9 @@ ./inc/functions.php:92: // @TODO Extension 'msg' does not exist ./inc/gen_sql_patches.php:95:// @TODO Rewrite this to a filter ./inc/install-functions.php:57: // @TODO DEACTIVATED: changeDataInLocalConfigurationFile('OUTPUT-MODE', "setConfigEntry('OUTPUT_MODE', '", "');", postRequestParameter('omode'), 0); -./inc/language/de.php:1084: // @TODO Rewrite these two constants -./inc/language/de.php:1105: // @TODO Rewrite these three constants -./inc/language/de.php:779:// @TODO Are these constants longer used? +./inc/language/de.php:1083: // @TODO Rewrite these two constants +./inc/language/de.php:1104: // @TODO Rewrite these three constants +./inc/language/de.php:778:// @TODO Are these constants longer used? ./inc/language-functions.php:250: // @TODO These are all valid languages, again hard-coded ./inc/language-functions.php:44:// @TODO Rewrite all language constants to this function. ./inc/language/newsletter_de.php:13: * @TODO This language file is completely out-dated, please do no * @@ -97,6 +97,7 @@ ./inc/libs/yoomedia_functions.php:114: $response = YOOMEDIA_QUERY_API('out_textmail.php', true); // @TODO Ask Yoo!Media for test script ./inc/load_config.php:75: // @TODO Rewrite them to avoid this else block ./inc/loader/load-extension.php:13: * @TODO Rewrite this whole file * +./inc/mails/doubler_mails.php:53:// @TODO Can this be rewritten to a filter? ./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:171: // @TODO This and the next getCurrentAdminId() call might be moved into the templates? @@ -142,9 +143,9 @@ ./inc/modules/admin/what-list_refs.php:107: // @TODO Try to rewrite some to EL ./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 +./inc/modules/admin/what-list_user.php:153: // @TODO Rewrite these to filters +./inc/modules/admin/what-list_user.php:261: // @TODO Rewrite this into a filter +./inc/modules/admin/what-list_user.php:309: // @TODO Rewrite this into a filter ./inc/modules/admin/what-list_user.php:57:// @TODO Rewrite these if-blocks in a filter ./inc/modules/admin/what-logs.php:64: // @TODO Fix content-type here ./inc/modules/admin/what-logs.php:70: // @TODO Fix content-type here @@ -181,11 +182,11 @@ ./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:1208: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1466: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() -./inc/mysql-manager.php:1551: // @TODO Rewrite these lines to a filter -./inc/mysql-manager.php:1575: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1949: // @TODO Rewrite this to a filter -./inc/mysql-manager.php:1993:// @TODO Fix inconsistency between last_module and getWhat() +./inc/mysql-manager.php:1468: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY() +./inc/mysql-manager.php:1556: // @TODO Rewrite these lines to a filter +./inc/mysql-manager.php:1580: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1954: // @TODO Rewrite this to a filter +./inc/mysql-manager.php:1998:// @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/revision-functions.php:169:// @TODO This function does also set and get in 'cache_array' diff --git a/inc/language/de.php b/inc/language/de.php index ff40cd97fd..d180136ee3 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -466,7 +466,6 @@ addMessages(array( 'ACCOUNT_STATUS_LOCKED' => "Gesperrt", 'ACCOUNT_STATUS_DELETED' => "Gelöscht", 'ACCOUNT_STATUS_PENDING' => "Wartend", - 'ADMIN_ALL_ACCOUNTS' => "Alle Mitglieder-Accounts auflisten", 'ADMIN_NO_NONE_REGISTERED' => "Ihre Suchkriterieren ergaben keine Treffer in der Mitgliederliste. ", 'ADMIN_MEMBER_404' => "Mitglieds-Account %s existiert nicht.", 'LAST_ONLINE_SHORT' => "Zuletzt Online", @@ -1112,6 +1111,7 @@ addMessages(array( 'MEMBER_REFLIST_ACTIVITY' => "Mitglied aktiv?", // Special user lists (what=list_user) + 'ADMIN_LIST_ALL_ACCOUNTS' => "Alle Mitglieder-Accounts auflisten", 'ADMIN_LIST_STATUS_LOCKED_ACCOUNTS' => "Alle gesperrten Mitglieder-Accounts auflisten", 'ADMIN_LIST_STATUS_CONFIRMED_ACCOUNTS' => "Alle bestätigten Mitglieder-Accounts auflisten", 'ADMIN_LIST_MODE_CONFIRMED_ACCOUNTS' => "Alle bestätigten Mitglieder-Accounts auflisten", diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index fa1dbf2336..760bad363d 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -742,5 +742,23 @@ function doExpressionUser ($data) { return $code; } +// Template call-back function for list_user admin function +function doTemplateAdminListUserTitle ($template, $dummy = false) { + // Init title with "all accounts" + $code = '{--ADMIN_LIST_ALL_ACCOUNTS--}'; + + // Do we have a 'status' or 'mode' set? + if (isGetRequestParameterSet('status')) { + // Set title according to the 'status' + $code = sprintf("{--ADMIN_LIST_STATUS_%s_ACCOUNTS--}", strtoupper(getRequestParameter('status'))); + } elseif (isGetRequestParameterSet('mode')) { + // Set title according to the "mode" + $code = sprintf("{--ADMIN_LIST_MODE_%s_ACCOUNTS--}", strtoupper(getRequestParameter('mode'))); + } + + // Return the code + return $code; +} + // [EOF] ?> diff --git a/inc/mails/doubler_mails.php b/inc/mails/doubler_mails.php index e914caadfa..91f3988d91 100644 --- a/inc/mails/doubler_mails.php +++ b/inc/mails/doubler_mails.php @@ -39,15 +39,21 @@ if (!defined('__SECURITY')) { die(); } elseif (!isExtensionActive('doubler')) { + // Do not execute when extension is absent + return; +} elseif (!isHtmlOutputMode()) { + // Do not execute when script is in CSS mode return; } -// Do not execute when script is in CSS mode -if (!isHtmlOutputMode()) return; - // Initialize variables -$jackpotPoints = '0'; $userPoints = '0'; -if (isExtensionActive('jackpot')) $jackpotPoints = getJackpotPoints(); +$jackpotPoints = '0'; +$userPoints = '0'; + +// @TODO Can this be rewritten to a filter? +if (isExtensionActive('jackpot')) { + $jackpotPoints = getJackpotPoints(); +} // END - if // Get total points of the doubler itself $DOUBLER_POINTS = getDoublerTotalPointsLeft(); diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index e3f9daf36a..5c6be90d02 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -134,12 +134,12 @@ if (isGetRequestParameterSet('reg_ext')) { // Load required data if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { - $result = SQL_QUERY_ESC("SELECT ext_has_css, ext_active FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `ext_has_css`, `ext_active` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1", array(bigintval($ext_id)), __FILE__, __LINE__); list($css, $active) = SQL_FETCHROW($result); SQL_FREERESULT($result); } else { - $result = SQL_QUERY_ESC("SELECT ext_active FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1", + $result = SQL_QUERY_ESC("SELECT `ext_active` FROM `{?_MYSQL_PREFIX?}_extensions` WHERE `id`=%s LIMIT 1", array(bigintval($ext_id)), __FILE__, __LINE__); list($active) = SQL_FETCHROW($result); SQL_FREERESULT($result); diff --git a/inc/modules/admin/what-list_user.php b/inc/modules/admin/what-list_user.php index dc797f59ad..40f53bb898 100644 --- a/inc/modules/admin/what-list_user.php +++ b/inc/modules/admin/what-list_user.php @@ -136,7 +136,6 @@ LIMIT 1", // Prepare data for template $content['email_link'] = generateEmailLink($content['email'], 'user_data'); $content['last_online'] = generateDateTime($content['last_online'], 0); - if ($content['emails_sent'] > 0) $content['emails_sent'] = $base . '&what=email_details&userid=' . $userid . '%}">}{%pipe,translateComma=' . $content['emails_sent'] . '%}]'; $content['joined'] = generateDateTime($content['joined'], 0); $content['last_update'] = generateDateTime($content['last_update'], 0); $content['last_profile_sent'] = generateDateTime($content['last_profile_sent'], 0); @@ -145,9 +144,16 @@ LIMIT 1", $content['lock_timestamp'] = generateDateTime($content['lock_timestamp'], 2); $content['nickname'] = '{--EXT_NICKNAME_404--}'; + // Link to email_details if some are sent + if ($content['emails_sent'] > 0) { + $content['emails_sent'] = $base . '&what=email_details&userid=' . $userid . '%}">}{%pipe,translateComma=' . $content['emails_sent'] . '%}]'; + } // END - if + // Nickname inclusion? // @TODO Rewrite these to filters - if (isExtensionInstalled('nickname')) $content['nickname'] = getNickname($content['userid']); + if (isExtensionInstalled('nickname')) { + $content['nickname'] = getNickname($content['userid']); + } // END - if // Clickrate $content['click_rate'] = '0'; @@ -267,14 +273,20 @@ LIMIT 1", // Get number of unconfirmed mails $content['links'] = countSumTotalData($content['userid'], 'user_links', 'id', 'userid', true); - if ($content['links'] > 0) $content['links'] = $base . '&what=list_links&userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['links'] . '%}]'; + if ($content['links'] > 0) { + $content['links'] = $base . '&what=list_links&userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['links'] . '%}]'; + } // END - if // Set link to sent mails if present - if ($content['emails_sent'] > 0) $content['emails_sent'] = $base . '&what=email_details&userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['emails_sent'] . '%}]'; + if ($content['emails_sent'] > 0) { + $content['emails_sent'] = $base . '&what=email_details&userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['emails_sent'] . '%}]'; + } // END - if // Add nickname $content['nickname'] = '{--EXT_NICKNAME_404--}'; - if (isExtensionInstalled('nickname')) $content['nickname'] = getNickname($content['userid']); + if (isExtensionInstalled('nickname')) { + $content['nickname'] = getNickname($content['userid']); + } // END - if // Clickrate $content['rate'] = '0'; @@ -289,7 +301,9 @@ LIMIT 1", $content['locked'] = countSumTotalData($content['userid'], 'user_points', 'locked_points'); // If we have at least one referal, make it clickable to referal list - if ($content['refs'] > 0) $content['refs'] = $base . '&what=list_refs&userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['refs'] . '%}]'; + if ($content['refs'] > 0) { + $content['refs'] = $base . '&what=list_refs&userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['refs'] . '%}]'; + } // END - if // Is the extension 'country' installed? // @TODO Rewrite this into a filter @@ -314,16 +328,6 @@ LIMIT 1", // Remember all rows $content['rows'] = $OUT; - // Init title with "all accounts" - $content['title'] = '{--ADMIN_ALL_ACCOUNTS--}'; - if (isGetRequestParameterSet('status')) { - // Set title according to the 'status' - $content['title'] = sprintf("{--ADMIN_LIST_STATUS_%s_ACCOUNTS--}", strtoupper(getRequestParameter('status'))); - } elseif (isGetRequestParameterSet('mode')) { - // Set title according to the "mode" - $content['title'] = sprintf("{--ADMIN_LIST_MODE_%s_ACCOUNTS--}", strtoupper(getRequestParameter('mode'))); - } - // Merge more data again $content = merge_array($content, $templateContent); diff --git a/inc/modules/member/what-points.php b/inc/modules/member/what-points.php index 0fdd37c130..d83e597a0b 100644 --- a/inc/modules/member/what-points.php +++ b/inc/modules/member/what-points.php @@ -72,12 +72,26 @@ while ($data = SQL_FETCHARRAY($result_depths)) { $content = merge_array($content, $data); // Initialize array elements - $content['counter'] = '0'; - $content['points'] = '0.00000'; + $content['counter'] = '0'; + $content['points'] = '0.00000'; $content['locked_points'] = '0.00000'; // Load referal points - $result_points = SQL_QUERY_ESC("SELECT `points`, `locked_points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1", + $result_points = SQL_QUERY_ESC("SELECT + p.`points`, + p.`locked_points`, + r.`counter` +FROM + `{?_MYSQL_PREFIX?}_user_points` AS p +INNER JOIN + `{?_MYSQL_PREFIX?}_refsystem` AS r +ON + p.`userid`=r.`userid` AND + p.`ref_depth`=r.`level` +WHERE + p.`userid`=%s AND + p.`ref_depth`='%s' +LIMIT 1", array( getMemberId(), bigintval($content['level']) @@ -88,27 +102,9 @@ while ($data = SQL_FETCHARRAY($result_depths)) { // Load data $content = merge_array($content, SQL_FETCHARRAY($result_points)); - // Add both points - $content['total_points'] += $content['points']; - $content['total_locked'] += $content['locked_points']; - } // END - if - - // Free result - SQL_FREERESULT($result_points); - - // Load referal counts - $result_refs = SQL_QUERY_ESC("SELECT `counter` FROM `{?_MYSQL_PREFIX?}_refsystem` WHERE `userid`=%s AND `level`='%s' LIMIT 1", - array( - getMemberId(), - bigintval($content['level']) - ), __FILE__, __LINE__); - - // Do we have an entry? - if (SQL_NUMROWS($result_refs) == 1) { - // Load data - $content = merge_array($content, SQL_FETCHARRAY($result_refs)); - - // Add them to total refs + // Add all entries + $content['total_points'] += $content['points']; + $content['total_locked'] += $content['locked_points']; $content['total_referals'] += $content['counter']; } // END - if @@ -129,7 +125,9 @@ $content['rows'] = $OUT; $content['total_points'] = ($content['total_points'] - getUserData('used_points')); // Fixes a bug when there is no bonus extension installed -if (isExtensionInstalledAndOlder('bonus', '0.4.4')) setConfigEntry('bonus_active', 'X'); +if (isExtensionInstalledAndOlder('bonus', '0.4.4')) { + setConfigEntry('bonus_active', 'X'); +} // END - if // Members shall see no special rows here $content['special_rows'] = ''; diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 531aa79a79..6285dd3c61 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1449,7 +1449,9 @@ function generateOptionList ($table, $id, $name, $default = '', $special = '', $ } else { // Data from database $SPEC = ', `' . $id . '`'; - if (!empty($special)) $SPEC = ', `' . $special . '`'; + if (!empty($special)) { + $SPEC = ', `' . $special . '`'; + } // END - if // Query the database $result = SQL_QUERY_ESC("SELECT `%s`, `%s`".$SPEC." FROM `{?_MYSQL_PREFIX?}_%s` ".$where." ORDER BY `%s` ASC", @@ -1476,7 +1478,9 @@ function generateOptionList ($table, $id, $name, $default = '', $special = '', $ } // Add it, if set - if (!empty($add)) $add = ' ('.$add.')'; + if (!empty($add)) { + $add = ' ('.$add.')'; + } // END - if // Is the call-back function set? if (!empty($callback)) { @@ -1529,6 +1533,7 @@ function deleteUserAccount ($userid, $reason) { // Init points $data['points'] = '0'; + // Search for the points and user data $result = SQL_QUERY_ESC("SELECT (SUM(p.`points`) - d.`used_points`) AS `points` FROM diff --git a/templates/de/html/admin/admin_list_user.tpl b/templates/de/html/admin/admin_list_user.tpl index acccecfcf0..c341708166 100644 --- a/templates/de/html/admin/admin_list_user.tpl +++ b/templates/de/html/admin/admin_list_user.tpl @@ -2,7 +2,7 @@ $content[alpha_sort]
- $content[title]: + {%template,AdminListUserTitle%}: