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 - 2013 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 = sqlQuery("SELECT
58 `{?_MYSQL_PREFIX?}_pool`
62 `timestamp` ASC", __FILE__, __LINE__);
64 if ((!ifSqlHasZeroNums($result_main)) || (isFormSent('lock'))) {
65 if (isFormSent('accept')) {
66 if (ifPostContainsSelections()) {
68 foreach (postRequestElement('sel') as $id => $value) {
72 // Get pool data from given id
73 $content = getPoolDataFromId($id);
76 if (isFilledArray($content)) {
77 // Is the surfbar installed?
78 // @TODO Rewrite these if-blocks to a filter
79 if ((isExtensionActive('surfbar')) && (getConfig('surfbar_migrate_order') == 'Y')) {
80 // Then "migrate" the URL to the surfbar
81 doSurfbarAdminMigrateUrl($content['url'], $content['sender']);
84 // Check for bonus extension version >= 0.4.4 for the order bonus
85 if ((isExtensionInstalledAndNewer('bonus', '0.4.4')) && (isBonusRallyeActive())) {
86 // Add points directly
87 sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `bonus_order`=`bonus_order`+{?bonus_order?} WHERE `userid`=%s LIMIT 1",
88 array(bigintval($content['sender'])), __FILE__, __LINE__);
90 // Subtract bonus points from system
91 handleBonusPoints(getBonusOrder(), $content['sender']);
94 // Load email template
95 $message_user = loadEmailTemplate('member_order_accepted', $content, $content['sender']);
98 sendEmail($content['sender'], '{--MEMBER_ORDER_ACCEPTED--}', $message_user);
100 // Unlock selected email
101 updatePoolDataById($id, 'data_type', 'NEW', NULL, " AND `data_type`='ADMIN'");
106 $message = '{--ADMIN_MAILS_ACTIVATED--}';
109 $message = '{--ADMIN_MAILS_NOTHING_CHECKED--}';
112 // Mails unlocked for mail delivery
113 displayMessage($message);
114 } elseif (isPostRequestElementSet('reject')) {
115 if (ifPostContainsSelections()) {
116 // Reject mail orders
118 foreach (postRequestElement('sel') as $id => $value) {
120 $id = bigintval($id);
122 // Get pool data from given id
123 $content = getPoolDataFromId($id);
125 // Load email template and send it away
126 $message_user = loadEmailTemplate('member_order_rejected', $content, $content['sender']);
127 sendEmail($content['sender'], '{--MEMBER_ORDER_REJECTED--}', $message_user);
129 // If you do not enter an URL to redirect to, your URL will be set!
130 if ((!isPostRequestElementSet('redirect')) || (postRequestElement('redirect') == 'http://')) {
131 setPostRequestElement('redirect', getUrl());
135 updatePoolDataById($id, NULL, array('url' => postRequestElement('redirect'), 'data_type' => 'NEW'));
137 // Prepare data for the row template
140 'url' => postRequestElement('url', $id),
143 // Load row template and switch colors
144 $OUT .= loadTemplate('admin_unlock_emails_redir_row', TRUE, $content);
147 // Load main template
148 loadTemplate('admin_unlock_emails_redir', FALSE, $OUT);
151 displayMessage('{--ADMIN_MAILS_NOTHING_CHECKED--}');
153 } elseif ((isFormSent('lock')) && (ifPostContainsSelections()) && (isExtensionActive('blacklist')) && (isUrlBlacklistEnabled())) {
155 foreach (postRequestElement('sel') as $id => $url) {
157 $id = bigintval($id);
159 // Lookup in blacklist
160 insertUrlInBlacklist($url);
164 displayMessage('{--ADMIN_URLS_BLOCKED--}');
165 } elseif ((!isFormSent('lock')) && (!isFormSent('accept')) && (!isFormSent('reject'))) {
166 // Mail orders are in pool so we can display them
168 while ($content = sqlFetchArray($result_main)) {
169 // Prepare data for the template
170 $content['timestamp'] = generateDateTime($content['timestamp'], 2);
172 // Load row template and switch colors
173 $OUT .= loadTemplate('admin_unlock_emails_row', TRUE, $content);
177 sqlFreeResult($result_main);
180 $content['rows'] = $OUT;
182 // Load main template
183 loadTemplate('admin_unlock_emails', FALSE, $content);
184 } elseif ((isFormSent('lock')) && ((!isExtensionActive('blacklist')) || (!isUrlBlacklistEnabled()))) {
185 // URL blacklist not activated
186 displayMessage('{--ADMIN_URL_BLACKLIST_DISABLED--}');
189 displayMessage('{--ADMIN_WRONG_CALL--}');
192 // No mail orders fond
193 displayMessage('{--ADMIN_NO_MAILS_IN_POOL--}');