2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/29/2003 *
4 * =================== Last change: 01/06/2006 *
6 * -------------------------------------------------------------------- *
8 * -------------------------------------------------------------------- *
9 * Short description : Submits your order to the administrators *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Sendet die Buchung an die Administratoren *
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...
40 if (!defined('__SECURITY')) {
42 } elseif ((!isExtensionActive('order')) && (!isAdmin())) {
43 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=order%}');
45 } elseif (!isMember()) {
46 // Sorry, no guest access!
47 $url = 'modules.php?module=index';
48 } elseif (!isGetRequestElementSet('order')) {
49 // You cannot call this module directly!
50 $url = 'modules.php?module=login&what=order';
53 // When URL is empty nothing bad happend here
55 // Auto-send is inactive
56 $content['admin_autosend'] = '{--ADMIN_AUTOSEND_INACTIVE--}';
57 $content['member_autosend'] = '{--MEMBER_AUTOSEND_INACTIVE--}';
60 // Is the auto-send mechanism active or inactive?
61 if (isAutosendMemberMailsEnabled()) {
62 // Auto-send is active
63 $content['admin_autosend'] = '{--ADMIN_AUTOSEND_ACTIVE--}';
64 $content['member_autosend'] = '{--MEMBER_AUTOSEND_ACTIVE--}';
68 // Update pool data and check if the entry is valid
69 if (!updatePoolDataById(getRequestElement('order'), 'data_type', $type, NULL, sprintf(" AND `sender`=%s AND `data_type`='TEMP'", getMemberId()))) {
70 // Merge array with pool data
71 // @TODO Unused: timestamp
72 $content = merge_array($content, getPoolDataFromId(getRequestElement('order')));
74 // Fix empty subject line
75 if (empty($content['subject'])) {
76 $content['subject'] = '{--DEFAULT_SUBJECT--}';
79 // Calculate used points
80 $content['payed_points'] = $content['target_send'] * getPaymentPrice($content['payment_id']);
82 // Subtract them from the user's account and ignore return status
83 subtractPoints('order', getMemberId(), $content['payed_points']);
87 if ((isExtensionInstalledAndNewer('order', '0.1.1')) && (getOrderMaxFull() == 'ORDER')) {
88 $add = ',`mail_orders`=`mail_orders`+1';
91 // Send an email to the user
92 $message_mem = loadEmailTemplate('member_order_normal', $content, getMemberId());
93 sendEmail(getMemberId(), '{--MEMBER_NEW_QUEUE--}', $message_mem);
95 // Notify admins about this
96 sendAdminNotification('{--ADMIN_NEW_QUEUE--}', 'admin_order_normal', $content, getMemberId());
98 // Create new task (we ignore the task id here)
100 '{--ADMIN_NEW_QUEUE--}',
101 '<pre>' . loadEmailTemplate('admin_order_normal', $content, getMemberId()) . '</pre>',
108 // Output back bottom
109 loadTemplate('member_order_thanks');
111 // Matching line not found or already 'placed' in send queue
112 redirectToUrl('modules.php?module=login');