]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Surfbar actions will never be deleted/locked/undeleted
[mailer.git] / inc / mysql-manager.php
index 41a80d2e7df0882533fbf10348bf7bc882ff2b7f..424ac96cafa0ba4ac1697a1dbae7280ce867233d 100644 (file)
@@ -924,7 +924,7 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = 0, $i
 }
 
 // Calculate sum (default) or count records of given criteria
-function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '') {
+function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatement = 'userid', $countRows = false, $add = '', $mode = '=') {
        // Init count/sum
        $data['res'] = '0';
 
@@ -934,22 +934,40 @@ function countSumTotalData ($search, $tableName, $lookFor = 'id', $whereStatemen
                if ($countRows === true) {
                        // Count whole table
                        $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add,
-                               array($lookFor, $tableName), __FUNCTION__, __LINE__);
+                               array(
+                                       $lookFor,
+                                       $tableName
+                               ), __FUNCTION__, __LINE__);
                } else {
                        // Sum whole table
                        $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s`".$add,
-                               array($lookFor, $tableName), __FUNCTION__, __LINE__);
+                               array(
+                                       $lookFor,
+                                       $tableName
+                               ), __FUNCTION__, __LINE__);
                }
        } elseif (($countRows === true) || ($lookFor == 'userid')) {
                // Count rows
                //* DEBUG: */ debugOutput('COUNT!');
-               $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`='%s'".$add,
-                       array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
+               $result = SQL_QUERY_ESC("SELECT COUNT(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add,
+                       array(
+                               $lookFor,
+                               $tableName,
+                               $whereStatement,
+                               $mode,
+                               $search
+                       ), __FUNCTION__, __LINE__);
        } else {
                // Add all rows
                //* DEBUG: */ debugOutput('SUM!');
-               $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`='%s'".$add,
-                       array($lookFor, $tableName, $whereStatement, $search), __FUNCTION__, __LINE__);
+               $result = SQL_QUERY_ESC("SELECT SUM(`%s`) AS `res` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`%s'%s'".$add,
+                       array(
+                               $lookFor,
+                               $tableName,
+                               $whereStatement,
+                               $mode,
+                               $search
+                       ), __FUNCTION__, __LINE__);
        }
 
        // Load row
@@ -1871,31 +1889,27 @@ function generateReceiverList ($categoryId, $receiver, $mode = '') {
 function getUserReferalPoints ($userid, $level) {
        //* DEBUG: */ debugOutput('----------------------- <font color="#00aa00">'.__FUNCTION__.' - ENTRY</font> ------------------------<ul><li>');
        // Default is no refs and no nickname
-       $add = '';
        $refs = array();
 
-       // Do we have nickname extension installed?
-       if (isExtensionActive('nickname')) {
-               $add = ', ud.nickname';
-       } // END - if
-
        // Get refs from database
        $result = SQL_QUERY_ESC("SELECT
-       ur.id, ur.refid, ud.status, ud.last_online, ud.mails_confirmed, ud.emails_received".$add."
+       ur.`id`, ur.`refid`, ud.`status`, ud.`last_online`, ud.`mails_confirmed`, ud.`emails_received`
 FROM
        `{?_MYSQL_PREFIX?}_user_refs` AS ur
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_user_points` AS up
 ON
-       ur.refid=up.userid AND ur.level=0
+       ur.refid=up.userid AND
+       (ur.level=0 OR ur.level IS NULL)
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_user_data` AS ud
 ON
-       ur.refid=ud.userid
+       ur.`refid`=ud.`userid`
 WHERE
-       ur.userid=%s AND ur.level=%s
+       ur.`userid`=%s AND
+       ur.`level`=%s
 ORDER BY
-       ur.refid ASC",
+       ur.`refid` ASC",
                array(
                        bigintval($userid),
                        bigintval($level)