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, 2010 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 // Normal mails ordered by your members
48 `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `mails_sent`, `cat_id`
50 `{?_MYSQL_PREFIX?}_pool`
52 `data_type` IN('ADMIN','TEMP','NEW','ACTIVE')
59 if (isGetRequestParameterSet('mid')) {
60 // Only a specific mail shall be displayed
61 $sql = sprintf("SELECT
62 `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
64 `{?_MYSQL_PREFIX?}_pool`
68 bigintval(getRequestParameter('mid'))
70 $WHO = '{--MAIL_ID--}' . ': ' . getRequestParameter('mid');
71 } elseif (isGetRequestParameterSet('userid')) {
72 // All mails by a specific member shall be displayed
73 $sql = sprintf("SELECT
74 `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
76 `{?_MYSQL_PREFIX?}_pool`
81 bigintval(getRequestParameter('userid'))
83 $WHO = '{--USER_ID--}' . ': ' . getRequestParameter('userid');
87 $result_bonus = false;
89 if ((isExtensionActive('bonus')) && (empty($WHO))) {
90 // Check for maximum pages
91 $result_bonus = SQL_QUERY("SELECT
92 `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`, `clicks`,
93 (`mails_sent` - `clicks`) AS `unconfirmed`
95 `{?_MYSQL_PREFIX?}_bonus`
99 `timestamp` DESC", __FILE__, __LINE__);
102 // Check for maximum pages
103 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
105 // Set offset an current page to default values
106 if (!isGetRequestParameterSet('page')) setGetRequestParameter('page', 1);
108 if (!isGetRequestParameterSet('offset')) {
109 if (isConfigEntrySet('mails_page')) {
111 setGetRequestParameter('offset', getConfig('mails_page'));
114 setGetRequestParameter('offset', 10);
118 // Add limitation to SQL string
119 if (!isGetRequestParameterSet('mid')) {
120 // Create limitation line
121 $add = ' LIMIT ' . (bigintval(getRequestParameter('offset')) * bigintval(getRequestParameter('page')) - bigintval(getRequestParameter('offset'))) . ', ' . bigintval(getRequestParameter('offset'));
127 if (!empty($SQL2)) $SQL2 .= $add;
130 // Run SQL query for normal mails
131 $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
132 if ((!empty($SQL2)) && (empty($WHO))) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
136 if (isConfigEntrySet('mails_page')) {
137 $numPages = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3);
141 SQL_FREERESULT($result_normal);
144 if (!SQL_HASZERONUMS($result_list)) {
148 // Walk through all entries
149 while ($content = SQL_FETCHARRAY($result_list)) {
150 // Unconfirmed mails and sent mails
151 $result_uncon = SQL_QUERY_ESC("SELECT (`max_rec` - `clicks`) AS `unconfirmed` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
152 array(bigintval($content['id'])), __FILE__, __LINE__);
154 // Load and merge data
155 $content = merge_array($content, SQL_FETCHARRAY($result_uncon));
158 SQL_FREERESULT($result_uncon);
161 $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], ($content['unconfirmed']), 'mid');
164 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
167 $OUT .= loadTemplate('admin_list_emails_row', true, $content);
171 SQL_FREERESULT($result_list);
173 // Add navigation (with change box and colspan=3)
174 $content['nav'] = addEmailNavigation($numPages, getConfig('mails_page'), false, 3, true);
177 $content['rows'] = $OUT;
178 $content['who'] = $WHO;
180 // Mail orders are in pool so we can display them
181 loadTemplate('admin_list_emails', false, $content);
184 if ((isExtensionActive('bonus')) && (empty($WHO))) {
185 // Only check if bonus extension is active
186 if (!SQL_HASZERONUMS($result_bonus)) outputHtml('<br /><br />');
190 if ((isExtensionActive('bonus')) && (empty($WHO))) {
191 // Load bonus mails only when extension is active
192 if (!SQL_HASZERONUMS($result_bonus)) {
194 $numPages = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
198 while ($content = SQL_FETCHARRAY($result_bonus)) {
199 // Add link to list_unconfirmed what-file
200 $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed']);
203 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
206 $OUT .= loadTemplate('admin_list_bonus_emails_row', true, $content);
209 // Add navigation (without change box but with colspan=3)
210 $content['nav'] = addEmailNavigation($numPages, getConfig('mails_page'), false, 3, true);
213 $content['rows'] = $OUT;
215 // Load main template
216 loadTemplate('admin_list_bonus_emails', false, $content);
221 if ($MAIL === false) {
222 // No mail orders fond
223 loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_MAILS_IN_POOL--}');