diff options
Diffstat (limited to 'rt/share/html/Elements/SelectOwnerDropdown')
-rw-r--r-- | rt/share/html/Elements/SelectOwnerDropdown | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/rt/share/html/Elements/SelectOwnerDropdown b/rt/share/html/Elements/SelectOwnerDropdown index acd8bc964..60e9cde7e 100644 --- a/rt/share/html/Elements/SelectOwnerDropdown +++ b/rt/share/html/Elements/SelectOwnerDropdown @@ -49,10 +49,6 @@ %if ($DefaultValue) { <option value=""<% !$Default ? qq[ selected="selected"] : '' |n %>><%$DefaultLabel |n%></option> %} -% $Default = 0 unless defined $Default && $Default =~ /^\d+$/; -% my @formatednames = sort {lc $a->[1] cmp lc $b->[1]} map {[$_, $m->scomp('/Elements/ShowUser', User => $_)]} grep { $_->id != RT->Nobody->id } @users; -% my $nobody = [RT->Nobody, $m->scomp('/Elements/ShowUser', User => RT->Nobody)]; -% unshift @formatednames, $nobody; %foreach my $UserRef ( @formatednames) { %my $User = $UserRef->[0]; <option <% ( $User->Id == $Default) ? qq[ selected="selected"] : '' |n %> @@ -61,7 +57,7 @@ %} elsif ($ValueAttribute eq 'Name') { value="<%$User->Name%>" %} -><% $UserRef->[1] |n %></option> +><% $UserRef->[1] %></option> %} </select> <%INIT> @@ -71,6 +67,7 @@ my $isSU = $session{CurrentUser} ->HasRight( Right => 'SuperUser', Object => $RT::System ); foreach my $object (@$Objects) { my $Users = RT::Users->new( $session{CurrentUser} ); + $Users->LimitToPrivileged; $Users->WhoHaveRight( Right => 'OwnTicket', Object => $object, @@ -81,12 +78,35 @@ foreach my $object (@$Objects) { $user_uniq_hash{ $User->Id() } = $User; } } + +my $dropdown_limit = 50; +$m->callback( CallbackName => 'ModifyDropdownLimit', DropdownLimit => \$dropdown_limit ); + +if (keys(%user_uniq_hash) > $dropdown_limit ) { + if ($Objects->[0]->id) { + my $desc = $Objects->[0]->RecordType." ".$Objects->[0]->id; + RT->Logger->notice("More than $dropdown_limit possible Owners found for $desc; switching to autocompleter. See the \$AutocompleteOwners configuration option"); + } + $m->comp("/Elements/SelectOwnerAutocomplete", %ARGS); + return; +} + if ($Default && $Default != RT->Nobody->id && !$user_uniq_hash{$Default}) { $user_uniq_hash{$Default} = RT::User->new($session{CurrentUser}); $user_uniq_hash{$Default}->Load($Default); } +$Default = 0 unless defined $Default && $Default =~ /^\d+$/; + +my @formatednames = sort {lc $a->[1] cmp lc $b->[1]} + map {[$_, $_->Format]} + grep { $_->id != RT->Nobody->id } + values %user_uniq_hash; + +my $nobody_user = RT::User->new( $session{CurrentUser} ); +$nobody_user->Load( RT->Nobody->id ); +my $nobody = [$nobody_user, $nobody_user->Format]; +unshift @formatednames, $nobody; -my @users = values %user_uniq_hash; </%INIT> <%ARGS> |