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

Alex Vandiver alexmv at bestpractical.com
Mon Mar 25 20:05:08 EDT 2013


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

- Log -----------------------------------------------------------------
commit 629217344764707d8005a4878d721c1c6350bc21
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 870e15f8c72b1b8a8e9920879b0fc7ed574dae89
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 f91bad286ce5ef2fda148369ca79164f5a83008d
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 b2d1ac2d9d6f176c003164d4d9bf9b48ffcfefe0
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 %>\
+% }

commit 7b444cb9aefb3829755d6f977e1e027dde3c576e
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 d295e49004ff77797b63aba4e8a1aa077968c141
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..f6157ca 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -81,6 +81,21 @@ my $LinkCallback = sub {
     }
 };
 
+my $linkUsers;
+$linkUsers = sub {
+    my ($what) = @_;
+    if ($what->isa("RT::Group")) {
+        my @ret = map {$linkUsers->($_->[1]), ", "}
+            sort {$a->[0] cmp $b->[0]}
+            map {+[($_->EmailAddress||''), $_]}
+            @{ $what->UserMembersObj->ItemsArrayRef };
+        pop @ret; # Remove ending ", "
+        return @ret;
+    } else {
+        return \($m->scomp("/Elements/ShowUser", User => $what));
+    }
+};
+
 $COLUMN_MAP = {
     Queue => {
         attribute => 'Queue',
@@ -97,6 +112,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 +199,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

commit 3404df7f2dcabe7ef760a3de9bbbbfb6f83627a7
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 07541d7d3eb1603479ae9b2238908cfd3004ffae
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 c7700d9f7593fcdd14db0aedcb7202cd3fcb69b7
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 = @_;

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


More information about the Rt-commit mailing list