r304: Added tab navigation system.
[bugdar.git] / vote.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 define('SVN', '$Id$');
14
15 $focus['showreport'] = 'focus';
16
17 require_once('./global.php');
18
19 // ###################################################################
20
21 if (empty($_REQUEST['do']))
22 {
23 $message->error(lang::p('error_invalid_id'));
24 }
25
26 // ###################################################################
27
28 if ($_REQUEST['do'] == 'vote')
29 {
30 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid']) . ((!can_perform('canviewhidden')) ? " AND !bug.hidden" : ''));
31 $vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX . "vote WHERE bugid = $bug[bugid]");
32
33 if (!$bug)
34 {
35 $message->error(lang::p('error_invalid_id'));
36 }
37
38 if ($vote['uservote'])
39 {
40 $message->error('you have already voted on this bug');
41 }
42
43 // handle userids
44 $userids = $vote['userids'];
45 if ($bugsys->userinfo['userid'])
46 {
47 if (trim($vote['userids']))
48 {
49 $userids .= ',' . $bugsys->userinfo['userid'];
50 }
51 else
52 {
53 $userids = $bugsys->userinfo['userid'];
54 }
55 }
56
57 $uservote = intval($bugsys->in['vote']);
58
59 $votefor = $vote['votefor'];
60 $voteagainst = $vote['voteagainst'];
61
62 if ($uservote > 0)
63 {
64 $votefor++;
65 }
66 else
67 {
68 $voteagainst++;
69 }
70
71 $db->query("UPDATE " . TABLE_PREFIX . "vote SET userids = '$userids', votefor = $votefor, voteagainst = $voteagainst WHERE bugid = $bug[bugid]");
72
73 $message->redirect('your vote has been added', "showreport.php?bugid=$bug[bugid]");
74 }
75
76 /*=====================================================================*\
77 || ###################################################################
78 || # $HeadURL$
79 || # $Id$
80 || ###################################################################
81 \*=====================================================================*/
82 ?>