]> src.bluestatic.org Git - bugdar.git/blob - favorite.php
We were hitting an infinite loop with isso_pre_parse_hook
[bugdar.git] / favorite.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright ©2002-2007 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 define('SVN', '$Id$');
23
24 if (empty($_REQUEST['do']))
25 {
26 $_REQUEST['do'] = 'manage';
27 }
28
29 $focus[ ($_REQUEST['do'] == 'handle' ? 'showreport' : 'favorites') ] = 'focus';
30
31 $fetchtemplates = array(
32 'favorites',
33 'trackerhome_bits',
34 'list_head'
35 );
36
37 require_once('./global.php');
38 require_once('./includes/class_sort.php');
39
40 // ###################################################################
41
42 if ($_REQUEST['do'] == 'handle')
43 {
44 $bugsys->input_clean('bugid', TYPE_UINT);
45 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . $bugsys->in['bugid']);
46 if (!check_bug_permissions($bug))
47 {
48 $message->errorPermission();
49 }
50
51 if (!can_perform('cansubscribe', $bug['product']))
52 {
53 $message->errorPermission();
54 }
55
56 if ($db->query_first("SELECT * FROM " . TABLE_PREFIX . "favorite WHERE userid = " . bugdar::$userinfo['userid'] . " AND bugid = " . $bugsys->in['bugid']))
57 {
58 $db->query("DELETE FROM " . TABLE_PREFIX . "favorite WHERE userid = " . bugdar::$userinfo['userid'] . " AND bugid = " . $bugsys->in['bugid']);
59 $message->redirect(T('This bug has been removed from your favorites list.'), "showreport.php?bugid=" . $bugsys->in['bugid']);
60 }
61 else
62 {
63 $db->query("INSERT INTO " . TABLE_PREFIX . "favorite (userid, bugid) VALUES (" . bugdar::$userinfo['userid'] . ", " . $bugsys->in['bugid'] . ")");
64 $message->redirect(T('This bug has been added to your favorites list.'), "showreport.php?bugid=" . $bugsys->in['bugid']);
65 }
66 }
67
68 // ###################################################################
69
70 if ($_REQUEST['do'] == 'manage')
71 {
72 if (!can_perform('canviewbugs'))
73 {
74 $message->errorPermission();
75 }
76
77 $favorites = $db->query("
78 SELECT favorite.bugid, bug.* FROM " . TABLE_PREFIX . "favorite AS favorite
79 RIGHT JOIN " . TABLE_PREFIX . "bug AS bug
80 ON (favorite.bugid = bug.bugid)
81 WHERE favorite.userid = " . bugdar::$userinfo['userid'] . "
82 AND (!bug.hidden OR (bug.hidden AND bug.product IN (" . fetch_on_bits('canviewhidden') . "))" . (can_perform('canviewownhidden') ? " OR (bug.hidden AND bug.userid = " . bugdar::$userinfo['userid'] . " AND bug.product IN (" . fetch_on_bits('canviewownhidden') . "))" : "") . ")
83 ");
84
85 if ($db->num_rows($favorites) < 1)
86 {
87 $message->error(T('You do not have any favorites in your list. To add a bug to your list, while viewing the report, click the [Add to Favorites] link next to the bug\'s ID.'));
88 }
89
90 $sort = new ListSorter('favorite');
91
92 $headers = $sort->constructColumnHeaders(false);
93
94 foreach ($favorites as $bug)
95 {
96 BSFunctions::swap_css_classes('altcolor', '');
97 $bug = ProcessBugDataForDisplay($bug, BSFunctions::$cssClass);
98 $bugs .= $sort->constructRow($bug);
99 }
100
101 eval('$template->flush("' . $template->fetch('favorites') . '");');
102 }
103
104 /*=====================================================================*\
105 || ###################################################################
106 || # $HeadURL$
107 || # $Id$
108 || ###################################################################
109 \*=====================================================================*/
110 ?>