r765: Say hello to the GPL
[bugdar.git] / favourite.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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 [#]gpl[#] 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 $focus['showreport'] = 'focus';
25
26 require_once('./global.php');
27
28 // ###################################################################
29
30 if (empty($_REQUEST['do']))
31 {
32 $message->error($lang->getlex('error_invalid_id'));
33 }
34
35 // ###################################################################
36
37 if ($_REQUEST['do'] == 'handle')
38 {
39 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid']));
40 if (!$bug OR (!can_perform('canviewhidden', $bug['productid']) AND $bug['hidden']))
41 {
42 $message->error($lang->getlex('error_invalid_id'));
43 }
44
45 if (!can_perform('cansubscribe', $bug['productid']) OR !can_perform('canviewbugs', $bug['productid']))
46 {
47 $message->error_permission();
48 }
49
50 if ($db->query_first("SELECT * FROM " . TABLE_PREFIX . "favourite WHERE userid = " . $bugsys->userinfo['userid'] . " AND bugid = " . intval($bugsys->in['bugid'])))
51 {
52 $db->query("DELETE FROM " . TABLE_PREFIX . "favourite WHERE userid = " . $bugsys->userinfo['userid'] . " AND bugid = " . intval($bugsys->in['bugid']));
53 $message->redirect($lang->string('This bug has been removed from your favourites list.'), "showreport.php?bugid=" . intval($bugsys->in['bugid']));
54 }
55 else
56 {
57 $db->query("INSERT INTO " . TABLE_PREFIX . "favourite (userid, bugid) VALUES (" . $bugsys->userinfo['userid'] . ", " . intval($bugsys->in['bugid']) . ")");
58 $message->redirect($lang->string('This bug has been added to your favourites list.'), "showreport.php?bugid=" . intval($bugsys->in['bugid']));
59 }
60 }
61
62 /*=====================================================================*\
63 || ###################################################################
64 || # $HeadURL$
65 || # $Id$
66 || ###################################################################
67 \*=====================================================================*/
68 ?>