[Rt-commit] rt branch, 4.2/user-autocomplete-cfs, created. rt-4.1.8-416-g6af0f52
Alex Vandiver
alexmv at bestpractical.com
Tue May 28 15:20:47 EDT 2013
The branch, 4.2/user-autocomplete-cfs has been created
at 6af0f52b8c114d6cdd29721e7ed5739e7126aae7 (commit)
- Log -----------------------------------------------------------------
commit cab63260a18961b9d2f10f9283603c6304eb5870
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 23 17:48:19 2013 -0400
Make owner autocomplete use the RT::Users->SimpleSearch API
Refactoring which was mistakenly omitted from d7163ec
diff --git a/share/html/Helpers/Autocomplete/Owners b/share/html/Helpers/Autocomplete/Owners
index 18c3e08..21adc31 100644
--- a/share/html/Helpers/Autocomplete/Owners
+++ b/share/html/Helpers/Autocomplete/Owners
@@ -65,9 +65,6 @@ $m->abort unless defined $return
my $CurrentUser = $session{'CurrentUser'};
-my %fields = %{ RT->Config->Get('UserSearchFields')
- || { EmailAddress => 1, Name => 1, RealName => 'LIKE' } };
-
my %user_uniq_hash;
my $isSU = $session{CurrentUser}
->HasRight( Right => 'SuperUser', Object => $RT::System );
@@ -89,22 +86,13 @@ foreach my $spec (map { [split /\-/, $_, 2] } split /\|/, $limit) {
}
my $Users = RT::Users->new( $session{CurrentUser} );
- $Users->RowsPerPage( $max );
-
# Limit by our autocomplete term BEFORE we limit to OwnTicket because that
# does a funky union hack
- while (my ($name, $op) = each %fields) {
- $op = 'STARTSWITH'
- unless $op =~ /^(?:LIKE|(?:START|END)SWITH)$/i;
-
- $Users->Limit(
- FIELD => $name,
- OPERATOR => $op,
- VALUE => $term,
- ENTRYAGGREGATOR => 'OR',
- SUBCLAUSE => 'autocomplete',
- );
- }
+ $Users->SimpleSearch(
+ Max => $max,
+ Term => $term,
+ Return => $return,
+ );
$Users->WhoHaveRight(
Right => 'OwnTicket',
commit 3135205efab4f79cd1508d696cceb45a02ecada8
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 23 17:49:47 2013 -0400
Remove an unnecessary access of UserSearchFields
This also removes a misleading "default" value (which would never occur,
because of RT_Config's default) which also specified operators of '1'
instead of 'STARTSWITH'.
diff --git a/share/html/Helpers/Autocomplete/Users b/share/html/Helpers/Autocomplete/Users
index b80a604..aa97d45 100644
--- a/share/html/Helpers/Autocomplete/Users
+++ b/share/html/Helpers/Autocomplete/Users
@@ -84,13 +84,6 @@ my $CurrentUser = $session{'CurrentUser'};
$m->abort unless $CurrentUser->Privileged
or RT->Config->Get('AllowUserAutocompleteForUnprivileged');
-my %fields = %{ RT->Config->Get('UserSearchFields')
- || { EmailAddress => 1, Name => 1, RealName => 'LIKE' } };
-
-# If an operator is provided, check against only the returned field
-# using that operator
-%fields = ( $return => $op ) if $op;
-
# the API wants a list of ids
my @exclude = split /\s*,\s*/, $exclude;
push @exclude, RT->SystemUser->id, RT->Nobody->id;
@@ -101,7 +94,9 @@ $users->SimpleSearch( Privileged => $privileged,
Term => $term,
Max => $max,
Exclude => \@exclude,
- Fields => \%fields,
+ # If an operator is provided, check against only
+ # the returned field using that operator
+ $op ? ( Fields => { $return => $op } ) : (),
);
my @suggestions;
commit 5ad3ee486a43787345b16b52e401239b8a387027
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 23 18:02:19 2013 -0400
Allow searching and autocompleting users by custom fields
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 642d61c..60f9d1e 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1453,9 +1453,11 @@ Set($AutocompleteOwnersForSearch, 0);
Used by the User Autocompleter as well as the User Search.
-Specifies which fields of L<RT::User> to match against and how to
-match each field when autocompleting users. Valid match methods are
-LIKE, STARTSWITH, ENDSWITH, =, and !=.
+Specifies which fields of L<RT::User> to match against and how to match
+each field when autocompleting users. Valid match methods are LIKE,
+STARTSWITH, ENDSWITH, =, and !=. Valid search fields are the core User
+fields, as well as custom fields, which are specified as "CF.{1234}" or
+"CF.{Name}"
=cut
diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index cf27993..36d3e4b 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -610,13 +610,24 @@ sub SimpleSearch {
$op = 'STARTSWITH'
unless $op =~ /^(?:LIKE|(?:START|END)SWITH|=|!=)$/i;
- $self->Limit(
- FIELD => $name,
- OPERATOR => $op,
- VALUE => $args{Term},
- ENTRYAGGREGATOR => 'OR',
- SUBCLAUSE => 'autocomplete',
- );
+ if ($name =~ /^CF\.\{(.*)}$/) {
+ my $cfname = $1;
+ $self->LimitCustomField(
+ CUSTOMFIELD => $cfname,
+ OPERATOR => $op,
+ VALUE => $args{Term},
+ ENTRYAGGREGATOR => 'OR',
+ SUBCLAUSE => 'autocomplete',
+ );
+ } else {
+ $self->Limit(
+ FIELD => $name,
+ OPERATOR => $op,
+ VALUE => $args{Term},
+ ENTRYAGGREGATOR => 'OR',
+ SUBCLAUSE => 'autocomplete',
+ );
+ }
}
# Exclude users we don't want
commit 6af0f52b8c114d6cdd29721e7ed5739e7126aae7
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu May 23 19:27:41 2013 -0400
If there is but one user search result, redirect to it
diff --git a/share/html/User/Search.html b/share/html/User/Search.html
index 530467f..75b3aed 100644
--- a/share/html/User/Search.html
+++ b/share/html/User/Search.html
@@ -92,6 +92,12 @@ $users->SimpleSearch( Return => 'Name',
Max => 100,
Exclude => $exclude );
+my $first = $users->First;
+RT::Interface::Web::Redirect(RT->Config->Get('WebURL')."User/Summary.html?id=".$first->Id)
+ if $users->Count == 1;
+
+$users->GotoFirstItem;
+
my $Format = RT->Config->Get('UserSearchResultFormat');
my $search_fields = join ", ", map loc($_), keys %{RT->Config->Get('UserSearchFields')};
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list