summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2011-07-04 22:43:06 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2011-07-04 22:43:06 +0200
commit77a3c5bc2fe22cf744ba74144532459a46ac5571 (patch)
tree95aa96d887e69288f924255da4bbce1476b5e8ac
parent846ac8ad0ad2668219c10d5805185bed7459ad47 (diff)
downloadbugzilla-77a3c5bc2fe22cf744ba74144532459a46ac5571.tar.gz
bugzilla-77a3c5bc2fe22cf744ba74144532459a46ac5571.tar.xz
Bug 616679: A user with local editcomponents privs should be able to set the grant and request groups to groups the user belongs to only
a=LpSolit
-rwxr-xr-xeditflagtypes.cgi12
-rw-r--r--template/en/default/admin/flag-type/edit.html.tmpl13
2 files changed, 20 insertions, 5 deletions
diff --git a/editflagtypes.cgi b/editflagtypes.cgi
index 4d11eecdb..d78942c07 100755
--- a/editflagtypes.cgi
+++ b/editflagtypes.cgi
@@ -122,7 +122,7 @@ if (my ($category_action) = grep { $_ =~ /^categoryAction-(?:\w+)$/ } $cgi->para
}
}
- $vars->{'groups'} = [Bugzilla::Group->get_all];
+ $vars->{'groups'} = get_settable_groups();
$vars->{'action'} = $action;
my $type = {};
@@ -226,7 +226,7 @@ if ($action eq 'enter') {
if $user->in_group('editcomponents');
$vars->{'can_fully_edit'} = 1;
# Get a list of groups available to restrict this flag type against.
- $vars->{'groups'} = [Bugzilla::Group->get_all];
+ $vars->{'groups'} = get_settable_groups();
$template->process("admin/flag-type/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@@ -258,7 +258,7 @@ if ($action eq 'edit' || $action eq 'copy') {
}
# Get a list of groups available to restrict this flag type against.
- $vars->{'groups'} = [Bugzilla::Group->get_all];
+ $vars->{'groups'} = get_settable_groups();
$template->process("admin/flag-type/edit.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@@ -490,6 +490,12 @@ sub get_editable_flagtypes {
return $flagtypes;
}
+sub get_settable_groups {
+ my $user = Bugzilla->user;
+ my $groups = $user->in_group('editcomponents') ? [Bugzilla::Group->get_all] : $user->groups;
+ return $groups;
+}
+
sub filter_group {
my ($flag_types, $gid) = @_;
return $flag_types unless $gid;
diff --git a/template/en/default/admin/flag-type/edit.html.tmpl b/template/en/default/admin/flag-type/edit.html.tmpl
index 8db36e6ed..f44c44d9d 100644
--- a/template/en/default/admin/flag-type/edit.html.tmpl
+++ b/template/en/default/admin/flag-type/edit.html.tmpl
@@ -252,10 +252,19 @@
[% BLOCK group_select %]
<select name="[% selname %]" id="[% selname %]" [%- ' disabled="disabled"' UNLESS can_fully_edit %]>
<option value="">(no group)</option>
+ [% group_found = 0 %]
[% FOREACH group = groups %]
<option value="[% group.name FILTER html %]"
- [% " selected" IF (type.${selname} && type.${selname}.name == group.name) %]>
- [%- group.name FILTER html %]
+ [% IF type.${selname} && type.${selname}.name == group.name %]
+ [% ' selected="selected"' %]
+ [% group_found = 1 %]
+ [% END %]>
+ [%- group.name FILTER html ~%]
+ </option>
+ [% END %]
+ [% IF !group_found && type.${selname} %]
+ <option value="[% type.${selname}.name FILTER html %]" selected="selected">
+ [%- type.${selname}.name FILTER html ~%]
</option>
[% END %]
</select>