Renamed ifSqlHasZeroNums() to ifSqlHasZeroNumRows() and improved some queries.
[mailer.git] / inc / filter / user_filter.php
index 150568dbdf752c33a940066e0f893581f1a2ff18..e9eec0aca4d5e5ff1272b20f1a6161534d1460cd 100644 (file)
@@ -16,7 +16,7 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2012 by Mailer Developer Team                   *
+ * 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 *
  * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -131,7 +131,7 @@ function FILTER_TESTER_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) {
 
        // Return filter data
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
 
        // Return filter data
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
-       //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=<pre>'.print_r($filterData,true).'</pre>';
+       //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=<pre>'.print_r($filterData,TRUE).'</pre>';
        return $filterData;
 }
 
        return $filterData;
 }
 
@@ -153,7 +153,7 @@ function FILTER_HANDLE_USER_SUBID ($filterData) {
 
        // Return filter data
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
 
        // Return filter data
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Done!');
-       //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=<pre>'.print_r($filterData,true).'</pre>';
+       //* NOISY-DEBUG: */ print __FUNCTION__.':filterData=<pre>'.print_r($filterData,TRUE).'</pre>';
        return $filterData;
 }
 
        return $filterData;
 }
 
@@ -175,28 +175,31 @@ function FILTER_SUBID_USER_REGISTRATION_ADD_SQL_COLUMNS ($filterData) {
 
 // Generic filter for updating referral counter of currently detected referral id
 function FILTER_GENERIC_UPDATE_USER_REFERRAL ($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
        // Make sure the referral id is detected
-       assert(isReferralIdValid());
+       assert(isValidReferralId());
 
        // Update ref counter, determineReferralId() must already be called before this filter is executed
 
        // Update ref counter, determineReferralId() must already be called before this filter is executed
-       SQL_QUERY('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`={%pipe,getReferralId%} LIMIT 1', __FUNCTION__, __LINE__);
+       sqlQuery('UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `ref_clicks`=`ref_clicks`+1 WHERE `userid`={%pipe,getReferralId%} LIMIT 1', __FUNCTION__, __LINE__);
 
        // Return filter data
 
        // 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
        return $filterData;
 }
 
 // Filter for updating sub id records
 function FILTER_UPDATE_USER_SUBID ($filterData) {
        // Make sure the referral id is detected
-       assert(isReferralIdValid());
+       assert(isValidReferralId());
 
        // Get sub id and secure it
 
        // Get sub id and secure it
-       $subId = SQL_ESCAPE(getRequestElement('subid'));
+       $subId = sqlEscapeString(getRequestElement('subid'));
 
        // Is the sub id available and registered with referral id?
 
        // Is the sub id available and registered with referral id?
-       if (countSumTotalData(getReferralId(), 'user_subids', 'id', 'userid', true, sprintf(" AND `subid`='%s'", $subId)) == 1) {
+       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
                // Sub id is assigned to referral id, so add a record
-               SQL_QUERY_ESC("INSERT INTO
+               sqlQueryEscaped("INSERT INTO
        `{?_MYSQL_PREFIX?}_subid_log`
 (
        `refid`,
        `{?_MYSQL_PREFIX?}_subid_log`
 (
        `refid`,
@@ -212,12 +215,12 @@ function FILTER_UPDATE_USER_SUBID ($filterData) {
        '{%%pipe,detectUserAgent%%}'
 )",
                        array(
        '{%%pipe,detectUserAgent%%}'
 )",
                        array(
-                               // @NOTE: SQL_QUERY_ESC() already escape it, don't use $subId here
+                               // @NOTE: sqlQueryEscaped() already escape it, don't use $subId here
                                getRequestElement('subid')
                        ), __FUNCTION__, __LINE__);
 
                // Add insert id for other filters
                                getRequestElement('subid')
                        ), __FUNCTION__, __LINE__);
 
                // Add insert id for other filters
-               $filterData['insert_id'] = SQL_INSERTID();
+               $filterData['insert_id'] = getSqlInsertId();
 
                // Register sub id in filter
                setSession('subid', $subId);
 
                // Register sub id in filter
                setSession('subid', $subId);
@@ -247,24 +250,24 @@ function FILTER_MEMBER_REFLINK_USER_SUBIDS_CONTENT ($content = '') {
        // Does the current user have sub ids?
        if (getTotalMemberSubIds() > 0) {
                // Then Load all
        // Does the current user have sub ids?
        if (getTotalMemberSubIds() > 0) {
                // Then Load all
-               $result = SQL_QUERY_ESC('SELECT `id`, `subid` FROM `{?_MYSQL_PREFIX?}_user_subids` WHERE `userid`=%s ORDER BY `subid` ASC',
+               $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
                        array(getMemberId()), __FUNCTION__, __LINE__);
 
                // There should be entries left
-               assert(!SQL_HASZERONUMS($result));
+               assert(!ifSqlHasZeroNumRows($result));
 
                // Load all
                $out = '';
 
                // Load all
                $out = '';
-               while ($row = SQL_FETCHARRAY($result)) {
+               while ($row = sqlFetchArray($result)) {
                        // Load row template
                        // Load row template
-                       $out .= loadTemplate('member_list_reflink_user_subids_row', true, $row);
+                       $out .= loadTemplate('member_list_reflink_user_subids_row', TRUE, $row);
                } // END - while
 
                // Load main template
                } // END - while
 
                // Load main template
-               $content .= loadTemplate('member_list_reflink_user_subids', true, $out);
+               $content .= loadTemplate('member_list_reflink_user_subids', TRUE, $out);
 
                // Free result
 
                // Free result
-               SQL_FREERESULT($result);
+               sqlFreeResult($result);
        } // END - if
 
        // Return data
        } // END - if
 
        // Return data
@@ -272,5 +275,25 @@ function FILTER_MEMBER_REFLINK_USER_SUBIDS_CONTENT ($content = '') {
        return $content;
 }
 
        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]
 ?>
 // [EOF]
 ?>