From: Hugo Seabrook Date: Fri, 15 Feb 2013 06:07:34 +0000 (+0800) Subject: Bug 830330: Make flags honour bug_check_can_change_field X-Git-Tag: bugzilla-4.4rc2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5f626b52feeaa49358ffbd5e5604f3a3e4020e9;p=thirdparty%2Fbugzilla.git Bug 830330: Make flags honour bug_check_can_change_field r=dkl, a=LpSolit --- diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 8cdbb19291..497ca09916 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -4057,8 +4057,8 @@ sub check_can_change_field { return 1; } - # Allow anyone to change comments. - if ($field =~ /^longdesc/) { + # Allow anyone to change comments, or set flags + if ($field =~ /^longdesc/ || $field eq 'flagtypes.name') { return 1; } diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm index b7cf7cc678..a1b8c2c23b 100644 --- a/Bugzilla/Flag.pm +++ b/Bugzilla/Flag.pm @@ -296,6 +296,12 @@ sub set_flag { ThrowCodeError('flag_unexpected_object', { 'caller' => ref $obj }); } + # Make sure the user can change flags + my $privs; + $bug->check_can_change_field('flagtypes.name', 0, 1, \$privs) + || ThrowUserError('illegal_change', + { field => 'flagtypes.name', privs => $privs }); + # Update (or delete) an existing flag. if ($params->{id}) { my $flag = $class->check({ id => $params->{id} }); diff --git a/template/en/default/flag/list.html.tmpl b/template/en/default/flag/list.html.tmpl index 88486c7f67..7a3f88fc5d 100644 --- a/template/en/default/flag/list.html.tmpl +++ b/template/en/default/flag/list.html.tmpl @@ -6,7 +6,7 @@ # defined by the Mozilla Public License, v. 2.0. #%] -[% IF user.id AND !read_only_flags %] +[% IF user.id && !read_only_flags && bug.check_can_change_field('flagtypes.name', 0, 1) %] [%# We list flags by looping twice over the flag types relevant for the bug. # In the first loop, we display existing flags and then, for active types,