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 * -------------------------------------------------------------------- *
37 * Moded What-email_details.php / also Editet ! *
38 * Auf langsammen Servern (wie mein z.B Dauert das Laden) *
39 * enorm hoch zu lang. Jetzt werden nur auftraege aufgelistet die *
40 * NEU sind ( DB NEW) oder ADMIN freischalten muss (DB ADMIN ) *
41 * oder noch als TEMP gespecihert sind *
42 * der rest der schon als SEND sich melden darf wird per *
43 * what-email_archiv .php aufgerufen *
44 * beste gruesse Robert Niedziela / www.personal-webserver.de *
45 * oder auch www.mc-p.org *
46 ************************************************************************/
48 // Some security stuff...
49 if ((!defined('__SECURITY')) || (!isAdmin())) {
53 // Add description as navigation point
54 addMenuDescription('admin', __FILE__);
56 // Normal mails ordered by your members
58 `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
60 `{?_MYSQL_PREFIX?}_pool`
62 `data_type` IN('ADMIN','TEMP','NEW','ACTIVE')
69 if (isGetRequestParameterSet('mid')) {
70 // Only a specific mail shall be displayed
71 $sql = sprintf("SELECT
72 `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
74 `{?_MYSQL_PREFIX?}_pool`
78 bigintval(getRequestParameter('mid'))
80 $WHO = '{--MAIL_ID--}' . ': ' . getRequestParameter('mid');
81 } elseif (isGetRequestParameterSet('userid')) {
82 // All mails by a specific member shall be displayed
83 $sql = sprintf("SELECT
84 `id`, `sender`, `subject`, `text`, `receivers`, `payment_id`, `data_type`, `timestamp`, `url`, `target_send`, `cat_id`
86 `{?_MYSQL_PREFIX?}_pool`
91 bigintval(getRequestParameter('userid'))
93 $WHO = '{--USER_ID--}' . ': ' . getRequestParameter('userid');
97 $result_bonus = false;
99 if ((isExtensionActive('bonus')) && (empty($WHO))) {
100 // Check for maximum pages
101 $result_bonus = SQL_QUERY("SELECT
102 `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `mails_sent`, `clicks`,
103 (`mails_sent` - `clicks`) AS `unconfirmed`
105 `{?_MYSQL_PREFIX?}_bonus`
109 `timestamp` DESC", __FILE__, __LINE__);
112 // Check for maximum pages
113 $result_normal = SQL_QUERY($sql, __FILE__, __LINE__);
115 // Set offset an current page to default values
116 if (!isGetRequestParameterSet('page')) setGetRequestParameter('page', 1);
118 if (!isGetRequestParameterSet('offset')) {
119 if (isConfigEntrySet('mails_page')) {
121 setGetRequestParameter('offset', getConfig('mails_page'));
124 setGetRequestParameter('offset', 10);
128 // Add limitation to SQL string
129 if (!isGetRequestParameterSet('mid')) {
130 // Create limitation line
131 $add = ' LIMIT ' . (bigintval(getRequestParameter('offset')) * bigintval(getRequestParameter('page')) - bigintval(getRequestParameter('offset'))) . ', ' . bigintval(getRequestParameter('offset'));
137 if (!empty($SQL2)) $SQL2 .= $add;
140 // Run SQL query for normal mails
141 $result_list = SQL_QUERY($sql, __FILE__, __LINE__);
142 if ((!empty($SQL2)) && (empty($WHO))) $result_bonus = SQL_QUERY($SQL2, __FILE__, __LINE__);
146 if (isConfigEntrySet('mails_page')) {
147 $numPages = round(SQL_NUMROWS($result_normal) / getConfig('mails_page') + 0.3);
151 SQL_FREERESULT($result_normal);
154 if (!SQL_HASZERONUMS($result_list)) {
158 // Walk through all entries
159 while ($content = SQL_FETCHARRAY($result_list)) {
160 // Unconfirmed mails and sent mails
161 $result_uncon = SQL_QUERY_ESC("SELECT (`max_rec` - `clicks`) AS `unconfirmed` FROM `{?_MYSQL_PREFIX?}_user_stats` WHERE `pool_id`=%s LIMIT 1",
162 array(bigintval($content['id'])), __FILE__, __LINE__);
164 // Load and merge data
165 $content = merge_array($content, SQL_FETCHARRAY($result_uncon));
168 SQL_FREERESULT($result_uncon);
171 $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], ($content['unconfirmed']), 'mid');
174 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
177 $OUT .= loadTemplate('admin_list_emails_row', true, $content);
181 SQL_FREERESULT($result_list);
183 // Add navigation (with change box and colspan=3)
184 $content['nav'] = addEmailNavigation($numPages, getConfig('mails_page'), false, 3, true);
187 $content['rows'] = $OUT;
188 $content['who'] = $WHO;
190 // Mail orders are in pool so we can display them
191 loadTemplate('admin_list_emails', false, $content);
194 if ((isExtensionActive('bonus')) && (empty($WHO))) {
195 // Only check if bonus extension is active
196 if (!SQL_HASZERONUMS($result_bonus)) outputHtml('<br /><br />');
200 if ((isExtensionActive('bonus')) && (empty($WHO))) {
201 // Load bonus mails only when extension is active
202 if (!SQL_HASZERONUMS($result_bonus)) {
204 $numPages = round(SQL_NUMROWS($result_bonus) / getConfig('mails_page') + 0.5);
208 while ($content = SQL_FETCHARRAY($result_bonus)) {
209 // Add link to list_unconfirmed what-file
210 $content['unconfirmed'] = generateUnconfirmedAdminLink($content['id'], $content['unconfirmed']);
213 $content['timestamp'] = generateDateTime($content['timestamp'], 0);
216 $OUT .= loadTemplate('admin_list_bonus_emails_row', true, $content);
219 // Add navigation (without change box but with colspan=3)
220 $content['nav'] = addEmailNavigation($numPages, getConfig('mails_page'), false, 3, true);
223 $content['rows'] = $OUT;
225 // Load main template
226 loadTemplate('admin_list_bonus_emails', false, $content);
231 if ($MAIL === false) {
232 // No mail orders fond
233 loadTemplate('admin_settings_saved', false, '{--ADMIN_NO_MAILS_IN_POOL--}');