Double->single rewrites, fixes for email archive
[mailer.git] / inc / modules / admin / what-email_archiv.php
index 6474a7a1a4e80d4e2c04f777f8ec7ca6e0ee59ee..c4768750fd4fcfd3a0581490477dd8513fce8bae 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 09/28/2003 *
- * ===============                              Last change: 04/03/2004 *
+ * Mailer v0.2.1-FINAL                                Start: 09/28/2003 *
+ * ===================                          Last change: 04/03/2004 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : what-email_archiv .php                           *
@@ -61,11 +61,11 @@ ORDER BY
 $result_maximum = SQL_QUERY($sql, __FILE__, __LINE__);
 
 // Set offset an current page to default values
-if (!isGetRequestElementSet('page'))   setRequestGetElement('page'  , '1');
+if (!isGetRequestElementSet('page'))   setRequestGetElement('page'  , 1);
 if (!isGetRequestElementSet('offset')) setRequestGetElement('offset', getConfig('mails_page'));
 
 // Add limitation to SQL string
-$sql .= " LIMIT ".(getRequestElement('offset') * getRequestElement('page') - getRequestElement('offset')).", ".getRequestElement('offset');
+$sql .= " LIMIT ".(getRequestElement('offset') * getRequestElement('page') - getRequestElement('offset')) . ', ' . getRequestElement('offset');
 
 // Run SQL query for normal mails
 $result = SQL_QUERY($sql, __FILE__, __LINE__);
@@ -83,47 +83,51 @@ if (SQL_NUMROWS($result) > 0) {
        $content['top_email_nav']    = '';
        $content['bottom_email_nav'] = '';
        if ($pages > 1) {
-               $content['top_email_nav']    = addEmailNavigation($pages, getConfig('mails_page'), true , '3', true);
-               $content['bottom_email_nav'] = addEmailNavigation($pages, getConfig('mails_page'), false, '3', true);
+               $content['top_email_nav']    = addEmailNavigation($pages, getConfig('mails_page'), true , 3, true);
+               $content['bottom_email_nav'] = addEmailNavigation($pages, getConfig('mails_page'), false, 3, true);
        } // END - if
 
+       // List all entries
        $OUT = ''; $SW = 2;
-       // @TODO Rewrite to SQL_FETCHARRAY()
-       while ($pool = SQL_FETCHROW($result)) {
+       while ($pool = SQL_FETCHARRAY($result)) {
                // Check sent mails and clicks
                $result_mails = SQL_QUERY_ESC("SELECT `max_rec`, `clicks` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
-                       array(bigintval($pool[0])), __FILE__, __LINE__);
-               list($sent, $clicks) = SQL_FETCHROW($result_mails);
+                       array(bigintval($pool['id'])), __FILE__, __LINE__);
+
+               // Load entries
+               $pool = merge_array($pool, SQL_FETCHARRAY($result_mails);
+
+               // Merge result
                SQL_FREERESULT($result_mails);
 
                // Unconfirmed mails
-               $unconfirmed = $sent - $clicks;
-               if ($unconfirmed > 0) {
+               $pool['unconfirmed'] = $pool['max_rec'] - $pool['clicks'];
+               if ($pool['unconfirmed'] > 0) {
                        // Add link to list_unconfirmed what-file
-                       $unconfirmed = "<strong><a href=\"{?URL?}/modules.php?module=admin&amp;what=list_unconfirmed&amp;mid=".$pool[0]."\">".$unconfirmed."</a></strong>";
+                       $pool['unconfirmed'] = '<strong><a href="{?URL?}/modules.php?module=admin&amp;what=list_unconfirmed&amp;mid=' . $pool['id'] . '">' . $pool['unconfirmed'] . '</a></strong>';
                } // END - if
 
                // Prepare data for the row template
-               $row = array(
+               $content = array(
                        'sw'          => $SW,
-                       'u_link'      => generateUserProfileLink($pool[1]),
-                       'subj'        => $pool[2],
-                       'text'        => $pool[3],
-                       'pay'         => getPaymentTitlePrice($pool[5]),
-                       'cat'         => getCategory($pool[10]),
-                       'sent'        => $sent,
-                       'ruserids'       => str_replace(';', ", ", $pool[4]),
-                       'unconfirmed' => $unconfirmed,
-                       'type'        => translatePoolType($pool[6]),
-                       'tsend'       => $pool[9],
-                       'frametester' => generateFrametesterUrl($pool[8]),
-                       'url'         => $pool[8],
-                       'stamp'       => generateDateTime($pool[7], '0'),
-                       'mid'         => $pool[0],
+                       'u_link'      => generateUserProfileLink($pool['sender']),
+                       'subject'     => $pool['subject'],
+                       'text'        => $pool['text'],
+                       'pay'         => getPaymentTitlePrice($pool['payment_id']),
+                       'cat'         => getCategory($pool['cat_id']),
+                       'sent'        => $pool['max_rec'],
+                       'ruserids'    => convertReceivers($pool['receivers']),
+                       'unconfirmed' => $pool['unconfirmed'],
+                       'type'        => translatePoolType($pool['data_type']),
+                       'target_send' => $pool['target_send'],
+                       'frametester' => generateFrametesterUrl($pool['url']),
+                       'url'         => $pool['url'],
+                       'timestamp'   => generateDateTime($pool['timestamp'], 0),
+                       'mid'         => $pool['id'],
                );
 
                // Load row template and switch colors
-               $OUT .= loadTemplate('admin_email_archiv_row', true, $row);
+               $OUT .= loadTemplate('admin_email_archiv_row', true, $content);
                $SW = 3 - $SW;
        } // END - while