X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FTemplate.pm;h=d15c1cdcb4f0b35d90415fe40c8fd57bc2754dcb;hp=158547a0e8e241a9a57912d25b66899e31a02f95;hb=e9e0cf0989259b94d9758eceff448666a2e5a5cc;hpb=43a06151e47d2c59b833cbd8c26d97865ee850b6 diff --git a/rt/lib/RT/Template.pm b/rt/lib/RT/Template.pm index 158547a0e..d15c1cdcb 100755 --- a/rt/lib/RT/Template.pm +++ b/rt/lib/RT/Template.pm @@ -2,7 +2,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -96,10 +96,34 @@ sub _Accessible { sub _Set { my $self = shift; + my %args = ( + Field => undef, + Value => undef, + @_, + ); unless ( $self->CurrentUserHasQueueRight('ModifyTemplate') ) { return ( 0, $self->loc('Permission Denied') ); } + + if (exists $args{Value}) { + if ($args{Field} eq 'Queue') { + if ($args{Value}) { + # moving to another queue + my $queue = RT::Queue->new( $self->CurrentUser ); + $queue->Load($args{Value}); + unless ($queue->Id and $queue->CurrentUserHasRight('ModifyTemplate')) { + return ( 0, $self->loc('Permission Denied') ); + } + } else { + # moving to global + unless ($self->CurrentUser->HasRight( Object => RT->System, Right => 'ModifyTemplate' )) { + return ( 0, $self->loc('Permission Denied') ); + } + } + } + } + return $self->SUPER::_Set( @_ ); } @@ -232,7 +256,7 @@ sub Create { $args{'Queue'} = $QueueObj->Id; } - my $result = $self->SUPER::Create( + my ( $result, $msg ) = $self->SUPER::Create( Content => $args{'Content'}, Queue => $args{'Queue'}, Description => $args{'Description'}, @@ -240,7 +264,11 @@ sub Create { Type => $args{'Type'}, ); - return ($result); + if ( wantarray ) { + return ( $result, $msg ); + } else { + return ( $result ); + } } @@ -311,7 +339,7 @@ sub Parse { my ($rv, $msg); - if ($self->Content =~ m{^Content-Type:\s+text/html\b}im) { + if (not $self->IsEmpty and $self->Content =~ m{^Content-Type:\s+text/html\b}im) { local $RT::Transaction::PreferredContentType = 'text/html'; ($rv, $msg) = $self->_Parse(@_); } @@ -366,6 +394,7 @@ sub _Parse { # Unfold all headers $self->{'MIMEObj'}->head->unfold; + $self->{'MIMEObj'}->head->modify(1); return ( 1, $self->loc("Template parsed") ); @@ -433,7 +462,7 @@ sub _ParseContentPerl { foreach my $key ( keys %{ $args{TemplateArgs} } ) { my $val = $args{TemplateArgs}{ $key }; next unless ref $val; - next if ref $val =~ /^(ARRAY|HASH|SCALAR|CODE)$/; + next if ref($val) =~ /^(ARRAY|HASH|SCALAR|CODE)$/; $args{TemplateArgs}{ $key } = \$val; }