2 /************************************************************************
3 * MXChange v0.2.1 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 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 * -------------------------------------------------------------------- *
38 * Moded What-email_details.php / also Editet ! *
39 * Auf langsammen Servern (wie mein z.B Dauert das Laden) *
40 * enorm hoch zu lang. Jetzt werden nur auftraege aufgelistet die *
41 * NEU sind ( DB NEW) oder ADMIN freischalten muss (DB ADMIN ) *
42 * oder noch als TEMP gespecihert sind *
43 * der rest der schon als SEND sich melden darf wird per *
44 * what-email_archiv .php aufgerufen *
45 * beste gruesse Robert Niedziela / www.personal-webserver.de *
46 * oder auch www.mc-p.org *
47 ************************************************************************/
49 // Some security stuff...
50 if ((!defined('__SECURITY')) || (!isAdmin())) {
54 // Add description as navigation point
55 addMenuDescription('admin', __FILE__);
57 // Normal mails ordered by your members
58 // 0 1 2 3 4 5 6 7 8 9 10
59 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
60 FROM `{?_MYSQL_PREFIX?}_pool`
61 WHERE data_type IN('ADMIN','TEMP','NEW','ACTIVE')
62 ORDER BY timestamp DESC";
64 $WHO = getMessage('_ALL');
67 if (isGetRequestElementSet(('mid'))) {
68 // Only a specific mail shall be displayed
69 // 0 1 2 3 4 5 6 7 8 9 10
70 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
71 FROM `{?_MYSQL_PREFIX?}_pool`
72 WHERE `id`='".bigintval(getRequestElement('mid'))."'
74 $WHO = getMessage('MAIL_ID').": ".getRequestElement('mid');
75 } elseif (isGetRequestElementSet('userid')) {
76 // All mails by a specific member shall be displayed
77 // 0 1 2 3 4 5 6 7 8 9 10
78 $sql = "SELECT id, sender, subject, text, receivers, payment_id, data_type, timestamp, url, target_send, cat_id
79 FROM `{?_MYSQL_PREFIX?}_pool`
80 WHERE sender='".bigintval(getRequestElement('userid'))."'
81 ORDER by timestamp DESC";
82 $WHO = getMessage('USER_ID').": ".getRequestElement('userid');
85 if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
86 // Bonus mails sent by you
87 // 0 1 2 3 4 5 6 7 8 9 10 11 12
88 $SQL2 = "SELECT id, subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, clicks
89 FROM `{?_MYSQL_PREFIX?}_bonus`
91 ORDER BY timestamp DESC";
93 // Check for maximum pages
94 $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
97 // Check for maximum pages
98 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
100 // Set offset an current page to default values
101 if (!isGetRequestElementSet('page')) setRequestGetElement('page', 1);
103 if (!isGetRequestElementSet('offset')) {
104 if (isConfigEntrySet('mails_page')) {
106 setRequestGetElement('offset', getConfig('mails_page'));
109 setRequestGetElement('offset', 10);
113 // Add limitation to SQL string
114 if (!isGetRequestElementSet(('mid'))) {
115 // Create limitation line
116 $add = " LIMIT ".(bigintval(getRequestElement('offset')) * bigintval(getRequestElement('page')) - bigintval(getRequestElement('offset'))).", ".bigintval(getRequestElement('offset'));
122 if (!empty($SQL2)) $SQL2 .= $add;
125 // Run SQL query for normal mails
126 $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
127 if ((!empty($SQL2)) && ($WHO == getMessage('_ALL'))) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
131 if (isConfigEntrySet('mails_page')) {
132 $PAGES = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3);
136 SQL_FREERESULT($result_normal);
139 if (SQL_NUMROWS($result_list) > 0) {
141 $OUT = ''; $content = array();
143 // Walk through all entries
144 while ($pool = SQL_FETCHARRAY($result_list)) {
145 // Unconfirmed mails and sent mails
146 $result_uncon = SQL_QUERY_ESC("SELECT max_rec, clicks FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
147 array(bigintval($pool['id'])), __FILE__, __LINE__);
148 list($pool['sent_email'], $pool['clicks']) = SQL_FETCHROW($result_uncon);
149 SQL_FREERESULT($result_uncon);
152 $pool['unconfirmed'] = $pool['sent_email'] - $pool['clicks'];
153 if ($pool['unconfirmed'] > 0) {
154 // Add link to list_unconfirmed what-file
155 $pool['unconfirmed'] = "<strong><a href=\"{?URL?}/modules.php?module=admin&what=list_unconfirmed&mid=".$pool['id']."\">".$pool['unconfirmed']."</a></strong>";
156 } elseif ($pool['unconfirmed'] < 0) {
157 // Sometimes rarely displayed minus values will be "fixed" to zero
158 $pool['unconfirmed'] = 0;
163 $content['sender_link'] = generateUserProfileLink($pool['sender']);
164 $content['payment'] = getPaymentTitlePrice($pool['payment_id']);
165 $content['category'] = getCategory($pool['cat_id']);
166 $content['receivers'] = convertReceivers($pool['receivers']);
167 $content['type'] = translatePoolType($pool['data_type']);
168 $content['frametester'] = generateFrametesterUrl($pool['url']);
169 $content['timestamp'] = generateDateTime($pool['timestamp'], 0);
172 $OUT .= loadTemplate('admin_list_emails_row', true, $content);
176 SQL_FREERESULT($result_list);
178 // Add navigation (with change box and colspan=3)
179 $content['nav'] = '';
180 if ($PAGES > 1) $content['nav'] = addEmailNavigation($PAGES, getConfig('mails_page'), false, 3, true);
183 $content['rows'] = $OUT;
184 $content['who'] = $WHO;
186 // Mail orders are in pool so we can display them
187 loadTemplate('admin_list_emails', false, $content);
190 if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
191 // Check only if bonus extension is active
192 if (SQL_NUMROWS($result_bonus) > 0) outputHtml('<br /><br />');
196 if ((isExtensionActive('bonus')) && ($WHO == getMessage('_ALL'))) {
197 // Load bonus mails only when extension is active
198 if (SQL_NUMROWS($result_bonus) > 0) {
200 $PAGES = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
203 $OUT = ''; $content = array();
204 while ($bonus = SQL_FETCHARRAY($result_bonus)) {
205 // Calculate unconfirmed emails
206 $bonus['unconfirmed'] = $bonus['mails_sent'] - $bonus['clicks'];
209 if ($bonus['unconfirmed'] > 0) {
210 // Add link to list_unconfirmed what-file
211 $bonus['unconfirmed'] = "<strong><a href=\"{?URL?}/modules.php?module=admin&what=list_unconfirmed&bid=".$bonus['id']."\">".$bonus['unconfirmed']."</a></strong>";
216 $content['time'] = createFancyTime($content['time']);
217 $content['category'] = getCategory($content['cat_id']);
218 $content['receivers'] = convertReceivers($content['receivers']);
219 $content['type'] = translatePoolType($content['data_type']);
220 $content['frametester'] = generateFrametesterUrl($content['url']);
221 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
224 $OUT .= loadTemplate('admin_list_bonus_emails_row', true, $content);
227 // Add navigation (without change box but with colspan=3)
228 $content['nav'] = '';
229 if ($PAGES > 1) $content['nav'] = addEmailNavigation($PAGES, getConfig('mails_page'), false, 3, true);
232 $content['rows'] = $OUT;
234 // Load main template
235 loadTemplate('admin_list_bonus_emails', false, $content);
240 if ($MAIL === false) {
241 // No mail orders fond
242 loadTemplate('admin_settings_saved', false, getMessage('ADMIN_NO_MAILS_IN_POOL'));