2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 09/28/2003 *
4 * =================== Last change: 10/29/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-email_details.php *
8 * -------------------------------------------------------------------- *
9 * Short description : See all email details of ordered mails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Alle Details einer gebuchten Mail ansehen *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 * -------------------------------------------------------------------- *
39 * Moded What-email_details.php / also Editet ! *
40 * Auf langsammen Servern (wie mein z.B Dauert das Laden) *
41 * enorm hoch zu lang. Jetzt werden nur auftraege aufgelistet die *
42 * NEU sind ( DB NEW) oder ADMIN freischalten muss (DB ADMIN ) *
43 * oder noch als TEMP gespecihert sind *
44 * der rest der schon als SEND sich melden darf wird per *
45 * what-email_archiv .php aufgerufen *
46 * beste gruesse Robert Niedziela / www.personal-webserver.de *
47 * oder auch www.mc-p.org *
48 ************************************************************************/
50 // Some security stuff...
51 if ((!defined('__SECURITY')) || (!isAdmin())) {
55 // Add description as navigation point
56 addMenuDescription('admin', __FILE__);
58 // Normal mails ordered by your members
59 // 0 1 2 3 4 5 6 7 8 9 10
60 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
61 FROM `{?_MYSQL_PREFIX?}_pool`
62 WHERE data_type IN('ADMIN','TEMP','NEW','ACTIVE')
63 ORDER BY timestamp DESC";
65 $WHO = getMessage('_ALL');
68 if (isGetRequestParameterSet(('mid'))) {
69 // Only a specific mail shall be displayed
70 // 0 1 2 3 4 5 6 7 8 9 10
71 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
72 FROM `{?_MYSQL_PREFIX?}_pool`
73 WHERE `id`='".bigintval(getRequestParameter('mid'))."'
75 $WHO = getMessage('MAIL_ID').": ".getRequestParameter('mid');
76 } elseif (isGetRequestParameterSet('userid')) {
77 // All mails by a specific member shall be displayed
78 // 0 1 2 3 4 5 6 7 8 9 10
79 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
80 FROM `{?_MYSQL_PREFIX?}_pool`
81 WHERE sender='".bigintval(getRequestParameter('userid'))."'
82 ORDER by timestamp DESC";
83 $WHO = getMessage('USER_ID').": ".getRequestParameter('userid');
86 if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
87 // Bonus mails sent by you
88 // 0 1 2 3 4 5 6 7 8 9 10 11 12
89 $SQL2 = "SELECT id, subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, clicks
90 FROM `{?_MYSQL_PREFIX?}_bonus`
92 ORDER BY timestamp DESC";
94 // Check for maximum pages
95 $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
98 // Check for maximum pages
99 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
101 // Set offset an current page to default values
102 if (!isGetRequestParameterSet('page')) setGetRequestParameter('page', 1);
104 if (!isGetRequestParameterSet('offset')) {
105 if (isConfigEntrySet('mails_page')) {
107 setGetRequestParameter('offset', getConfig('mails_page'));
110 setGetRequestParameter('offset', 10);
114 // Add limitation to SQL string
115 if (!isGetRequestParameterSet(('mid'))) {
116 // Create limitation line
117 $add = " LIMIT ".(bigintval(getRequestParameter('offset')) * bigintval(getRequestParameter('page')) - bigintval(getRequestParameter('offset'))).", ".bigintval(getRequestParameter('offset'));
123 if (!empty($SQL2)) $SQL2 .= $add;
126 // Run SQL query for normal mails
127 $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
128 if ((!empty($SQL2)) && ($WHO == getMessage('_ALL'))) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
132 if (isConfigEntrySet('mails_page')) {
133 $PAGES = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3);
137 SQL_FREERESULT($result_normal);
140 if (SQL_NUMROWS($result_list) > 0) {
142 $OUT = ''; $content = array();
144 // Walk through all entries
145 while ($pool = SQL_FETCHARRAY($result_list)) {
146 // Unconfirmed mails and sent mails
147 $result_uncon = SQL_QUERY_ESC("SELECT max_rec, clicks FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
148 array(bigintval($pool['id'])), __FILE__, __LINE__);
149 list($pool['sent_email'], $pool['clicks']) = SQL_FETCHROW($result_uncon);
150 SQL_FREERESULT($result_uncon);
153 $pool['unconfirmed'] = $pool['sent_email'] - $pool['clicks'];
154 if ($pool['unconfirmed'] > 0) {
155 // Add link to list_unconfirmed what-file
156 $pool['unconfirmed'] = "<strong><a href=\"{%url=modules.php?module=admin&what=list_unconfirmed&mid=" . $pool['id'] . "%}\">" . $pool['unconfirmed'] . "</a></strong>";
157 } elseif ($pool['unconfirmed'] < 0) {
158 // Sometimes rarely displayed minus values will be "fixed" to zero
159 $pool['unconfirmed'] = '0';
164 $content['sender_link'] = generateUserProfileLink($pool['sender']);
165 $content['payment'] = getPaymentTitlePrice($pool['payment_id']);
166 $content['category'] = getCategory($pool['cat_id']);
167 $content['receivers'] = convertReceivers($pool['receivers']);
168 $content['type'] = translatePoolType($pool['data_type']);
169 $content['frametester'] = generateFrametesterUrl($pool['url']);
170 $content['timestamp'] = generateDateTime($pool['timestamp'], 0);
173 $OUT .= loadTemplate('admin_list_emails_row', true, $content);
177 SQL_FREERESULT($result_list);
179 // Add navigation (with change box and colspan=3)
180 $content['nav'] = '';
181 if ($PAGES > 1) $content['nav'] = addEmailNavigation($PAGES, getConfig('mails_page'), false, 3, true);
184 $content['rows'] = $OUT;
185 $content['who'] = $WHO;
187 // Mail orders are in pool so we can display them
188 loadTemplate('admin_list_emails', false, $content);
191 if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
192 // Check only if bonus extension is active
193 if (SQL_NUMROWS($result_bonus) > 0) outputHtml('<br /><br />');
197 if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
198 // Load bonus mails only when extension is active
199 if (SQL_NUMROWS($result_bonus) > 0) {
201 $PAGES = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
204 $OUT = ''; $content = array();
205 while ($bonus = SQL_FETCHARRAY($result_bonus)) {
206 // Calculate unconfirmed emails
207 $bonus['unconfirmed'] = $bonus['mails_sent'] - $bonus['clicks'];
210 if ($bonus['unconfirmed'] > 0) {
211 // Add link to list_unconfirmed what-file
212 $bonus['unconfirmed'] = "<strong><a href=\"{%url=modules.php?module=admin&what=list_unconfirmed&bid=" . $bonus['id'] . "%}\">" . $bonus['unconfirmed'] . "</a></strong>";
217 $content['time'] = createFancyTime($content['time']);
218 $content['category'] = getCategory($content['cat_id']);
219 $content['receivers'] = convertReceivers($content['receivers']);
220 $content['type'] = translatePoolType($content['data_type']);
221 $content['frametester'] = generateFrametesterUrl($content['url']);
222 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
225 $OUT .= loadTemplate('admin_list_bonus_emails_row', true, $content);
228 // Add navigation (without change box but with colspan=3)
229 $content['nav'] = '';
230 if ($PAGES > 1) $content['nav'] = addEmailNavigation($PAGES, getConfig('mails_page'), false, 3, true);
233 $content['rows'] = $OUT;
235 // Load main template
236 loadTemplate('admin_list_bonus_emails', false, $content);
241 if ($MAIL === false) {
242 // No mail orders fond
243 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NO_MAILS_IN_POOL'));