X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffilter%2Fuser_filter.php;h=e9eec0aca4d5e5ff1272b20f1a6161534d1460cd;hp=d0b8cdc5c4dbe760f484fc7ea0f11aa1a8e9dd78;hb=49acdb7a7adbcf25a8e8683b5581bfcec72b23bd;hpb=adb05fb6876bdca84e73f4ea04998c1400e2cfb7 diff --git a/inc/filter/user_filter.php b/inc/filter/user_filter.php index d0b8cdc5c4..e9eec0aca4 100644 --- a/inc/filter/user_filter.php +++ b/inc/filter/user_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 - 2015 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,12 +41,258 @@ if (!defined('__SECURITY')) { } // END - if // Filter for returning given user's points -function FILTER_USER_POINTS ($data) { +function FILTER_USER_POINTS ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + // Get the points and add them to the existing - $data['points'] += countSumTotalData($content['userid'], 'user_points', 'points'); + $filterData['points'] += countSumTotalData($filterData['userid'], 'user_points', 'points'); + + // Return the data for next filter + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Filter for returning given user's locked points +function FILTER_LOCKED_USER_POINTS ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Get the points and add them to the existing + $filterData['points'] += countSumTotalData($filterData['userid'], 'user_points', 'locked_points'); + + // Return the data for next filter + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Filter for returning all user points column names +function FILTER_GET_ALL_USER_POINTS_COLUMN_NAMES ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + // Add 'points' and 'locked_points' + $filterData['columns'] .= $filterData['alias'] . 'points' . $filterData['separator'] . $filterData['alias'] . 'locked_points' . $filterData['separator']; + + // Return the data for next filter + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Filter for excluding tester users in WHERE statements +function FILTER_TESTER_USER_EXCLUSION_SQL ($sql) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called! - sql(' . strlen($sql) . ')=' . $sql); + + /* + * Allow testers to be included? Do only this when you only want to test + * it, normally you don't want these accounts being included everywhere. + */ + if (ifTesterAccountsAllowed()) { + // Do not exclude tester accounts + return $sql; + } // END - if + + // Add it, as of this filter is registered only with ext-user >= 0.5.0 + if (empty($sql)) { + // Add WHERE + $sql = " WHERE `surname` NOT LIKE '{?tester_user_surname_prefix?}%%'"; + } else { + // Add AND + $sql .= " AND `surname` NOT LIKE '{?tester_user_surname_prefix?}%%'"; + } // Return the data for next filter - return $data; + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done! - sql(' . strlen($sql) . ')=' . $sql); + return $sql; +} + +// Filter for including tester users in WHERE statements +function FILTER_TESTER_USER_INCLUSION_SQL ($sql) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called! - sql(' . strlen($sql) . ')=' . $sql); + // Add it, as of this filter is registered only with ext-user >= 0.5.0 + if (empty($sql)) { + // Add WHERE + $sql = " WHERE `surname` LIKE '{?tester_user_surname_prefix?}%%'"; + } else { + // Add AND + $sql .= " AND `surname` LIKE '{?tester_user_surname_prefix?}%%'"; + } + + // Return the data for next filter + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done! - sql(' . strlen($sql) . ')=' . $sql); + return $sql; +} + +// Filter to add SQL columns to user registration +function FILTER_TESTER_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Does the admin create a tester account? + if ((isAdmin()) && (isTesterUserName(postRequestElement('surname')))) { + // Yes, these accounts never needs confirmation (you can still test it by creating a usual account). + setPostRequestElement('status', 'CONFIRMED'); + } // END - if + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=
'.print_r($filterData,TRUE).'
'; + return $filterData; +} + +// Filter to add 'converting' SQL statements +function FILTER_ADD_USER_DATA_CONVERT_SQL_COLUMNS ($sql) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called! - sql(' . strlen($sql) . ')=' . $sql); + + // Add it + $sql .= ', UNIX_TIMESTAMP(`lock_timestamp`) AS `lock_timestamp`'; + + // Return the data for next filter + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done! - sql(' . strlen($sql) . ')=' . $sql); + return $sql; +} + +// Filter for handling user subids (called by referral link) +function FILTER_HANDLE_USER_SUBID ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=
'.print_r($filterData,TRUE).'
'; + return $filterData; +} + +// Filter for adding SQL columns on user registration for subid +function FILTER_SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Is the sub id set in session? + if (isSessionVariableSet('subid')) { + // Okay, add subid here + addExtraRegistrationColumns(', `subid`'); + addExtraRegistrationData(", '" . getSession('subid') . "'"); + } // END - if + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Generic filter for updating referral counter of currently detected referral id +function FILTER_GENERIC_UPDATE_USER_REFERRAL ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Make sure the referral id is detected + assert(isValidReferralId()); + + // Update ref counter, determineReferralId() must already be called before this filter is executed + sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`={%pipe,getReferralId%} LIMIT 1', __FUNCTION__, __LINE__); + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Filter for updating sub id records +function FILTER_UPDATE_USER_SUBID ($filterData) { + // Make sure the referral id is detected + assert(isValidReferralId()); + + // Get sub id and secure it + $subId = sqlEscapeString(getRequestElement('subid')); + + // Is the sub id available and registered with referral id? + if (countSumTotalData(getReferralId(), 'user_subids', 'id', 'userid', TRUE, sprintf(" AND `subid`='%s'", $subId)) == 1) { + // Sub id is assigned to referral id, so add a record + sqlQueryEscaped("INSERT INTO + `{?_MYSQL_PREFIX?}_subid_log` +( + `refid`, + `subid`, + `referral_url`, + `remote_address`, + `user_agent` +) VALUES ( + {%%pipe,getReferralId%%}, + '%s', + '{%%pipe,detectReferer%%}', + '{%%pipe,detectRemoteAddr%%}', + '{%%pipe,detectUserAgent%%}' +)", + array( + // @NOTE: sqlQueryEscaped() already escape it, don't use $subId here + getRequestElement('subid') + ), __FUNCTION__, __LINE__); + + // Add insert id for other filters + $filterData['insert_id'] = getSqlInsertId(); + + // Register sub id in filter + setSession('subid', $subId); + } // END - if + + // Return filter data + return $filterData; +} + +// Filter for adding member action +function FILTER_ADD_USER_SUBID_MEMBER_ACTION ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + // Add entry + array_push($filterData, 'list_user_subid'); + + // Return data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Filter for rendering content for sub id listing in what=reflinks +function FILTER_MEMBER_REFLINK_USER_SUBIDS_CONTENT ($content = '') { + // Do this only for members + assert(isMember()); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Does the current user have sub ids? + if (getTotalMemberSubIds() > 0) { + // Then Load all + $result = sqlQueryEscaped('SELECT `id`, `subid` FROM `{?_MYSQL_PREFIX?}_user_subids` WHERE `userid`=%s ORDER BY `subid` ASC', + array(getMemberId()), __FUNCTION__, __LINE__); + + // There should be entries left + assert(!ifSqlHasZeroNumRows($result)); + + // Load all + $out = ''; + while ($row = sqlFetchArray($result)) { + // Load row template + $out .= loadTemplate('member_list_reflink_user_subids_row', TRUE, $row); + } // END - while + + // Load main template + $content .= loadTemplate('member_list_reflink_user_subids', TRUE, $out); + + // Free result + sqlFreeResult($result); + } // END - if + + // Return data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $content; +} + +// Filter for generic user login +// @TODO 0% done +function FILTER_GENERIC_USER_LOGIN ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; +} + +// Filter for generic user login check +// @TODO 0% done +function FILTER_GENERIC_USER_LOGIN_CHECK ($filterData) { + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Called!'); + + // Return filter data + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!'); + return $filterData; } // [EOF]