]>
src.bluestatic.org Git - bugdar.git/blob - vote.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2002-2007 Blue Static
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.
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
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 \*=====================================================================*/
23 $focus [ 'showreport' ] = 'focus' ;
25 require_once ( './global.php' );
27 // ###################################################################
29 if ( empty ( $_REQUEST [ 'do' ]))
31 $message- > error ( L_INVALID_ID
);
34 // ###################################################################
36 if ( $_REQUEST [ 'do' ] == 'vote' )
38 $bug = $db- > query_first ( "SELECT * FROM " . TABLE_PREFIX
. "bug WHERE bugid = " . $bugsys- > input_clean ( 'bugid' , TYPE_UINT
));
39 $vote = $db- > query_first ( "SELECT *, FIND_IN_SET(" . $bugsys- > userinfo
[ 'userid' ] . ", userids) AS uservote FROM " . TABLE_PREFIX
. "vote WHERE bugid = $bug [bugid]" );
41 if (! check_bug_permissions ( $bug ))
43 $message- > errorPermission ();
46 if (! can_perform ( 'canvote' , $bug [ 'product' ]))
48 $message- > errorPermission ();
53 $message- > error ( L_INVALID_ID
);
56 if ( $vote [ 'uservote' ])
58 $message- > error ( T ( 'You have already voted on this bug.' ));
62 $userids = $vote [ 'userids' ];
63 if ( $bugsys- > userinfo
[ 'userid' ])
65 if ( trim ( $vote [ 'userids' ]))
67 $userids .= ',' . $bugsys- > userinfo
[ 'userid' ];
71 $userids = $bugsys- > userinfo
[ 'userid' ];
75 $uservote = $bugsys- > input_clean ( 'vote' , TYPE_INT
);
77 $votefor = $vote [ 'votefor' ];
78 $voteagainst = $vote [ 'voteagainst' ];
84 else if ( $uservote < 0 )
90 $message- > error ( T ( 'You need to specify whether you want to vote for or against this bug.' ));
93 $db- > query ( "UPDATE " . TABLE_PREFIX
. "vote SET userids = ' $userids' , votefor = $votefor , voteagainst = $voteagainst WHERE bugid = $bug [bugid]" );
95 $message- > redirect ( T ( 'Your vote has been added.' ), "showreport.php?bugid= $bug [bugid]" );