[Rt-commit] rt branch, 3.9-trunk, updated. rt-3.8.8-340-gb4eb275

Thomas Sibley trs at bestpractical.com
Mon Aug 16 16:19:51 EDT 2010


The branch, 3.9-trunk has been updated
       via  b4eb27574a099dc25aceadc2e8beeaa4a2cd24dc (commit)
      from  0d96f1bed21431492b670545a64e397dd38d6d8d (commit)

Summary of changes:
 share/html/Admin/Users/index.html      |   25 ++++++++++++++++++++++++-
 share/html/Elements/RT__User/ColumnMap |   10 ++++++++++
 share/html/Elements/SelectUsers        |   15 ++++++++++++++-
 3 files changed, 48 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit b4eb27574a099dc25aceadc2e8beeaa4a2cd24dc
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Mon Aug 16 16:20:05 2010 -0400

    Show most user fields when searching for users at /Admin/Users/
    
    This also makes the display use the new RT::Users ColumnMap.

diff --git a/share/html/Admin/Users/index.html b/share/html/Admin/Users/index.html
index 295ce4a..9ed60b3 100755
--- a/share/html/Admin/Users/index.html
+++ b/share/html/Admin/Users/index.html
@@ -83,7 +83,7 @@
 %     next unless defined $ARGS{ $field } && length $ARGS{ $field };
 <input type="hidden" name="<% $field %>" value="<% $ARGS{ $field } %>" />
 % }
-<&|/l&>Find all users whose</&> <& /Elements/SelectUsers, %ARGS &><br />
+<&|/l&>Find all users whose</&> <& /Elements/SelectUsers, %ARGS, Fields => \@fields &><br />
 <input type="checkbox" class="checkbox" name="FindDisabledUsers" value="1" <% $FindDisabledUsers? 'checked="checked"': '' %> />
 <&|/l&>Include disabled users in search.</&>
 <br />
@@ -122,6 +122,29 @@ else {
 
 $Format ||= RT->Config->Get('AdminSearchResultFormat')->{'Users'};
 
+# Build up the list of fields to display for searching
+my $i = 0;
+my %sorted = map { $_ => $i++ } qw(
+    Name EmailAddress RealName Organization NickName WorkPhone HomePhone
+    MobilePhone PagerPhone Address1 Address2 City State Zip Country
+    Timezone Lang Gecos Comments
+);
+
+my @attrs = sort { $sorted{$a} <=> $sorted{$b} }
+            grep { !/(?:^id$|ContactInfo|Encoding|^External|System|PGPKey|^Last|^Creat(?:ed|or)$|^Signature$)/ }
+            RT::User->ReadableAttributes;
+my @fields;
+
+for my $name (@attrs) {
+    my $label = $m->comp(
+        '/Elements/ColumnMap',
+        Class   => 'RT__User',
+        Name    => $name,
+        Attr    => 'title'
+    );
+
+    push @fields, [ $name, $label || $name ];
+}
 </%INIT>
 <%ARGS>
 $Format => undef,
diff --git a/share/html/Elements/RT__User/ColumnMap b/share/html/Elements/RT__User/ColumnMap
index 75c81d2..52ecfb6 100644
--- a/share/html/Elements/RT__User/ColumnMap
+++ b/share/html/Elements/RT__User/ColumnMap
@@ -132,6 +132,16 @@ my $COLUMN_MAP = {
 	attribute => 'Country',
 	value     => sub { return $_[0]->Country() },
     },
+    Gecos => {
+        title       => 'Unix login', #loc
+        attribute   => 'Gecos',
+        value       => sub { return $_[0]->Gecos() },
+    },
+    Lang => {
+        title       => 'Language', #loc
+        attribute   => 'Lang',
+        value       => sub { return $_[0]->Lang() },
+    },
 };
 
 </%ONCE>
diff --git a/share/html/Elements/SelectUsers b/share/html/Elements/SelectUsers
index 3e1ba90..0c41d02 100755
--- a/share/html/Elements/SelectUsers
+++ b/share/html/Elements/SelectUsers
@@ -46,7 +46,7 @@
 %# 
 %# END BPS TAGGED BLOCK }}}
 <select name="UserField">
-% foreach my $col (RT::User->BasicColumns) {
+% foreach my $col (@fields) {
 <option <% ($UserField eq $col->[0]) ? 'selected="selected"' : '' |n %> value="<% $col->[0] %>"><% loc($col->[1]) %></option>
 % }
 % while (my $CF = $CFs->Next) {
@@ -60,9 +60,22 @@
 my $CFs = RT::CustomFields->new($session{'CurrentUser'});
 $CFs->LimitToChildType('RT::User');
 $CFs->OrderBy( FIELD => 'Name' );
+
+my @fields = RT::User->BasicColumns;
+
+if ( $Fields and ref $Fields eq 'ARRAY' ) {
+    if ( ref $Fields->[0] eq 'ARRAY' ) {
+        @fields = @$Fields;
+    }
+    else {
+        # make the name equal the label
+        @fields = [ @$Fields, @$Fields ];
+    }
+}
 </%INIT>
 <%ARGS>
 $UserField  => ''
 $UserOp     => ''
 $UserString => ''
+$Fields     => undef
 </%ARGS>

-----------------------------------------------------------------------


More information about the Rt-commit mailing list