From b02a9debd9a723e1544568e6fc894ef21660b7b5 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 11 Dec 2006 00:14:17 +0000 Subject: [PATCH] r1356: We can now save a search! --- search.php | 55 +++++++++++++++++++++++++++++++++--- templates/search_results.tpl | 5 +++- templates/search_save.tpl | 46 ++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 templates/search_save.tpl diff --git a/search.php b/search.php index 4f3d292..70b4939 100644 --- a/search.php +++ b/search.php @@ -312,9 +312,9 @@ if ($_REQUEST['do'] == 'process') if ($_REQUEST['do'] == 'search') { - if ($bugsys->userinfo['userid'] AND !$bugsys->in['new']) + if ($bugsys->in['searchid'] AND !$bugsys->in['new']) { - if ($cachedsearch = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NULL AND userid = " . $bugsys->userinfo['userid'])) + if ($cachedsearch = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid'])) { $_POST['do'] = 'results'; $searchid = $cachedsearch['searchid']; @@ -324,9 +324,9 @@ if ($_REQUEST['do'] == 'search') $newsearch = true; } } - else if ($bugsys->in['searchid'] AND !$bugsys->in['new']) + else if ($bugsys->userinfo['userid'] AND !$bugsys->in['new']) { - if ($cachedsearch = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid'])) + if ($cachedsearch = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NULL AND userid = " . $bugsys->userinfo['userid'])) { $_POST['do'] = 'results'; $searchid = $cachedsearch['searchid']; @@ -457,6 +457,51 @@ if ($_REQUEST['do'] == 'export') // ################################################################### +if ($_POST['do'] == 'dosave') +{ + $search = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->input_clean('searchid', TYPE_UINT) . " AND userid = " . $bugsys->userinfo['userid']); + if (!$search) + { + $message->add_error(_('The search does not exist.')); + } + if ($search['name']) + { + $message->add_error(sprintf(_('This search has already been named "%1$s".'), $search['name'])); + } + if (empty($bugsys->in['name'])) + { + $message->add_error(_('The name cannot be empty.')); + } + + if (!$message->items) + { + $db->query("UPDATE " . TABLE_PREFIX . "search SET name = '" . $bugsys->input_escape('name') . "' WHERE searchid = " . $bugsys->in['searchid']); + $message->redirect(_('Your search has been saved.'), 'search.php?searchid=' . $search['searchid']); + } + else + { + $message->error_list_process(); + $_REQUEST['do'] = 'save'; + $show['errors'] = true; + } +} + +// ################################################################### + +if ($_REQUEST['do'] == 'save') +{ + if (!$bugsys->userinfo['userid']) + { + $message->error_permission(); + } + + $message- + + eval('$template->flush("' . $template->fetch('search_save') . '");'); +} + +// ################################################################### + if ($_POST['do'] == 'results') { $show['cached'] = false; @@ -484,6 +529,8 @@ if ($_POST['do'] == 'results') $sort = new ListSorter('search'); + $show['save'] = ($bugsys->userinfo['userid'] AND !$search['name']); + $bugs = ''; $search = $db->query("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid IN ($search[ids]) $search[orderby] LIMIT " . $pagination->fetchLimit($pagination->getPage() - 1) . ", " . $pagination->getPerPage()); while ($bug = $db->fetch_array($search)) diff --git a/templates/search_results.tpl b/templates/search_results.tpl index 7b11a82..b99c4f6 100644 --- a/templates/search_results.tpl +++ b/templates/search_results.tpl @@ -22,7 +22,10 @@ $columnHeads $bugs -
{@"Export results as XML"}
+
+ [{@"Export results as XML"}] + [{@"Save Search"}] +
diff --git a/templates/search_save.tpl b/templates/search_save.tpl new file mode 100644 index 0000000..c781056 --- /dev/null +++ b/templates/search_save.tpl @@ -0,0 +1,46 @@ +$doctype + + +$headinclude + + {$bugsys->options['trackertitle']} - {@"Save Search"} + + + + +$header + + +
+ {@"The following errors occurred"}: + {$message->process} +
+
+ +
+ + + +
+
+
{@"Save Search"}
+ +
+ {@"You can save this search criteria for later by naming this search."} + +
+
+ +
{@"Name"}:
+
+ +
+ + +
+
+
+ +
+ +$footer \ No newline at end of file -- 2.43.5