]> git.mxchange.org Git - mailer.git/blobdiff - inc/mysql-manager.php
Rewrite of language strings
[mailer.git] / inc / mysql-manager.php
index 47478a726b0105fd965cc33bbf322a4be15a19b3..c9fad71c38bd45b68868552f4ecc139b956bb10c 100644 (file)
@@ -340,7 +340,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false) {
        // Begin the navigation line
        if ((!isset($GLOBALS['nav_depth'])) && ($return === false)) {
                $GLOBALS['nav_depth'] = '0';
-               $prefix = "<div class=\"you_are_here\">{--YOU_ARE_HERE--}&nbsp;<strong><a class=\"you_are_here\" href=\"{?URL?}/modules.php?module=".getModule().$LINK_ADD."\">Home</a></strong>";
+               $prefix = "<div class=\"you_are_here\">{--YOU_ARE_HERE--}&nbsp;<strong><a class=\"you_are_here\" href=\"{%url=modules.php?module=" . getModule() . $LINK_ADD . "%}\">Home</a></strong>";
        } else {
                if ($return === false) $GLOBALS['nav_depth']++;
                $prefix = '';
@@ -356,7 +356,7 @@ function addMenuDescription ($accessLevel, $FQFN, $return = false) {
 
        if (((isExtensionInstalledAndNewer('sql_patches', '0.2.3')) && (getConfig('youre_here') == 'Y')) || ((isAdmin()) && ($modCheck == 'admin'))) {
                // Output HTML code
-               $OUT = $prefix . "<strong><a class=\"you_are_here\" href=\"{?URL?}/modules.php?module=" . $modCheck . '&amp;' . $type . '=' . $search . $LINK_ADD . "\">" . getTitleFromMenu($accessLevel, $search, $type, $ADD) . "</a></strong>\n";
+               $OUT = $prefix . "<strong><a class=\"you_are_here\" href=\"{%url=modules.php?module=" . $modCheck . '&amp;' . $type . '=' . $search . $LINK_ADD . "%}\">" . getTitleFromMenu($accessLevel, $search, $type, $ADD) . "</a></strong>\n";
 
                // Can we close the you-are-here navigation?
                //* DEBUG: */ print(__LINE__."*".$type.'/'.getWhat()."*<br />");
@@ -447,7 +447,7 @@ function addMenu ($mode, $action, $what) {
                                                } // END - if
 
                                                // Navigation link
-                                               $OUT .= "<a name=\"menu\" class=\"menu_blur\" href=\"{?URL?}/modules.php?module=".getModule()."&amp;what=".$content['sub_what']."\" target=\"_self\">";
+                                               $OUT .= "<a name=\"menu\" class=\"menu_blur\" href=\"{%url=modules.php?module=" . getModule() . '&amp;what=' . $content['sub_what'] . "%}\" target=\"_self\">";
                                        } else {
                                                // Not found! - open
                                                $OUT .= "<em style=\"cursor:help\" class=\"admin_note\" title=\"{--MENU_WHAT_404--}\">";
@@ -607,7 +607,7 @@ function isMember () {
 }
 
 // Fetch user data for given user id
-function fetchUserData ($userid, $column='userid') {
+function fetchUserData ($userid, $column = 'userid') {
        // If we should look for userid secure&set it here
        if (substr($column, -2, 2) == 'id') {
                // Secure userid
@@ -1246,7 +1246,8 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                                // Load email template
                                $message = loadEmailTemplate('confirm-referal', $content, bigintval($userid));
 
-                               sendEmail(getUserData('email'), THANX_REFERAL_ONE, $message);
+                               // Send email
+                               sendEmail($userid, getMessage('THANX_REFERAL_ONE_SUBJECT'), $message);
                        } elseif (($sendNotify) && (getUserData('refid') == '0') && ($locked === false) && ($add_mode == 'direct')) {
                                // Prepare content
                                $content = array(
@@ -1258,7 +1259,7 @@ function addPointsThroughReferalSystem ($subject, $userid, $points, $sendNotify
                                $message = loadEmailTemplate('add-points', $content, $userid);
 
                                // And sent it away
-                               sendEmail(getUserData('email'), getMessage('SUBJECT_DIRECT_PAYMENT'), $message);
+                               sendEmail($userid, getMessage('SUBJECT_DIRECT_PAYMENT'), $message);
                                if (!isGetRequestElementSet('mid')) loadTemplate('admin_settings_saved', false, getMessage('ADMIN_POINTS_ADDED'));
                        }
 
@@ -2082,21 +2083,34 @@ ORDER BY ur.refid ASC",
 // Recuce the amount of received emails for the receipients for given email
 function reduceRecipientReceivedMails ($column, $id, $count) {
        // Search for mail in database
-       $result = SQL_QUERY_ESC("SELECT `userid` FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s ORDER BY `userid` ASC LIMIT %s",
+       $result = SQL_QUERY_ESC("SELECT * FROM `{?_MYSQL_PREFIX?}_user_links` WHERE `%s`=%s ORDER BY `userid` ASC LIMIT %s",
                array($column, bigintval($id), $count), __FUNCTION__, __LINE__);
 
        // Are there entries?
        if (SQL_NUMROWS($result) > 0) {
                // Now load all userids for one big query!
-               // @TODO This can be somehow rewritten
-               $UIDs = array();
-               while (list($userid) = SQL_FETCHROW($result)) {
-                       $UIDs[$userid] = $userid;
+               $userids = array();
+               while ($data = SQL_FETCHARRAY($result)) {
+                       // By default we want to reduce and have no mails found
+                       $num = 0;
+
+                       // We must now look if he has already confirmed this mail, so might sound double, but it may resolve problems
+                       // @TODO Rewrite this to a filter
+                       if ((isset($data['stats_id'])) && ($data['stats_id'] > 0)) {
+                               // User email
+                               $num = countSumTotalData($data['userid'], 'user_stats_data', 'id', 'userid', true, sprintf(" AND `stats_type`='mailid' AND `stats_data`=%s", bigintval($data['stats_id'])));
+                       } elseif ((isset($data['bonus_id'])) && ($data['bonus_id'] > 0)) {
+                               // Bonus mail
+                               $num = countSumTotalData($data['userid'], 'user_stats_data', 'id', 'userid', true, sprintf(" AND `stats_type`='bonusid' AND `stats_data`=%s", bigintval($data['bonus_id'])));
+                       }
+
+                       // Reduce this users total received emails?
+                       if ($num === 0) $userids[$data['userid']] = $data['userid'];
                } // END - while
 
                // Now update all user accounts
                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`-1 WHERE `userid` IN (%s) LIMIT %s",
-                       array(implode(',', $UIDs), count($UIDs)), __FUNCTION__, __LINE__);
+                       array(implode(',', $userids), count($userids)), __FUNCTION__, __LINE__);
        } // END - if
 
        // Free result