]> git.mxchange.org Git - mailer.git/blob - inc/filter/order_filter.php
mailer project continued:
[mailer.git] / inc / filter / order_filter.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 07/02/2011 *
4  * ===================                          Last change: 07/02/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : order_filter.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Filters for ext-order                            *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Filter fuer ext-order                            *
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 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Filter for returning given user's order points
44 function FILTER_ORDER_POINTS ($filterData) {
45         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
46         // Is ext-user installed and active?
47         if (isExtensionActive('user')) {
48                 // Get the points and add them to the existing
49                 $filterData['points'] += countSumTotalData($filterData['userid'], 'user_points', 'order_points');
50         } // END - if
51
52         // Return the data for next filter
53         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
54         return $filterData;
55 }
56
57 // Filter for returning given user's locked order points
58 function FILTER_LOCKED_ORDER_POINTS ($filterData) {
59         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
60         // Is ext-user installed and active?
61         if (isExtensionActive('user')) {
62                 // Get the points and add them to the existing
63                 $filterData['points'] += countSumTotalData($filterData['userid'], 'user_points', 'locked_order_points');
64         } // END - if
65
66         // Return the data for next filter
67         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
68         return $filterData;
69 }
70
71 // Filter for returning all user's order points column names
72 function FILTER_GET_ALL_ORDER_POINTS_COLUMN_NAMES ($filterData) {
73         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
74         // Add 'order_points' and 'locked_order_points'
75         $filterData['columns'] .= $filterData['alias'] . 'order_points' . $filterData['separator'] . $filterData['alias'] . 'locked_order_points' . $filterData['separator'];
76
77         // Return the data for next filter
78         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
79         return $filterData;
80 }
81
82 // Filter for ZIP code inclusion (not exclusion but it must be run in exclusion filter chain)
83 function FILTER_ORDER_ZIP_CODE_SQL ($sql) {
84         // Check if category and number of receivers is okay
85         if ((isOrderMultiPageEnabled()) && (isPostRequestElementSet('zip')) && (postRequestElement('zip') != '')) {
86                 // Choose recipients by ZIP code
87                 if (empty($sql)) {
88                         $sql = sprintf(" WHERE d.`zip` LIKE '%s%%'",
89                                 bigintval(postRequestElement('zip'))
90                         );
91                 } else {
92                         $sql .= sprintf(" AND d.`zip` LIKE '%s%%'",
93                                 bigintval(postRequestElement('zip'))
94                         );
95                 }
96         } // END - if
97
98         // Return expanded SQL
99         return $sql;
100 }
101
102 // Filter for adding columns of points to array
103 function FILTER_ORDER_POINTS_COLUMNS ($filterData) {
104         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
105         // Add column
106         array_push($filterData, 'order_points');
107
108         // Return the data for next filter
109         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
110         return $filterData;
111 }
112
113 // [EOF]
114 ?>