Extension ext-earning continued:
[mailer.git] / inc / filter / earning_filter.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 08/03/2011 *
4  * ===================                          Last change: 08/03/2011 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : earning_filter.php                               *
8  * -------------------------------------------------------------------- *
9  * Short description : Filters for ext-earning                          *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Filter fuer ext-earning                          *
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 - 2011 by Mailer Developer Team                   *
20  * For more information visit: http://www.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 function to add 'earning_group' POPUP
44 function FILTER_ADD_EARNING_GROUP_POPUP ($filterData) {
45         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
46         // Check if the current userid is same as in $filterData
47         if (getMemberId() != $filterData['userid']) {
48                 // Not the same
49                 debug_report_bug(__FUNCTION__, __LINE__, 'Validation of userid failed. ' . getMemberId() . '!=' . $filterData['userid']);
50         } // END - if
51
52         // Now check if the user has subscription and amount left
53         $result = SQL_QUERY_ESC("SELECT
54         d.`earning_id`,
55         d.`earning_name`,
56         u.`earning_current_amount`,
57         u.`earning_daily_amount`
58 FROM
59         `{?_MYSQL_PREFIX?}_user_earning` AS u
60 INNER JOIN
61         `{?_MYSQL_PREFIX?}_earning_data` AS d
62 ON
63         u.`earning_id`=d.`earning_id`
64 WHERE
65         u.`earning_userid`=%s AND
66         u.`earning_active`='Y' AND
67         u.`earning_current_amount` < u.`earning_daily_amount` AND
68         d.`earning_group`='POPUP'
69 ORDER BY
70         d.`earning_sorting` ASC",
71                 array(
72                         getMemberId()
73                 ), __FUNCTION__, __LINE__);
74
75         // Do we have entries left?
76         if (SQL_NUMROWS($result) > 0) {
77                 // Load all names
78                 while ($content = SQL_FETCHARRAY($result)) {
79                         // Merge the $filterData array in
80                         $content = merge_array($content, $filterData);
81
82                         // Construct callback function name
83                         $callbackName = 'get' . capitalizeUnderscoreString($content['earning_name']) . 'DataByEarningArray';
84
85                         // And call it
86                         $content = call_user_func($callbackName, $content);
87                 } // END - if
88         } // END - if
89
90         // Free result
91         SQL_FREERESULT($result);
92
93         // Return filter data
94         //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
95         return $filterData;
96 }
97
98 // [EOF]
99 ?>