]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Fix for missing language string and variable renamed to better naming convention
[mailer.git] / inc / mysql-manager.php
index 6a20170870348e45f93c3556d754842cf72e9459..981d6f65a75a91f1f0bb1e6cda071d0ea0014a5b 100644 (file)
@@ -522,8 +522,8 @@ function isAdmin () {
        // If admin login is not given take current from cookies...
        if ((isSessionVariableSet('admin_id')) && (isSessionVariableSet('admin_md5'))) {
                // Get admin login and password from session/cookies
-               $adminId    = getSession('admin_id');
-               $passCookie = getSession('admin_md5');
+               $adminId    = getCurrentAdminId();
+               $passCookie = getAdminMd5();
        } // END - if
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $adminId.'/'.$passCookie);
 
@@ -809,6 +809,8 @@ function getPaymentTitlePrice ($pid, $full=false) {
        // Load payment data
        $result = SQL_QUERY_ESC("SELECT `mail_title`, `price` FROM `{?_MYSQL_PREFIX?}_payments` WHERE `id`=%s LIMIT 1",
                array(bigintval($pid)), __FUNCTION__, __LINE__);
+
+       // Do we have an entry?
        if (SQL_NUMROWS($result) == 1) {
                // Payment type found... :-)
                $data = SQL_FETCHARRAY($result);
@@ -819,7 +821,7 @@ function getPaymentTitlePrice ($pid, $full=false) {
                } else {
                        $ret = $data['mail_title'] . ' / {%pipe,translateComma=' . $data['price'] . '%} {?POINTS?}';
                }
-       }
+       } // END - if
 
        // Free result
        SQL_FREERESULT($result);
@@ -851,7 +853,7 @@ function getPaymentPoints ($pid, $lookFor = 'price') {
 }
 
 // Remove a receiver's id from $receivers and add a link for him to confirm
-function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $bonus = false) {
+function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = 0, $isBonusMail = false) {
        // Default is not removed
        $ret = 'failed';
 
@@ -862,9 +864,12 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $
 
                // Is there already a line for this user available?
                if ($stats_id > 0) {
+                       // Default is 'normal' mail
+                       $type = 'NORMAL';
+                       $rowName = 'stats_id';
+
                        // Only when we got a real stats id continue searching for the entry
-                       $type = 'NORMAL'; $rowName = 'stats_id';
-                       if ($bonus) {
+                       if ($isBonusMail === true) {
                                $type = 'BONUS';
                                $rowName = 'bonus_id';
                        } // END - if
@@ -878,6 +883,13 @@ function removeReceiver (&$receivers, $key, $userid, $pool_id, $stats_id = '', $
                                // So we add one!
                                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_links` (`%s`, `userid`, `link_type`) VALUES ('%s','%s','%s')",
                                        array($rowName, $stats_id, bigintval($userid), $type), __FUNCTION__, __LINE__);
+
+                               // Update 'mails_sent' if 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($pool_id)), __FUNCTION__, __LINE__);
+                               } // END - if
                                $ret = 'done';
                        } else {
                                // Already found
@@ -1235,6 +1247,9 @@ function getAdminId ($adminLogin) {
 
 // "Getter" for current admin id
 function getCurrentAdminId () {
+       // Log debug message
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'called!');
+
        // Do we have cache?
        if (!isset($GLOBALS['current_admin_id'])) {
                // Get the admin login from session
@@ -1716,7 +1731,10 @@ function addBonusMailToQueue ($subject, $text, $receiverList, $points, $seconds,
                $HTML = 'N';
 
                // HTML mode?
-               if ($mode == 'html') $HTML = 'Y';
+               if ($mode == 'html') {
+                       // Yes, please
+                       $HTML = 'Y';
+               } // END - if
 
                // Add HTML mail
                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_bonus`