]> git.mxchange.org Git - mailer.git/blob - inc/modules/order.php
Forgot it to comment out ... :(
[mailer.git] / inc / modules / order.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/29/2003 *
4  * ===================                          Last change: 01/06/2006 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : order.php                                        *
8  * -------------------------------------------------------------------- *
9  * Short description : Submits your order to the administrators         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Sendet die Buchung an die Administratoren        *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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                      *
21  *                                                                      *
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.                                  *
26  *                                                                      *
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.                         *
31  *                                                                      *
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,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 $url = '';
40 if (!defined('__SECURITY')) {
41         exit();
42 } elseif ((!isExtensionActive('order')) && (!isAdmin())) {
43         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=order%}');
44         return;
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&amp;what=order';
51 }
52
53 // When URL is empty nothing bad happend here
54 if (empty($url)) {
55         // Auto-send is inactive
56         $content['admin_autosend']  = '{--ADMIN_AUTOSEND_INACTIVE--}';
57         $content['member_autosend'] = '{--MEMBER_AUTOSEND_INACTIVE--}';
58         $type = 'ADMIN';
59
60         // Is the auto-send mechanism active or inactive?
61         if (getConfig('autosend_active') == 'Y') {
62                 // Auto-send is active
63                 $content['admin_autosend']  = '{--ADMIN_AUTOSEND_ACTIVE--}';
64                 $content['member_autosend'] = '{--MEMBER_AUTOSEND_ACTIVE--}';
65                 $type = 'NEW';
66         } // END - if
67
68         // Update sending pool
69         SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='%s' WHERE `id`=%s AND `sender`=%s AND `data_type`='TEMP' LIMIT 1",
70                 array(
71                         $type,
72                         bigintval(getRequestElement('order')),
73                         getMemberId()
74                 ), __FILE__, __LINE__);
75
76         // Finally is the entry valid?
77         if (!SQL_HASZEROAFFECTED()) {
78                 // @TODO Unused: 2,4
79                 // Load mail again...              0         1          2             3            4         5       6            7
80                 $result = SQL_QUERY_ESC("SELECT `subject`, `text`, `receivers`, `payment_id`, `timestamp`, `url`, `cat_id`, `target_send` FROM `{?_MYSQL_PREFIX?}_pool` WHERE `id`=%s AND `sender`=%s LIMIT 1",
81                         array(
82                                 bigintval(getRequestElement('order')),
83                                 getMemberId()
84                         ), __FILE__, __LINE__);
85
86                 // Merge arrays
87                 $content = merge_array($content, SQL_FETCHARRAY($result));
88
89                 // Free result
90                 SQL_FREERESULT($result);
91
92                 // Fix empty subject line
93                 if (empty($content['subject'])) {
94                         $content['subject'] = '{--DEFAULT_SUBJECT--}';
95                 } // END - if
96
97                 // Calculate used points
98                 $content['payed_points'] = $content['target_send'] * getPaymentData($content['payment_id']);
99
100                 // Subtract them from the user's account and ignore return status
101                 subtractPoints('order', getMemberId(), $content['payed_points']);
102
103                 // Update used points
104                 $add = '';
105                 if ((isExtensionInstalledAndNewer('order', '0.1.1')) && (getConfig('order_max_full') == 'ORDER')) {
106                         $add = ',`mail_orders`=`mail_orders`+1';
107                 } // END - if
108
109                 // Send an email to the user
110                 $message_mem = loadEmailTemplate('member_order_normal', $content, getMemberId());
111                 sendEmail(getMemberId(), '{--MEMBER_NEW_QUEUE--}', $message_mem);
112
113                 // Notify admins about this
114                 sendAdminNotification('{--ADMIN_NEW_QUEUE--}', 'admin_order_normal', $content, getMemberId());
115
116                 // Create new task (we ignore the task id here)
117                 createNewTask(
118                         '{--ADMIN_NEW_QUEUE--}',
119                         '<pre>' . loadEmailTemplate('admin_order_normal', $content, getMemberId()) . '</pre>',
120                         'MEMBER_ORDER',
121                         getMemberId(),
122                         0,
123                         false
124                 );
125
126                 // Output back bottom
127                 loadTemplate('member_order_thanks');
128         } else {
129                 // Matching line not found or already 'placed' in send queue
130                 redirectToUrl('modules.php?module=login');
131         }
132 } else {
133         // Redirect...
134         redirectToUrl($url);
135 }
136
137 // [EOF]
138 ?>