|
From: Benjamin C. <bc...@us...> - 2001-07-11 13:05:47
|
Update of /cvsroot/phpbt/phpbt
In directory usw-pr-cvs1:/tmp/cvs-serv16465
Modified Files:
bug.php strings-en.php
Log Message:
Added bug history
Index: bug.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/bug.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- bug.php 2001/07/10 14:00:44 1.10
+++ bug.php 2001/07/11 13:05:44 1.11
@@ -5,17 +5,49 @@
include 'include.php';
page_open(array('sess' => 'usess', 'auth' => 'uauth', 'perm' => 'uperm'));
-
$u = $auth->auth['uid'];
///
+/// Show the activity for a bug
+function show_history($bugid) {
+ global $q, $t;
+
+ if (!is_numeric($bugid)) {
+ show_text($STRING['nobughistory']);
+ return;
+ }
+
+ $q->query("select bh.*, Email from BugHistory bh left join User on CreatedBy = UserID where BugID = $bugid");
+ if (!$q->num_rows()) {
+ show_text($STRING['nobughistory']);
+ return;
+ }
+
+ $t->set_file('content','bughistory.html');
+ $t->set_block('content', 'row', 'rows');
+ $t->set_var('bugid', $bugid);
+ while ($row = $q->grab()) {
+ $t->set_var(array(
+ 'bgcolor' => (++$i % 2 == 0) ? '#dddddd' : '#ffffff',
+ 'field' => stripslashes($row['ChangedField']),
+ 'oldvalue' => stripslashes($row['OldValue']),
+ 'newvalue' => stripslashes($row['NewValue']),
+ 'createdby' => stripslashes($row['Email']),
+ 'date' => date(DATEFORMAT.' '.TIMEFORMAT, $row['CreatedDate'])
+ ));
+ $t->parse('rows', 'row', true);
+ }
+}
+
+///
/// Send the email about changes to the bug and (later) log the changes in the DB
function do_changedfields($userid, $buginfo, $cf, $comments) {
- global $q, $t, $u, $select;
+ global $q, $t, $u, $select, $now;
$t->set_file('emailout','bugemail.txt');
foreach(array('Title','URL') as $field) {
- if ($cf[$field]) {
+ if (isset($cf[$field])) {
+ $q->query("insert into BugHistory (BugID, ChangedField, OldValue, NewValue, CreatedBy, CreatedDate) values ({$buginfo['BugID']}, '$field', '$buginfo[$field]', '$cf[$field]', $u, $now)");
$t->set_var(array(
$field => $cf[$field],
$field.'Stat' => '!'
@@ -30,16 +62,17 @@
foreach(array('Project','Component','Status','Resolution','Severity','OS',
'Version') as $field) {
+ $oldvalue = $q->grab_field("select Name from $field where ${field}ID = $buginfo[$field]");
if ($cf[$field]) {
- $t->set_var(array(
- $field => $q->grab_field("select Name from $field where ${field}ID =
- $cf[$field]"),
+ $newvalue = $q->grab_field("select Name from $field where ${field}ID = $cf[$field]");
+ $q->query("insert into BugHistory (BugID, ChangedField, OldValue, NewValue, CreatedBy, CreatedDate) values ({$buginfo['BugID']}, '$field', '$oldvalue', '$newvalue', $u, $now)");
+ $t->set_var(array(
+ $field => $newvalue,
$field.'Stat' => '!'
));
} else {
$t->set_var(array(
- $field => $q->grab_field("select Name from $field where ${field}ID =
- $buginfo[$field]"),
+ $field => $oldvalue,
$field.'Stat' => ' '
));
}
@@ -123,7 +156,12 @@
if ($pv = $GLOBALS['HTTP_POST_VARS']) {
while (list($k,$v) = each($GLOBALS['HTTP_POST_VARS'])) {
$$k = $v;
- if ($buginfo[$k] and $buginfo[$k] != $v) $changedfields[$k] = $v;
+ if ($k == 'URL') {
+ if ($v == 'http://') $v = '';
+ elseif ($v and substr($v,0,7) != 'http://') $v = 'http://'.$v;
+ $URL = $v;
+ }
+ if ($buginfo[$k] != $v) { $changedfields[$k] = $v; }
}
}
@@ -209,8 +247,6 @@
from Status where Name = '$statusfield'");
$changedfields['Status'] = $status;
}
- if ($URL == 'http://') $URL = '';
- elseif ($URL and substr($URL,0,7) != 'http://') $URL = 'http://'.$URL;
$q->query("Update Bug set Title = '$Title', URL = '$URL', Severity = $Severity,
Priority = $Priority, ".($status ? "Status = $status, " : '').
@@ -440,6 +476,7 @@
if ($op) {
switch($op) {
+ case 'history' : show_history($bugid); break;
case 'add' :
if ($project) show_form();
else show_projects();
Index: strings-en.php
===================================================================
RCS file: /cvsroot/phpbt/phpbt/strings-en.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- strings-en.php 2001/07/10 04:01:54 1.5
+++ strings-en.php 2001/07/11 13:05:44 1.6
@@ -29,7 +29,8 @@
'bugbadperm' => 'You cannot change this bug',
'bugbadnum' => 'That bug does not exist',
'datecollision' => 'Someone has updated this bug since you viewed it. The bug info has been reloaded with the latest changes.',
- 'passwordmatch' => 'Those passwords don\'t match -- please try again'
+ 'passwordmatch' => 'Those passwords don\'t match -- please try again',
+ 'nobughistory' => 'There is no history for that bug'
);
// Page titles
|