[Rt-commit] r14078 - in rtfm/trunk: . html/Callbacks/RTFM/Elements/MessageBox html/RTFM/Elements
falcone at bestpractical.com
falcone at bestpractical.com
Mon Jul 14 13:22:31 EDT 2008
Author: falcone
Date: Mon Jul 14 13:22:31 2008
New Revision: 14078
Modified:
rtfm/trunk/ (props changed)
rtfm/trunk/html/Callbacks/RTFM/Elements/MessageBox/Default
rtfm/trunk/html/RTFM/Elements/BeforeMessageBox
rtfm/trunk/lib/RT/FM/Article_Overlay.pm
Log:
r35559 at ketch: falcone | 2008-07-14 13:21:29 -0400
* refactor article loading that parses RTFM-Include-Article form arguments
* It wasn't properly copy-and-pasted to the RefersTo handling code meaning
we didn't always correctly set RefersTo Links
RT-Ticket: 9216
RT-Action: Correspond
RT-Status: Resolved
Modified: rtfm/trunk/html/Callbacks/RTFM/Elements/MessageBox/Default
==============================================================================
--- rtfm/trunk/html/Callbacks/RTFM/Elements/MessageBox/Default (original)
+++ rtfm/trunk/html/Callbacks/RTFM/Elements/MessageBox/Default Mon Jul 14 13:22:31 2008
@@ -48,21 +48,8 @@
<%INIT>
my $parent_args = $m->caller_args(-1);
foreach my $arg ( keys %$parent_args ) {
- my $article;
- if ($arg eq 'RTFM-Include-Article' && $parent_args->{$arg} ) {
- $article = RT::FM::Article->new($session{'CurrentUser'});
- $article->Load($parent_args->{$arg});
- } elsif ( $arg =~ /^RTFM-Include-Article-(\d+)$/ ) {
- $article = RT::FM::Article->new($session{'CurrentUser'});
- $article->Load($1);
- } elsif ( $arg =~ /^RTFM-Include-Article-Named/ && $parent_args->{ $arg } ) {
- $article = RT::FM::Article->new($session{'CurrentUser'});
- if ( $parent_args->{$arg} =~ /\D/ ) {
- $article->LoadByCols( Name => $parent_args->{ $arg } );
- } else {
- $article->LoadByCols( id => $parent_args->{ $arg } );
- }
- }
+ my $article = RT::FM::Article->new($session{'CurrentUser'});
+ $article->LoadByInclude( Field => $arg, Value => $parent_args->{$arg} );
next unless $article && $article->id;
my $Ticket = $ARGS{Ticket};
Modified: rtfm/trunk/html/RTFM/Elements/BeforeMessageBox
==============================================================================
--- rtfm/trunk/html/RTFM/Elements/BeforeMessageBox (original)
+++ rtfm/trunk/html/RTFM/Elements/BeforeMessageBox Mon Jul 14 13:22:31 2008
@@ -135,14 +135,12 @@
$uri{$_}++ for split ' ', ($ARGS{$ARGS{'id'}.'-RefersTo'} || '');
foreach my $arg (keys %ARGS) {
- if ($arg =~ /^RTFM-Include-Article-(\d+)$/) {
- my $art = RT::FM::Article->new($session{'CurrentUser'});
- $art->Load($1);
- if ($art->Id) {
- $uri{$art->URI}++;
- }
-
+ my $article = RT::FM::Article->new($session{'CurrentUser'});
+ $article->LoadByInclude( Field => $arg, Value => $ARGS{$arg} );
+ if ($article->Id) {
+ $uri{$article->URI}++;
}
+
}
}
Modified: rtfm/trunk/lib/RT/FM/Article_Overlay.pm
==============================================================================
--- rtfm/trunk/lib/RT/FM/Article_Overlay.pm (original)
+++ rtfm/trunk/lib/RT/FM/Article_Overlay.pm Mon Jul 14 13:22:31 2008
@@ -602,4 +602,36 @@
}
+=head2 LoadByInclude Field Value
+
+Takes the name of a form field from RTFM's "Include Article" callbacks
+and the value submitted by the browser and attempts to load an Article.
+
+This handles Articles included by searching, by the Name and via
+the hotlist.
+
+=cut
+
+sub LoadByInclude {
+ my $self = shift;
+ my %args = @_;
+ my $Field = $args{Field};
+ my $Value = $args{Value};
+
+ return unless $Field;
+
+ if ( $Field eq 'RTFM-Include-Article' && $Value ) {
+ return $self->Load( $Value );
+ } elsif ( $Field =~ /^RTFM-Include-Article-(\d+)$/ ) {
+ return $self->Load( $1 );
+ } elsif ( $Field =~ /^RTFM-Include-Article-Named/ && $Value ) {
+ if ( $Value =~ /\D/ ) {
+ return $self->LoadByCols( Field => $Value );
+ } else {
+ return $self->LoadByCols( id => $Value );
+ }
+ }
+
+}
+
1;
More information about the Rt-commit
mailing list