X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffilter%2Fbonus_filter.php;h=4a09b2449147c361a0710c7351f2fd40cff75eaa;hb=a524135c24dd0a8fa359c9a92399467d50fd69e0;hp=5faccd7cb23669996c6d5b85697a57ad45248511;hpb=2e394cb5b8a6225a39a6942b1fcc17c37a17a175;p=mailer.git diff --git a/inc/filter/bonus_filter.php b/inc/filter/bonus_filter.php index 5faccd7cb2..4a09b24491 100644 --- a/inc/filter/bonus_filter.php +++ b/inc/filter/bonus_filter.php @@ -16,8 +16,8 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2011 by Mailer Developer Team * - * For more information visit: http://www.mxchange.org * + * Copyright (c) 2009 - 2016 by Mailer Developer Team * + * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -41,19 +41,20 @@ if (!defined('__SECURITY')) { } // END - if // Filter for adding login bonus to the user's account -function FILTER_ADD_LOGIN_BONUS () { +function FILTER_ADD_LOGIN_BONUS ($filterData) { // Is the user data valid? + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); if (!isMember()) { // Do only run for logged in members - debug_report_bug(__FUNCTION__, __LINE__, 'Please only run this filter for logged in users.'); + reportBug(__FUNCTION__, __LINE__, 'Please only run this filter for logged in users.'); } // END - if // Bonus is not given by default ;-) - $bonus = false; - if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (isBonusRallyeActive()) && (getConfig('bonus_login_yn') == 'Y')) { + $bonus = FALSE; + if ((isExtensionInstalledAndNewer('sql_patches', '0.2.8')) && (isBonusRallyeActive()) && (isIncludeBonusLoginEnabled())) { // Update last login if far enougth away // @TODO This query isn't right, it will only update if the user was for a longer time away! - SQL_QUERY_ESC('UPDATE + sqlQueryEscaped('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `last_login`=UNIX_TIMESTAMP() @@ -67,16 +68,100 @@ LIMIT 1', ); // Updated entry? - $bonus = (!SQL_HASZEROAFFECTED()); + $bonus = (!ifSqlHasZeroAffectedRows()); } // END - if - if (($bonus === true) && (getRequestParameter('mode') == 'bonus')) { + if (($bonus === TRUE) && (getRequestElement('do') == 'bonus')) { // Output message with added points $GLOBALS['message'] .= '
{--MEMBER_BONUS_LOGIN_BONUS_ADDED--}
'; } else { // No login bonus added! $GLOBALS['message'] .= '
{--MEMBER_BONUS_LOGIN_BONUS_NOT_ADDED--}
'; } + + // Return data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Filter for generating admin mail links for bonus mails +function FILTER_GENERATE_BONUS_MAIL_LINKS ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Is the type 'bonus'? + if ($filterData['type'] == 'bonus') { + // Load template + $filterData['__output'] .= loadTemplate('admin_links_bonus_mail', TRUE, $filterData); + } // END - if + + // Return data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Filter for adding bonus columns with a plus (+) sign +function FILTER_ADD_BONUS_POINTS_USER_COLUMNS ($add = '') { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Skip out-dated extension, because this causes an error + if (isExtensionInstalledAndOlder('bonus', '0.9.7')) { + // Skip this silently + return $add; + } // END - if + + // Add more columns only when the corresponding configuration is enabled, too + if (isIncludeBonusClickEnabled()) $add .= ' + `turbo_bonus`'; + if (isIncludeBonusLoginEnabled()) $add .= ' + `login_bonus`'; + if (isIncludeBonusOrderEnabled()) $add .= ' + `bonus_order`'; + if (isIncludeBonusRefEnabled() ) $add .= ' + `bonus_ref`'; + if (isIncludeBonusStatsEnabled()) $add .= ' + `bonus_stats`'; + + // Return $add + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $add; +} + +// Filter for adding SQL columns on user registration for bonus/"active" rallye notification +function FILTER_BONUS_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Next: active rallye + if (!isBonusNewMemberNotifyEnabled()) { + addExtraRegistrationColumns(', `bonus_rallye_enable_notify`, `bonus_rallye_disable_notify`'); + $GLOBALS['register_sql_data'] .= ', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()'; + } // END - if + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=
'.print_r($filterData,TRUE).'
'; + return $filterData; +} + +// Filter for sending out bonus rallye notifications +function FILTER_SEND_BONUS_NOTIFICATIONS ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + // Check for bonus rallye is active and send mails out + if ((isBonusRallyeActive()) && (isBonusNewMemberNotifyEnabled())) { + // Include file for sending out mails + addIncludeToPool('notify', 'inc/mails/bonus_mails.php'); + } // END - if + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=
'.print_r($filterData,TRUE).'
'; + return $filterData; +} + +// Filter to add exclusion SQL for configured userid +function FILTER_EXLCUDE_BONUS_USERID ($filterData = array()) { + // Is it valid? + if (isValidId(getBonusUserid())) { + // Exclude it + array_push($filterData, '{?bonus_userid?}'); + } // END - if + + // Return it + return $filterData; } // [EOF]