From 223bd464bdfc6bcdff59e698ff3875eed7988207 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Thu, 5 Jul 2007 02:05:58 +0000 Subject: Bug 339437: Make flag requestee a select box and limit users to requestable only - Patch by Seth r/a=LpSolit --- Bugzilla/FlagType.pm | 16 ++++++ skins/standard/global.css | 2 +- template/en/default/attachment/edit.html.tmpl | 2 - template/en/default/flag/list.html.tmpl | 67 +++++++++++++++++++------ template/en/default/global/userselect.html.tmpl | 7 ++- 5 files changed, 76 insertions(+), 18 deletions(-) diff --git a/Bugzilla/FlagType.pm b/Bugzilla/FlagType.pm index 1504be87d..ffa36863e 100644 --- a/Bugzilla/FlagType.pm +++ b/Bugzilla/FlagType.pm @@ -186,6 +186,11 @@ sub sortkey { return $_[0]->{'sortkey'}; } =over +=item C + +Returns a reference to an array of users who have permission to grant this flag type. +The arrays are populated with hashrefs containing the login, identity and visibility of users. + =item C Returns the group (as a Bugzilla::Group object) in which a user @@ -214,6 +219,17 @@ explicitly excluded from the flagtype. =cut +sub grant_list { + my $self = shift; + my @custusers; + my @allusers = @{Bugzilla->user->get_userlist}; + foreach my $user (@allusers) { + my $user_obj = new Bugzilla::User({name => $user->{login}}); + push(@custusers, $user) if $user_obj->can_set_flag($self); + } + return \@custusers; +} + sub grant_group { my $self = shift; diff --git a/skins/standard/global.css b/skins/standard/global.css index 5c03f8832..b729b1aad 100644 --- a/skins/standard/global.css +++ b/skins/standard/global.css @@ -259,7 +259,7 @@ span.quote { table#flags th, table#flags td { - vertical-align: baseline; + vertical-align: middle; text-align: left; } diff --git a/template/en/default/attachment/edit.html.tmpl b/template/en/default/attachment/edit.html.tmpl index 94581ab56..d0a75b3fd 100644 --- a/template/en/default/attachment/edit.html.tmpl +++ b/template/en/default/attachment/edit.html.tmpl @@ -40,8 +40,6 @@ table.attachment_info th { text-align: right; vertical-align: top; } table.attachment_info td { text-align: left; vertical-align: top; } #noview { text-align: left; vertical-align: middle; } - - table#flags th, table#flags td { font-size: small; vertical-align: baseline; text-align: left; } " %] diff --git a/template/en/default/flag/list.html.tmpl b/template/en/default/flag/list.html.tmpl index 61ecf2dfa..308552d25 100644 --- a/template/en/default/flag/list.html.tmpl +++ b/template/en/default/flag/list.html.tmpl @@ -45,10 +45,19 @@ function disableRequesteeFields() { var inputElements = document.getElementsByTagName("input"); + var selectElements = document.getElementsByTagName("select"); + //You cannot update Node lists, so you must create an array to combine the NodeLists + var allElements = []; + for( var i=0; i < inputElements.length; i++ ) { + allElements[allElements.length] = inputElements.item(i); + } + for( var i=0; i < selectElements.length; i++ ) { //Combine inputs with selects + allElements[allElements.length] = selectElements.item(i); + } var inputElement, id, flagField; - for ( var i=0 ; i [% IF type.is_active && type.is_requesteeble %] - () + [% IF Param('usemenuforusers') %] + [% INCLUDE global/userselect.html.tmpl + name => "requestee-$flag.id" + id => "requestee-$flag.id" + value => flag.requestee.login + multiple => 0 + emptyok => 1 + custom_userlist => flag.type.grant_list + %] + [% ELSE %] + () + [% END %] [% END %] @@ -173,9 +192,19 @@ [% IF type.is_requesteeble %] - () + [% IF Param('usemenuforusers') %] + [% INCLUDE global/userselect.html.tmpl + name => "requestee_type-$type.id" + id => "requestee_type-$type.id" + multiple => type.is_multiplicable * 3 + emptyok => !type.is_multiplicable + custom_userlist => type.grant_list + %] + [% ELSE %] + () + [% END %] [% END %] @@ -216,11 +245,21 @@ [% IF any_flags_requesteeble %] [% IF type.is_requesteeble %] - + + [% IF Param('usemenuforusers') %] + [% INCLUDE global/userselect.html.tmpl + name => "requestee_type-$type.id" + id => "requestee_type-$type.id" + multiple => type.is_multiplicable * 3 + emptyok => !type.is_multiplicable + custom_userlist => type.grant_list + %] + [% ELSE %] () - + [% END %] + [% END %] [% END %] diff --git a/template/en/default/global/userselect.html.tmpl b/template/en/default/global/userselect.html.tmpl index 398300b52..8fa7e0360 100644 --- a/template/en/default/global/userselect.html.tmpl +++ b/template/en/default/global/userselect.html.tmpl @@ -25,6 +25,7 @@ # emptyok: optional, select only; if true, prepend menu option to start of select # multiple: optional, do multiselect box, value is size (height) of box # do_not_change: optional, contains the string meaning "do not alter this role" + # custom_userlist: optional, specify a limited list of users to use #%] [% IF Param("usemenuforusers") %] @@ -45,7 +46,11 @@ [% END %] - [% FOREACH tmpuser = user.get_userlist %] + [% UNLESS custom_userlist %] + [% custom_userlist = user.get_userlist %] + [% END %] + + [% FOREACH tmpuser = custom_userlist %] [% IF tmpuser.visible OR value.match("\\b$tmpuser.login\\b") %]