|
From: Benjamin C. <bc...@us...> - 2002-01-25 15:10:13
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv21799
Modified Files:
bug.php
Log Message:
Starting on the bug voting
Index: bug.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/bug.php,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- bug.php 2002/01/23 14:25:24 1.73
+++ bug.php 2002/01/25 15:10:10 1.74
@@ -25,6 +25,36 @@
include 'include.php';
///
+/// Add a vote to a bug to (possibly) promote it
+function vote_bug($bug_id) {
+ global $u, $q, $now, $_pv, $STRING;
+
+ // Check to see if the user already voted on this bug
+ if ($q->grab_field("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bug_id and user_id = $u")) {
+ show_bug($bug_id, array('vote' => $STRING['already_voted']));
+ return;
+ }
+ // Check whether the user has used his allotment of votes (if there is a max)
+ if (MAX_USER_VOTES and $q->grab_field("select count(*) from ".TBL_BUG_VOTE." where user_id = $u") > MAX_USER_VOTES) {
+ show_bug($bug_id, array('vote' => $STRING['too_many_votes']));
+ return;
+ }
+
+ // Record the vote
+ $q->query("insert into ".TBL_BUG_VOTE." (user_id, bug_id, created_date) values ($u, $bug_id, $now)");
+
+ // If a number of votes are required to promote a bug, check for promotion
+ if (PROMOTE_VOTES and $q->grab_field("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bug_id") > PROMOTE_VOTES) {
+ $status_id = $q->grab_field("select status_id from ".TBL_STATUS." where status_name = 'New'");
+ $buginfo = $q->grab("select * from ".TBL_BUG." where bug_id = $bug_id");
+ $changedfields = array('status_id' => $status_id);
+ do_changedfields($u, $buginfo, $changedfields);
+ }
+ header("Location: bug.php?op=show&bugid=$bug_id&pos={$_pv['pos']}");
+
+}
+
+///
/// Beautify the bug comments
function format_comments($comments) {
global $me;
|