]> git.mxchange.org Git - mailer.git/blobdiff - inc/filter/earning_filter.php
Disallow subtraction on unsigned columns:
[mailer.git] / inc / filter / earning_filter.php
index 8efff96a8ceb0378ddb6322eef8f42e6bd234c75..1125cf1c3ad78e50622d951bcb63901b88e55bf0 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 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 *
@@ -46,49 +46,57 @@ function FILTER_ADD_EARNING_GROUP_POPUP ($filterData) {
        // Check if the current userid is same as in $filterData
        if (getMemberId() != $filterData['userid']) {
                // Not the same
-               debug_report_bug(__FUNCTION__, __LINE__, 'Validation of userid failed. ' . getMemberId() . '!=' . $filterData['userid']);
+               reportBug(__FUNCTION__, __LINE__, 'Validation of userid failed. ' . getMemberId() . '!=' . $filterData['userid']);
        } // END - if
 
        // Now check if the user has subscription and amount left
-       $result = SQL_QUERY_ESC("SELECT
-       d.`earning_id`,
-       d.`earning_provider`,
-       u.`earning_current_amount`,
-       u.`earning_daily_amount`
+       $result = sqlQueryEscaped("SELECT
+       `d`.`earning_id`,
+       `d`.`earning_provider`,
+       `u`.`earning_current_amount`,
+       `u`.`earning_daily_amount`,
+       `u`.`earning_active`,
+       `u`.`earning_added`,
+       `u`.`earning_canceled`,
+       `u`.`earning_points`
 FROM
-       `{?_MYSQL_PREFIX?}_user_earning` AS u
+       `{?_MYSQL_PREFIX?}_user_earning` AS `u`
 INNER JOIN
-       `{?_MYSQL_PREFIX?}_earning_data` AS d
+       `{?_MYSQL_PREFIX?}_earning_data` AS `d`
 ON
-       u.`earning_id`=d.`earning_id`
+       `u`.`earning_id`=`d`.`earning_id`
 WHERE
-       u.`earning_userid`=%s AND
-       u.`earning_active`='Y' AND
-       u.`earning_current_amount` < u.`earning_daily_amount` AND
-       d.`earning_group`='POPUP'
+       `u`.`earning_userid`=%s AND
+       `u`.`earning_active`='Y' AND
+       `u`.`earning_current_amount` < `u`.`earning_daily_amount` AND
+       `d`.`earning_group`='POPUP'
 ORDER BY
-       d.`earning_sorting` ASC",
+       `d`.`earning_sorting` ASC",
                array(
                        getMemberId()
                ), __FUNCTION__, __LINE__);
 
-       // Do we have entries left?
-       if (SQL_NUMROWS($result) > 0) {
+       // Are there entries left?
+       if (!ifSqlHasZeroNums($result)) {
                // Load all names
-               while ($content = SQL_FETCHARRAY($result)) {
+               while ($content = sqlFetchArray($result)) {
                        // Merge the $filterData array in
                        $content = merge_array($content, $filterData);
 
                        // Construct callback function name
                        $callbackName = 'get' . capitalizeUnderscoreString($content['earning_provider']) . 'DataByEarningArray';
 
-                       // And call it
+                       /*
+                        * And call it, the called function should NOT write data in
+                        * '__output'. This however is done here in this function. The
+                        * called function shall ALWAYS put it's data in '__data'.
+                        */
                        $content = call_user_func($callbackName, $content);
                } // END - if
        } // END - if
 
        // Free result
-       SQL_FREERESULT($result);
+       sqlFreeResult($result);
 
        // Return filter data
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');