]> git.mxchange.org Git - mailer.git/blob - inc/filter/rallye_filter.php
Code in 'init' phase of ext-order swapped out to daily_order.php, added filters for...
[mailer.git] / inc / filter / rallye_filter.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/02/2011 *
4  * ===================                          Last change: 06/02/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : _filter.php                                      *
8  * -------------------------------------------------------------------- *
9  * Short description : Filters for ext-                                 *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Filter fuer ext-                                 *
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 extra-autpurge
44 function FILTER_RALLYE_EXTRA_AUTOPURGE ($filterData) {
45         // Check expired rallyes (hard-coded 3 days limit for displaying expired rallyes!)
46         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
47         purgeExpiredReferralRallyes();
48
49         // Return data
50         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
51         return $filterData;
52 }
53
54 // Run filter for notifying users about rallyes
55 function FILTER_RALLYE_NOTIFY_USERS ($filerData) {
56         // Do stuff only when not in CSS mode
57         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
58         if (!isCssOutputMode()) {
59                 // Get total member count
60                 $total = getTotalConfirmedUser();
61
62                 // Run filter to get SQL "addons"
63                 $sqlAddons = runFilterChain('add_rallye_notify_sqls', array(
64                         'add' => '',
65                         'or'  => ''
66                 ));
67
68                 // Check for new started but not notified rallyes
69                 $result = SQL_QUERY("SELECT SQL_SMALL_RESULT
70         d.`id`,
71         d.`title`,
72         d.`start_time`,
73         d.`end_time`,
74         d.`send_notify`
75         " . $sqlAddons['add'] . "
76 FROM
77         `{?_MYSQL_PREFIX?}_rallye_data` AS d
78 WHERE
79         d.`is_active`='Y' AND
80         d.`notified`='N' AND
81         d.`expired`='N' AND
82         d.`start_time` <= UNIX_TIMESTAMP() AND
83         d.`end_time` > UNIX_TIMESTAMP()
84 LIMIT 1", __FILE__, __LINE__);
85                 if (SQL_NUMROWS($result) == 1) {
86                         // Start rallye
87                         autostartReferralRallyes($result);
88                 } // END - if
89
90                 // Free memory
91                 SQL_FREERESULT($result);
92
93                 // Check for expired rallyes
94                 $result = SQL_QUERY("SELECT SQL_SMALL_RESULT
95         d.`id`,
96         d.`title`,
97         d.`start_time`,
98         d.`end_time`,
99         d.`send_notify`
100         " . $sqlAddons['add'] . "
101 FROM
102         `{?_MYSQL_PREFIX?}_rallye_data` AS d
103 WHERE
104         d.`is_active`='Y' AND
105         d.`notified`='Y' AND
106         d.`expired`='N' AND
107         (d.`end_time` <= UNIX_TIMESTAMP()" . $sqlAddons['or'] . ")
108 LIMIT 1", __FILE__, __LINE__);
109                 if ((SQL_NUMROWS($result) == 1) && (isExtensionActive('autopurge'))) {
110                         // End rallye here...
111                         stopRallyeByResult($result);
112                 } // END - if
113
114                 // Free memory
115                 SQL_FREERESULT($result);
116         } // END - if
117
118         // Return data
119         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
120         return $filterData;
121 }
122
123 // Filter for adding SQL columns
124 function FILTER_ADD_RALLYE_SQL_COLUMNS ($filterData) {
125         // Are all requirements met?
126         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
127         if (isExtensionInstalledAndNewer('rallye', '0.2.0')) {
128                 // Add more data on higher versions
129                 $filterData['add'] .= ',`min_users`,`min_prices`';
130                 $filterData['or']  .= ' OR (d.`min_users` <= ' . $total . ' AND d.`min_users` > 0)';
131         } // END  - if
132
133         // Return data
134         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
135         return $filterData;
136 }
137
138 // [EOF]
139 ?>