]> git.mxchange.org Git - mailer.git/blob - inc/filter/order_filter.php
Updated copyright notice as there are changes in this year
[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 - 2013 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()) {
86                 // Default is no zip code limitation
87                 $zip = NULL;
88
89                 // POST or GET elements?
90                 if ((isPostRequestElementSet('zip')) && (postRequestElement('zip') != '')) {
91                         // Choose recipients by zip code from POST
92                         $zip = bigintval(postRequestElement('zip'));
93                 } elseif ((isGetRequestElementSet('zip')) && (getRequestElement('zip') != '')) {
94                         // Choose recipients by zip code from GET
95                         $zip = bigintval(getRequestElement('zip'));
96                 }
97
98                 // Is the zip code set?
99                 if (!is_null($zip)) {
100                         // Is the previous SQL statement empty?
101                         if (empty($sql)) {
102                                 // SQL statemet is empty, so use WHERE
103                                 $sql = sprintf(" WHERE `zip` LIKE '%s%%%%'", $zip);
104                         } else {
105                                 // ... otherwise use AND
106                                 $sql .= sprintf(" AND `zip` LIKE '%s%%%%'", $zip);
107                         }
108                 } // END - if
109         } // END - if
110
111         // Return expanded SQL
112         return $sql;
113 }
114
115 // Filter for adding columns of points to array
116 function FILTER_ORDER_POINTS_COLUMNS ($filterData) {
117         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
118         // Add column
119         array_push($filterData, 'order_points');
120
121         // Return the data for next filter
122         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
123         return $filterData;
124 }
125
126 // [EOF]
127 ?>