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 - 2011 by Mailer Developer Team *
20 * For more information visit: http://www.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
55 `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `mails_sent`, `cat_id`
57 `{?_MYSQL_PREFIX?}_pool`
59 `data_type` IN('ADMIN','TEMP','NEW','ACTIVE')
66 if (isGetRequestParameterSet('mid')) {
67 // Only a specific mail shall be displayed
68 $sql = sprintf("SELECT
69 `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
71 `{?_MYSQL_PREFIX?}_pool`
75 bigintval(getRequestParameter('mid'))
77 $WHO = '{--MAIL_ID--}' . ': ' . getRequestParameter('mid');
78 } elseif (isGetRequestParameterSet('userid')) {
79 // All mails by a specific member shall be displayed
80 $sql = sprintf("SELECT
81 `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
83 `{?_MYSQL_PREFIX?}_pool`
88 bigintval(getRequestParameter('userid'))
90 $WHO = '{--USER_ID--}' . ': ' . getRequestParameter('userid');
94 $result_bonus = false;
96 if ((isExtensionActive('bonus')) && (empty($WHO))) {
97 // Check for maximum pages
98 $result_bonus = SQL_QUERY("SELECT
99 `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`, `clicks`,
100 (`mails_sent` - `clicks`) AS `unconfirmed`
102 `{?_MYSQL_PREFIX?}_bonus`
106 `timestamp` DESC", __FILE__, __LINE__);
109 // Check for maximum pages
110 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
112 // Set offset an current page to default values
113 if (!isGetRequestParameterSet('page')) setGetRequestParameter('page', 1);
115 if (!isGetRequestParameterSet('offset')) {
116 if (isConfigEntrySet('mails_page')) {
118 setGetRequestParameter('offset', getMailsPage());
121 setGetRequestParameter('offset', 10);
125 // Add limitation to SQL string
126 if (!isGetRequestParameterSet('mid')) {
127 // Create limitation line
128 $add = ' LIMIT ' . (bigintval(getRequestParameter('offset')) * bigintval(getRequestParameter('page')) - bigintval(getRequestParameter('offset'))) . ', ' . bigintval(getRequestParameter('offset'));
134 if (!empty($SQL2)) $SQL2 .= $add;
137 // Run SQL query for normal mails
138 $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
139 if ((!empty($SQL2)) && (empty($WHO))) {
140 $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
145 if (isConfigEntrySet('mails_page')) {
146 $numPages = round(SQL_NUMROWS($result_normal) / getMailsPage() + 0.3);
150 SQL_FREERESULT($result_normal);
153 if (!SQL_HASZERONUMS($result_list)) {
157 // Walk through all entries
158 while ($content = SQL_FETCHARRAY($result_list)) {
159 // Unconfirmed mails and sent mails
160 $result_uncon = SQL_QUERY_ESC("SELECT (`max_rec` - `clicks`) AS `unconfirmed` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
161 array(bigintval($content['id'])), __FILE__, __LINE__);
163 // Load and merge data
164 $content = merge_array($content, SQL_FETCHARRAY($result_uncon));
167 SQL_FREERESULT($result_uncon);
170 $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], ($content['unconfirmed']), 'mid');
173 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
176 $OUT .= loadTemplate('admin_list_emails_row', true, $content);
180 SQL_FREERESULT($result_list);
182 // Add navigation (with change box and colspan=3)
183 $content['nav'] = addEmailNavigation($numPages, getMailsPage(), false, 3, true);
186 $content['rows'] = $OUT;
187 $content['who'] = $WHO;
189 // Mail orders are in pool so we can display them
190 loadTemplate('admin_list_emails', false, $content);
193 if ((isExtensionActive('bonus')) && (empty($WHO))) {
194 // Only check if bonus extension is active
195 if (!SQL_HASZERONUMS($result_bonus)) outputHtml('<br /><br />');
199 if ((isExtensionActive('bonus')) && (empty($WHO))) {
200 // Load bonus mails only when extension is active
201 if (!SQL_HASZERONUMS($result_bonus)) {
203 $numPages = round(SQL_NUMROWS($result_bonus) / getMailsPage() + 0.5);
207 while ($content = SQL_FETCHARRAY($result_bonus)) {
208 // Add link to list_unconfirmed what-file
209 $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed']);
212 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
215 $OUT .= loadTemplate('admin_list_bonus_emails_row', true, $content);
218 // Add navigation (without change box but with colspan=3)
219 $content['nav'] = addEmailNavigation($numPages, getMailsPage(), false, 3, true);
222 $content['rows'] = $OUT;
224 // Load main template
225 loadTemplate('admin_list_bonus_emails', false, $content);
230 if ($MAIL === false) {
231 // No mail orders fond
232 displayMessage('{--ADMIN_NO_MAILS_IN_POOL--}');