[Rt-commit] rt branch, records_history, updated. rt-3.8.8-113-gb2f9227
Ruslan Zakirov
ruz at bestpractical.com
Mon Jul 5 15:06:03 EDT 2010
The branch, records_history has been updated
via b2f92270097d5fd970cf4565086135c5edbbc60a (commit)
via 3667ebb9fa187d3572888dd374ca55dd0ebd0019 (commit)
via d488b27242eaf9d2ccdae3375445bd648c43050c (commit)
via d6431511e49b62d32214fd9bef29b17f89c31ce9 (commit)
via 52cd1b10257e74c658be58ab8e8f49a8daee98d7 (commit)
via 25ebf9023e0d41ce982b8ad8db1c37365ae04605 (commit)
via ce67ff7e2e19d9c7d72f8e91dca63d1cdb49d5a3 (commit)
from 9795a8e14a17b3e3fc66fb3565ad279bf7d7e7c4 (commit)
Summary of changes:
lib/RT/Record.pm | 74 +++++++++-
lib/RT/Transaction_Overlay.pm | 4 +-
share/html/Elements/ShowHistory | 21 +++-
share/html/Elements/ShowTransaction | 252 +++++++++++++++++++++++++++++++++++
4 files changed, 339 insertions(+), 12 deletions(-)
create mode 100644 share/html/Elements/ShowTransaction
- Log -----------------------------------------------------------------
commit ce67ff7e2e19d9c7d72f8e91dca63d1cdb49d5a3
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jul 3 04:43:38 2010 +0400
introduce RecordType and deprecate ObjectTypeStr
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 299f11f..5ac9d75 100755
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -121,21 +121,28 @@ sub Delete {
}
}
-=head2 ObjectTypeStr
+=head2 RecordType
+
+Returns a string which is this record's type. It's not localized and by
+default last part (everything after last ::) of class name is returned.
+
+=cut
+
+sub RecordType {
+ my $res = ref($_[0]) || $_[0];
+ $res =~ s/.*:://;
+ return $res;
+}
-Returns a string which is this object's type. The type is the class,
-without the "RT::" prefix.
+=head2 ObjectTypeStr
+DEPRECATED. Stays here for backwards. Returns localized L</RecordType>.
=cut
sub ObjectTypeStr {
my $self = shift;
- if (ref($self) =~ /^.*::(\w+)$/) {
- return $self->loc($1);
- } else {
- return $self->loc(ref($self));
- }
+ return $self->loc( $self->RecordType( @_ ) );
}
=head2 Attributes
commit 25ebf9023e0d41ce982b8ad8db1c37365ae04605
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jul 3 04:49:39 2010 +0400
describe reasons for deprecation in a comment
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 5ac9d75..f23747f 100755
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -140,6 +140,13 @@ DEPRECATED. Stays here for backwards. Returns localized L</RecordType>.
=cut
+# we deprecate because of:
+# * ObjectType is used in several classes with ObjectId to store
+# records of different types, for example transactions use those
+# and it's unclear what this method should return 'Transaction'
+# or type of referenced record
+# * returning localized thing is not good idea
+
sub ObjectTypeStr {
my $self = shift;
return $self->loc( $self->RecordType( @_ ) );
commit 52cd1b10257e74c658be58ab8e8f49a8daee98d7
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Sat Jul 3 04:51:25 2010 +0400
use Object->RecordType in Txn->FriendlyObjectType
it gives more control to extensions that add new tables into RT
diff --git a/lib/RT/Transaction_Overlay.pm b/lib/RT/Transaction_Overlay.pm
index d1630ea..7faaedf 100755
--- a/lib/RT/Transaction_Overlay.pm
+++ b/lib/RT/Transaction_Overlay.pm
@@ -1095,9 +1095,7 @@ sub Object {
sub FriendlyObjectType {
my $self = shift;
- my $type = $self->ObjectType or return undef;
- $type =~ s/^RT:://;
- return $self->loc($type);
+ return $self->loc( $self->Object->RecordType );
}
=head2 UpdateCustomFields
commit d6431511e49b62d32214fd9bef29b17f89c31ce9
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Jul 5 03:11:53 2010 +0400
Record's ClassifyTransaction method
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index f23747f..4bbbe44 100755
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1528,6 +1528,50 @@ sub Transactions {
return $transactions;
}
+our %TRANSACTION_CLASSIFICATION = (
+ Create => 'message',
+ Correspond => 'message',
+ Comment => 'message',
+
+ AddWatcher => 'people',
+ DelWatcher => 'people',
+
+ Take => 'people',
+ Untake => 'people',
+ Force => 'people',
+ Steal => 'people',
+ Give => 'people',
+
+ AddLink => 'links',
+ DeleteLink => 'links',
+
+ Status => 'basics',
+ Set => {
+ __default => 'basics',
+ map( { $_ => 'dates' } qw(
+ Told Starts Started Due LastUpdated Created LastUpdated
+ ) ),
+ map( { $_ => 'people' } qw(
+ Owner Creator LastUpdatedBy
+ ) ),
+ },
+ __default => 'other',
+);
+
+sub ClassifyTransaction {
+ my $self = shift;
+ my $txn = shift;
+
+ my $type = $txn->Type;
+
+ my $res = $TRANSACTION_CLASSIFICATION{ $type };
+ return $res || $TRANSACTION_CLASSIFICATION{ '__default' }
+ unless ref $res;
+
+ return $res->{ $txn->Field } || $res->{'__default'}
+ || $TRANSACTION_CLASSIFICATION{ '__default' };
+}
+
=head2 Attachments
Returns an L<RT::Attachments> object of all attachments on this record object
commit d488b27242eaf9d2ccdae3375445bd648c43050c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Jul 5 03:13:05 2010 +0400
generate default paths using $m->request_path
diff --git a/share/html/Elements/ShowHistory b/share/html/Elements/ShowHistory
index 73f7b16..71f9819 100644
--- a/share/html/Elements/ShowHistory
+++ b/share/html/Elements/ShowHistory
@@ -138,6 +138,25 @@ push @{ $attachments{ $_->TransactionId } ||= [] }, $_
my %attachment_content = map { $_->id => $_ }
@{ $AttachmentContent->ItemsArrayRef };
+{
+ my %tmp = (
+ DisplayPath => 'Display.html',
+ AttachmentPath => 'Attachment',
+ UpdatePath => 'Update.html',
+ ForwardPath => 'Forward.html',
+ EmailRecordPath => 'ShowEmailRecord.html',
+ EncryptionPath => 'GnuPG.html',
+ );
+
+ my $request_path = $m->request_path;
+ $request_path =~ s/[^\/]+$//;
+
+ while ( my ($arg, $path) = each %tmp ) {
+ next if defined $ARGS{ $arg };
+
+ $ARGS{ $arg } = $request_path . $path;
+ }
+}
</%INIT>
<%ARGS>
$Object
commit 3667ebb9fa187d3572888dd374ca55dd0ebd0019
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Jul 5 23:03:56 2010 +0400
first implementation of ShowTransaction
diff --git a/share/html/Elements/ShowTransaction b/share/html/Elements/ShowTransaction
new file mode 100644
index 0000000..de5dda1
--- /dev/null
+++ b/share/html/Elements/ShowTransaction
@@ -0,0 +1,252 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
+%# <jesse 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 }}}
+<div class="<% join ' ', @classes %>">
+<div class="<% $record_type %>-transaction">
+ <div class="metadata">
+ <span class="type">
+ <a name="txn-<% $Transaction->id %>" \
+% if ( $DisplayPath ) {
+ href="<% $DisplayPath %>#txn-<% $Transaction->id %>" \
+% }
+ >#</a>
+% if ( $LastTransaction ) {
+ <a id="lasttrans" name="lasttrans"></a>
+% }
+ </span>
+% $m->callback( %ARGS, Transaction => $Transaction, CallbackName => 'AfterAnchor' );
+ <span class="date"><% $date |n %></span>
+ <span class="description">
+ <& /Elements/ShowUser, User => $Transaction->CreatorObj &> - <% $desc %>
+% $m->callback( %ARGS, Transaction => $Transaction, CallbackName => 'AfterDescription' );
+ </span>
+ <span class="time-taken"><% $time %></span>
+% if ( $actions ) {
+ <span class="actions"><% $actions |n %></span>
+% }
+ </div>
+
+ <div class="content">
+<%PERL>
+if ( $Transaction->CustomFieldValues->Count ) {
+ $m->comp('/Elements/ShowCustomFields', Object => $Transaction );
+}
+$m->comp(
+ '/Ticket/Elements/ShowTransactionAttachments', %ARGS, Parent => 0
+) if $ShowBody;
+</%PERL>
+ </div>
+
+</div>
+</div>
+
+<%ARGS>
+$Transaction
+$Object => $Transaction->Object
+
+$Attachments => undef
+$AttachmentContent => undef
+
+$ShowBody => 1
+$ShowActions => 1
+$RowNum => 1
+$LastTransaction => 0
+
+$DisplayPath => undef
+$AttachmentPath => undef
+$UpdatePath => undef
+$ForwardPath => undef
+$EncryptionPath => undef
+$EmailRecordPath => undef
+</%ARGS>
+
+<%ONCE>
+
+</%ONCE>
+<%INIT>
+my $record_type = $Object->RecordType;
+
+my @classes = (
+ $record_type . '-transaction',
+ $Object->ClassifyTransaction( $Transaction ),
+ ($RowNum % 2 ? 'odd' : 'even')
+);
+
+my $desc = $Transaction->BriefDescription;
+if ( $Object->id != $Transaction->ObjectId ) {
+ # merged objects
+ $desc = loc("[_1] #[_1]:", loc($record_type), $Transaction->ObjectId)
+ .' - '. $desc;
+}
+
+my $date = $Transaction->CreatedAsString;
+
+my $time = '';
+$time = loc('[quant,_1,min,min]', $Transaction->TimeTaken)
+ if $Transaction->TimeTaken;
+
+unless ( $Attachments ) {
+ my $attachments = $Transaction->Attachments;
+ $attachments->Columns( qw(
+ Id TransactionId Parent MessageId
+ Subject Filename Headers
+ ContentEncoding ContentType
+ Creator Created
+ ) );
+ $ARGS{'Attachments'} = $Attachments = $attachments->ItemsArrayRef;
+}
+
+my @actions = ();
+if ( $ShowActions ) {
+ my $txn_type = $Transaction->Type;
+ if ( $txn_type =~ /EmailRecord$/ ) {
+ push @actions, {
+ title => loc('Show'),
+ target => '_blank',
+ path => $EmailRecordPath
+ .'?id='. $Object->id
+ .'&Transaction='. $Transaction->id
+ .'&Attachment='. ( $Attachments->[0] && $Attachments->[0]->id ),
+ } if $EmailRecordPath;
+
+ $ShowBody = 0;
+ }
+
+ # If the transaction has anything attached to it at all
+ elsif ( @$Attachments ) {
+ my %has_right = map {
+ $_ => RT::ACE->CanonicalizeRightName( $_ . $record_type )
+ } qw(Modify CommentOn ReplyTo);
+
+ my $can_modify = $has_right{'Modify'}
+ && $Object->CurrentUserHasRight( $has_right{'Modify'} );
+
+ if ( $UpdatePath && $has_right{'ReplyTo'}
+ && ( $can_modify
+ || $Object->CurrentUserHasRight( $has_right{'ReplyTo'} )
+ )
+ ) {
+ push @actions, {
+ title => loc('Reply'),
+ path => $UpdatePath
+ .'?id='. $Object->id
+ .'&QuoteTransaction='. $Transaction->id
+ .'&Action=Respond'
+ ,
+ };
+ }
+ if ( $UpdatePath && $has_right{'CommentOn'}
+ && ( $can_modify
+ || $Object->CurrentUserHasRight( $has_right{'CommentOn'} )
+ )
+ ) {
+ push @actions, {
+ title => loc('Comment'),
+ path => $UpdatePath
+ .'?id='. $Object->id
+ .'&QuoteTransaction='. $Transaction->id
+ .'&Action=Comment'
+ ,
+ };
+ }
+ if ( $ForwardPath && $Object->CurrentUserHasRight('ForwardMessage') ) {
+ push @actions, {
+ title => loc('Forward'),
+ path => $ForwardPath
+ .'?id='. $Object->id
+ .'&QuoteTransaction='. $Transaction->id
+ ,
+ };
+ }
+ if ( $EncryptionPath && $can_modify
+ && RT->Config->Get('GnuPG')->{'Enable'}
+ && RT->Config->Get('GnuPG')->{'AllowEncryptDataInDB'}
+ ) {
+ push @actions, {
+ title => loc('Encrypt/Decrypt'),
+ path => $EncryptionPath
+ .'?id='. $Transaction->id
+ .'&QuoteTransaction='. $Transaction->id
+ ,
+ };
+ }
+ }
+}
+
+$m->callback(
+ %ARGS,
+ Transaction => $Transaction,
+ Object => $Object,
+
+ Classes => \@classes,
+ Actions => \@actions,
+ Created => \$date,
+ TimeTakes => \$time,
+ Description => \$desc,
+);
+
+my $actions = '';
+if ( @actions ) {
+ my $i = $m->interp;
+
+ foreach my $a ( @actions ) {
+ $a = '<a'
+ .' href="'. $i->apply_escapes( $a->{'path'}, 'h' ) .'"'
+ . ($a->{'target'}
+ ? ' target="'. $i->apply_escapes( $a->{'target'}, 'h' ) .'"'
+ : ''
+ )
+ .'>'. $i->apply_escapes( $a->{'title'}, 'h' ) .'</a>'
+ ;
+ }
+ $actions = join ' ', map "[$_]", @actions;
+}
+
+# make date unbreakable
+$date = $m->interp->apply_escapes( $date, 'h' );
+$date =~ s/\s/ /g;
+</%INIT>
commit b2f92270097d5fd970cf4565086135c5edbbc60a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Mon Jul 5 23:04:24 2010 +0400
use new ShowTransaction instead of ticket's
diff --git a/share/html/Elements/ShowHistory b/share/html/Elements/ShowHistory
index 71f9819..e75f2fc 100644
--- a/share/html/Elements/ShowHistory
+++ b/share/html/Elements/ShowHistory
@@ -95,7 +95,7 @@ while ( my $Transaction = $Transactions->Next ) {
}
#Args is first because we're clobbering the "Attachments" parameter
- $m->comp( '/Ticket/Elements/ShowTransaction',
+ $m->comp( '/Elements/ShowTransaction',
%ARGS,
Ticket => $Object,
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list