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 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2012 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if ((!defined('__SECURITY')) || (!isAdmin())) {
43 // Add description as navigation point
44 addYouAreHereLink('admin', __FILE__);
46 // Is 'sql_patches' updated?
47 if (!isExtensionInstalledAndNewer('sql_patches', '0.7.4')) {
49 displayMessage(generateExtensionOutdatedMessage('sql_patches', '0.7.4'));
53 // Normal mails ordered by your members
68 `{?_MYSQL_PREFIX?}_pool`
70 `data_type` IN('ADMIN','TEMP','NEW','ACTIVE')
77 if ((isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
78 // Only a specific mail shall be displayed
79 $sql = sprintf("SELECT
93 `{?_MYSQL_PREFIX?}_pool`
97 bigintval(getRequestElement('id'))
99 $WHO = '{--MAIL_ID--}' . ': ' . getRequestElement('id');
100 } elseif (isGetRequestElementSet('userid')) {
101 // All mails by a specific member shall be displayed
102 $sql = sprintf("SELECT
116 `{?_MYSQL_PREFIX?}_pool`
121 bigintval(getRequestElement('userid'))
123 $WHO = '{--USER_ID--}' . ': ' . getRequestElement('userid');
127 $result_bonus = FALSE;
129 if ((isExtensionActive('bonus')) && (empty($WHO))) {
130 // Check for maximum pages
131 $result_bonus = SQL_QUERY("SELECT
145 (`mails_sent` - `clicks`) AS `unconfirmed`
147 `{?_MYSQL_PREFIX?}_bonus`
151 `timestamp` DESC", __FILE__, __LINE__);
154 // Check for maximum pages
155 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
157 // Set offset an current page to default values
158 if (!isGetRequestElementSet('page')) setGetRequestElement('page', 1);
160 if (!isGetRequestElementSet('offset')) {
161 if (isConfigEntrySet('mails_page')) {
163 setGetRequestElement('offset', getMailsPage());
166 setGetRequestElement('offset', 10);
170 // Add limitation to SQL string
171 if (!(isPostRequestElementSet('id')) && (isGetRequestElementSet('type')) && (postRequestElement('type') == 'normal')) {
172 // Create limitation line
173 $add = ' LIMIT ' . (bigintval(getRequestElement('offset')) * bigintval(getRequestElement('page')) - bigintval(getRequestElement('offset'))) . ', ' . bigintval(getRequestElement('offset'));
179 if (!empty($SQL2)) $SQL2 .= $add;
182 // Run SQL query for normal mails
183 $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
184 if ((!empty($SQL2)) && (empty($WHO))) {
185 $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
190 if (isConfigEntrySet('mails_page')) {
191 $numPages = round(SQL_NUMROWS($result_normal) / getMailsPage() + 0.3);
195 SQL_FREERESULT($result_normal);
198 if (!SQL_HASZERONUMS($result_list)) {
202 // Walk through all entries
203 while ($content = SQL_FETCHARRAY($result_list)) {
204 // Unconfirmed mails and sent mails
205 $result_uncon = SQL_QUERY_ESC("SELECT (`max_rec` - `clicks`) AS `unconfirmed` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
206 array(bigintval($content['id'])), __FILE__, __LINE__);
208 // Load and merge data
209 $content = merge_array($content, SQL_FETCHARRAY($result_uncon));
212 SQL_FREERESULT($result_uncon);
215 $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], ($content['unconfirmed']), 'normal');
218 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
221 $OUT .= loadTemplate('admin_list_emails_row', TRUE, $content);
225 SQL_FREERESULT($result_list);
227 // Add navigation (with change box and colspan=3)
228 $content['nav'] = addEmailNavigation($numPages, getMailsPage(), FALSE, 3, TRUE);
231 $content['rows'] = $OUT;
232 $content['who'] = $WHO;
234 // Mail orders are in pool so we can display them
235 loadTemplate('admin_list_emails', FALSE, $content);
238 if ((isExtensionActive('bonus')) && (empty($WHO))) {
239 // Only check if bonus extension is active
240 if (!SQL_HASZERONUMS($result_bonus)) outputHtml('<br /><br />');
244 if ((isExtensionActive('bonus')) && (empty($WHO))) {
245 // Load bonus mails only when extension is active
246 if (!SQL_HASZERONUMS($result_bonus)) {
248 $numPages = round(SQL_NUMROWS($result_bonus) / getMailsPage() + 0.5);
252 while ($content = SQL_FETCHARRAY($result_bonus)) {
253 // Add link to list_unconfirmed what-file
254 $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed'], 'bonus');
257 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
260 $OUT .= loadTemplate('admin_list_bonus_emails_row', TRUE, $content);
263 // Add navigation (without change box but with colspan=3)
264 $content['nav'] = addEmailNavigation($numPages, getMailsPage(), FALSE, 3, TRUE);
267 $content['rows'] = $OUT;
269 // Load main template
270 loadTemplate('admin_list_bonus_emails', FALSE, $content);
275 if ($MAIL === FALSE) {
276 // No mail orders fond
277 displayMessage('{--ADMIN_NO_MAILS_IN_POOL--}');