summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2008-01-06 09:52:17 +0100
committermkanat%bugzilla.org <>2008-01-06 09:52:17 +0100
commitc2ebd1bb43d06223d26426a233c00a6ca22f45d6 (patch)
treea387d87722d08e39a5241a4dcca6910ef95af7d2 /Bugzilla
parent91d9ad905e8e74a7284e3484ca995c97b1c146ce (diff)
downloadbugzilla-c2ebd1bb43d06223d26426a233c00a6ca22f45d6.tar.gz
bugzilla-c2ebd1bb43d06223d26426a233c00a6ca22f45d6.tar.xz
Bug 355847: Make the WebService able to add a comment to a bug
Patch By Tsahi Asher <tsahi_75@yahoo.com> r=mkanat, a=mkanat
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/WebService/Bug.pm81
-rwxr-xr-xBugzilla/WebService/Constants.pm2
2 files changed, 82 insertions, 1 deletions
diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm
index 8dacfe956..7148b78cb 100755
--- a/Bugzilla/WebService/Bug.pm
+++ b/Bugzilla/WebService/Bug.pm
@@ -14,6 +14,8 @@
#
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Max Kanat-Alexander <mkanat@bugzilla.org>
+# Mads Bondo Dydensborg <mbd@dbc.dk>
+# Tsahi Asher <tsahi_75@yahoo.com>
package Bugzilla::WebService::Bug;
@@ -25,7 +27,6 @@ use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Field;
use Bugzilla::WebService::Constants;
-use Bugzilla::Util qw(detaint_natural);
use Bugzilla::Bug;
use Bugzilla::BugMail;
use Bugzilla::Constants;
@@ -177,6 +178,36 @@ sub legal_values {
return { values => \@result };
}
+sub add_comment {
+ my ($self, $params) = @_;
+
+ #The user must login in order add a comment
+ Bugzilla->login(LOGIN_REQUIRED);
+
+ # Check parameters
+ defined $params->{id}
+ || ThrowCodeError('param_required', { param => 'id' });
+ ValidateBugID($params->{id});
+
+ my $comment = $params->{comment};
+ defined $comment
+ || ThrowCodeError('param_required', { param => 'comment' });
+
+ my $bug = new Bugzilla::Bug($params->{id});
+
+ Bugzilla->user->can_edit_product($bug->product_id)
+ || ThrowUserError("product_edit_denied", {product => $bug->product});
+
+ # Append comment
+ $bug->add_comment($comment, { isprivate => $params->{private},
+ work_time => $params->{work_time} });
+ $bug->update();
+
+ # Send mail.
+ Bugzilla::BugMail::Send($bug->bug_id, { changer => Bugzilla->user->login });
+ return undef;
+}
+
1;
__END__
@@ -467,5 +498,53 @@ in them. The error message will have more details.
=back
+=item C<add_comment> B<EXPERIMENTAL>
+
+=over
+
+=item B<Description>
+
+This allows you to add a comment to a bug in Bugzilla.
+
+=item B<Params>
+
+=over
+
+=item C<id> (int) B<Required> - The id or alias of the bug to append a
+comment to.
+
+=item C<comment> (string) B<Required> - The comment to append to the bug.
+
+=item C<private> (boolean) - If set to true, the comment is private, otherwise
+it is assumed to be public.
+
+=item C<work_time> (double) - Adds this many hours to the "Hours Worked"
+on the bug. If you are not in the time tracking group, this value will
+be ignored.
+
+
+=back
+
+=item B<Errors>
+
+=over
+
+=item 100 (Invalid Bug Alias)
+
+If you specified an alias and either: (a) the Bugzilla you're querying
+doesn't support aliases or (b) there is no bug with that alias.
+
+=item 101 (Invalid Bug ID)
+
+The id you specified doesn't exist in the database.
+
+=item 108 (Bug Edit Denied)
+
+You did not have the necessary rights to edit the bug.
+
+=back
+
+=back
+
=back
diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm
index 2dfb0b112..a1ecb53ed 100755
--- a/Bugzilla/WebService/Constants.pm
+++ b/Bugzilla/WebService/Constants.pm
@@ -75,6 +75,8 @@ use constant WS_ERROR_CODE => {
product_disabled => 106,
# Invalid Summary
require_summary => 107,
+ # Not authorized to edit the bug
+ product_edit_denied => 108,
# Authentication errors are usually 300-400.
invalid_username_or_password => 300,