Infra 2090 - Fix for takemeback on login menu item

Change-Id: Iacc4b9226a2b87365ce0a4318805b4291b150c5c
Signed-off-by: Eric Poirier <eric@eclipse.org>
diff --git a/eclipse.org-common/classes/themes/baseTheme.class.php b/eclipse.org-common/classes/themes/baseTheme.class.php
index d7fc113..084f923 100644
--- a/eclipse.org-common/classes/themes/baseTheme.class.php
+++ b/eclipse.org-common/classes/themes/baseTheme.class.php
@@ -1728,6 +1728,27 @@
   }
 
   /**
+   * Returns a Take me back
+   *
+   * @return string
+   */
+  private function _getTakeMeBack() {
+
+    $path = parse_url($this->App->getCurrentURL(), PHP_URL_PATH);
+    if (substr($path, 0, 1) == "/") {
+      $path = substr($path, 1);
+    }
+
+    // Check to see if URI already contains a takemeback
+    if (strpos($path, '?takemeback=')) {
+      // Return only the value of takemeback
+      return "?takemeback=" . preg_replace('/(.+)?takemeback=/', "", $path);
+    }
+
+    return "?takemeback=" . $this->getBaseUrl() . $path;
+  }
+
+  /**
    * Get $ession_variables
    *
    * @param string $id
@@ -1744,7 +1765,7 @@
       $Session = $this->_getSession();
       $Friend = $Session->getFriend();
       $this->session_variables['create_account_link'] = '<a href="' . $this->getBaseUrlLogin() . '/site_login/createaccount.php"><i class="fa fa-user fa-fw"></i> Create account</a>';
-      $this->session_variables['my_account_link'] = '<a href="' . $this->getBaseUrlLogin() . '/site_login/?takemeback=' . $this->getBaseUrl() . $_SERVER['REQUEST_URI'] . '"><i class="fa fa-sign-in fa-fw"></i> Log in</a>';
+      $this->session_variables['my_account_link'] = '<a href="' . $this->getBaseUrlLogin() . '/site_login/' . $this->_getTakeMeBack() . '"><i class="fa fa-sign-in fa-fw"></i> Log in</a>';
       $this->session_variables['logout'] = '';
 
       if ($Session->isLoggedIn()) {
diff --git a/eclipse.org-common/classes/users/siteLogin.class.php b/eclipse.org-common/classes/users/siteLogin.class.php
index 10e5992..9533891 100644
--- a/eclipse.org-common/classes/users/siteLogin.class.php
+++ b/eclipse.org-common/classes/users/siteLogin.class.php
@@ -1332,7 +1332,7 @@
       $this->takemeback = "https://" . $matches[1];
     }
 
-  if (preg_match('#^https?://dev.eclipse.org/#', $this->takemeback) && !preg_match('#^https?://dev.eclipse.org/site_login/myaccount.php#', $this->takemeback)){
+    if (preg_match('#^https?://dev.eclipse.org/#', $this->takemeback) && !preg_match('#^https?://dev.eclipse.org/site_login/myaccount.php#', $this->takemeback)){
       $this->takemeback = "";
     }
     if (!$this->validateTakemebackUrl()) {
diff --git a/eclipse.org-common/system/app.class.php b/eclipse.org-common/system/app.class.php
index 77b017d..757e6c2 100644
--- a/eclipse.org-common/system/app.class.php
+++ b/eclipse.org-common/system/app.class.php
@@ -575,7 +575,9 @@
         'eclipse.org',
         'staging.eclipse.org',
         'eclipse.local',
-        'www.eclipse.local'
+        'www.eclipse.local',
+        'dev.eclipse.local',
+        'dev.eclipse.org'
       );
       $http_protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? 'https://' : 'http://';
       // Force http://www.eclipse.org if the serve_name is not whitelisted.