[Rt-commit] rt branch, 4.2/dont-recurse-groups-in-role-columnmap, created. rt-4.1.8-576-g9d85251
Alex Vandiver
alexmv at bestpractical.com
Thu Jun 13 18:03:46 EDT 2013
The branch, 4.2/dont-recurse-groups-in-role-columnmap has been created
at 9d85251978c738ec9d1e13be4dbd1aa6e46b9911 (commit)
- Log -----------------------------------------------------------------
commit 3868d66170423651cdec776926089e69f9f65313
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Jun 6 21:22:27 2013 -0400
Don't expand groups assigned as roles in ticket columnmap
Previous to d8fc54b, the ticket columnmap used
MemberEmailAddressesAsString fr role groups. This method does a
recursive memership lookup, and thus a single large group added as a Cc
would be listed as the entirety of their email addresses. d8fc54b kept
this behavior.
Instead of dispalying a potentially large list of email addresses,
simply display the name of the group instead. This mirrors what the
ticket display page does for such cases.
diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index d1dbc10..6d930d1 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -85,10 +85,16 @@ my $linkUsers;
$linkUsers = sub {
my ($what, $more) = @_;
if ($what->isa("RT::Group")) {
+ # Link the users (non-recursively)
my @ret = map {$linkUsers->($_->[1], $more), ", "}
sort {$a->[0] cmp $b->[0]}
map {+[($_->EmailAddress||''), $_]}
- @{ $what->UserMembersObj->ItemsArrayRef };
+ @{ $what->UserMembersObj( Recursively => 0 )->ItemsArrayRef };
+
+ # But don't link the groups
+ push @ret, map {+("Group: $_", ",")}
+ sort map {$_->Name} @{ $what->GroupMembersObj( Recursively => 0)->ItemsArrayRef };
+
pop @ret; # Remove ending ", "
return @ret;
} else {
commit 983ee481bb6a0a4524e2a7a43e6e208bb9f79f62
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Jun 13 16:06:57 2013 -0400
Ensure that RT::Ticket has a method for every role group
Roles are in the singular declension; thus support and encourage
->Requestor for consistency.
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index bcfcfcbe..2bbc861 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -851,20 +851,25 @@ sub CcAddresses {
-=head2 Requestors
+=head2 Requestor
Takes nothing.
Returns this ticket's Requestors as an RT::Group object
=cut
-sub Requestors {
+sub Requestor {
my $self = shift;
return RT::Group->new($self->CurrentUser)
unless $self->CurrentUserHasRight('ShowTicket');
return $self->RoleGroup( 'Requestor' );
}
+sub Requestors {
+ my $self = shift;
+ return $self->Requestor;
+}
+
=head2 Cc
commit 4748343c65c9090ebd1f943e1bb2a6a30167ce05
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Jun 13 16:14:10 2013 -0400
Move $linkUsers into an element so it can be used externally
Multiple locations, particularly where role groups are involved, may
wish to enumerate and link group and user contents.
diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index 6d930d1..939005d 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -81,36 +81,14 @@ my $LinkCallback = sub {
}
};
-my $linkUsers;
-$linkUsers = sub {
- my ($what, $more) = @_;
- if ($what->isa("RT::Group")) {
- # Link the users (non-recursively)
- my @ret = map {$linkUsers->($_->[1], $more), ", "}
- sort {$a->[0] cmp $b->[0]}
- map {+[($_->EmailAddress||''), $_]}
- @{ $what->UserMembersObj( Recursively => 0 )->ItemsArrayRef };
-
- # But don't link the groups
- push @ret, map {+("Group: $_", ",")}
- sort map {$_->Name} @{ $what->GroupMembersObj( Recursively => 0)->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!)");
+ return $m->interp->apply_escapes(' ' . loc("(no pubkey!)"), "h");
} elsif ($key{'info'}{'TrustLevel'} == 0) {
- return ' ' . loc("(untrusted!)");
+ return $m->interp->apply_escapes(' ' . loc("(untrusted!)"), "h");
}
};
@@ -133,7 +111,7 @@ $COLUMN_MAP = {
Owner => {
title => 'Owner', # loc
attribute => 'Owner',
- value => sub { return $linkUsers->($_[0]->OwnerObj) }
+ value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->OwnerObj ) ) }
},
Status => {
title => 'Status', # loc
@@ -217,17 +195,17 @@ $COLUMN_MAP = {
Requestors => {
title => 'Requestors', # loc
attribute => 'Requestor.EmailAddress',
- value => sub { return $linkUsers->( $_[0]->Requestors ) }
+ value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->Requestor ) ) }
},
Cc => {
title => 'Cc', # loc
attribute => 'Cc.EmailAddress',
- value => sub { return $linkUsers->( $_[0]->Cc ) }
+ value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->Cc ) ) }
},
AdminCc => {
title => 'AdminCc', # loc
attribute => 'AdminCc.EmailAddress',
- value => sub { return $linkUsers->( $_[0]->AdminCc ) }
+ value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->AdminCc ) ) }
},
StartsRelative => {
title => 'Starts', # loc
@@ -299,7 +277,7 @@ $COLUMN_MAP = {
KeyRequestors => {
title => 'Requestors', # loc
attribute => 'Requestor.EmailAddress',
- value => sub { return $linkUsers->($_[0]->Requestors, $trustSub); }
+ value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->Requestor, PostUser => $trustSub ) ) }
},
KeyOwnerName => {
title => 'Owner', # loc
@@ -321,7 +299,7 @@ $COLUMN_MAP = {
KeyOwner => {
title => 'Owner', # loc
attribute => 'Owner',
- value => sub { return $linkUsers->($_[0]->OwnerObj, $trustSub); }
+ value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->OwnerObj, PostUser => $trustSub ) ) }
},
# Everything from LINKTYPEMAP
diff --git a/share/html/Elements/ShowPrincipal b/share/html/Elements/ShowPrincipal
new file mode 100644
index 0000000..b8e7ddd
--- /dev/null
+++ b/share/html/Elements/ShowPrincipal
@@ -0,0 +1,71 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2013 Best Practical Solutions, LLC
+%# <sales at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+%# 02110-1301 or visit their web page on the internet at
+%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+%# Released under the terms of version 2 of the GNU Public License
+<%args>
+$Object
+$PostUser => undef
+$Separator => ", "
+</%args>
+<%init>
+if ($Object->isa("RT::Group")) {
+ # Link the users (non-recursively)
+ my @ret = map {$m->scomp("ShowPrincipal", Object => $_->[1], PostUser => $PostUser)}
+ sort {$a->[0] cmp $b->[0]}
+ map {+[($_->EmailAddress||''), $_]}
+ @{ $Object->UserMembersObj( Recursively => 0 )->ItemsArrayRef };
+
+ # But don't link the groups
+ push @ret, sort map {$m->interp->apply_escapes( loc("Group: [_1]", $_->Name), 'h' )}
+ @{ $Object->GroupMembersObj( Recursively => 0)->ItemsArrayRef };
+
+ $m->out( join($Separator, @ret) );
+} else {
+ $m->comp("/Elements/ShowUser", User => $Object);
+ $m->out( $PostUser->($Object) ) if $PostUser;
+}
+</%init>
commit e272cedc888529770318c17ea87bf90eae8769ea
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Jun 13 16:14:26 2013 -0400
Add role groups to ColumnMap computationally
If a class ColumnMap does not explicitly define handlers for its role
groups, compute and display them computationally. Unfortunately, $Class
is already in the form RT__Ticket and not RT::Ticket, and thus must be
computationally transformed back.
This also implicitly changes from using the ->Requestors method to
calling ->RoleGroup("Requestor"), which bypasses the ShowTicket ACL.
However, as results in the ticket list have already had ShowTicket
applied, this cannot cause an information leak.
diff --git a/share/html/Elements/ColumnMap b/share/html/Elements/ColumnMap
index 01ba3ab..c5f9f26 100644
--- a/share/html/Elements/ColumnMap
+++ b/share/html/Elements/ColumnMap
@@ -213,6 +213,25 @@ if (RT::Interface::Web->ComponentPathIsSafe($Class) and $m->comp_exists("/Elemen
my $class_map = $m->comp("/Elements/$Class/ColumnMap", Attr => $Attr, Name => $Name, GenericMap => $COLUMN_MAP );
return $class_map if defined $class_map;
}
+
+# Check for roles, if not handled already
+$Class =~ s/_/:/g;
+if ($Class->DOES("RT::Record::Role::Roles")) {
+ my $ROLE_MAP = {};
+ for my $role ($Class->Roles) {
+ my $attrs = $Class->Role($role);
+ $ROLE_MAP->{$role} = {
+ title => $role,
+ attribute => $attrs->{Column} || "$role.EmailAddress",
+ value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->RoleGroup($role) ) ) },
+ };
+ $ROLE_MAP->{$role . "s"} = $ROLE_MAP->{$role}
+ unless $attrs->{Single};
+ }
+ my $role_entry = GetColumnMapEntry( Map => $ROLE_MAP, Name => $Name, Attribute => $Attr );
+ return $role_entry if defined $role_entry;
+}
+
return GetColumnMapEntry( Map => $COLUMN_MAP, Name => $Name, Attribute => $Attr );
</%INIT>
diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index 939005d..88c77ae 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -108,11 +108,6 @@ $COLUMN_MAP = {
attribute => 'Owner',
value => sub { return $_[0]->OwnerObj->Name }
},
- Owner => {
- title => 'Owner', # loc
- attribute => 'Owner',
- value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->OwnerObj ) ) }
- },
Status => {
title => 'Status', # loc
attribute => 'Status',
@@ -192,21 +187,6 @@ $COLUMN_MAP = {
title => 'Time Estimated', # loc
value => sub { return $_[0]->TimeEstimated }
},
- Requestors => {
- title => 'Requestors', # loc
- attribute => 'Requestor.EmailAddress',
- value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->Requestor ) ) }
- },
- Cc => {
- title => 'Cc', # loc
- attribute => 'Cc.EmailAddress',
- value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->Cc ) ) }
- },
- AdminCc => {
- title => 'AdminCc', # loc
- attribute => 'AdminCc.EmailAddress',
- value => sub { return \($m->scomp("/Elements/ShowPrincipal", Object => $_[0]->AdminCc ) ) }
- },
StartsRelative => {
title => 'Starts', # loc
attribute => 'Starts',
commit 9d85251978c738ec9d1e13be4dbd1aa6e46b9911
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Thu Jun 13 16:03:00 2013 -0400
Move ShowGroupMembers to new ShowPrincipal method
Both accomplish identical purposes; happily ShowPrincipal gives
sufficient rope to re-implement ShowGroupMembers.
diff --git a/share/html/Ticket/Elements/ShowGroupMembers b/share/html/Ticket/Elements/ShowGroupMembers
index 046a433..c2e1a1e 100644
--- a/share/html/Ticket/Elements/ShowGroupMembers
+++ b/share/html/Ticket/Elements/ShowGroupMembers
@@ -46,22 +46,15 @@
%#
%# END BPS TAGGED BLOCK }}}
%# Released under the terms of version 2 of the GNU Public License
-
-% my $Users = $Group->UserMembersObj( Recursively => $Recursively );
-% while ( my $user = $Users->Next ) {
-<& /Elements/ShowUser, User => $user, Ticket => $Ticket &>
-<& /Elements/ShowUserEmailFrequency, User => $user, Ticket => $Ticket &>
-% $m->callback( User => $user, Ticket => $Ticket, %ARGS, CallbackName => 'AboutThisUser' );
-<br />
-% }
-% my $Groups = $Group->GroupMembersObj( Recursively => $Recursively );
-% $Groups->LimitToUserDefinedGroups;
-% while (my $group = $Groups->Next) {
-<&|/l&>Group</&>: <% $group->Name %><br />
-% }
-
+<%init>
+my $post_user = sub {
+ my $user = shift;
+ $m->comp("/Elements/ShowUserEmailFrequency", User => $user, Ticket => $Ticket);
+ $m->callback( User => $user, Ticket => $Ticket, %ARGS, CallbackName => 'AboutThisUser' );
+};
+$m->comp("/Elements/ShowPrincipal", Object => $Group, Separator => "<br />", PostUser => $post_user);
+</%init>
<%ARGS>
$Group => undef
-$Recursively => 0,
$Ticket => undef
</%ARGS>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list