Introduced template call-back function 'doTemplateAdminListUserTitle':
authorRoland Häder <roland@mxchange.org>
Sat, 25 Jun 2011 02:09:37 +0000 (02:09 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 25 Jun 2011 02:09:37 +0000 (02:09 +0000)
- Introduced template call-back function doTemplateAdminListUserTitle() which
  encapsulates some nasty code into a small function
- Several minor cleanups/rewrites
- TODOs.txt updated

DOCS/TODOs.txt
inc/language/de.php
inc/libs/user_functions.php
inc/mails/doubler_mails.php
inc/modules/admin/what-extensions.php
inc/modules/admin/what-list_user.php
inc/modules/member/what-points.php
inc/mysql-manager.php
templates/de/html/admin/admin_list_user.tpl

index 9a3bc1d..270d5e6 100644 (file)
@@ -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?
 ./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
 ./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'
index ff40cd9..d180136 100644 (file)
@@ -466,7 +466,6 @@ addMessages(array(
        'ACCOUNT_STATUS_LOCKED' => "<span class=\"status_locked\">Gesperrt</span>",
        'ACCOUNT_STATUS_DELETED' => "<span class=\"status_deleted\">Gel&ouml;scht</span>",
        'ACCOUNT_STATUS_PENDING' => "<span class=\"status_pending\">Wartend</span>",
-       'ADMIN_ALL_ACCOUNTS' => "Alle Mitglieder-Accounts auflisten",
        'ADMIN_NO_NONE_REGISTERED' => "Ihre Suchkriterieren ergaben keine Treffer in der Mitgliederliste. ",
        'ADMIN_MEMBER_404' => "Mitglieds-Account <span class=\"data\">%s</span> 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&auml;tigten Mitglieder-Accounts auflisten",
        'ADMIN_LIST_MODE_CONFIRMED_ACCOUNTS' => "Alle best&auml;tigten Mitglieder-Accounts auflisten",
index fa1dbf2..760bad3 100644 (file)
@@ -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]
 ?>
index e914caa..91f3988 100644 (file)
 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();
index e3f9daf..5c6be90 100644 (file)
@@ -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);
index dc797f5..40f53bb 100644 (file)
@@ -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 . '&amp;what=email_details&amp;userid=' . $userid . '%}">}{%pipe,translateComma=' . $content['emails_sent'] . '%}</a>]';
                $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 . '&amp;what=email_details&amp;userid=' . $userid . '%}">}{%pipe,translateComma=' . $content['emails_sent'] . '%}</a>]';
+               } // 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 . '&amp;what=list_links&amp;userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['links'] . '%}</a>]';
+                       if ($content['links'] > 0) {
+                               $content['links'] = $base . '&amp;what=list_links&amp;userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['links'] . '%}</a>]';
+                       } // END - if
 
                        // Set link to sent mails if present
-                       if ($content['emails_sent'] > 0) $content['emails_sent'] = $base . '&amp;what=email_details&amp;userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['emails_sent'] . '%}</a>]';
+                       if ($content['emails_sent'] > 0) {
+                               $content['emails_sent'] = $base . '&amp;what=email_details&amp;userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['emails_sent'] . '%}</a>]';
+                       } // 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 . '&amp;what=list_refs&amp;userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['refs'] . '%}</a>]';
+                       if ($content['refs'] > 0) {
+                               $content['refs'] = $base . '&amp;what=list_refs&amp;userid=' . $content['userid'] . '%}">{%pipe,translateComma=' . $content['refs'] . '%}</a>]';
+                       } // 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);
 
index 0fdd37c..d83e597 100644 (file)
@@ -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'] = '';
index 531aa79..6285dd3 100644 (file)
@@ -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
index acccecf..c341708 100644 (file)
@@ -2,7 +2,7 @@
 <table border="0" cellspacing="0" cellpadding="0" class="table dashed">
        <tr>
                <td class="table_header bottom" colspan="$content[colspan2]" align="center">
-                       <strong>$content[title]:</strong>
+                       <strong>{%template,AdminListUserTitle%}:</strong>
                </td>
        </tr>
        $content[alpha_sort]