[Rt-commit] rt branch, 4.2/link-user-summary, created. rt-4.1.6-392-gb12af0d

Alex Vandiver alexmv at bestpractical.com
Fri Mar 29 02:34:49 EDT 2013


The branch, 4.2/link-user-summary has been created
        at  b12af0df5b5d5b7e07c5db9af27a352806f5eb2c (commit)

- Log -----------------------------------------------------------------
commit c8866f9f0841ff946e7ee3a3e5849fa836c01c56
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 20 15:21:37 2013 -0400

    Update documentation on UsernameFormat to be correct
    
    The Verbose vs Concise option was originally added in 07ec5dc.  At that
    time, Concise did indeed check the Privileged state of the user;
    however, this logic was removed in 20d879f and vastly simplified, and
    the documentation was never updated to reflect this fact.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 279103c..d1e079f 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -934,10 +934,9 @@ Set(@CSSFiles, qw//);
 
 =item C<$UsernameFormat>
 
-This determines how user info is displayed. 'concise' will show one of
-either NickName, RealName, Name or EmailAddress, depending on what
-exists and whether the user is privileged or not. 'verbose' will show
-RealName and EmailAddress.
+This determines how user info is displayed. 'concise' will show the
+first of RealName, Name or EmailAddress that has a value. 'verbose' will
+show EmailAddress, and the first of RealName or Name which is defined.
 
 =cut
 

commit b3a239f1b2cc381917cff6051e6c81f4f6d4b983
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 20 16:25:27 2013 -0400

    Call $user->Format directly, instead of using the component
    
    When this code was originally added in 8e85e99, ->Format did not exist
    yet.  c3ef8c7 removed all other all sites which made use of NoEscape;
    remove this last vestige of it, in favor of calling the object's API
    directly.

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 0e1a70e..7056d24 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -3446,13 +3446,9 @@ sub GetPrincipalsMap {
             $Users->Limit( ALIAS => $groups, FIELD => 'Domain', VALUE => 'ACLEquivalence' );
             $Users->Limit( ALIAS => $groups, FIELD => 'Type', VALUE => 'UserEquiv' );
 
-
-            my $display = sub {
-                $m->scomp('/Elements/ShowUser', User => $_[0], NoEscape => 1)
-            };
             push @map, [
                 'Users' => $Users,  # loc_left_pair
-                $display => 0
+                'Format' => 0
             ];
         }
     }

commit 75a3890eabf03db08d1ca2876d11f6dd3a01ce03
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 20 16:30:45 2013 -0400

    Remove the no-longer-used NoEscape option

diff --git a/share/html/Elements/ShowUser b/share/html/Elements/ShowUser
index 178976d..234d80c 100644
--- a/share/html/Elements/ShowUser
+++ b/share/html/Elements/ShowUser
@@ -60,18 +60,13 @@ $m->callback(
     ARGSRef         => \%ARGS,
     User            => $User,
     Address         => $Address,
-    NoEscape        => \$NoEscape,
     display         => \$display,
     CallbackName    => 'Modify',
 );
-
-$display = $m->interp->apply_escapes($display, 'h')
-    unless $NoEscape;
 </%INIT>
 <%ARGS>
 $User => undef
 $Address => undef
-$NoEscape => 0
 $style => undef
 </%ARGS>
-<% $display |n %>\
+<% $display %>\

commit 333e97fbdec27aabbda2d29952c2cb190663a754
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Tue Mar 5 14:51:51 2013 -0800

    Link user references to the User Summary page
    
    The User Summary page is currently only available to Privileged users,
    so we only generate links if the current user is privileged.
    
    Nobody and RT_System are not linked.

diff --git a/share/html/Elements/ShowUser b/share/html/Elements/ShowUser
index 234d80c..4060032 100644
--- a/share/html/Elements/ShowUser
+++ b/share/html/Elements/ShowUser
@@ -56,11 +56,25 @@ my $display = RT::User->Format(
     Format      => $style,
 );
 
+# RT::User->Format does this itself, but we want to make sure we have a $User
+# if at all possible for the rest of our code below.
+if ($Address and not $User) {
+    $User = RT::User->new( $session{CurrentUser} );
+    $User->LoadByEmail( $Address->address );
+    undef $User unless $User->id;
+}
+
+my %system_user = (
+    RT->Nobody->id      => 1,
+    RT->SystemUser->id  => 1,
+);
+
 $m->callback(
     ARGSRef         => \%ARGS,
     User            => $User,
     Address         => $Address,
     display         => \$display,
+    system_user     => \%system_user,
     CallbackName    => 'Modify',
 );
 </%INIT>
@@ -69,4 +83,10 @@ $User => undef
 $Address => undef
 $style => undef
 </%ARGS>
+% if ($User and $User->id and not $system_user{$User->id} and $session{CurrentUser}->Privileged) {
+<a href="<% RT->Config->Get("WebPath") %>/User/Summary.html?id=<% $User->id %>">\
+<% $display %>\
+</a>\
+% } else {
 <% $display %>\
+% }
diff --git a/t/web/ticket_owner.t b/t/web/ticket_owner.t
index 8150853..4704935 100644
--- a/t/web/ticket_owner.t
+++ b/t/web/ticket_owner.t
@@ -383,10 +383,10 @@ diag
         fields    => { Owner => $user_a->id },
         button => 'SubmitTicket',
     );
-    $agent_a->content_like( qr/user_a\s+-\s+Taken/, 'got user_a Taken message' );
+    $agent_a->content_like( qr{<a\b[^>]+>user_a</a>\s+-\s+Taken}, 'got user_a Taken message' );
 
     $agent_b->goto_ticket($id);
-    $agent_b->content_like( qr/user_a\s+-\s+Taken/, 'got user_a Taken message for user b ' );
+    $agent_b->content_like( qr{<a\b[^>]+>user_a</a>\s+-\s+Taken}, 'got user_a Taken message for user b ' );
 }
 
 diag
@@ -410,9 +410,9 @@ diag
     $agent_a->content_contains( 'Owner changed from Nobody to user_a',
         'got set message in Basics' );
     $agent_a->goto_ticket($id);
-    $agent_a->content_like( qr/user_a\s+-\s+Taken/, 'got user_a Taken message' );
+    $agent_a->content_like( qr{<a\b[^>]+>user_a</a>\s+-\s+Taken}, 'got user_a Taken message' );
 
     $agent_b->goto_ticket($id);
-    $agent_b->content_like( qr/user_a\s+-\s+Taken/, 'got user_a Taken message for user b ' );
+    $agent_b->content_like( qr{<a\b[^>]+>user_a</a>\s+-\s+Taken}, 'got user_a Taken message for user b ' );
 }
 

commit 0b86c1624fbb89bcb59a6250dd44b69b34eb02bb
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Tue Mar 5 14:53:12 2013 -0800

    Upgrade text-only user references to their HTML versions
    
    Library code outside of Mason, such as RT::Transaction, shouldn't call
    into /Elements/ShowUser.  To properly linkify those user references, we
    wrap the text-only user reference in an HTML element which is replaced
    by JavaScript on page load.

diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index 13635ec..285fc6f 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -687,7 +687,7 @@ sub _FormatUser {
     my $self = shift;
     my $user = shift;
     return [
-        \'<span class="user" data-user-id="', $user->id, \'">',
+        \'<span class="user" data-replace="user" data-user-id="', $user->id, \'">',
         $user->Format,
         \'</span>'
     ];
diff --git a/share/html/Helpers/TicketHistory b/share/html/Helpers/TicketHistory
index 43fed95..d47a4ca 100644
--- a/share/html/Helpers/TicketHistory
+++ b/share/html/Helpers/TicketHistory
@@ -54,13 +54,12 @@ $TicketObj->Load($id);
 
 my $attachments = $TicketObj->Attachments;
 my $attachment_content = $TicketObj->TextAttachments;
-
-$m->comp('/Elements/ShowHistory',
+</%INIT>
+<& /Elements/ShowHistory,
     Object => $TicketObj,
     ShowHeaders => $ARGS{'ShowHeaders'},
     Attachments => $attachments,
     AttachmentContent => $attachment_content
-);
-
-$m->abort();
-</%INIT>
+    &>
+<script type="text/javascript">ReplaceUserReferences()</script>
+% $m->abort();
diff --git a/share/static/js/event-registration.js b/share/static/js/event-registration.js
index 5601459..f8a2184 100644
--- a/share/static/js/event-registration.js
+++ b/share/static/js/event-registration.js
@@ -1,3 +1,4 @@
+// Disable chosing individual objects when a scrip is applied globally
 jQuery(function() {
     var global_checkboxes = [
         "form[name=AddRemoveScrip] input[type=checkbox][name^=AddScrip-][value=0]",
@@ -13,3 +14,29 @@ jQuery(function() {
                 .attr("disabled", checked ? "disabled" : "");
         });
 });
+
+// Replace user references in history with the HTML versions
+function ReplaceUserReferences() {
+    var users = jQuery(".user[data-replace=user]");
+    var ids   = users.map(function(){
+        return "id=" + encodeURIComponent(jQuery(this).attr("data-user-id"))
+    }).toArray().join(";");
+
+    if (!ids.length)
+        return
+
+    jQuery.get(
+        RT.Config.WebPath + "/Helpers/UserInfo?" + ids,
+        function(json) {
+            users.each(function() {
+                var user = jQuery(this);
+                var uid  = user.attr("data-user-id");
+                if (!json[uid])
+                    return
+                user.removeAttr("data-replace")
+                    .html( json[uid]._html );
+            });
+        }
+    );
+}
+jQuery(ReplaceUserReferences);

commit d8fc54bda227da51f9652ecd6872e8851dd5076d
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 20 16:36:59 2013 -0400

    Use ShowUser in ColumnMap, to link to user summaries
    
    This alters formats to use the user's preferred display format, instead
    of hard-coding the user's email address (for AdminCcs, Ccs and
    Requestors) or the users's name (for Owners).  This makes user display
    generally more consistent, although in some use cases the RealName of
    users may obscure which Name or EmailAddress is involved.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index d1e079f..dfe9006 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -991,7 +991,7 @@ Set($UserSummaryTicketListFormat, q{
        '<B><A HREF="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a></B>/TITLE:Subject',
        Status,
        QueueName,
-       OwnerName,
+       Owner,
        Priority,
        '__NEWLINE__',
        '',
@@ -1241,7 +1241,7 @@ Set ($DefaultSearchResultFormat, qq{
    '<B><A HREF="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a></B>/TITLE:Subject',
    Status,
    QueueName,
-   OwnerName,
+   Owner,
    Priority,
    '__NEWLINE__',
    '',
@@ -1263,7 +1263,7 @@ Set($DefaultSelfServiceSearchResultFormat, qq{
    '<B><A HREF="__WebPath__/SelfService/Display.html?id=__id__">__Subject__</a></B>/TITLE:Subject',
    Status,
    Requestors,
-   OwnerName});
+   Owner});
 
 =item C<%FullTextSearch>
 
@@ -1339,7 +1339,7 @@ Control the appearance of the ticket lists in the 'More About Requestors' box.
 
 Set($MoreAboutRequestorTicketListFormat, q{
        '<a href="__WebPath__/Ticket/Display.html?id=__id__">__id__</a>',
-       '(__OwnerName__)',
+       '(__Owner__)',
        '<a href="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a>',
        '__Status__',
 });
diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index 82f55a3..d1dbc10 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -81,6 +81,33 @@ my $LinkCallback = sub {
     }
 };
 
+my $linkUsers;
+$linkUsers = sub {
+    my ($what, $more) = @_;
+    if ($what->isa("RT::Group")) {
+        my @ret = map {$linkUsers->($_->[1], $more), ", "}
+            sort {$a->[0] cmp $b->[0]}
+            map {+[($_->EmailAddress||''), $_]}
+            @{ $what->UserMembersObj->ItemsArrayRef };
+        pop @ret; # Remove ending ", "
+        return @ret;
+    } else {
+        my @ret = \($m->scomp("/Elements/ShowUser", User => $what));
+        push @ret, $more->($what) if $more;
+        return @ret;
+    }
+};
+my $trustSub = sub {
+    my $user = shift;
+    require RT::Crypt::GnuPG;
+    my %key = RT::Crypt::GnuPG::GetKeyInfo($user->EmailAddress);
+    if (!defined $key{'info'}) {
+        return ' ' . loc("(no pubkey!)");
+    } elsif ($key{'info'}{'TrustLevel'} == 0) {
+        return ' ' . loc("(untrusted!)");
+    }
+};
+
 $COLUMN_MAP = {
     Queue => {
         attribute => 'Queue',
@@ -97,6 +124,11 @@ $COLUMN_MAP = {
         attribute => 'Owner',
         value     => sub { return $_[0]->OwnerObj->Name }
     },
+    Owner => {
+        title     => 'Owner', # loc
+        attribute => 'Owner',
+        value     => sub { return $linkUsers->($_[0]->OwnerObj) }
+    },
     Status => {
         title     => 'Status', # loc
         attribute => 'Status',
@@ -179,17 +211,17 @@ $COLUMN_MAP = {
     Requestors => {
         title     => 'Requestors', # loc
         attribute => 'Requestor.EmailAddress',
-        value     => sub { return $_[0]->Requestors->MemberEmailAddressesAsString }
+        value     => sub { return $linkUsers->( $_[0]->Requestors ) }
     },
     Cc => {
         title     => 'Cc', # loc
         attribute => 'Cc.EmailAddress',
-        value     => sub { return $_[0]->Cc->MemberEmailAddressesAsString }
+        value     => sub { return $linkUsers->( $_[0]->Cc ) }
     },
     AdminCc => {
         title     => 'AdminCc', # loc
         attribute => 'AdminCc.EmailAddress',
-        value     => sub { return $_[0]->AdminCc->MemberEmailAddressesAsString }
+        value     => sub { return $linkUsers->( $_[0]->AdminCc ) }
     },
     StartsRelative => {
         title     => 'Starts', # loc
@@ -261,21 +293,7 @@ $COLUMN_MAP = {
     KeyRequestors => {
         title     => 'Requestors', # loc
         attribute => 'Requestor.EmailAddress',
-        value => sub {
-            my $t = shift;
-            my @requestors = $t->Requestors->MemberEmailAddresses;
-            for my $email (@requestors)
-            {
-                my %key = RT::Crypt::GnuPG::GetKeyInfo($email);
-                if (!defined $key{'info'}) {
-                    $email .= ' ' . loc("(no pubkey!)");
-                }
-                elsif ($key{'info'}{'TrustLevel'} == 0) {
-                    $email .= ' ' . loc("(untrusted!)");
-                }
-            }
-            return join ', ', @requestors;
-        }
+        value     => sub { return $linkUsers->($_[0]->Requestors, $trustSub); }
     },
     KeyOwnerName => {
         title     => 'Owner', # loc
@@ -294,6 +312,11 @@ $COLUMN_MAP = {
             return $name;
         }
     },
+    KeyOwner => {
+        title     => 'Owner', # loc
+        attribute => 'Owner',
+        value     => sub { return $linkUsers->($_[0]->OwnerObj, $trustSub); }
+    },
 
     # Everything from LINKTYPEMAP
     (map {
diff --git a/t/web/crypt-gnupg.t b/t/web/crypt-gnupg.t
index 1743a3a..89dfdfa 100644
--- a/t/web/crypt-gnupg.t
+++ b/t/web/crypt-gnupg.t
@@ -2,7 +2,7 @@ use strict;
 use warnings;
 
 use RT::Test::GnuPG
-  tests         => 102,
+  tests         => 101,
   gnupg_options => {
     passphrase    => 'recipient',
     'trust-model' => 'always',
@@ -17,9 +17,9 @@ RT->Config->Set( CorrespondAddress => 'general at example.com');
 RT->Config->Set( DefaultSearchResultFormat => qq{
    '<B><A HREF="__WebPath__/Ticket/Display.html?id=__id__">__id__</a></B>/TITLE:#',
    '<B><A HREF="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a></B>/TITLE:Subject',
-   'OO-__OwnerName__-O',
+   'OO-__Owner__-O',
    'OR-__Requestors__-O',
-   'KO-__KeyOwnerName__-K',
+   'KO-__KeyOwner__-K',
    'KR-__KeyRequestors__-K',
    Status});
 
@@ -426,22 +426,32 @@ $m->get("$baseurl/Search/Simple.html?q=General");
 my $content = $m->content;
 $content =~ s/(/(/g;
 $content =~ s/)/)/g;
-
-like($content, qr/OO-Nobody-O/, "original OwnerName untouched");
-like($content, qr/OO-nokey-O/, "original OwnerName untouched");
-like($content, qr/OO-root-O/, "original OwnerName untouched");
-
-like($content, qr/OR-recipient\@example.com-O/, "original Requestors untouched");
-like($content, qr/OR-nokey\@example.com-O/, "original Requestors untouched");
-
-like($content, qr/KO-root-K/, "KeyOwnerName does not issue no-pubkey warning for recipient");
-like($content, qr/KO-nokey \(no pubkey!\)-K/, "KeyOwnerName issues no-pubkey warning for root");
-like($content, qr/KO-Nobody \(no pubkey!\)-K/, "KeyOwnerName issues no-pubkey warning for nobody");
-
-like($content, qr/KR-recipient\@example.com-K/, "KeyRequestors does not issue no-pubkey warning for recipient\@example.com");
-
-like($content, qr/KR-general\@example.com-K/, "KeyRequestors does not issue no-pubkey warning for general\@example.com");
-like($content, qr/KR-nokey\@example.com \(no pubkey!\)-K/, "KeyRequestors DOES issue no-pubkey warning for nokey\@example.com");
+$content =~ s/<a\b[^>]+>//g;
+$content =~ s/<\/a>//g;
+$content =~ s/</</g;
+$content =~ s/>/>/g;
+
+like($content, qr/OO-Nobody in particular-O/,
+     "original Owner untouched");
+like($content, qr/OO-nokey-O/,
+     "original Owner untouched");
+like($content, qr/OO-Enoch Root-O/,
+     "original Owner untouched");
+like($content, qr/OR-recipient\@example\.com-O/,
+     "original Requestors untouched");
+like($content, qr/OR-nokey-O/,
+     "original Requestors untouched");
+
+like($content, qr/KO-Nobody in particular \(no pubkey!\)-K/,
+     "KeyOwner issues no-pubkey warning for nobody");
+like($content, qr/KO-nokey \(no pubkey!\)-K/,
+     "KeyOwner issues no-pubkey warning for root");
+like($content, qr/KO-Enoch Root-K/,
+     "KeyOwner does not issue no-pubkey warning for recipient");
+like($content, qr/KR-recipient\@example\.com-K/,
+     "KeyRequestors does not issue no-pubkey warning for recipient\@example.com");
+like($content, qr/KR-nokey \(no pubkey!\)-K/,
+     "KeyRequestors DOES issue no-pubkey warning for nokey\@example.com");
 
 $m->next_warning_like(qr/public key not found/);
 $m->next_warning_like(qr/public key not found/);

commit 93e4fd3427c51c4063c2362b2a8063ada13ddf92
Author: Kevin Falcone <falcone at bestpractical.com>
Date:   Thu Mar 14 22:06:02 2013 -0400

    Link user summary in "More About Requestor"

diff --git a/share/html/Elements/ShowUser b/share/html/Elements/ShowUser
index 4060032..bc40e40 100644
--- a/share/html/Elements/ShowUser
+++ b/share/html/Elements/ShowUser
@@ -82,8 +82,9 @@ $m->callback(
 $User => undef
 $Address => undef
 $style => undef
+$Link => 1
 </%ARGS>
-% if ($User and $User->id and not $system_user{$User->id} and $session{CurrentUser}->Privileged) {
+% if ($Link and $User and $User->id and not $system_user{$User->id} and $session{CurrentUser}->Privileged) {
 <a href="<% RT->Config->Get("WebPath") %>/User/Summary.html?id=<% $User->id %>">\
 <% $display %>\
 </a>\
diff --git a/share/html/NoAuth/css/base/ticket.css b/share/html/NoAuth/css/base/ticket.css
index da5ff7b..55049c0 100644
--- a/share/html/NoAuth/css/base/ticket.css
+++ b/share/html/NoAuth/css/base/ticket.css
@@ -45,6 +45,10 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
+
+#requestor-accordion h3 { clear: right }
+#requestor-accordion a.user-summary { float: right; }
+
 #requestor-accordion a.modify-user {
     font-size: 80%;
     color: black !important;
diff --git a/share/html/Ticket/Elements/ShowRequestor b/share/html/Ticket/Elements/ShowRequestor
index df46376..a1fd380 100644
--- a/share/html/Ticket/Elements/ShowRequestor
+++ b/share/html/Ticket/Elements/ShowRequestor
@@ -50,7 +50,11 @@
         jQuery("#requestor-accordion").accordion({
             active: <% $count == 1 ? 0 : 'false' %>,
             collapsible: true,
-            heightStyle: 'content'
+            heightStyle: 'content',
+            header: "h3"
+        }).find("h3 a.user-summary").click(function(ev){
+            ev.stopPropagation();
+            return true;
         });
 
 % if ($ShowTickets) {
@@ -71,7 +75,8 @@
 <div id="requestor-accordion" class="rt-accordion">
 
 % while ( my $requestor = $people->Next ) {
-  <h3><a href="#"><& /Elements/ShowUser, User => $requestor &></a></h3>
+<h3><a href="#"><& /Elements/ShowUser, User => $requestor, Link => 0 &></a>
+    <a class="user-summary" href="<%RT->Config->Get('WebPath')%>/User/Summary.html?id=<%$requestor->Id%>">User Summary</a></h3>
   <div class="details">
 
 %# Additional information about this user.  Empty by default.

commit 14baf7528a3296e184835aa8c5ae0262740dfc1b
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 20 22:03:29 2013 -0400

    Move "Modify this user" to a pagemenu on user summaries

diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
index caaefdc..a2f7743 100644
--- a/share/html/Elements/Tabs
+++ b/share/html/Elements/Tabs
@@ -895,6 +895,17 @@ my $build_main_nav = sub {
 
     }
 
+    if ( $request_path =~ m{^/User/Summary.html} ) {
+        my $admin = $session{'CurrentUser'}->HasRight(
+            Object => $RT::System, Right => 'AdminUsers'
+        );
+        my $config = $session{'CurrentUser'}->HasRight(
+            Object => $RT::System, Right => 'ShowConfigTab'
+        );
+        PageMenu()->child( edit => title => loc('Edit'), path => '/Admin/Users/Modify.html?id=' . $DECODED_ARGS->{'id'} )
+            if $admin && $config;
+    }
+
     if ( $request_path =~ /^\/(?:index.html|$)/ ) {
         PageMenu()->child( edit => title => loc('Edit'), path => '/Prefs/MyRT.html' );
     }
diff --git a/share/html/Ticket/Elements/ShowRequestor b/share/html/Ticket/Elements/ShowRequestor
index a1fd380..fb19662 100644
--- a/share/html/Ticket/Elements/ShowRequestor
+++ b/share/html/Ticket/Elements/ShowRequestor
@@ -136,10 +136,6 @@
 </div>
 % }
 
-% if ( $has_right_adminusers ) {
-    <a class="modify-user" href="<% RT->Config->Get('WebPath')."/Admin/Users/Modify.html?id=".$requestor->id %>">Modify this user</a>
-% }
-
 %# end of individual requestor details <div>
   </div>
 % }

commit b12af0df5b5d5b7e07c5db9af27a352806f5eb2c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Wed Mar 20 16:37:46 2013 -0400

    Add a user format between concise and verbose based on Privileged
    
    The "concise" format, when originally introduced in 07ec5dc, contained
    similar logic which depended on the state of ->Privileged.  However,
    this was removed in 20d879f, after it appeared to incur a notable
    performance penalty.
    
    However, upon closer analysis, much of the penalty was incurred by the
    need to render the names of several hundred users for the ShowUser
    dropdown -- a configuration which causes performance penalties
    regardless.
    
    At a possible minor performance cost, use the Privileged bit to control
    how users are displayed.

diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index dfe9006..0d59ea4 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -940,7 +940,7 @@ show EmailAddress, and the first of RealName or Name which is defined.
 
 =cut
 
-Set($UsernameFormat, "concise");
+Set($UsernameFormat, "role");
 
 =item C<$UserSearchResultFormat>
 
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index f6b3fd9..3eb1b15 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -1659,11 +1659,25 @@ sub Format {
             "Either system config or user #" . $args{CurrentUser}->id .
             " picked UsernameFormat $args{Format}, but RT::User->$method doesn't exist"
         );
-        $formatter = $self->can("_FormatUserConcise");
+        $formatter = $self->can("_FormatUserRole");
     }
     return $formatter->( $self, map { $_ => $args{$_} } qw(User Address) );
 }
 
+sub _FormatUserRole {
+    my $self = shift;
+    my %args = @_;
+
+    my $user = $args{User};
+    return $self->_FormatUserVerbose(@_)
+        unless $user and $user->Privileged;
+
+    my $name = $user->Name;
+    $name .= " (".$user->RealName.")"
+        if $user->RealName and lc $user->RealName ne lc $user->Name;
+    return $name;
+}
+
 sub _FormatUserConcise {
     my $self = shift;
     my %args = @_;
diff --git a/t/web/case-sensitivity.t b/t/web/case-sensitivity.t
index f9c61b5..c8dc77c 100644
--- a/t/web/case-sensitivity.t
+++ b/t/web/case-sensitivity.t
@@ -22,7 +22,7 @@ $m->login;
     require JSON;
     is_deeply(
         JSON::from_json( $m->content ),
-        [{"value" =>  "root\@localhost","label" => "Enoch Root"}]
+        [{"value" =>  "root\@localhost","label" => "root (Enoch Root)"}]
     );
 }
 
diff --git a/t/web/crypt-gnupg.t b/t/web/crypt-gnupg.t
index 89dfdfa..a5ec2e5 100644
--- a/t/web/crypt-gnupg.t
+++ b/t/web/crypt-gnupg.t
@@ -435,9 +435,9 @@ like($content, qr/OO-Nobody in particular-O/,
      "original Owner untouched");
 like($content, qr/OO-nokey-O/,
      "original Owner untouched");
-like($content, qr/OO-Enoch Root-O/,
+like($content, qr/OO-root \(Enoch Root\)-O/,
      "original Owner untouched");
-like($content, qr/OR-recipient\@example\.com-O/,
+like($content, qr/OR-<recipient\@example\.com>-O/,
      "original Requestors untouched");
 like($content, qr/OR-nokey-O/,
      "original Requestors untouched");
@@ -446,9 +446,9 @@ like($content, qr/KO-Nobody in particular \(no pubkey!\)-K/,
      "KeyOwner issues no-pubkey warning for nobody");
 like($content, qr/KO-nokey \(no pubkey!\)-K/,
      "KeyOwner issues no-pubkey warning for root");
-like($content, qr/KO-Enoch Root-K/,
+like($content, qr/KO-root \(Enoch Root\)-K/,
      "KeyOwner does not issue no-pubkey warning for recipient");
-like($content, qr/KR-recipient\@example\.com-K/,
+like($content, qr/KR-<recipient\@example\.com>-K/,
      "KeyRequestors does not issue no-pubkey warning for recipient\@example.com");
 like($content, qr/KR-nokey \(no pubkey!\)-K/,
      "KeyRequestors DOES issue no-pubkey warning for nokey\@example.com");
diff --git a/t/web/ticket_forward.t b/t/web/ticket_forward.t
index 7a7d8d1..422be4d 100644
--- a/t/web/ticket_forward.t
+++ b/t/web/ticket_forward.t
@@ -44,7 +44,7 @@ diag "Forward Ticket" if $ENV{TEST_VERBOSE};
     );
     $m->content_contains( 'Sent email successfully', 'sent mail msg' );
     $m->content_contains(
-        'Forwarded Ticket to rt-to at example.com, rt-too at example.com, rt-cc at example.com, Enoch Root',
+        'Forwarded Ticket to <rt-to at example.com>, <rt-too at example.com>, <rt-cc at example.com>, root (Enoch Root)',
         'txn msg' );
     my ($mail) = RT::Test->fetch_caught_mails;
     like( $mail, qr!Subject: test forward!,           'Subject field' );
@@ -71,7 +71,7 @@ diag "Forward Transaction" if $ENV{TEST_VERBOSE};
     );
     $m->content_contains( 'Sent email successfully', 'sent mail msg' );
     $m->content_like(
-qr/Forwarded .*?Transaction #\d+.*? to rt-to\@example.com, rt-too\@example.com, rt-cc\@example.com, Enoch Root/,
+qr/Forwarded .*?Transaction #\d+.*? to <rt-to\@example\.com>, <rt-too\@example\.com>, <rt-cc\@example\.com>, root (Enoch Root)/,
         'txn msg'
     );
     my ($mail) = RT::Test->fetch_caught_mails;
@@ -142,7 +142,7 @@ diag "Forward Transaction with attachments but empty content" if $ENV{TEST_VERBO
         button => 'ForwardAndReturn'
     );
     $m->content_contains( 'Sent email successfully', 'sent mail msg' );
-    $m->content_like( qr/Forwarded .*?Transaction #\d+.*? to rt-test\@example\.com/, 'txn msg' );
+    $m->content_like( qr/Forwarded .*?Transaction #\d+.*? to <rt-test\@example\.com>/, 'txn msg' );
     my ($mail) = RT::Test->fetch_caught_mails;
     like( $mail, qr/Subject: test forward, empty content but attachments/, 'Subject field' );
     like( $mail, qr/To: rt-test\@example.com/,         'To field' );
@@ -200,7 +200,7 @@ diag "Forward Transaction with attachments but no 'content' part" if $ENV{TEST_V
         button => 'ForwardAndReturn'
     );
     $m->content_contains( 'Sent email successfully', 'sent mail msg' );
-    $m->content_like( qr/Forwarded .*?Transaction #\d+.*? to rt-test\@example\.com/, 'txn msg' );
+    $m->content_like( qr/Forwarded .*?Transaction #\d+.*? to <rt-test\@example\.com>/, 'txn msg' );
     
     # Forward ticket
     $m->follow_link_ok( { text => 'Forward', n => 1 }, 'follow 1st Forward' );
@@ -212,7 +212,7 @@ diag "Forward Transaction with attachments but no 'content' part" if $ENV{TEST_V
         button => 'ForwardAndReturn'
     );
     $m->content_contains( 'Sent email successfully', 'sent mail msg' );
-    $m->content_like( qr/Forwarded Ticket to rt-test\@example\.com/, 'txn msg' );
+    $m->content_like( qr/Forwarded Ticket to <rt-test\@example\.com>/, 'txn msg' );
 
     my ($forward_txn, $forward_ticket) = RT::Test->fetch_caught_mails;
     my $tag = qr/Fwd: \[example\.com #\d+\]/;
diff --git a/t/web/ticket_modify_people.t b/t/web/ticket_modify_people.t
index 750be3f..5b59dbb 100644
--- a/t/web/ticket_modify_people.t
+++ b/t/web/ticket_modify_people.t
@@ -80,7 +80,7 @@ ok(
 $m->reload;
 ok(
     $m->find_link(
-        text      => 'Enoch Root',
+        text      => 'root (Enoch Root)',
         url_regex => qr!/Admin/Users/Modify\.html!,
     ),
     'got link to modify user'

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


More information about the Rt-commit mailing list