_binary From abb0ab2aa5d1f493744ba4f36bb8a52bdc0a8ab2 Mon Sep 17 00:00:00 2001
From: epinapala <epinapala@ebay.com>
Date: Fri, 14 Nov 2014 16:10:14 -0800
Subject: [PATCH] * Fixes issue with machinestatus not updating when help open 
 is triggered. * Fixes issue with Cookie params showing up in the back url.

---
 views/helpers/helpbutton_helper.php | 11 ++++++++---
 views/layouts/web_layout.php        |  3 ++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/views/helpers/helpbutton_helper.php b/views/helpers/helpbutton_helper.php
index 519f01e..817d3c0 100644
--- a/views/helpers/helpbutton_helper.php
+++ b/views/helpers/helpbutton_helper.php
@@ -126,8 +126,13 @@ class HelpbuttonHelper extends Helper
             'wiki_view_read :"' . tl('wiki_view_read') . '"' .
             "}";
         $this->backParams = "{";
-        $back_params_array = array_diff_key($_REQUEST, array_flip(
-            array("a", "c", "u", "p", CSRF_TOKEN, "open_help_page")
+        /**
+         * Use all the GET params to fille the back_params attr
+         * this ensures that the user can come back to the exact same url
+         * he originated from.
+         */
+        $back_params_array = array_diff_key($_GET, array_flip(
+            array("a", "c", CSRF_TOKEN, "open_help_page")
         ));
         array_walk($back_params_array, array($this, 'clean'));
         $back_params_only_keys = array_keys($back_params_array);
@@ -135,7 +140,7 @@ class HelpbuttonHelper extends Helper
         foreach($back_params_array as $key => $value) {
             $this->backParams .= $key . ' : "' . $value . '"';
             if($key != $last_key) {
-                $this->backParams .= ',';
+                $this->backParams .= ', ';
             }
         }
         $this->backParams .= "}";
diff --git a/views/layouts/web_layout.php b/views/layouts/web_layout.php
index 396860b..1668e77 100755
--- a/views/layouts/web_layout.php
+++ b/views/layouts/web_layout.php
@@ -245,7 +245,8 @@ class WebLayout extends Layout
             if(!isset($data['SCRIPT'])) {
                 $data['SCRIPT'] = "";
             }
-            $data['SCRIPT'] .= $this->view->helper('helpbutton')->script;
+            $data['SCRIPT'] = $this->view->helper('helpbutton')->script .
+                   $data['SCRIPT'];
         }
         if(isset($data['INCLUDE_SCRIPTS'])) {
             foreach($data['INCLUDE_SCRIPTS'] as $script_name) {
-- 
2.1.2

