|
From: Benjamin C. <bc...@us...> - 2003-09-01 13:40:14
|
Update of /cvsroot/phpbt/phpbt
In directory sc8-pr-cvs1:/tmp/cvs-serv15310
Modified Files:
Tag: htmltemplates
bug.php
Log Message:
Cleaned up code and bug dependency display
Index: bug.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/bug.php,v
retrieving revision 1.134.2.1
retrieving revision 1.134.2.2
diff -u -r1.134.2.1 -r1.134.2.2
--- bug.php 30 Aug 2003 22:07:12 -0000 1.134.2.1
+++ bug.php 1 Sep 2003 13:40:09 -0000 1.134.2.2
@@ -2,7 +2,7 @@
// bug.php - All the interactions with a bug
// ------------------------------------------------------------------------
-// Copyright (c) 2001, 2002 The phpBugTracker Group
+// Copyright (c) 2001 - 2003 The phpBugTracker Group
// ------------------------------------------------------------------------
// This file is part of phpBugTracker
//
@@ -29,58 +29,49 @@
function vote_view($bug_id) {
global $u, $db, $t, $STRING;
- $t->assign('votes', $db->getAll('select login, v.created_date '.
- 'from '.TBL_AUTH_USER.' u, '.TBL_BUG_VOTE." v ".
- "where u.user_id = v.user_id and bug_id = $bug_id ".
- 'order by v.created_date'));
- $t->render('bugvotes.html', translate('Bug Votes'));
+ $t->assign('votes', $db->getAll('select login, v.created_date '.'from '.TBL_AUTH_USER.' u, '.TBL_BUG_VOTE." v where u.user_id = v.user_id and bug_id = $bug_id order by v.created_date"));
+ $t->render('bugvotes.html', translate("Bug Votes"));
}
///
/// Add a vote to a bug to (possibly) promote it
function vote_bug($bug_id) {
- global $u, $db, $now, $_pv, $STRING;
+ global $u, $db, $now;
// Check to see if the user already voted on this bug
- if ($db->getOne("select count(*) from ".TBL_BUG_VOTE.
- " where bug_id = $bug_id and user_id = $u")) {
- show_bug($bug_id, array('vote' => $STRING['already_voted']));
+ if ($db->getOne("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bug_id and user_id = $u")) {
+ show_bug($bug_id, array('vote' => translate("You have already voted for this bug")));
return;
}
// Check whether the user has used his allotment of votes (if there is a max)
- if (MAX_USER_VOTES and $db->getOne("select count(*) from ".TBL_BUG_VOTE.
- " where user_id = $u") >= MAX_USER_VOTES) {
- show_bug($bug_id, array('vote' => $STRING['too_many_votes']));
+ if (MAX_USER_VOTES and
+ $db->getOne("select count(*) from ".TBL_BUG_VOTE." where user_id = $u") >= MAX_USER_VOTES) {
+ show_bug($bug_id, array('vote' => translate("You have reached the maximum number of votes per user")));
return;
}
// Record the vote
- $db->query("insert into ".TBL_BUG_VOTE." (user_id, bug_id, created_date)
- values ($u, $bug_id, $now)");
+ $db->query("insert into ".TBL_BUG_VOTE." (user_id, bug_id, created_date) values ($u, $bug_id, $now)");
// Proceed only if promoting by votes is turned on
if (PROMOTE_VOTES) {
// Has this bug already been promoted?
- $bug_is_new = $db->getOne("select count(*) from ".TBL_BUG." b, ".
- TBL_STATUS." s where bug_id = $bug_id and b.status_id = s.status_id and
- status_name = 'New'");
+ $bug_is_new = $db->getOne("select count(*) from ".TBL_BUG." b, ".TBL_STATUS." s where bug_id = $bug_id and b.status_id = s.status_id and status_name = 'New'");
// If a number of votes are required to promote a bug, check for promotion
- if (!$bug_is_new and $db->getOne("select count(*) from ".
- TBL_BUG_VOTE." where bug_id = $bug_id") == PROMOTE_VOTES) {
+ if (!$bug_is_new and $db->getOne("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bug_id") == PROMOTE_VOTES) {
$status_id = BUG_PROMOTED;
$buginfo = $db->getOne("select * from ".TBL_BUG." where bug_id = $bug_id");
- $changedfields = array('status_id' => $status_id);
+ $changedfields = array('status_id' => $status_id);
do_changedfields($u, $buginfo, $changedfields);
}
}
- if (isset($_pv['pos'])) {
- $posinfo = "&pos={$_pv['pos']}";
+ if (isset($_POST['pos'])) {
+ $posinfo = "&pos={$_POST['pos']}";
} else {
$posinfo = '';
}
- header("Location: bug.php?op=show&bugid=$bug_id$posinfo");
-
+ header("Location: bug.php?op=show&bugid=$bug_id$posinfo");
}
///
@@ -108,18 +99,18 @@
global $db, $t, $STRING, $QUERY;
if (!is_numeric($bugid)) {
- show_text($STRING['nobughistory']);
+ show_text(translate("There is no history for this bug"));
return;
}
$t->assign('history', $db->getAll(sprintf($QUERY['bug-history'], $bugid)));
- $t->render('bughistory.html', translate('Bug History'));
+ $t->render('bughistory.html', translate("Bug History"));
}
///
/// Send the email about changes to the bug and log the changes in the DB
function do_changedfields($userid, &$buginfo, $cf = array(), $comments = '') {
- global $db, $t, $u, $select, $now, $STRING, $QUERY, $_pv;
+ global $db, $t, $u, $select, $now, $STRING, $QUERY;
// It's a new bug if the changedfields array is empty and there are no comments
$newbug = (!count($cf) and !$comments);
@@ -128,20 +119,16 @@
$template = $newbug ? "bugemail-newbug.$template_ext" : "bugemail.$template_ext";
foreach(array('title','url','priority') as $field) {
if (isset($cf[$field])) {
- $db->query('insert into '.TBL_BUG_HISTORY.
- ' (bug_id, changed_field, old_value, new_value, created_by, created_date)'.
- " values (". join(', ', array($buginfo['bug_id'], $db->quote($field),
- $db->quote(stripslashes($buginfo[$field])),
- $db->quote(stripslashes($cf[$field])), $u, $now)).")");
- $t->assign(array(
+ $db->query('insert into '.TBL_BUG_HISTORY.' (bug_id, changed_field, old_value, new_value, created_by, created_date) values ('. join(', ', array($buginfo['bug_id'], $db->quote($field), $db->quote(stripslashes($buginfo[$field])), $db->quote(stripslashes($cf[$field])), $u, $now)).")");
+ $t->assign(array(
$field => stripslashes($cf[$field]),
$field.'_stat' => '!'
- ));
+ ));
} else {
- $t->assign(array(
+ $t->assign(array(
$field => stripslashes($buginfo[$field]),
$field.'_stat' => ' '
- ));
+ ));
}
}
@@ -161,21 +148,15 @@
foreach($cfgDatabase as $field => $table) {
if (isset($buginfo[$field.'_id'])) {
- $oldvalue = $db->getOne("select ${field}_name from $table".
- " where ${field}_id = {$buginfo[$field.'_id']}");
+ $oldvalue = $db->getOne("select ${field}_name from $table"." where ${field}_id = {$buginfo[$field.'_id']}");
}
if (empty($oldvalue)) $oldvalue = 'None';
if (isset($cf[$field.'_id'])) {
- $newvalue = $db->getOne("select ${field}_name from $table".
- " where ${field}_id = {$cf[$field.'_id']}");
- if (empty($newvalue)) $newvalue = 'None';
+ $newvalue = $db->getOne("select ${field}_name from $table where ${field}_id = {$cf[$field.'_id']}");
+ if (empty($newvalue)) $newvalue = 'None';
- $db->query('insert into '.TBL_BUG_HISTORY.
- ' (bug_id, changed_field, old_value, new_value, created_by, created_date)'.
- " values (". join(', ', array($buginfo['bug_id'], $db->quote($STRING['BUGDISPLAY'][$field]),
- $db->quote(stripslashes($oldvalue)),
- $db->quote(stripslashes($newvalue)), $u, $now)).")");
+ $db->query('insert into '.TBL_BUG_HISTORY.' (bug_id, changed_field, old_value, new_value, created_by, created_date) values ('. join(', ', array($buginfo['bug_id'], $db->quote($STRING['BUGDISPLAY'][$field]), $db->quote(stripslashes($oldvalue)), $db->quote(stripslashes($newvalue)), $u, $now)).")");
$t->assign(array(
$field.'_id' => stripslashes($newvalue),
$field.'_id_stat' => '!'
@@ -194,19 +175,15 @@
foreach($versions as $field => $field_name) {
if (isset($buginfo[$field.'_id'])) {
- $oldvalue = $db->getOne('select version_name from '.$cfgDatabase['version'].
- ' where version_id = '.$buginfo[$field.'_id']);
+ $oldvalue = $db->getOne('select version_name from '.$cfgDatabase['version'].' where version_id = '.$buginfo[$field.'_id']);
}
if (empty($oldvalue)) $oldvalue = 'None';
if (isset($cf[$field.'_id'])) {
- $newvalue = $db->getOne('select version_name from '.$cfgDatabase['version'].
- ' where version_id = '.$cf[$field.'_id']);
+ $newvalue = $db->getOne('select version_name from '.$cfgDatabase['version'].' where version_id = '.$cf[$field.'_id']);
if (empty($newvalue)) $newvalue = 'None';
- $db->query('insert into '.TBL_BUG_HISTORY.
- ' (bug_id, changed_field, old_value, new_value, created_by, created_date)'.
- " values (". join(', ', array($buginfo['bug_id'], $db->quote($STRING['BUGDISPLAY'][$field_name]),
+ $db->query('insert into '.TBL_BUG_HISTORY.' (bug_id, changed_field, old_value, new_value, created_by, created_date) values ('. join(', ', array($buginfo['bug_id'], $db->quote($STRING['BUGDISPLAY'][$field_name]),
$db->quote(stripslashes($oldvalue)),
$db->quote(stripslashes($newvalue)), $u, $now)).")");
$t->assign(array(
@@ -222,41 +199,28 @@
}
// See if the assignment has changed -- grab the email for notifications either way
- list($assignedto, $emailassignedto) = $db->getRow('select email, email_notices from '.
- TBL_AUTH_USER." u, ".TBL_USER_PREF.' p where u.user_id = '.
- (!empty($cf['assigned_to']) ? $cf['assigned_to'] : $buginfo['assigned_to']).
- " and u.user_id = p.user_id", DB_FETCHMODE_ORDERED);
+ list($assignedto, $emailassignedto) = $db->getRow('select email, email_notices from '.TBL_AUTH_USER." u, ".TBL_USER_PREF.' p where u.user_id = '.(!empty($cf['assigned_to']) ? $cf['assigned_to'] : $buginfo['assigned_to'])." and u.user_id = p.user_id", DB_FETCHMODE_ORDERED);
if (!empty($cf['assigned_to'])) {
$assignedtostat = '!';
- $oldassignedto = $db->getOne('select email from '.
- TBL_AUTH_USER.' u where u.user_id = '.$buginfo['assigned_to']);
+ $oldassignedto = $db->getOne('select email from '.TBL_AUTH_USER.' u where u.user_id = '.$buginfo['assigned_to']);
if (is_null($oldassignedto)) {
$oldassignedto = '';
}
- $db->query('insert into '.TBL_BUG_HISTORY.
- ' (bug_id, changed_field, old_value, new_value, created_by, created_date)'.
- " values (". join(', ', array($buginfo['bug_id'],
- $db->quote($STRING['BUGDISPLAY']['assignedto']),
- $db->quote($oldassignedto), $db->quote($assignedto), $u, $now)).")");
+ $db->query('insert into '.TBL_BUG_HISTORY.' (bug_id, changed_field, old_value, new_value, created_by, created_date) values ('. join(', ', array($buginfo['bug_id'], $db->quote($STRING['BUGDISPLAY']['assignedto']), $db->quote($oldassignedto), $db->quote($assignedto), $u, $now)).")");
} else {
$assignedtostat = ' ';
}
- if (!empty($_pv['suppress_email'])) return; // Don't send email if silent update requested.
+ if (!empty($_POST['suppress_email'])) return; // Don't send email if silent update requested.
// Reporter never changes
- $reporter = $db->getOne('select email from '.TBL_AUTH_USER.
- " u, ".TBL_USER_PREF." p where u.user_id = {$buginfo['created_by']} ".
- "and u.user_id = p.user_id and email_notices = 1");
+ $reporter = $db->getOne('select email from '.TBL_AUTH_USER." u, ".TBL_USER_PREF." p where u.user_id = {$buginfo['created_by']} and u.user_id = p.user_id and email_notices = 1");
$reporterstat = ' ';
// If there are new comments grab the comments immediately before the latest
if ($comments or $newbug) {
- $rs = $db->limitQuery('select u.login, c.comment_text, c.created_date'.
- ' from '.TBL_COMMENT.' c, '.TBL_AUTH_USER.' u'.
- " where bug_id = {$buginfo['bug_id']} and c.created_by = u.user_id".
- ' order by created_date desc', 0, 2);
+ $rs = $db->limitQuery('select u.login, c.comment_text, c.created_date from '.TBL_COMMENT.' c, '.TBL_AUTH_USER." u where bug_id = {$buginfo['bug_id']} and c.created_by = u.user_id order by created_date desc", 0, 2);
$rs->fetchInto($row);
$t->assign(array(
'newpostedby' => $row['login'],
@@ -268,10 +232,7 @@
// If this comment is the first additional comment after the creation of the
// bug then we need to grab the bug's description as the previous comment
if ($rs->numRows() < 2) {
- list($by, $on, $comments) = $db->getRow('select u.login, b.created_date, b.description'.
- ' from '.TBL_BUG.' b, '.TBL_AUTH_USER.' u'.
- " where b.created_by = u.user_id and bug_id = {$buginfo['bug_id']}",
- null, DB_FETCHMODE_ORDERED);
+ list($by, $on, $comments) = $db->getRow('select u.login, b.created_date, b.description from '.TBL_BUG.' b, '.TBL_AUTH_USER." u where b.created_by = u.user_id and bug_id = {$buginfo['bug_id']}", null, DB_FETCHMODE_ORDERED);
$t->assign(array(
'oldpostedby' => $by,
'oldpostedon' => date(TIME_FORMAT,$on).' on '.date(DATE_FORMAT,$on),
@@ -315,7 +276,8 @@
'bugid' => $buginfo['bug_id'],
'siteroot' => INSTALL_URL,
'bugurl' => INSTALL_URL."/bug.php?op=show&bugid={$buginfo['bug_id']}",
- 'priority' => $select['priority'][(!empty($cf['priority']) ? $cf['priority'] : $buginfo['priority'])],
+ 'priority' => $select['priority'][(!empty($cf['priority'])
+ ? $cf['priority'] : $buginfo['priority'])],
'priority_stat' => !empty($cf['priority']) ? '!' : ' ',
'reporter' => $reporter,
'reporter_stat' => $reporterstat,
@@ -332,14 +294,14 @@
}
function update_bug($bugid = 0) {
- global $db, $t, $u, $STRING, $perm, $now, $_pv;
+ global $db, $t, $u, $perm, $now;
// Pull bug from database to determine changed fields and for user validation
$buginfo = $db->getRow("select * from ".TBL_BUG." where bug_id = $bugid");
$changedfields = array();
- if (isset($_pv)) {
- foreach ($_pv as $k => $v) {
+ if (isset($_POST)) {
+ foreach ($_POST as $k => $v) {
$$k = $v;
if ($k == 'url') {
if (($v == 'http://') || ($v == 'https://')) {
@@ -359,35 +321,31 @@
// Should we allow changes to be made to this bug by this user?
if (STRICT_UPDATING and !($u == $buginfo['assigned_to'] or
$u == $buginfo['created_by'] or $perm->have_perm('Manager'))) {
- show_bug($bugid,array('status' => $STRING['bugbadperm']));
+ show_bug($bugid,array('status' => translate("You can not change this bug")));
return;
}
// Check for more than one person modifying the bug at the same time
if ($last_modified_date != $buginfo['last_modified_date']) {
- show_bug($bugid, array('status' => $STRING['datecollision']));
+ show_bug($bugid, array('status' => translate("Someone has updated this bug since you viewed it. The bug info has been reloaded with the latest changes.")));
return;
}
// Add CC if specified
if ($add_cc) {
- if (!$cc_uid = $db->getOne("select user_id from ".TBL_AUTH_USER.
- " where login = ".$db->quote(stripslashes($add_cc)))) {
- show_bug($bugid,array('status' => $STRING['nouser']));
+ if (!$cc_uid = $db->getOne("select user_id from ".TBL_AUTH_USER." where login = ".$db->quote(stripslashes($add_cc)))) {
+ show_bug($bugid,array('status' => translate("That user does not exist")));
return;
}
- $cc_already = $db->getOne('select user_id from '.TBL_BUG_CC.
- " where bug_id = $bugid and user_id = $cc_uid");
+ $cc_already = $db->getOne('select user_id from '.TBL_BUG_CC." where bug_id = $bugid and user_id = $cc_uid");
if (!$cc_already && $cc_uid != $buginfo['created_by']) {
- $db->query("insert into ".TBL_BUG_CC." (bug_id, user_id, created_by,
- created_date) values ($bugid, $cc_uid, $u, $now)");
+ $db->query("insert into ".TBL_BUG_CC." (bug_id, user_id, created_by, created_date) values ($bugid, $cc_uid, $u, $now)");
}
}
// Remove CCs if requested
if (isset($remove_cc) and $remove_cc[0]) {
- $db->query('delete from '.TBL_BUG_CC." where bug_id = $bugid and user_id in (".
- delimit_list(',', $remove_cc).')');
+ $db->query('delete from '.TBL_BUG_CC." where bug_id = $bugid and user_id in (".@join(',', $remove_cc).')');
}
// Add dependency if requested
@@ -396,62 +354,43 @@
// Validate the bug number
if (!is_numeric($add_dependency)) {
- show_bug($bugid, array('add_dep' => $STRING['nobug']));
+ show_bug($bugid, array('add_dep' => translate("That bug does not exist")));
return;
}
if (!$db->getOne('select count(*) from '.TBL_BUG." where bug_id = $add_dependency")) {
- show_bug($bugid, array('add_dep' => $STRING['nobug']));
+ show_bug($bugid, array('add_dep' => translate("That bug does not exist")));
return;
}
// Check if the dependency has already been added
- if ($db->getOne('select count(*) from '.TBL_BUG_DEPENDENCY.
- " where bug_id = $bugid and depends_on = $add_dependency")) {
- show_bug($bugid, array('add_dep' => $STRING['dupe_dependency']));
+ if ($db->getOne('select count(*) from '.TBL_BUG_DEPENDENCY." where bug_id = $bugid and depends_on = $add_dependency")) {
+ show_bug($bugid, array('add_dep' => translate("That bug dependency has already been added")));
return;
}
// Add it
- $db->query("insert into ".TBL_BUG_DEPENDENCY.
- " (bug_id, depends_on) values($bugid, $add_dependency)");
+ $db->query("insert into ".TBL_BUG_DEPENDENCY." (bug_id, depends_on) values($bugid, $add_dependency)");
}
// Remove dependency if requested
if (!empty($del_dependency)) {
$del_dependency = preg_replace('/\D/', '', $del_dependency);
if (is_numeric($del_dependency)) {
- $db->query("delete from ".TBL_BUG_DEPENDENCY.
- " where bug_id = $bugid and depends_on = $del_dependency");
+ $db->query("delete from ".TBL_BUG_DEPENDENCY." where bug_id = $bugid and depends_on = $del_dependency");
}
}
if ($comments) {
// $comments = strip_tags($comments); -- Uncomment this if you want no <> content in the comments
- $db->query("insert into ".TBL_COMMENT." (comment_id, bug_id, comment_text, created_by, created_date)".
- " values (".$db->nextId(TBL_COMMENT).", $bugid, ".
- $db->quote(stripslashes($comments)).", $u, $now)");
+ $db->query("insert into ".TBL_COMMENT." (comment_id, bug_id, comment_text, created_by, created_date) values (".$db->nextId(TBL_COMMENT).", $bugid, ".$db->quote(stripslashes($comments)).", $u, $now)");
}
- // Allow for removing of some items from the bug page
- $priority = $priority ? $priority : 0;
- $os_id = $os_id ? $os_id : 0;
- $severity_id = $severity_id ? $severity_id : 0;
-
if (is_closed($status_id)) {
$closed_query = ", close_date = $now";
} else {
$closed_query = '';
}
- $db->query("update ".TBL_BUG." set title = ".$db->quote(stripslashes($title)).
- ', url = '.$db->quote(stripslashes($url)).", severity_id = $severity_id, ".
- "priority = $priority, status_id = $status_id, ".
- "database_id = $database_id, to_be_closed_in_version_id = $to_be_closed_in_version_id, ".
- 'closed_in_version_id = '.$closed_in_version_id.', '.
- 'site_id ='.$site_id.', '.
- "resolution_id = $resolution_id, assigned_to = $assigned_to, ".
- "project_id = $project_id, version_id = $version_id, ".
- "component_id = $component_id, os_id = $os_id, last_modified_by = $u, ".
- "last_modified_date = $now $closed_query where bug_id = $bugid");
+ $db->query("update ".TBL_BUG." set title = ".$db->quote(stripslashes($title)).', url = '.$db->quote(stripslashes($url)).", severity_id = ".(int)$severity_id.", priority = ".(int)$priority.", status_id = ".(int)$status_id.", database_id = ".(int)$database_id.", to_be_closed_in_version_id = ".(int)$to_be_closed_in_version_id.", closed_in_version_id = ".(int)$closed_in_version_id.', site_id ='.(int)$site_id.", resolution_id = ".(int)$resolution_id.", assigned_to = ".(int)$assigned_to.", project_id = $project_id, version_id = $version_id, component_id = ".(int)$component_id.", os_id = ".(int)$os_id.", last_modified_by = $u, last_modified_date = $now $closed_query where bug_id = $bugid");
// If the project has changed, move any attachments
if (!empty($changedfields['project_id'])) {
@@ -466,29 +405,26 @@
}
function add_attachment($bugid, $description) {
- global $db, $HTTP_POST_FILES, $now, $u, $STRING, $t, $_pv;
+ global $db, $now, $u, $t;
- if (!isset($HTTP_POST_FILES['attachment']) ||
- $HTTP_POST_FILES['attachment']['tmp_name'] == 'none') {
+ if (!isset($_FILES['attachment']) ||
+ $_FILES['attachment']['tmp_name'] == 'none') {
return;
}
// Check the upload size. If the size was greater than the max in
// php.ini, the file won't even be set and will fail at the check above
- if ($HTTP_POST_FILES['attachment']['size'] > ATTACHMENT_MAX_SIZE) {
+ if ($_FILES['attachment']['size'] > ATTACHMENT_MAX_SIZE) {
return;
}
$projectid = $db->getOne("select project_id from ".TBL_BUG." where bug_id = $bugid");
if (!$projectid) {
- show_text($STRING['nobug'], true);
return;
}
// Check for a previously-uploaded attachment with the same name, bug, and project
- $rs = $db->query("select a.bug_id, project_id from ".TBL_ATTACHMENT." a, ".
- TBL_BUG." b where file_name = '{$HTTP_POST_FILES['attachment']['name']}' ".
- "and a.bug_id = b.bug_id");
+ $rs = $db->query("select a.bug_id, project_id from ".TBL_ATTACHMENT." a, ".TBL_BUG." b where file_name = '{$_FILES['attachment']['name']}' and a.bug_id = b.bug_id");
while ($rs->fetchInto($ainfo)) {
if ($bugid == $ainfo['bug_id'] && $projectid == $ainfo['project_id']) {
return;
@@ -496,8 +432,8 @@
}
$filepath = ATTACHMENT_PATH;
- $tmpfilename = $HTTP_POST_FILES['attachment']['tmp_name'];
- $filename = "$bugid-{$HTTP_POST_FILES['attachment']['name']}";
+ $tmpfilename = $_FILES['attachment']['tmp_name'];
+ $filename = "$bugid-{$_FILES['attachment']['name']}";
if (!is_dir($filepath)) {
return;
@@ -511,28 +447,15 @@
@mkdir("$filepath/$projectid", 0775);
}
- if (!@move_uploaded_file($HTTP_POST_FILES['attachment']['tmp_name'],
+ if (!@move_uploaded_file($_FILES['attachment']['tmp_name'],
"$filepath/$projectid/$filename")) {
return;
}
@chmod("$filepath/$projectid/$filename", 0766);
- $db->query("insert into ".TBL_ATTACHMENT." (attachment_id, bug_id, file_name, ".
- "description, file_size, mime_type, created_by, created_date) values (".
- join(', ', array($db->nextId(TBL_ATTACHMENT), $bugid,
- $db->quote($HTTP_POST_FILES['attachment']['name']),
- $db->quote(stripslashes($description)),
- $HTTP_POST_FILES['attachment']['size'],
- $db->quote($HTTP_POST_FILES['attachment']['type']), $u, $now)).")");
-
- if ($_pv['use_js']) {
- $t->display('admin/edit-submit.html');
- } else {
- header("Location: bug.php?op=show&bugid=$bugid");
- }
+ $db->query("insert into ".TBL_ATTACHMENT." (attachment_id, bug_id, file_name, description, file_size, mime_type, created_by, created_date) values (".join(', ', array($db->nextId(TBL_ATTACHMENT), $bugid, $db->quote($_FILES['attachment']['name']), $db->quote(stripslashes($description)), $_FILES['attachment']['size'], $db->quote($_FILES['attachment']['type']), $u, $now)).")");
}
-
///
/// Move attachments from one project directory to another
function move_attachments($bug_id, $old_project, $new_project) {
@@ -543,86 +466,51 @@
@mkdir("$filepath/$new_project", 0775);
}
- $rs = $db->query("select attachment_id, file_name from ".TBL_ATTACHMENT.
- " where bug_id = $bug_id");
+ $rs = $db->query("select attachment_id, file_name from ".TBL_ATTACHMENT." where bug_id = $bug_id");
while ($row = $rs->fetchRow()) {
@rename("$filepath/$old_project/$bug_id-{$row['file_name']}",
"$filepath/$new_project/$bug_id-{$row['file_name']}");
}
}
-
-
-
function do_form($bugid = 0) {
- global $db, $me, $u, $_pv, $_gv, $STRING, $now, $HTTP_SERVER_VARS;
+ global $db, $me, $u, $now;
$error = '';
// Validation
- if (!$_pv['title'] = htmlspecialchars(trim($_pv['title']))) {
- $error = $STRING['givesummary'];
- } elseif (!$_pv['description'] = htmlspecialchars(trim($_pv['description']))) {
- $error = $STRING['givedesc'];
+ if (!$_POST['title'] = htmlspecialchars(trim($_POST['title']))) {
+ $error = translate("Please enter a summary");
+ } elseif (!$_POST['description'] = htmlspecialchars(trim($_POST['description']))) {
+ $error = translate("Please enter a description");
}
if ($error) {
- $_gv['project'] = $_pv['project'];
+ $_GET['project'] = $_POST['project'];
show_form($bugid, $error);
return;
}
- while (list($k,$v) = each($_pv)) {
- $$k = $v;
- }
-
+ extract($_POST);
if ($url == 'http://') {
$url = '';
}
- // Allow for removing of some items from the bug page
- $priority = $priority ? $priority : 0;
- $os = $os ? $os : 0;
- $severity = $severity ? $severity : 0;
-
- if (!$bugid) {
- $bugid = $db->nextId(TBL_BUG);
-
- // Check to see if this bug's component has an owner and should be assigned
- if ($owner = $db->getOne("select owner from ".TBL_COMPONENT." c where component_id = $component")) {
- $status = BUG_ASSIGNED;
- } else {
- $owner = 0;
- // If we aren't using voting to promote, then auto-promote to New
- $status = PROMOTE_VOTES ? BUG_UNCONFIRMED : BUG_PROMOTED;
- }
-
- $db->query('insert into '.TBL_BUG.' (bug_id, title, description, url, '.
- 'severity_id, priority, status_id, assigned_to, created_by, created_date, '.
- 'last_modified_by, last_modified_date, project_id, site_id, database_id, version_id, '.
- 'component_id, os_id, browser_string) values ('.$bugid.', '.
- join(', ', array($db->quote(stripslashes($title)),
- $db->quote(stripslashes($description)),
- $db->quote(stripslashes($url)))).', '.
- $severity.', '.$priority.', '.$status.', '.$owner.', '.$u.', '.$now.', '.$u.', '.$now.', '.$project.', '.
- $site.', '.$database.', '.$version.', '.$component.', '.$os.', '.
- $db->quote(stripslashes($HTTP_SERVER_VARS['HTTP_USER_AGENT'])).')');
- $buginfo = $db->getRow('select * from '.TBL_BUG." where bug_id = $bugid");
- do_changedfields($u, $buginfo);
+ // Check to see if this bug's component has an owner and should be assigned
+ if ($owner = $db->getOne("select owner from ".TBL_COMPONENT." c where component_id = $component")) {
+ $status = BUG_ASSIGNED;
} else {
- $db->query('update '.TBL_BUG.' set title = '.$db->quote(stripslashes($title)).
- ", description = ".$db->quote(stripslashes($description)).
- ", url = ".$db->quote(stripslashes($url)).
- ", severity_id = '$severity', priority = '$priority', ".
- "status_id = $status, assigned_to = '$assignedto', ".
- 'database_id = '.$database.', site_id = '.$site.', '.
- "project_id = $project, version_id = $version, ".
- "component_id = $component, os_id = '$os', ".
- "browser_string = '{$GLOBALS['HTTP_USER_AGENT']}' ".
- "last_modified_by = $u, last_modified_date = $time ".
- "where bug_id = '$bugid'");
+ $owner = 0;
+ // If we aren't using voting to promote, then auto-promote to New
+ $status = PROMOTE_VOTES ? BUG_UNCONFIRMED : BUG_PROMOTED;
}
- if (isset($_pv['at_description']))
- add_attachment($bugid, $_pv['at_description']); //attachment (initial)
+ $bugid = $db->nextId(TBL_BUG);
+
+ $db->query('insert into '.TBL_BUG.' (bug_id, title, description, url, severity_id, priority, status_id, assigned_to, created_by, created_date, last_modified_by, last_modified_date, project_id, site_id, database_id, version_id, component_id, os_id, browser_string) values ('.$bugid.', '.join(', ', array($db->quote(stripslashes($title)), $db->quote(stripslashes($description)), $db->quote(stripslashes($url)))).', '.(int)$severity.', '.(int)$priority.', '.(int)$status.', '.$owner.', '.$u.', '.$now.', '.$u.', '.$now.', '.$project.', '.(int)$site.', '.(int)$database.', '.(int)$version.', '.(int)$component.', '.(int)$os.', '.$db->quote(stripslashes($_SERVER['HTTP_USER_AGENT'])).')');
+ $buginfo = $db->getRow('select * from '.TBL_BUG." where bug_id = $bugid");
+ do_changedfields($u, $buginfo);
+
+ if (isset($_POST['at_description']))
+ add_attachment($bugid, $_POST['at_description']); //attachment (initial)
if (isset($another)) {
header("Location: $me?op=add&project=$project");
@@ -638,50 +526,41 @@
if ($bugid && !$error) {
$t->assign($db->getRow("select * from ".TBL_BUG." where bug_id = '$bugid'"));
} else {
- $t->assign($_pv);
+ $t->assign($_POST);
$t->assign(array(
'error' => $error,
'project' => $_GET['project'],
'projectname' => $projectname
));
}
- $t->render('bugform.html', translate('Create Bug'));
+ $t->render('bugform.html', translate("Create Bug"));
}
function show_bug_printable($bugid) {
- global $db, $me, $t, $select, $TITLE, $QUERY, $restricted_projects;
+ global $db, $me, $t, $select, $QUERY, $restricted_projects;
if (!is_numeric($bugid) or
!$row = $db->getRow(sprintf($QUERY['bug-printable'], $bugid,
$restricted_projects))) {
- show_text($STRING['bugbadnum'],true);
+ show_text(translate("That bug does not exist"), true);
exit;
}
$t->assign($row);
$t->assign(array(
- 'bug_dependencies' => delimit_list(', ', $db->getCol('select '.
- db_concat("'<a href=\"$me?op=show&bugid='", 'depends_on', '\'">#\'',
- 'depends_on', '\'</a>\'').' from '.TBL_BUG_DEPENDENCY.
- " where bug_id = $bugid")),
- 'rev_bug_dependencies' => delimit_list(', ', $db->getCol('select '.
- db_concat("'<a href=\"$me?op=show&bugid='", 'bug_id', '\'">#\'',
- 'bug_id', '\'</a>\'').' from '.TBL_BUG_DEPENDENCY.
- " where depends_on = $bugid"))
+ 'bug_dependencies' => @join(', ', $db->getCol('select '.db_concat("'<a href=\"$me?op=show&bugid='", 'depends_on', '\'">#\'','depends_on', '\'</a>\'').' from '.TBL_BUG_DEPENDENCY." where bug_id = $bugid")),
+ 'rev_bug_dependencies' => @join(', ', $db->getCol('select '.db_concat("'<a href=\"$me?op=show&bugid='", 'bug_id', '\'">#\'','bug_id', '\'</a>\'').' from '.TBL_BUG_DEPENDENCY." where depends_on = $bugid"))
));
// Show the comments
- $t->assign('comments', $db->getAll('select comment_text, c.created_date, login'.
- ' from '.TBL_COMMENT.' c, '.TBL_AUTH_USER.
- " where bug_id = $bugid and c.created_by = user_id order by c.created_date"
- ));
- $t->render('bugdisplay-printable.html', translate('View Bug'));
+ $t->assign('comments', $db->getAll('select comment_text, c.created_date, login from '.TBL_COMMENT.' c, '.TBL_AUTH_USER." where bug_id = $bugid and c.created_by = user_id order by c.created_date"));
+ $t->render('bugdisplay-printable.html', translate("View Bug"));
}
///
/// Grab the links for the previous and next bugs in the list
function prev_next_links($bugid, $pos) {
- global $dsn, $_sv, $QUERY, $t;
+ global $dsn, $QUERY, $t;
// Create a new db connection because of the limit query affecting later queries
$db = DB::Connect($dsn);
@@ -691,7 +570,7 @@
$db->setOption('optimize', 'portability');
$db->setErrorHandling(PEAR_ERROR_CALLBACK, "handle_db_error");
- if (!isset($_sv['queryinfo']['query']) || !$_sv['queryinfo']['query']) {
+ if (!isset($_SESSION['queryinfo']['query']) || !$_SESSION['queryinfo']['query']) {
return array('', '');
}
@@ -703,8 +582,8 @@
$limit = 1;
}
$rs = $db->limitQuery(sprintf($QUERY['bug-prev-next'],
- $_sv['queryinfo']['query'], $bugid, $_sv['queryinfo']['order'],
- $_sv['queryinfo']['sort']), $offset, $limit);
+ $_SESSION['queryinfo']['query'], $bugid, $_SESSION['queryinfo']['order'],
+ $_SESSION['queryinfo']['sort']), $offset, $limit);
list($firstid, $chunks) = $rs->fetchRow();
list($secondid, $chunks) = $rs->fetchRow();
@@ -724,61 +603,31 @@
}
function show_bug($bugid = 0, $error = array()) {
- global $db, $me, $t, $STRING, $TITLE, $u, $_gv, $_pv, $QUERY, $restricted_projects;
+ global $db, $me, $t, $u, $QUERY, $restricted_projects;
if (!ereg('^[0-9]+$',$bugid) or
!$row = $db->getRow(sprintf($QUERY['bug-show-bug'], $bugid,
$restricted_projects))) {
- show_text($STRING['bugbadnum'],true);
+ show_text(translate("That bug does not exist"), true);
return;
}
- prev_next_links($bugid, isset($_gv['pos']) ? $_gv['pos'] : 0);
+ prev_next_links($bugid, isset($_GET['pos']) ? $_GET['pos'] : 0);
$t->assign($row);
// Override the database values with posted values if there were errors
- if (count($error)) $t->assign($_pv);
+ if (count($error)) $t->assign($_POST);
- $bug_dependencies = $db->query('SELECT '.TBL_BUG.'.status_id, '.
- TBL_BUG.'.bug_id FROM '.
- TBL_BUG.', '.TBL_BUG_DEPENDENCY.' WHERE '.TBL_BUG.'.bug_id = '.
- TBL_BUG_DEPENDENCY.'.depends_on AND '.TBL_BUG_DEPENDENCY.
- '.bug_id = '.$bugid);
-
- $bug_dependencies_display = array();
- if ($bug_dependencies->numRows()) {
- while ($bug_dependencies->fetchInto($dependency)) {
- $bug_dependencies_display[] =
- '<a href="'.$me.'?op=show&bugid='.$dependency['bug_id'].
- '">'.($dependency['status_id'] == 5 ? '<strike>':'').'#'.
- $dependency['bug_id'].($dependency['status_id'] == 5 ? '</strike>':'').'</a>';
- }
- }
+ $bug_dependencies = $db->getAll("select b.bug_id, s.bug_open from ".TBL_BUG_DEPENDENCY." d, ".TBL_BUG." b, ".TBL_STATUS." s where d.bug_id = $bugid and d.depends_on = b.bug_id and b.status_id = s.status_id");
- $bug_blocks = $db->query('SELECT '.TBL_BUG.'.status_id, '.
- TBL_BUG.'.bug_id FROM '.
- TBL_BUG.', '.TBL_BUG_DEPENDENCY.' WHERE '.TBL_BUG.'.bug_id = '.
- TBL_BUG_DEPENDENCY.'.bug_id AND '.TBL_BUG_DEPENDENCY.
- '.depends_on = '.$bugid);
-
- $bug_blocks_display = array();
- if ($bug_blocks->numRows()) {
- while ($bug_blocks->fetchInto($block)) {
- $bug_blocks_display[] =
- '<a href="'.$me.'?op=show&bugid='.$block['bug_id'].
- '">'.($block['status_id'] == 5 ? '<strike>':'').'#'.
- $block['bug_id'].($block['status_id'] == 5 ? '</strike>':'').'</a>';
- }
- }
+ $bug_blocks = $db->getAll("select b.bug_id, s.bug_open from ".TBL_BUG_DEPENDENCY." d, ".TBL_BUG." b, ".TBL_STATUS." s where d.depends_on = $bugid and d.bug_id = b.bug_id and b.status_id = s.status_id");
$t->assign(array(
'error' => $error,
- 'already_voted' => $db->getOne("select count(*) from ".TBL_BUG_VOTE.
- " where bug_id = $bugid and user_id = $u"),
- 'num_votes' => $db->getOne("select count(*) from ".TBL_BUG_VOTE.
- " where bug_id = $bugid"),
- 'bug_dependencies' => implode(', ', $bug_dependencies_display),
- 'rev_bug_dependencies' => implode(', ', $bug_blocks_display)
+ 'already_voted' => $db->getOne("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bugid and user_id = $u"),
+ 'num_votes' => $db->getOne("select count(*) from ".TBL_BUG_VOTE." where bug_id = $bugid"),
+ 'bug_dependencies' => $bug_dependencies,
+ 'bug_blocks' => $bug_blocks
));
// Show the attachments
@@ -795,16 +644,14 @@
// Show the comments
$t->assign(array(
'attachments' => $attachments,
- 'comments' => $db->getAll('select comment_text, c.created_date, login'.
- ' from '.TBL_COMMENT.' c, '.TBL_AUTH_USER.
- " where bug_id = $bugid and c.created_by = user_id order by c.created_date")
+ 'comments' => $db->getAll('select comment_text, c.created_date, login'.' from '.TBL_COMMENT.' c, '.TBL_AUTH_USER." where bug_id = $bugid and c.created_by = user_id order by c.created_date")
));
- $t->render('bugdisplay.html', translate('View Bug'));
+ $t->render('bugdisplay.html', translate("View Bug"));
}
function show_projects() {
- global $db, $t, $STRING, $perm, $restricted_projects, $_gv;
+ global $db, $t, $perm, $restricted_projects;
// Show only active projects with at least one component
if ($perm->have_perm('Admin')) { // Show admins all projects
@@ -813,15 +660,11 @@
$p_query = " and p.project_id not in ($restricted_projects)";
}
$projects = array();
- $projects = $db->getAll('select p.project_id, p.project_name, p.project_desc, p.created_date
- from '.TBL_PROJECT.' p, '.TBL_COMPONENT.
- ' c where p.active = 1 and p.project_id = c.project_id'.$p_query.
- ' group by p.project_id, p.project_name, p.project_desc, p.created_date'.
- ' order by project_name');
+ $projects = $db->getAll('select p.project_id, p.project_name, p.project_desc, p.created_date from '.TBL_PROJECT.' p, '.TBL_COMPONENT.' c where p.active = 1 and p.project_id = c.project_id'.$p_query.' group by p.project_id, p.project_name, p.project_desc, p.created_date order by project_name');
switch (count($projects)) {
case 0 :
- show_text($STRING['noprojects'], true);
+ show_text(translate("No projects found"), true);
return;
case 1 :
$_GET['project'] = $projects[0]['project_id'];
@@ -829,40 +672,40 @@
break;
default :
$t->assign('projects', $projects);
- $t->render('projectlist.html', translate('Select Project'));
+ $t->render('projectlist.html', translate("Select Project"));
}
}
-if ($op) {
- switch($op) {
+if (!empty($_REQUEST['op'])) {
+ switch($_REQUEST['op']) {
case 'history':
- show_history($_gv['bugid']);
+ show_history($_GET['bugid']);
break;
case 'add':
$perm->check('Editbug');
- if (isset($_gv['project'])) {
+ if (isset($_GET['project'])) {
show_form();
} else {
show_projects();
}
break;
case 'show':
- show_bug($_gv['bugid']);
+ show_bug($_GET['bugid']);
break;
case 'update':
- update_bug($_pv['bugid']);
+ update_bug($_POST['bugid']);
break;
case 'do':
- do_form($_pv['bugid']);
+ do_form($_POST['bugid']);
break;
case 'print':
- show_bug_printable($_gv['bugid']);
+ show_bug_printable($_GET['bugid']);
break;
case 'vote':
- vote_bug($_gv['bugid']);
+ vote_bug($_GET['bugid']);
break;
case 'viewvotes':
- vote_view($_gv['bugid']);
+ vote_view($_GET['bugid']);
break;
}
} else {
|