X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FElements%2FSelectOwnerDropdown;h=ce38159be99f4df34dad098f15146aeb81626f65;hp=acd8bc964a3f7dfdbdf20a9db7b14ce7c16eb761;hb=44dd00a3ff974a17999e86e64488e996edc71e3c;hpb=73a6a80a9ca5edbd43d139b7cb25bfee4abfd35e diff --git a/rt/share/html/Elements/SelectOwnerDropdown b/rt/share/html/Elements/SelectOwnerDropdown index acd8bc964..ce38159be 100644 --- a/rt/share/html/Elements/SelectOwnerDropdown +++ b/rt/share/html/Elements/SelectOwnerDropdown @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -49,10 +49,6 @@ %if ($DefaultValue) { %} -% $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]; +><% $UserRef->[1] %> %} <%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; <%ARGS>