From 95e4c4762316c2de4fe49380bbefe28aedd1a757 Mon Sep 17 00:00:00 2001
From: aydreeihn <adriane@enhancesoft.com>
Date: Tue, 26 Jun 2018 16:35:12 -0500
Subject: [PATCH] Issue: Dumping Tickets From User View

This commit fixes an issue with how we export tickets from a specific User. Since changes were made to how Ticket exports are done, we needed to modify the call to export the Tickets from users.php as well since we were unintentionally sending the file name in where the csv headers should've been (variable added in dumpTickets method).
---
 include/class.export.php | 4 ++++
 scp/users.php            | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/class.export.php b/include/class.export.php
index 3a47bcc94..1cf4d9bf4 100644
--- a/include/class.export.php
+++ b/include/class.export.php
@@ -57,6 +57,10 @@ class Export {
             $fields[$key] = $f;
             $cdata[$key] = $f->getLocal('label');
         }
+
+        if (!is_array($target))
+          $target = CustomQueue::getExportableFields() + $cdata;
+
         // Reset the $sql query
         $tickets = $sql->models()
             ->select_related('user', 'user__default_email', 'dept', 'staff',
diff --git a/scp/users.php b/scp/users.php
index 047d0f91c..a905981fd 100644
--- a/scp/users.php
+++ b/scp/users.php
@@ -184,7 +184,7 @@ if ($user ) {
         } elseif ($_REQUEST['a'] == 'export' && ($query=$_SESSION[':U:tickets'])) {
             $filename = sprintf('%s-tickets-%s.csv',
                     $user->getName(), strftime('%Y%m%d'));
-            if (!Export::saveTickets($query, $filename, 'csv'))
+            if (!Export::saveTickets($query, '', $filename, 'csv'))
                 $errors['err'] = __('Unable to dump query results.')
                     .' '.__('Internal error occurred');
         }
-- 
GitLab