diff options
author | Shawn M Moore <shawn@bestpractical.com> | 2017-05-17 21:45:06 +0300 |
---|---|---|
committer | sunnavy <sunnavy@bestpractical.com> | 2022-10-19 00:25:59 +0300 |
commit | 65e82c67ea3acada2cc99b7258dcc0c39ce8d9b6 (patch) | |
tree | d389f5d3324e118278f38e167f992edd6ff8635a | |
parent | c8911b2fae995e46bef76b02236c820209ef0e2d (diff) |
Exclude asset custom roles from ticket search
This covers both search builder and bulk update.
-rw-r--r-- | lib/RT/Tickets.pm | 1 | ||||
-rw-r--r-- | share/html/Elements/ColumnMap | 7 | ||||
-rw-r--r-- | share/html/Search/Bulk.html | 2 | ||||
-rw-r--r-- | share/html/Search/Elements/BuildFormatString | 1 | ||||
-rw-r--r-- | share/html/Search/Elements/PickCustomRoles | 2 | ||||
-rw-r--r-- | share/html/Search/Elements/SelectPersonType | 4 |
6 files changed, 16 insertions, 1 deletions
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm index 1278f3b000..183932117f 100644 --- a/lib/RT/Tickets.pm +++ b/lib/RT/Tickets.pm @@ -1112,6 +1112,7 @@ sub _CustomRoleDecipher { if ( $field =~ /\D/ ) { my $roles = RT::CustomRoles->new( $self->CurrentUser ); + $roles->LimitToLookupType(RT::Ticket->CustomFieldLookupType); $roles->Limit( FIELD => 'Name', VALUE => $field, CASESENSITIVE => 0 ); # custom roles are named uniquely, but just in case there are diff --git a/share/html/Elements/ColumnMap b/share/html/Elements/ColumnMap index 8a5b89fcb1..da1f866efe 100644 --- a/share/html/Elements/ColumnMap +++ b/share/html/Elements/ColumnMap @@ -294,7 +294,12 @@ $WCOLUMN_MAP = $COLUMN_MAP = { my $role_obj = $m->notes($key); if (!$role_obj) { $role_obj = RT::CustomRole->new($_[0]->CurrentUser); - $role_obj->Load($role_name); + if ($role_name =~ /^\d+$/) { + $role_obj->Load($role_name); + } + else { + $role_obj->LoadByCols(Name => $role_name, LookupType => $_[0]->CustomFieldLookupType); + } RT->Logger->notice("Unable to load custom role $role_name") unless $role_obj->Id; diff --git a/share/html/Search/Bulk.html b/share/html/Search/Bulk.html index 1b9a2855f0..d038d587f5 100644 --- a/share/html/Search/Bulk.html +++ b/share/html/Search/Bulk.html @@ -154,6 +154,7 @@ </&> % my $single_roles = RT::CustomRoles->new($session{CurrentUser}); +% $single_roles->LimitToLookupType(RT::Ticket->CustomFieldLookupType); % $single_roles->LimitToSingleValue; % $single_roles->LimitToObjectId($_) for keys %$seen_queues; % while (my $role = $single_roles->Next) { @@ -163,6 +164,7 @@ % } % my $multi_roles = RT::CustomRoles->new($session{CurrentUser}); +% $multi_roles->LimitToLookupType(RT::Ticket->CustomFieldLookupType); % $multi_roles->LimitToMultipleValue; % $multi_roles->LimitToObjectId($_) for keys %$seen_queues; % while (my $role = $multi_roles->Next) { diff --git a/share/html/Search/Elements/BuildFormatString b/share/html/Search/Elements/BuildFormatString index 15f0351c18..6211f8369c 100644 --- a/share/html/Search/Elements/BuildFormatString +++ b/share/html/Search/Elements/BuildFormatString @@ -211,6 +211,7 @@ else { next unless $queue->Id; $CustomRoles->LimitToObjectId( $queue->Id ); } + $CustomRoles->LimitToLookupType(RT::Ticket->CustomFieldLookupType) if $CustomRoles->_isLimited; my @user_fields = qw/id Name EmailAddress Organization RealName City Country/; my $user_cfs = RT::CustomFields->new( $session{CurrentUser} ); diff --git a/share/html/Search/Elements/PickCustomRoles b/share/html/Search/Elements/PickCustomRoles index b1acbad2f3..b24956e6fb 100644 --- a/share/html/Search/Elements/PickCustomRoles +++ b/share/html/Search/Elements/PickCustomRoles @@ -59,6 +59,8 @@ foreach my $id (keys %queues) { next unless $queue->Id; $CustomRoles->LimitToObjectId($queue->Id); } +# If there are no referenced queues, do not limit LookupType to return 0 custom roles. +$CustomRoles->LimitToLookupType( RT::Ticket->CustomFieldLookupType ) if $CustomRoles->_isLimited; $m->callback( CallbackName => 'MassageCustomRoles', CustomRoles => $CustomRoles, diff --git a/share/html/Search/Elements/SelectPersonType b/share/html/Search/Elements/SelectPersonType index 57e4c8a209..942a3a408a 100644 --- a/share/html/Search/Elements/SelectPersonType +++ b/share/html/Search/Elements/SelectPersonType @@ -113,6 +113,10 @@ else { next unless $queue->Id; $CustomRoles->LimitToObjectId($queue->Id); } + + # If there are no referenced queues/catalogs, do not limit LookupType to return 0 custom roles. + $CustomRoles->LimitToLookupType( $Class->RecordClass->CustomFieldLookupType ) if $CustomRoles->_isLimited; + $m->callback( CallbackName => 'MassageCustomRoles', CustomRoles => $CustomRoles, |