From c2ccb9dcb2c6440952a41761bd5312a5b9cc7e9d Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 7 Dec 2006 01:24:51 +0000 Subject: [PATCH] r1334: Allow the exporting of search results to XML format --- docs/changes.txt | 1 + search.php | 48 ++++++++++++++++++++++++++++++++++++ templates/search_results.tpl | 2 ++ 3 files changed, 51 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 6109214..6a1f2e0 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -2,6 +2,7 @@ =============================== - When a user does not have any favorites in his list, show a message instead of an empty screen - Added the ability to show all the users in a paginated list in the admin section (bug://report/55) +- Can export search results to an XML file (bug://report/41) 1.1.4 =============================== diff --git a/search.php b/search.php index 936f954..bb72ac0 100644 --- a/search.php +++ b/search.php @@ -372,6 +372,54 @@ if ($_REQUEST['do'] == 'search') // ################################################################### +if ($_REQUEST['do'] == 'export') +{ + // TODO - allow guests to use the export function too + $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE userid = " . $bugsys->userinfo['userid']); + $bugs = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid IN ($search[ids]) $search[orderby]"); + + $xml = ' + +'; + + while ($bug = $db->fetch_array($bugs)) + { + $xml .= "\n\t"; + + ProcessBugDataForDisplay(&$bug); + + $xml .= "\n\t\t" . $bug['bugid'] . ""; + $xml .= "\n\t\t" . $datef->format('r', $bug['dateline']) . ""; + if ($bug['userid']) + { + $xml .= "\n\t\t" . construct_user_display($db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = $bug[userid]"), false) . ""; + } + $xml .= "\n\t\t" . $bug['summary'] . ""; + $xml .= "\n\t\t" . $bug['product'] . ""; + if ($bug['component']) + { + $xml .= "\n\t\t" . $bug['component'] . ""; + } + $xml .= "\n\t\t" . $bug['version'] . ""; + $xml .= "\n\t\t" . $bug['status'] . ""; + if ($bug['assignedto']) + { + $xml .= "\n\t\t" . construct_user_display($bugsys->datastore['assignto']["$bug[assignedto]"], false) . ""; + } + $xml .= "\n\t\t" . $bug['resolution'] . ""; + $xml .= "\n\t\t" . $bug['severity'] . ""; + $xml .= "\n\t\t" . $bug['priority'] . ""; + + $xml .= "\n\t"; + } + + $xml .= "\n"; + + $funct->download_file($xml, _('bugdar-search-results.xml'), true); +} + +// ################################################################### + if ($_REQUEST['do'] == 'results') { $show['cached'] = false; diff --git a/templates/search_results.tpl b/templates/search_results.tpl index 8a780f6..e632f3b 100644 --- a/templates/search_results.tpl +++ b/templates/search_results.tpl @@ -27,6 +27,8 @@ $header $bugs +
{@"Export results as XML"}
+
-- 2.22.5