Some code moved
authorRoland Häder <roland@mxchange.org>
Thu, 5 Nov 2009 16:08:01 +0000 (16:08 +0000)
committerRoland Häder <roland@mxchange.org>
Thu, 5 Nov 2009 16:08:01 +0000 (16:08 +0000)
inc/libs/rallye_functions.php

index 331687e..22ddd6c 100644 (file)
@@ -321,6 +321,7 @@ LIMIT 1", __FUNCTION__, __LINE__);
        if (SQL_NUMROWS($result) == 1) {
                // Init variables
                $min_users = '0'; $min_prices = '0';
+
                // Load data
                if (getExtensionVersion('rallye') >= '0.2.0') {
                        list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result);
@@ -331,21 +332,6 @@ LIMIT 1", __FUNCTION__, __LINE__);
                // Free result
                SQL_FREERESULT($result);
 
-               // Check if line is already included...
-               $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `rallye_id`=%s AND `userid`=%s LIMIT 1",
-                       array(bigintval($id), bigintval($userid)), __FUNCTION__, __LINE__);
-
-               // Is this user added?
-               if (SQL_NUMROWS($result) == '0') {
-                       // Add userid and his ref count to table
-                       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_rallye_users` (`rallye_id`, `userid`, `refs`)
-VALUES ('%s','%s',0)",
-                       array(bigintval($id), bigintval($userid)), __FUNCTION__, __LINE__);
-               } // END - if
-
-               // Free memory
-               SQL_FREERESULT($result);
-
                if ($notify == 'Y') {
                        // Transfer all neccessary data to the global $content array
                        $content['start'] = generateDateTime($start, 2);
@@ -367,6 +353,27 @@ VALUES ('%s','%s',0)",
                        $message = loadEmailTemplate('member_rallye_notify', $content, $userid);
                        sendEmail($userid, sprintf(getMessage('RALLYE_MEMBER_NOTIFY'), $title), $message);
                } // END - if
+
+               // Check if line is already included...
+               $result = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_rallye_users` WHERE `rallye_id`=%s AND `userid`=%s LIMIT 1",
+                       array(
+                               bigintval($id),
+                               bigintval($userid)
+                       ), __FUNCTION__, __LINE__);
+
+               // Is this user added?
+               if (SQL_NUMROWS($result) < 1) {
+                       // Add userid and his ref count to table
+                       SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_rallye_users` (`rallye_id`, `userid`, `refs`)
+VALUES ('%s','%s',0)",
+                               array(
+                                       bigintval($id),
+                                       bigintval($userid)
+                               ), __FUNCTION__, __LINE__);
+               } // END - if
+
+               // Free memory
+               SQL_FREERESULT($result);
        } // END - if
 }