From 8e3a082563fb3b2c89a554faee088a8151af58a0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 2 Jul 2005 18:01:42 +0000 Subject: [PATCH] r279: - Added favourites system - Can search for favourite bugs - If no sort is specified in search.php, then use default (blank) - Made it so that custom select_single fields only are searched if they are set in the variable scope - Fixed a SQL error that would occur if you specified a sort --- docs/roadmap.txt | 1 - docs/schema_changes.sql | 6 +++++ docs/todo.txt | 1 - favourite.php | 55 ++++++++++++++++++++++++++++++++++++++++ search.php | 22 ++++++++++++---- showreport.php | 3 +++ templates/SHOWREPORT.tpl | 2 +- templates/search.tpl | 2 ++ 8 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 favourite.php diff --git a/docs/roadmap.txt b/docs/roadmap.txt index 0d8e7e9..b355a2a 100755 --- a/docs/roadmap.txt +++ b/docs/roadmap.txt @@ -10,7 +10,6 @@ BUGTRACK 1.0 ---------------------------------------- - Voting system - Complete phrase tool system for administrators -- Favourite bugs/watchers - Dependency graph (?) ---------------------------------------- diff --git a/docs/schema_changes.sql b/docs/schema_changes.sql index 9de1d44..313eebb 100644 --- a/docs/schema_changes.sql +++ b/docs/schema_changes.sql @@ -1,2 +1,8 @@ ## SVN $Id$ +CREATE TABLE `favourite` ( + `userid` INT(10) UNSIGNED NOT NULL, + `bugid` INT(10) UNSIGNED NOT NULL +); + +ALTER TABLE `favourite` ADD PRIMARY KEY (`userid`,`bugid`); \ No newline at end of file diff --git a/docs/todo.txt b/docs/todo.txt index 900a108..7682ad5 100755 --- a/docs/todo.txt +++ b/docs/todo.txt @@ -19,7 +19,6 @@ BUGTRACK 1.0 - Make summary field longer - When displaying a bug, show dependency and relation trees - Make it so that you can modify bug fields on showreport.php -- Ability to have a list of bug favourites/watched bugs ---------------------------------------- BUG REPORTING/EDITING diff --git a/favourite.php b/favourite.php new file mode 100644 index 0000000..bbad2e2 --- /dev/null +++ b/favourite.php @@ -0,0 +1,55 @@ +userinfo['userid']) +{ + $message->error_permission(); +} + +// ################################################################### + +if (empty($_REQUEST['do'])) +{ + $message->error(lang::p('error_invalid_id')); +} + +// ################################################################### + +if ($_REQUEST['do'] == 'handle') +{ + $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid']) . ((!can_perform('canviewhidden')) ? " AND !bug.hidden" : '')); + if (!$bug) + { + $message->error(lang::p('error_invalid_id')); + } + + if ($db->query_first("SELECT * FROM " . TABLE_PREFIX . "favourite WHERE userid = " . $bugsys->userinfo['userid'] . " AND bugid = " . intval($bugsys->in['bugid']))) + { + $db->query("DELETE FROM " . TABLE_PREFIX . "favourite WHERE userid = " . $bugsys->userinfo['userid'] . " AND bugid = " . intval($bugsys->in['bugid'])); + $message->redirect('Favourite removed', "showreport.php?bugid=" . intval($bugsys->in['bugid'])); + } + else + { + $db->query("INSERT INTO " . TABLE_PREFIX . "favourite (userid, bugid) VALUES (" . $bugsys->userinfo['userid'] . ", " . intval($bugsys->in['bugid']) . ")"); + $message->redirect('Favourite added', "showreport.php?bugid=" . intval($bugsys->in['bugid'])); + } +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file diff --git a/search.php b/search.php index 876eeae..5b39df1 100644 --- a/search.php +++ b/search.php @@ -152,6 +152,18 @@ if ($_REQUEST['do'] == 'results') $querybuild['date'] = "AND bug.dateline >= $dateline"; } + // ------------------------------------------------------------------- + // favourites + if ($bugsys->in['favourite'] AND $bugsys->userinfo['userid']) + { + $favourites = $db->query("SELECT * FROM " . TABLE_PREFIX . "favourite WHERE userid = " . $bugsys->userinfo['userid']); + while ($favourite = $db->fetch_array($favourites)) + { + $ids[] = $favourite['bugid']; + } + $querybuild['favourites'] = "AND bug.bugid IN (" . implode(', ', $ids) . ")"; + } + // ------------------------------------------------------------------- // sort by $sortby = array('bugid', 'severity', 'priority', 'status', 'resolution', 'dateline'); @@ -167,7 +179,7 @@ if ($_REQUEST['do'] == 'results') } else { - $message->error('bad sort'); + $sortclause = ''; } // ------------------------------------------------------------------- @@ -183,7 +195,7 @@ if ($_REQUEST['do'] == 'results') ); while ($field = $bugsys->db->fetch_array($fields_fetch)) { - if (!empty($bugsys->in['custom']["$field[fieldid]"]) OR $field['type'] == 'select_single') + if (!empty($bugsys->in['custom']["$field[fieldid]"]) OR ($field['type'] == 'select_single' AND isset($bugsys->in['custom']["$field[fieldid]"]))) { if ($field['type'] == 'input_checkbox') { @@ -224,11 +236,11 @@ if ($_REQUEST['do'] == 'results') LEFT JOIN " . TABLE_PREFIX . "bugvaluefill AS bugfieldvalue ON (bug.bugid = bugfieldvalue.bugid) WHERE bug.bugid <> 0 - " . implode("\n\t\t\t", $querybuild) . ((!can_perform('canviewhidden')) ? " + " . implode("\n\t\t", $querybuild) . ((!can_perform('canviewhidden')) ? " AND !bug.hidden AND !comment.hidden" : "") . " - $sortclause - GROUP BY bug.bugid" + GROUP BY bug.bugid + $sortclause" ); $numrows = $db->num_rows($search); diff --git a/showreport.php b/showreport.php index 7a0f77a..1c2d89a 100644 --- a/showreport.php +++ b/showreport.php @@ -80,6 +80,9 @@ if ($bug['dependency']) $dependencies = implode(' ', $depends); } +$favourite = (bool)$db->query_first("SELECT * FROM " . TABLE_PREFIX . "favourite WHERE bugid = $bug[bugid] AND userid = " . $bugsys->userinfo['userid']); +$favouritetext = (($favourite) ? 'Remove from Favourites' : 'Add to Favourites'); + // ------------------------------------------------------------------- // custom fields $customfields = ''; diff --git a/templates/SHOWREPORT.tpl b/templates/SHOWREPORT.tpl index 700f960..021a3a9 100644 --- a/templates/SHOWREPORT.tpl +++ b/templates/SHOWREPORT.tpl @@ -14,7 +14,7 @@ $customfields -
[Show Bug History] [Edit Bug Report]
+
[Show Bug History] [Edit Bug Report] [$favouritetext]

diff --git a/templates/search.tpl b/templates/search.tpl index 8de23e6..49ce6f7 100644 --- a/templates/search.tpl +++ b/templates/search.tpl @@ -12,6 +12,8 @@
Reporter:
+
Favourite
+
Severity:
Priority:
Status:
-- 2.22.5