diff options
author | mkanat%kerio.com <> | 2005-03-10 17:20:41 +0100 |
---|---|---|
committer | mkanat%kerio.com <> | 2005-03-10 17:20:41 +0100 |
commit | 9ffc6eb52bb9c549dae85a51aaf2b29750b7ba14 (patch) | |
tree | b2ab207281d8d55fbfd057acd88e63ea38e39d79 /Bugzilla | |
parent | 7bfeeb6381c49662a58d6e8fe679ad4e8dbda013 (diff) | |
download | bugzilla-9ffc6eb52bb9c549dae85a51aaf2b29750b7ba14.tar.gz bugzilla-9ffc6eb52bb9c549dae85a51aaf2b29750b7ba14.tar.xz |
Bug 283561: Move AppendComment out of globals.pl
Patch By Max Kanat-Alexander <mkanat@kerio.com> r=vladd, a=justdave
Diffstat (limited to 'Bugzilla')
-rwxr-xr-x | Bugzilla/Bug.pm | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 2a4375081..4e494b8a6 100755 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -47,6 +47,7 @@ use Bugzilla::Error; use base qw(Exporter); @Bugzilla::Bug::EXPORT = qw( + AppendComment bug_alias_to_id ValidateComment ); @@ -603,6 +604,38 @@ sub bug_alias_to_id ($) { # Subroutines ##################################################################### +sub AppendComment ($$$;$$$) { + my ($bugid, $who, $comment, $isprivate, $timestamp, $work_time) = @_; + $work_time ||= 0; + my $dbh = Bugzilla->dbh; + + ValidateTime($work_time, "work_time") if $work_time; + trick_taint($work_time); + + # Use the date/time we were given if possible (allowing calling code + # to synchronize the comment's timestamp with those of other records). + $timestamp = "NOW()" unless $timestamp; + + $comment =~ s/\r\n/\n/g; # Handle Windows-style line endings. + $comment =~ s/\r/\n/g; # Handle Mac-style line endings. + + if ($comment =~ /^\s*$/) { # Nothin' but whitespace + return; + } + + # Comments are always safe, because we always display their raw contents, + # and we use them in a placeholder below. + trick_taint($comment); + my $whoid = &::DBNameToIdAndCheck($who); + my $privacyval = $isprivate ? 1 : 0 ; + $dbh->do(q{INSERT INTO longdescs + (bug_id, who, bug_when, thetext, isprivate, work_time) + VALUES (?,?,?,?,?,?)}, undef, + ($bugid, $whoid, $timestamp, $comment, $privacyval, $work_time)); + $dbh->do("UPDATE bugs SET delta_ts = ? WHERE bug_id = ?", + undef, $timestamp, $bugid); +} + sub EmitDependList { my ($myfield, $targetfield, $bug_id) = (@_); my $dbh = Bugzilla->dbh; |