More usage of EL, code rewrites/cleanups, SQLs improved:
authorRoland Häder <roland@mxchange.org>
Sun, 29 Aug 2010 19:26:09 +0000 (19:26 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 29 Aug 2010 19:26:09 +0000 (19:26 +0000)
- More usage of EL for admin templates (deletion of emails and notification)
- Unneccessary array re-initialization removed/cleaned up
- SQLs improved, a "LIMIT 1" was missing
- TODOs.txt updated

DOCS/TODOs.txt
inc/gen_mediadata.php
inc/language/html_mail_de.php
inc/modules/admin/what-del_email.php
inc/modules/member/what-stats.php
templates/de/html/admin/admin_del_email_bonus.tpl
templates/de/html/admin/admin_del_email_notify.tpl

index f0f933ba63c58dd0a0164a18f79d5f53c17e744c..ecde42a1f5b48991284c2156a2ca0df1c39e8200 100644 (file)
 ./inc/modules/member/what-unconfirmed.php:143: // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
 ./inc/modules/order.php:76:            // @TODO Unused: 2,4
 ./inc/monthly/monthly_bonus.php:69:    // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1173:  // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1428:                  // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
-./inc/mysql-manager.php:1536:  // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1903:                  // @TODO Rewrite this to a filter
-./inc/mysql-manager.php:1947:// @TODO Fix inconsistency between last_module and getWhat()
+./inc/mysql-manager.php:1174:  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1429:                  // @TODO Try to rewrite this to $content = SQL_FETCHARRAY()
+./inc/mysql-manager.php:1537:  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1904:                  // @TODO Rewrite this to a filter
+./inc/mysql-manager.php:1948:// @TODO Fix inconsistency between last_module and getWhat()
 ./inc/mysql-manager.php:370:   // @TODO Try to rewrite this to one or more functions
 ./inc/mysql-manager.php:46:// @TODO Can we cache this?
 ./inc/reset/reset_beg.php:51:// @TODO This should be converted in a daily beg rallye
index 8922660483b0431a3120658c7ed2384c646ee926..cd3fdb2ec2dead7b9d1b6a3f4ebff033317c2692 100644 (file)
@@ -42,47 +42,52 @@ if (!defined('__SECURITY')) {
        die();
 } // END - if
 
-// Init variables
-$bsent = '0'; $bclicks = '0'; $bcount = '0';
+// Init array/varriable
+$bcount = '0';
+$content = array(
+       'normal_send'   => 0,
+       'normal_clicks' => 0,
+       'bonus_send'    => 0,
+       'bonus_clicks'  => 0
+);
 
 // Check for normal mails
 $result_media = SQL_QUERY('SELECT
-       SUM(`max_rec`) AS max_rec,
-       SUM(`clicks`) AS clicks
+       SUM(`max_rec`) AS `normal_send`,
+       SUM(`clicks`) AS `normal_clicks`
 FROM
        `{?_MYSQL_PREFIX?}_user_stats`', __FILE__, __LINE__);
-list($nsent, $nclicks) = SQL_FETCHROW($result_media);
-if (empty($nsent))   $nsent   = '0';
-if (empty($nclicks)) $nclicks = '0';
+$content = merge_array($content, SQL_FETCHARRAY($result_media));
 
 // Free memory
 SQL_FREERESULT($result_media);
 
-// Count mail orders
-$ncount = countSumTotalData('', 'user_stats', 'id', '', true);
-
 // Check for bonus extension
 if (isExtensionActive('bonus')) {
        // Count bonus mails
        $bcount = countSumTotalData('', 'bonus', 'id', '', true);
 
        // Check for bonus mails
-       $result_media = SQL_QUERY('SELECT SUM(mails_sent) AS bonus_sent, SUM(clicks) AS bonus_clicks
-FROM `{?_MYSQL_PREFIX?}_bonus`', __FILE__, __LINE__);
-       list($bsent, $bclicks) = SQL_FETCHROW($result_media);
-       if (empty($bsent))   $bsent   = '0';
-       if (empty($bclicks)) $bclicks = '0';
+       $result_media = SQL_QUERY('SELECT
+       SUM(`mails_send`) AS `bonus_send`,
+       SUM(`clicks`) AS `bonus_clicks`
+FROM
+       `{?_MYSQL_PREFIX?}_bonus`', __FILE__, __LINE__);
+       $content = merge_array($content, SQL_FETCHARRAY($result_media));
+
+       // Free memory
+       SQL_FREERESULT($result_media);
 } // END - if
 
 // Load (maybe) missing file
 loadIncludeOnce('inc/libs/mediadata_functions.php');
 
 // Insert info to database
-updateMediadataEntry(array('total_send'  , 'normal_send')  , 'init', $nsent);
-updateMediadataEntry(array('total_clicks', 'normal_clicks'), 'init', $nclicks);
-updateMediadataEntry(array('total_orders', 'normal_orders'), 'init', $ncount);
-updateMediadataEntry(array('total_send'  , 'bonus_send' )  , 'init', $bsent);
-updateMediadataEntry(array('total_clicks', 'bonus_clicks') , 'init', $bclicks);
+updateMediadataEntry(array('total_send'  , 'normal_send')  , 'init', $content['normal_send']);
+updateMediadataEntry(array('total_clicks', 'normal_clicks'), 'init', $content['normal_clicks']);
+updateMediadataEntry(array('total_orders', 'normal_orders'), 'init', countSumTotalData('', 'user_stats', 'id', '', true));
+updateMediadataEntry(array('total_send'  , 'bonus_send' )  , 'init', $content['bonus_send']);
+updateMediadataEntry(array('total_clicks', 'bonus_clicks') , 'init', $content['bonus_clicks']);
 updateMediadataEntry(array('total_orders', 'bonus_orders') , 'init', $bcount);
 
 // Aquire total used points
index ca633e555dff37076b1113981d7566025874fd07..383593a360fbced4541cbbd28fd6ac363933f811 100644 (file)
@@ -44,7 +44,7 @@ if (!defined('__SECURITY')) {
 
 // Language definitions
 addMessages(array(
-       'ADMIN_HTML_DOWNLOAD_CLASS' => "Bitte laden Sie sich die Klasse <a href=\"".generateDerefererUrl("https://sourceforge.net/projects/phpmailer/")."\" target=\"_blank\">PHPMailer</a> herunter, um diese Funktion nutzen zu k&ouml;nnen.",
+       'ADMIN_HTML_DOWNLOAD_CLASS' => "Bitte laden Sie sich die Klasse <a href=\"{%pipe,generateDerefererUrl=https://sourceforge.net/projects/phpmailer/%}\" target=\"_blank\">PHPMailer</a> herunter, um diese Funktion nutzen zu k&ouml;nnen.",
        'MEMBER_HTML_INTRO' => "HTML-Emfpang - Einstellung",
        'MEMBER_HTML_TEXT' => "In unserem {?mt_word?} ist das Empfangen von HTML-Mails nun m&ouml;glich. Gleichzeitig k&ouml;nnen Sie auch selber HTML-Mails versenden. M&ouml;chten Sie dies beides nutzen?",
        'MEMBER_HTML_ORDER_INTRO' => "HTML- oder normale Text-Mails versenden?",
index 819770ab744b038eb5108897899de5cd9575cb6f..67e953a38c4111e5e6ac3677f629b56f0f94aabd 100644 (file)
@@ -38,7 +38,7 @@
 // Some security stuff...
 if ((!defined('__SECURITY')) || (!isAdmin())) {
        die();
-}
+} // END - if
 
 // Add description as navigation point
 addMenuDescription('admin', __FILE__);
@@ -164,7 +164,7 @@ LIMIT 1",
        loadTemplate('admin_settings_saved', false, '{--ADMIN_USER_STATS_REMOVED--}');
 } elseif ((isGetRequestParameterSet('bid')) && (isExtensionActive('bonus'))) {
        // Load data from bonus mail
-       $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp`, `mails_sent` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s",
+       $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp`, `mails_sent` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
                array(bigintval(getRequestParameter('bid'))), __FILE__, __LINE__);
 
        // Delete mail only once
@@ -187,7 +187,6 @@ LIMIT 1",
                $cnt += SQL_AFFECTEDROWS();
 
                // Prepare data for the template
-               $content['url']       = generateDerefererUrl($content['url']);
                $content['timestamp'] = generateDateTime($content['timestamp'], 0);
                $content['cnt']       = $cnt;
 
@@ -202,7 +201,7 @@ LIMIT 1",
        SQL_FREERESULT($result);
 } elseif ((isGetRequestParameterSet('nid')) && (isExtensionInstalledAndNewer('bonus', '0.8.7'))) {
        // Load data from bonus mail
-       $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s",
+       $result = SQL_QUERY_ESC("SELECT `id`, `subject`, `url`, `timestamp` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `id`=%s LIMIT 1",
                array(bigintval(getRequestParameter('nid'))), __FILE__, __LINE__);
 
        // Delete mail only once
@@ -222,7 +221,6 @@ LIMIT 1",
                $cnt += SQL_AFFECTEDROWS();
 
                // Prepare data for the template
-               $content['url']       = generateDerefererUrl($content['url']);
                $content['timestamp'] = generateDateTime($content['timestamp'], 0);
                $content['cnt']       = $cnt;
 
index 8a37457834b40138ecdace2802f72110ab840217..b10dd0a11811093b5bbf0d5edf26de0e569f2198 100644 (file)
@@ -100,21 +100,13 @@ if (!SQL_HASZERONUMS($result)) {
        $OUT = '';
        while ($content = SQL_FETCHARRAY($result)) {
                // Prepare data for the template
-               $content = array(
-                       'cat_id'            => $content['cat_id'],
-                       'payment_id'        => $content['payment_id'],
-                       'url'               => $content['url'],
-                       'timestamp_ordered' => generateDateTime($content['timestamp_ordered'], 2),
-                       'max_rec'           => $content['max_rec'],
-                       'timestamp_sent'    => generateDateTime($content['timestamp_send'], 2),
-                       'clicks'            => $content['clicks'],
-                       'subject'           => $content['subject'],
-                       'percents'          => ($content['clicks'] / $content['max_rec'] * 100),
-               );
+               $content['timestamp_ordered'] = generateDateTime($content['timestamp_ordered'], 2);
+               $content['timestamp_sent']    = generateDateTime($content['timestamp_send'], 2);
+               $content['percents']          = ($content['clicks'] / $content['max_rec'] * 100);
 
                // Load row template and switch colors
                $OUT .= loadTemplate('member_stats_row', true, $content);
-       } // END - if
+       } // END - while
 
        // Load main template
        $main_content['stats'] = loadTemplate('member_stats_table', true, $OUT);
index 01f9ac1b18a35816a97c1ecb7e4701934b28faa1..4e467eb2bc93e1345790e765fe23f747a11ced99 100644 (file)
@@ -15,7 +15,7 @@
                <td class="right" align="center">$content[id]</td>
                <td class="right" align="center">$content[subject]</td>
                <td class="right" align="center">
-                       <a href="$content[url]" target="_blank">{--ADMIN_TEST_URL--}</a>
+                       <a href="{%pipe,generateDerefererUrl=$content[url]%}" target="_blank">{--ADMIN_TEST_URL--}</a>
                </td>
                <td class="right" align="center">$content[timestamp]</td>
                <td align="center">$content[cnt]</td>
index 1f40e5c244cd83ccec94b2d620bf7f52afbcec64..259e258b768db32f1d74c531563aa9f184920d9a 100644 (file)
@@ -14,7 +14,7 @@
        <tr>
                <td class="right" align="center">$content[id]</td>
                <td class="right" align="center">$content[subject]</td>
-               <td class="right" align="center"><a href="$content[url]" target="_blank">{--ADMIN_TEST_URL--}</a></td>
+               <td class="right" align="center"><a href="{%pipe,generateDerefererUrl=$content[url]%}" target="_blank">{--ADMIN_TEST_URL--}</a></td>
                <td class="right" align="center">$content[timestamp]</td>
                <td align="center">$content[cnt]</td>
        </tr>