r303: Added SVN constant to user files; now ISSO debug information shows SVN details.
[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 require_once('./global.php');
16
17 // ###################################################################
18
19 if (empty($_REQUEST['do']))
20 {
21 $message->error(lang::p('error_invalid_id'));
22 }
23
24 // ###################################################################
25
26 if ($_REQUEST['do'] == 'vote')
27 {
28 $bug = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE bugid = " . intval($bugsys->in['bugid']) . ((!can_perform('canviewhidden')) ? " AND !bug.hidden" : ''));
29 $vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX . "vote WHERE bugid = $bug[bugid]");
30
31 if (!$bug)
32 {
33 $message->error(lang::p('error_invalid_id'));
34 }
35
36 if ($vote['uservote'])
37 {
38 $message->error('you have already voted on this bug');
39 }
40
41 // handle userids
42 $userids = $vote['userids'];
43 if ($bugsys->userinfo['userid'])
44 {
45 if (trim($vote['userids']))
46 {
47 $userids .= ',' . $bugsys->userinfo['userid'];
48 }
49 else
50 {
51 $userids = $bugsys->userinfo['userid'];
52 }
53 }
54
55 $uservote = intval($bugsys->in['vote']);
56
57 $votefor = $vote['votefor'];
58 $voteagainst = $vote['voteagainst'];
59
60 if ($uservote > 0)
61 {
62 $votefor++;
63 }
64 else
65 {
66 $voteagainst++;
67 }
68
69 $db->query("UPDATE " . TABLE_PREFIX . "vote SET userids = '$userids', votefor = $votefor, voteagainst = $voteagainst WHERE bugid = $bug[bugid]");
70
71 $message->redirect('your vote has been added', "showreport.php?bugid=$bug[bugid]");
72 }
73
74 /*=====================================================================*\
75 || ###################################################################
76 || # $HeadURL$
77 || # $Id$
78 || ###################################################################
79 \*=====================================================================*/
80 ?>