]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Renamed function, used more "pool functions":
[mailer.git] / inc / mysql-manager.php
index a242cd01c9238c28fa06393ffd5a767d3ce6cf41..28ba603cfe196063e7e2302e87b53ce23212ba87 100644 (file)
@@ -901,8 +901,26 @@ function getPaymentTitlePrice ($paymentsId, $full = FALSE) {
        return $ret;
 }
 
+// Get payment price
+function getPaymentPrice ($paymentsId) {
+       // Return result
+       return getPaymentData($paymentsId, 'price');
+}
+
+// Get payment time
+function getPaymentTime ($paymentsId) {
+       // Return result
+       return getPaymentData($paymentsId, 'time');
+}
+
+// Get payment 'payment'
+function getPaymentPayment ($paymentsId) {
+       // Return result
+       return getPaymentData($paymentsId, 'payment');
+}
+
 // "Getter" for payment data (cached)
-function getPaymentData ($paymentsId, $lookFor = 'price') {
+function getPaymentData ($paymentsId, $lookFor) {
        // Default value...
        $data[$lookFor] = NULL;
 
@@ -980,8 +998,7 @@ function removeReceiver (&$receivers, $key, $userid, $poolId, $statsId = 0, $isB
                                // Update 'mails_sent' if ext-sql_patches is updated
                                if (isExtensionInstalledAndNewer('sql_patches', '0.7.4')) {
                                        // Update the pool
-                                       SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1',
-                                               array(bigintval($poolId)), __FUNCTION__, __LINE__);
+                                       updatePoolDataById($poolId, 'mails_sent', 1, '+');
                                } // END - if
                                $ret = 'done';
                        } else {
@@ -1471,15 +1488,15 @@ function deleteUserAccount ($userid, $reason) {
 
        // Search for the points and user data
        $result = SQL_QUERY_ESC("SELECT
-       (SUM(p.`points`) - d.`used_points`) AS `points`
+       (SUM(`p`.`points`) - `d`.`used_points`) AS `points`
 FROM
        `{?_MYSQL_PREFIX?}_user_points` AS `p`
 LEFT JOIN
        `{?_MYSQL_PREFIX?}_user_data` AS `d`
 ON
-       p.`userid`=d.`userid`
+       `p`.`userid`=`d`.`userid`
 WHERE
-       p.`userid`=%s
+       `p`.`userid`=%s
 LIMIT 1",
                array(bigintval($userid)), __FUNCTION__, __LINE__);
 
@@ -1762,23 +1779,33 @@ function generateReceiverList ($categoryId, $receiver, $mode = '') {
        // Category given?
        if (isValidId($categoryId)) {
                // Select category
-               $extraColumns  = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS c ON d.`userid`=c.`userid`";
-               $addWhere = sprintf(" AND c.`cat_id`=%s", $categoryId);
+               $extraColumns  = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS `c` ON `d`.`userid`=`c`.`userid`";
+               $addWhere = sprintf(" AND `c`.`cat_id`=%s", $categoryId);
        } // END - if
 
        // Exclude users in holiday?
        if (isExtensionInstalledAndNewer('holiday', '0.1.3')) {
                // Add something for the holiday extension
-               $addWhere .= " AND d.`holiday_active`='N'";
+               $addWhere .= " AND `d`.`holiday_active`='N'";
        } // END - if
 
        // Include only HTML recipients?
        if ((isExtensionActive('html_mail')) && ($mode == 'html')) {
-               $addWhere .= " AND d.`html`='Y'";
+               $addWhere .= " AND `d`.`html`='Y'";
        } // END - if
 
        // Run query
-       $result = SQL_QUERY_ESC("SELECT d.`userid` FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$extraColumns." WHERE d.`status`='CONFIRMED' ".$addWhere." ORDER BY d.`{?order_select?}` {?order_mode?} LIMIT %s",
+       $result = SQL_QUERY_ESC("SELECT
+       `d`.`userid`
+FROM
+       `{?_MYSQL_PREFIX?}_user_data` AS `d`
+       " . $extraColumns . "
+WHERE
+       `d`.`status`='CONFIRMED'
+       " . $addWhere . "
+ORDER BY
+       `d`.`{?order_select?}` {?order_mode?}
+LIMIT %s",
                array(
                        $receiver
                ), __FUNCTION__, __LINE__);
@@ -1864,7 +1891,7 @@ function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId =
                ), __FUNCTION__, __LINE__, TRUE, $strip);
 
        // Return insert id which is the task id
-       return SQL_INSERTID();
+       return SQL_INSERT_ID();
 }
 
 // Updates last module / online time
@@ -2101,14 +2128,14 @@ function doGenericAddEntries ($tableName, $columns = array(), $filterFunctions =
                SQL_QUERY($sql, __FUNCTION__, __LINE__);
 
                // Add id number
-               setPostRequestElement('id', SQL_INSERTID());
+               setPostRequestElement('id', SQL_INSERT_ID());
 
                // Prepare filter data array
                $filterData = array(
                        'mode'          => 'add',
                        'table_name'    => $tableName,
                        'content'       => postRequestArray(),
-                       'id'            => SQL_INSERTID(),
+                       'id'            => SQL_INSERT_ID(),
                        'subject'       => '',
                        // @TODO Used generic 'userid' here
                        'userid_column' => array('userid'),
@@ -2441,40 +2468,6 @@ function doGenericListBuilder ($prefix, $listType, $tableName, $columns, $filter
        );
 }
 
-// Checks whether given URL is blacklisted
-function isUrlBlacklisted ($url) {
-       // Mark it as not listed by default
-       $listed = FALSE;
-
-       // Is black-listing enbaled?
-       if (!isUrlBlacklistEnabled()) {
-               // No, then all URLs are not in this list
-               return FALSE;
-       } elseif (!isset($GLOBALS['blacklist_data'][$url])) {
-               // Check black-list for given URL
-               $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`timestamp`) AS `blist_timestamp` FROM `{?_MYSQL_PREFIX?}_url_blacklist` WHERE `url`='%s' LIMIT 1",
-                       array($url), __FILE__, __LINE__);
-
-               // Is there an entry?
-               if (SQL_NUMROWS($result) == 1) {
-                       // Jupp, we got one listed
-                       $GLOBALS['blacklist_data'][$url] = SQL_FETCHARRAY($result);
-
-                       // Mark it as listed
-                       $listed = TRUE;
-               } // END - if
-
-               // Free result
-               SQL_FREERESULT($result);
-       } else {
-               // Is found in cache -> black-listed
-               $listed = TRUE;
-       }
-
-       // Return result
-       return $listed;
-}
-
 // Adds key/value pair to a working SQL string together
 function addKeyValueSql ($key, $value) {
        // Init SQL