2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 09/28/2003 *
4 * =================== Last change: 07/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-unlock_emails.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Unlock ordered emails *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Werbebuchungen freigeben *
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__);
47 $result_main = SQL_QUERY("SELECT
57 `{?_MYSQL_PREFIX?}_pool`
61 `timestamp` ASC", __FILE__, __LINE__);
63 if ((!SQL_HASZERONUMS($result_main)) || (isFormSent('lock'))) {
64 if (isFormSent('accept')) {
65 if (ifPostContainsSelections()) {
67 foreach (postRequestElement('sel') as $id => $value) {
71 // Order placed in queue...
72 $result = SQL_QUERY_ESC('SELECT
78 `{?_MYSQL_PREFIX?}_pool`
82 array($id), __FILE__, __LINE__);
85 if (SQL_NUMROWS($result) == 1) {
87 $content = SQL_FETCHARRAY($result);
89 // Get payment from getter to avoid JOIN
90 $content['payment'] = getPaymentData($content['payment_id', 'payment');
92 // Is the surfbar installed?
93 // @TODO Rewrite these if-blocks to a filter
94 if ((isExtensionActive('surfbar')) && (getConfig('surfbar_migrate_order') == 'Y')) {
95 // Then "migrate" the URL to the surfbar
96 doSurfbarAdminMigrateUrl($content['url'], $content['sender']);
99 // Check for bonus extension version >= 0.4.4 for the order bonus
100 if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) {
101 // Add points directly
102 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_order`=`bonus_order`+{?bonus_order?} WHERE `userid`=%s LIMIT 1",
103 array(bigintval($content['sender'])), __FILE__, __LINE__);
105 // Subtract bonus points from system
106 handleBonusPoints(getBonusOrder(), $content['sender']);
109 // Load email template
110 $message_user = loadEmailTemplate('member_order_accepted', $content, $content['sender']);
113 sendEmail($content['sender'], '{--MEMBER_ORDER_ACCEPTED--}', $message_user);
115 // Unlock selected email
116 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='NEW' WHERE `id`=%s AND `data_type`='ADMIN' LIMIT 1",
117 array($id), __FILE__, __LINE__);
121 SQL_FREERESULT($result);
125 $message = '{--ADMIN_MAILS_ACTIVATED--}';
128 $message = '{--ADMIN_MAILS_NOTHING_CHECKED--}';
131 // Mails unlocked for mail delivery
132 displayMessage($message);
133 } elseif (isPostRequestElementSet('reject')) {
134 if (ifPostContainsSelections()) {
135 // Reject mail orders
137 foreach (postRequestElement('sel') as $id => $value) {
139 $id = bigintval($id);
141 // Load URL and subject from pool
142 $result = SQL_QUERY_ESC("SELECT `url`, `subject`, `sender` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s LIMIT 1",
143 array($id), __FILE__, __LINE__);
146 $content = SQL_FETCHARRAY($result);
149 SQL_FREERESULT($result);
151 // Load email template and send it away
152 $message_user = loadEmailTemplate('member_order_rejected', $content, $content['sender']);
153 sendEmail($content['sender'], '{--MEMBER_ORDER_REJECTED--}', $message_user);
155 // If you do not enter an URL to redirect to, your URL will be set!
156 if ((!isPostRequestElementSet('redirect')) || (postRequestElement('redirect') == 'http://')) {
157 setPostRequestElement('redirect', getUrl());
161 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `url`='%s',`data_type`='NEW' WHERE `id`=%s LIMIT 1",
162 array(postRequestElement('redirect'), $id),__FILE__, __LINE__);
164 // Prepare data for the row template
167 'url' => postRequestElement('url', $id),
170 // Load row template and switch colors
171 $OUT .= loadTemplate('admin_unlock_emails_redir_row', TRUE, $content);
174 // Load main template
175 loadTemplate('admin_unlock_emails_redir', FALSE, $OUT);
178 displayMessage('{--ADMIN_MAILS_NOTHING_CHECKED--}');
180 } elseif ((isFormSent('lock')) && (ifPostContainsSelections()) && (isExtensionActive('blacklist')) && (isUrlBlacklistEnabled())) {
182 foreach (postRequestElement('sel') as $id => $url) {
184 $id = bigintval($id);
186 // Lookup in blacklist
187 insertUrlInBlacklist($url);
191 displayMessage('{--ADMIN_URLS_BLOCKED--}');
192 } elseif ((!isFormSent('lock')) && (!isFormSent('accept')) && (!isFormSent('reject'))) {
193 // Mail orders are in pool so we can display them
195 while ($content = SQL_FETCHARRAY($result_main)) {
196 // Prepare data for the template
197 $content['timestamp'] = generateDateTime($content['timestamp'], 2);
199 // Load row template and switch colors
200 $OUT .= loadTemplate('admin_unlock_emails_row', TRUE, $content);
204 SQL_FREERESULT($result_main);
207 $content['rows'] = $OUT;
209 // Load main template
210 loadTemplate('admin_unlock_emails', FALSE, $content);
211 } elseif ((isFormSent('lock')) && ((!isExtensionActive('blacklist')) || (!isUrlBlacklistEnabled()))) {
212 // URL blacklist not activated
213 displayMessage('{--ADMIN_URL_BLACKLIST_DISABLED--}');
216 displayMessage('{--ADMIN_WRONG_CALL--}');
219 // No mail orders fond
220 displayMessage('{--ADMIN_NO_MAILS_IN_POOL--}');