CONFIRM_SUCCESS_MOD should only be set for new accounts

Change-Id: Ifd4074289c962ca1abf152fed81c279598071b71
Signed-off-by: Christopher Guindon <chris.guindon@eclipse.org>
diff --git a/eclipse.org-common/classes/users/siteLogin.class.php b/eclipse.org-common/classes/users/siteLogin.class.php
index df21dc0..cf788b8 100644
--- a/eclipse.org-common/classes/users/siteLogin.class.php
+++ b/eclipse.org-common/classes/users/siteLogin.class.php
@@ -452,7 +452,7 @@
     }
     else {
       if ($this->t != "") {
-        $sql = "SELECT /* USE MASTER */ email, fname, lname, COUNT(1) AS RecordCount FROM account_requests WHERE token = " . $this->App->returnQuotedString($this->App->sqlSanitize($this->t));
+        $sql = "SELECT /* USE MASTER */ email, fname, password, lname, COUNT(1) AS RecordCount FROM account_requests WHERE token = " . $this->App->returnQuotedString($this->App->sqlSanitize($this->t));
         $rs = $this->App->eclipse_sql($sql);
         $myrow = mysql_fetch_assoc($rs);
         if ($myrow['RecordCount'] <= 0) {
@@ -476,38 +476,45 @@
           $EventLog->insertModLog("apache");
         }
         else {
+          // New accounts will always have a value in $myrow['password'].
+          $token_confirm = 'CONFIRM_SUCCESS_MOD';
+          if (empty($myrow['password'])) {
+            $token_confirm = 'CONFIRM_SUCCESS';
+          }
           # Update this row, change IP address to reflect that of the person who successfully confirmed this email to avoid bombing
-          $sql = "UPDATE account_requests SET token = 'CONFIRM_SUCCESS_MOD', ip = " . $this->App->returnQuotedString($this->App->sqlSanitize($_SERVER['REMOTE_ADDR']))
+          $sql = "UPDATE account_requests SET token = ". $this->App->returnQuotedString($this->App->sqlSanitize($token_confirm)) .", ip = " . $this->App->returnQuotedString($this->App->sqlSanitize($_SERVER['REMOTE_ADDR']))
           . " WHERE token = " . $this->App->returnQuotedString($this->App->sqlSanitize($this->t));
           $rs = $this->App->eclipse_sql($sql);
-/*
-          $this->messages['confirm']['success'][] = "Thank you for confirming your email address.
-          Your Eclipse.org account is now active and you may now </strong>log in</strong></a>.
-          Please note that some Eclipse.org pages may require you to provide your login
-          credentials.";
-*/
-          $this->messages['confirm']['success'][] = "Thank you for confirming your email address.
-          Your Eclipse.org account is under moderation and it can take up to few days before it's approved.";
 
-          # Send mail to webmaster
-          $mail = "Dear webmaster,\n\n";
-          $mail .= "A new eclipse.org account was confirmed and is ready for review:\n\n";
-          $mail .= "Email: " . $myrow['email'] . "\n\n";
-          $mail .= "First name: " . $myrow['fname'] . "\n\n";
-          $mail .= "Last name: " . $myrow['lname'] . "\n\n";
-          // add profile info if a record was found.
-          if ($this->_get_profile_from_token($this->t)) {
-             $mail .= "Organization: " . $this->organization. "\n\n";
-             $mail .= "Country: " . $this->country. "\n\n";
-             $mail .= "Gender: " . $this->gender. "\n\n";
-             $mail .= "Remote addr: " . $_SERVER['REMOTE_ADDR'] . "\n\n";
-             $mail .= "Browser: " . $_SERVER['HTTP_USER_AGENT'] . "\n\n";
-             $mail .= "Referer: " . $_SERVER['HTTP_REFERER'] . "\n\n";
+          if ($token_confirm === 'CONFIRM_SUCCESS') {
+            $this->messages['confirm']['success'][] = "Thank you for confirming your email address.
+            Your Eclipse.org account is now active and you may now </strong>log in</strong></a>.
+            Please note that some Eclipse.org pages may require you to provide your login
+            credentials.";
           }
-          $mail .= " -- Eclipse webdev\n";
-          $headers = 'From: Eclipse Webmaster (automated) <webmaster@eclipse.org>' . "\n" . 'Content-Type: text/plain; charset=UTF-8';
-          mail('webmaster@eclipse.org', "New account request (Moderation)", $mail, $headers);
+          else {
+            $this->messages['confirm']['success'][] = "Thank you for confirming your email address.
+            Your Eclipse.org account is under moderation and it can take up to few days before it's approved.";
 
+            # Send mail to webmaster
+            $mail = "Dear webmaster,\n\n";
+            $mail .= "A new eclipse.org account was confirmed and is ready for review:\n\n";
+            $mail .= "Email: " . $myrow['email'] . "\n\n";
+            $mail .= "First name: " . $myrow['fname'] . "\n\n";
+            $mail .= "Last name: " . $myrow['lname'] . "\n\n";
+            // add profile info if a record was found.
+            if ($this->_get_profile_from_token($this->t)) {
+               $mail .= "Organization: " . $this->organization. "\n\n";
+               $mail .= "Country: " . $this->country. "\n\n";
+               $mail .= "Gender: " . $this->gender. "\n\n";
+               $mail .= "Remote addr: " . $_SERVER['REMOTE_ADDR'] . "\n\n";
+               $mail .= "Browser: " . $_SERVER['HTTP_USER_AGENT'] . "\n\n";
+               $mail .= "Referer: " . $_SERVER['HTTP_REFERER'] . "\n\n";
+            }
+            $mail .= " -- Eclipse webdev\n";
+            $headers = 'From: Eclipse Webmaster (automated) <webmaster@eclipse.org>' . "\n" . 'Content-Type: text/plain; charset=UTF-8';
+            mail('webmaster@eclipse.org', "New account request (Moderation)", $mail, $headers);
+          }
           $EventLog = new EvtLog();
           $EventLog->setLogTable("__ldap");
           $EventLog->setPK1($this->App->sqlSanitize($this->t));