[Rt-commit] rt branch, 4.4-trunk, updated. rt-4.4.1-343-gaeeeb1c
Shawn Moore
shawn at bestpractical.com
Mon May 15 14:55:41 EDT 2017
The branch, 4.4-trunk has been updated
via aeeeb1c58b7dd1ac4069edf44f51ca0ece93739f (commit)
via 1da24b155d82318c5504160f5d35a6c9ca3786f0 (commit)
from 9eb6181f26d56ee8e7db3859f95d411bfbb98d34 (commit)
Summary of changes:
lib/RT/Users.pm | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
- Log -----------------------------------------------------------------
commit 1da24b155d82318c5504160f5d35a6c9ca3786f0
Author: Brian C. Duggan <brian at bestpractical.com>
Date: Fri Mar 31 12:12:04 2017 -0400
Make user search results sortable by user CFs
An admin can include an RT::User CF in user search results by defining
$AdminSearchFormat{Users} in RT_SiteConfig.pm, like so:
Set(%AdminSearchFormat,
Users =>
...
.q{'__CustomField{SomeUserCF}__'},
...
);
But the RT::Users collection did not support ordering search results
by CFs on RT::User objects.
This change defines the OrderByCols function in Users.pm with an
implementation that accounts for custom fields. With this change,
admins can include user CFs in search results by using
%AdminSearchFormat and sort the results by those CFs by clicking on
the column header.
diff --git a/lib/RT/Users.pm b/lib/RT/Users.pm
index 483f575..44b9425 100644
--- a/lib/RT/Users.pm
+++ b/lib/RT/Users.pm
@@ -100,6 +100,27 @@ sub _Init {
return (@result);
}
+sub OrderByCols {
+ my $self = shift;
+ my @res = ();
+
+ for my $row (@_) {
+ if (($row->{FIELD}||'') =~ /^CustomField\.\{(.*)\}$/) {
+ my $name = $1 || $2;
+ my $cf = RT::CustomField->new( $self->CurrentUser );
+ $cf->LoadByName(
+ Name => $name,
+ ObjectType => 'RT::User',
+ );
+ if ( $cf->id ) {
+ push @res, $self->_OrderByCF( $row, $cf->id, $cf );
+ }
+ } else {
+ push @res, $row;
+ }
+ }
+ return $self->SUPER::OrderByCols( @res );
+}
=head2 PrincipalsAlias
commit aeeeb1c58b7dd1ac4069edf44f51ca0ece93739f
Merge: 9eb6181 1da24b1
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Mon May 15 18:57:25 2017 +0000
Merge branch '4.4/cf-sortable-users' into 4.4-trunk
-----------------------------------------------------------------------
More information about the rt-commit
mailing list