From aa2dc850772e23b185b3f8cf483193eeeecc5b9f Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Wed, 13 May 2015 10:29:04 -0500
Subject: [PATCH] Make ticket queue selection sticky

If navigating back to the ticket queue (after closing a ticket, for
instance), return to the queue previously viewed.
---
 include/staff/tickets.inc.php |  3 +++
 scp/tickets.php               | 11 +++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/include/staff/tickets.inc.php b/include/staff/tickets.inc.php
index 4db119a23..6a30ac094 100644
--- a/include/staff/tickets.inc.php
+++ b/include/staff/tickets.inc.php
@@ -57,6 +57,9 @@ switch(strtolower($_REQUEST['status'])){ //Status is overloaded
         }
 }
 
+// Stash current queue view
+$_SESSION['::Q'] = $_REQUEST['status'];
+
 $qwhere ='';
 /*
    STRICT DEPARTMENTS BASED PERMISSION!
diff --git a/scp/tickets.php b/scp/tickets.php
index 873b99480..8b46034ea 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -36,9 +36,12 @@ if($_REQUEST['id']) {
 }
 
 //Lookup user if id is available.
-if ($_REQUEST['uid'])
+if ($_REQUEST['uid']) {
     $user = User::lookup($_REQUEST['uid']);
-
+}
+elseif (!isset($_REQUEST['status']) && isset($_SESSION['::Q'])) {
+    $_REQUEST['status'] = $_SESSION['::Q'];
+}
 // Configure form for file uploads
 $response_form = new Form(array(
     'attachments' => new FileUploadField(array('id'=>'attach',
@@ -385,7 +388,7 @@ $open_name = _P('queue-name',
 if($cfg->showAnsweredTickets()) {
     $nav->addSubMenu(array('desc'=>$open_name.' ('.number_format($stats['open']+$stats['answered']).')',
                             'title'=>__('Open Tickets'),
-                            'href'=>'tickets.php',
+                            'href'=>'tickets.php?status=open',
                             'iconclass'=>'Ticket'),
                         (!$_REQUEST['status'] || $_REQUEST['status']=='open'));
 } else {
@@ -394,7 +397,7 @@ if($cfg->showAnsweredTickets()) {
 
         $nav->addSubMenu(array('desc'=>$open_name.' ('.number_format($stats['open']).')',
                                'title'=>__('Open Tickets'),
-                               'href'=>'tickets.php',
+                               'href'=>'tickets.php?status=open',
                                'iconclass'=>'Ticket'),
                             (!$_REQUEST['status'] || $_REQUEST['status']=='open'));
     }
-- 
GitLab