2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 06/02/2011 *
4 * =================== Last change: 06/02/2011 *
6 * -------------------------------------------------------------------- *
8 * -------------------------------------------------------------------- *
9 * Short description : Filters for ext- *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Filter fuer ext- *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2016 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
43 // Filter for adding login bonus to the user's account
44 function FILTER_ADD_LOGIN_BONUS ($filterData) {
45 // Is the user data valid?
46 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
48 // Do only run for logged in members
49 reportBug(__FUNCTION__, __LINE__, 'Please only run this filter for logged in users.');
52 // Bonus is not given by default ;-)
54 if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (isBonusRallyeActive()) && (isIncludeBonusLoginEnabled())) {
55 // Update last login if far enougth away
56 // @TODO This query isn't right, it will only update if the user was for a longer time away!
57 sqlQueryEscaped('UPDATE
58 `{?_MYSQL_PREFIX?}_user_data`
60 `last_login`=UNIX_TIMESTAMP()
63 (UNIX_TIMESTAMP() - `last_login`) >= {?login_timeout?}
67 ), __FUNCTION__, __LINE__
71 $bonus = (!ifSqlHasZeroAffectedRows());
74 if (($bonus === TRUE) && (getRequestElement('do') == 'bonus')) {
75 // Output message with added points
76 $GLOBALS['message'] .= '<div class="tiny">{--MEMBER_BONUS_LOGIN_BONUS_ADDED--}</div>';
78 // No login bonus added!
79 $GLOBALS['message'] .= '<div class="notice">{--MEMBER_BONUS_LOGIN_BONUS_NOT_ADDED--}</div>';
83 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
87 // Filter for generating admin mail links for bonus mails
88 function FILTER_GENERATE_BONUS_MAIL_LINKS ($filterData) {
89 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
91 // Is the type 'bonus'?
92 if ($filterData['type'] == 'bonus') {
94 $filterData['__output'] .= loadTemplate('admin_links_bonus_mail', TRUE, $filterData);
98 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
102 // Filter for adding bonus columns with a plus (+) sign
103 function FILTER_ADD_BONUS_POINTS_USER_COLUMNS ($add = '') {
104 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
106 // Skip out-dated extension, because this causes an error
107 if (isExtensionInstalledAndOlder('bonus', '0.9.7')) {
108 // Skip this silently
112 // Add more columns only when the corresponding configuration is enabled, too
113 if (isIncludeBonusClickEnabled()) $add .= ' + `turbo_bonus`';
114 if (isIncludeBonusLoginEnabled()) $add .= ' + `login_bonus`';
115 if (isIncludeBonusOrderEnabled()) $add .= ' + `bonus_order`';
116 if (isIncludeBonusRefEnabled() ) $add .= ' + `bonus_ref`';
117 if (isIncludeBonusStatsEnabled()) $add .= ' + `bonus_stats`';
120 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
124 // Filter for adding SQL columns on user registration for bonus/"active" rallye notification
125 function FILTER_BONUS_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) {
126 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
128 // Next: active rallye
129 if (!isBonusNewMemberNotifyEnabled()) {
130 addExtraRegistrationColumns(', `bonus_rallye_enable_notify`, `bonus_rallye_disable_notify`');
131 $GLOBALS['register_sql_data'] .= ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()';
134 // Return filter data
135 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
136 //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=<pre>'.print_r($filterData,TRUE).'</pre>';
140 // Filter for sending out bonus rallye notifications
141 function FILTER_SEND_BONUS_NOTIFICATIONS ($filterData) {
142 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!');
143 // Check for bonus rallye is active and send mails out
144 if ((isBonusRallyeActive()) && (isBonusNewMemberNotifyEnabled())) {
145 // Include file for sending out mails
146 addIncludeToPool('notify', 'inc/mails/bonus_mails.php');
149 // Return filter data
150 //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
151 //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=<pre>'.print_r($filterData,TRUE).'</pre>';
155 // Filter to add exclusion SQL for configured userid
156 function FILTER_EXLCUDE_BONUS_USERID ($filterData = array()) {
158 if (isValidId(getBonusUserid())) {
160 array_push($filterData, '{?bonus_userid?}');