]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 830330: Make flags honour bug_check_can_change_field
authorHugo Seabrook <hugo.seabrook@gmail.com>
Fri, 15 Feb 2013 06:08:31 +0000 (14:08 +0800)
committerByron Jones <bjones@mozilla.com>
Fri, 15 Feb 2013 06:08:31 +0000 (14:08 +0800)
r=dkl, a=LpSolit

Bugzilla/Bug.pm
Bugzilla/Flag.pm
template/en/default/flag/list.html.tmpl

index 547e35fa7fadf02d9c238043f26141fd135a4ea2..5069214ba0779871a8a98e908da7dc19adfb692d 100644 (file)
@@ -4085,8 +4085,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;
     }
 
index 3660e2a7f143991cd17c2c590f1be933d332197e..98029a1b14c31fea9aae611016e4fea1ebb8d813 100644 (file)
@@ -294,6 +294,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} });
index 88486c7f67f943fa5b49356cbd86dd40e0a09054..7a3f88fc5d1b02cd00806cf5c73098e6ea067fbf 100644 (file)
@@ -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,