X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Flibs%2Fearning_functions.php;h=fb2e847bdde2249893f324acc431e10405ce70bd;hb=6b1e55213d76a67e9aa3d9f1e4dcb55e0bbf12ee;hp=7beda4063751fa2e375e62606d0338545a498c5f;hpb=63f159414369b5ea19a8ca75d8cd8033c45d8341;p=mailer.git diff --git a/inc/libs/earning_functions.php b/inc/libs/earning_functions.php index 7beda40637..fb2e847bdd 100644 --- a/inc/libs/earning_functions.php +++ b/inc/libs/earning_functions.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * Copyright (c) 2009 - 2013 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -79,7 +79,7 @@ function generateMemberEarningDataTable ($earningProvider) { $filterData = runFilterChain('member_earning_table_data', $filterData); // Load the proper template and return it - $output = loadTemplate('member_earning_data_' . strtolower($filterData['earning_group']), true, $filterData); + $output = loadTemplate('member_earning_data_' . strtolower($filterData['earning_group']), TRUE, $filterData); // Return it return $output; @@ -87,18 +87,8 @@ function generateMemberEarningDataTable ($earningProvider) { // Handle earning id function doMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { - // Does the user already have this earning? - $result = SQL_QUERY_ESC("SELECT COUNT(`id`) AS `cnt` FROM `{?_MYSQL_PREFIX?}_user_earning` WHERE `earning_id`=%s AND `earning_userid`=%s LIMIT 1", - array( - bigintval($earningId), - getMemberId() - ), __FUNCTION__, __LINE__); - - // Get the count - list($count) = SQL_FETCHROW($result); - // Does the user have this? - if ($count == 1) { + if (countSumTotalData(bigintval($earningId), 'user_earning', 'id', 'earning_id', TRUE, ' AND `earning_userid`=' . getMemberId()) == 1) { // Then update it $status = updateMemberEarning($earningId, $dailyAmount, $isActive); } else { @@ -106,9 +96,6 @@ function doMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { $status = insertMemberEarning($earningId, $dailyAmount, $isActive); } - // Free result - SQL_FREERESULT($result); - // Return status return $status; } @@ -116,7 +103,7 @@ function doMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { // Insert member earning entry function insertMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { // Insert the record - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_earning` (`earning_id`,`earning_userid`,`earning_daily_amount`,`earning_active`) VALUES(%s,%s,%s,'%s')", + sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_earning` (`earning_id`, `earning_userid`, `earning_daily_amount`, `earning_active`) VALUES(%s,%s,%s,'%s')", array( bigintval($earningId), getMemberId(), @@ -126,7 +113,7 @@ function insertMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { // Prepare content $content = array( - 'insert_id' => SQL_INSERTID(), + 'insert_id' => getSqlInsertId(), 'earning_id' => bigintval($earningId), 'daily_amount' => bigintval($dailyAmount), 'is_active' => $isActive @@ -142,7 +129,7 @@ function insertMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { sendAdminNotification('{--ADMIN_EARNING_INSERTED_SUBJECT--}', 'admin_earning_added', $content, getMemberId()); // Return status - return ($content['insert_id'] > 0); + return isValidId($content['insert_id']); } // Update a given earning amount @@ -157,7 +144,7 @@ function updateMemberEarning ($earningId, $dailyAmount, $isActive = 'Y') { } // END - if // Update database record - SQL_QUERY_ESC("UPDATE + sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_earning` SET `earning_daily_amount`=%s, @@ -174,10 +161,10 @@ LIMIT 1", array( ), __FUNCTION__, __LINE__); // Determine whether something has changed - $status = (!SQL_HASZEROAFFECTED()); + $status = (!ifSqlHasZeroAffectedRows()); // Has the record changed? - if ($status === true) { + if ($status === TRUE) { // Prepare content $content = array( 'earning_id' => bigintval($earningId),