From 6d128b575b65c8ba8f2943cdb69320ca1dad8688 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 11 Dec 2006 03:18:42 +0000 Subject: [PATCH] r1359: Added the saved searches manager to the options screen --- templates/userctrl.tpl | 16 +++++++++++++- templates/userctrl_search.tpl | 7 ++++++ userctrl.php | 41 +++++++++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 templates/userctrl_search.tpl diff --git a/templates/userctrl.tpl b/templates/userctrl.tpl index 1434996..f9422ee 100644 --- a/templates/userctrl.tpl +++ b/templates/userctrl.tpl @@ -138,7 +138,21 @@ $header - + + +
+ + + +
+
{@"Saved Searches"}
+ +
+ $searches +
+
+ +
diff --git a/templates/userctrl_search.tpl b/templates/userctrl_search.tpl new file mode 100644 index 0000000..ed36292 --- /dev/null +++ b/templates/userctrl_search.tpl @@ -0,0 +1,7 @@ +
+ $search[name] + + [{@"Run Search"}] + [{@"Delete"}] + +
\ No newline at end of file diff --git a/userctrl.php b/userctrl.php index 4592b02..a22e191 100644 --- a/userctrl.php +++ b/userctrl.php @@ -21,7 +21,8 @@ $fetchtemplates = array( 'userctrl', - 'userctrl_column' + 'userctrl_column', + 'userctrl_search' ); define('SVN', '$Id$'); @@ -54,6 +55,34 @@ if (empty($_REQUEST['do'])) // ################################################################### +if ($_POST['do'] == 'killsearch') +{ + $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->error_permission(); + } + + $db->query("DELETE FROM " . TABLE_PREFIX . "search WHERE searchid = " . $bugsys->in['searchid']); + + $message->redirect(_('This saved search has been removed from your list.'), 'userctrl.php'); +} + +// ################################################################### + +if ($_REQUEST['do'] == 'deletesearch') +{ + $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->error_permission(); + } + + $message->confirm(_('Are you sure you want to delete this saved search?'), 'userctrl.php', 'killsearch', _('Delete'), _('Cancel'), array('searchid' => $bugsys->in['searchid'])); +} + +// ################################################################### + if ($_POST['do'] == 'update') { // ------------------------------------------------------------------- @@ -253,7 +282,15 @@ if ($_REQUEST['do'] == 'modify') eval('$columnOptions .= "' . $template->fetch('userctrl_column') . '";'); } } - + + // searches + $searches = ''; + $searchesFetch = $db->query("SELECT * FROM " . TABLE_PREFIX . "search WHERE name IS NOT NULL AND userid = " . $bugsys->userinfo['userid']); + while ($search = $db->fetch_array($searchesFetch)) + { + eval('$searches .= "' . $template->fetch('userctrl_search') . '";'); + } + eval('$template->flush("' . $template->fetch('userctrl') . '");'); } -- 2.43.5