[freeside-commits] freeside/rt/lib/RT Attachment_Overlay.pm, 1.1.1.5, 1.1.1.5.4.1 CustomField_Overlay.pm, 1.1.1.5, 1.1.1.5.2.1 Date.pm, 1.1.1.4, 1.1.1.4.4.1 Group_Overlay.pm, 1.1.1.4, 1.1.1.4.4.1 I18N.pm, 1.1.1.5, 1.1.1.5.2.1 Link_Overlay.pm, 1.1.1.5, 1.1.1.5.2.1 Links_Overlay.pm, 1.1.1.3, 1.1.1.3.4.1 Record.pm, 1.1.1.5, 1.1.1.5.2.1 Template_Overlay.pm, 1.1.1.5, 1.1.1.5.4.1 Ticket_Overlay.pm, 1.1.1.6, 1.1.1.6.2.1 Tickets_Overlay.pm, 1.1.1.6, 1.1.1.6.2.1 Transaction_Overlay.pm, 1.1.1.6, 1.1.1.6.2.1 URI.pm, 1.1.1.4, 1.1.1.4.4.1
Ivan,,,
ivan at wavetail.420.am
Mon Mar 3 15:07:48 PST 2008
Update of /home/cvs/cvsroot/freeside/rt/lib/RT
In directory wavetail.420.am:/tmp/cvs-serv10370/lib/RT
Modified Files:
Tag: FREESIDE_1_7_BRANCH
Attachment_Overlay.pm CustomField_Overlay.pm Date.pm
Group_Overlay.pm I18N.pm Link_Overlay.pm Links_Overlay.pm
Record.pm Template_Overlay.pm Ticket_Overlay.pm
Tickets_Overlay.pm Transaction_Overlay.pm URI.pm
Log Message:
merge in rt 3.4.6. *gulp*!
Index: Date.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Date.pm,v
retrieving revision 1.1.1.4
retrieving revision 1.1.1.4.4.1
diff -u -d -r1.1.1.4 -r1.1.1.4.4.1
--- Date.pm 15 Oct 2005 09:10:22 -0000 1.1.1.4
+++ Date.pm 3 Mar 2008 23:07:46 -0000 1.1.1.4.4.1
@@ -226,23 +226,28 @@
# {{{ sub SetToMidnight
-=head2 SetToMidnight
+=head2 SetToMidnight [Timezone => 'utc']
-Sets the date to midnight (at the beginning of the day) GMT
+Sets the date to midnight (at the beginning of the day).
Returns the unixtime at midnight.
+Arguments:
+
+=over 4
+
+=item Timezone - Timezone context C<server> or C<UTC>
+
=cut
sub SetToMidnight {
my $self = shift;
-
- use Time::Local;
- my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime($self->Unix);
- $self->Unix(timegm (0,0,0,$mday,$mon,$year,$wday,$yday));
-
+ my %args = ( Timezone => 'UTC', @_ );
+ if ( lc $args{'Timezone'} eq 'server' ) {
+ $self->Unix( Time::Local::timelocal( 0,0,0,(localtime $self->Unix)[3..7] ) );
+ } else {
+ $self->Unix( Time::Local::timegm( 0,0,0,(gmtime $self->Unix)[3..7] ) );
+ }
return ($self->Unix);
-
-
}
Index: CustomField_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/CustomField_Overlay.pm,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.2.1
diff -u -d -r1.1.1.5 -r1.1.1.5.2.1
--- CustomField_Overlay.pm 17 Oct 2006 08:49:49 -0000 1.1.1.5
+++ CustomField_Overlay.pm 3 Mar 2008 23:07:46 -0000 1.1.1.5.2.1
@@ -366,7 +366,8 @@
return (0, $self->loc('Permission Denied'));
}
- unless ($args{'Name'}) {
+ # allow zero value
+ if ( !defined $args{'Name'} || $args{'Name'} eq '' ) {
return(0, $self->loc("Can't add a custom field value without a name"));
}
my $newval = RT::CustomFieldValue->new($self->CurrentUser);
@@ -876,10 +877,10 @@
if ( $ObjectCF->Id ) {
return ( 0, $self->loc("That is already the current value") );
}
- my ( $id, $msg ) =
+ my ( $oid, $msg ) =
$ObjectCF->Create( ObjectId => $id, CustomField => $self->Id );
- return ( $id, $msg );
+ return ( $oid, $msg );
}
@@ -911,9 +912,10 @@
unless ( $ObjectCF->Id ) {
return ( 0, $self->loc("This custom field does not apply to that object") );
}
- my ( $id, $msg ) = $ObjectCF->Delete;
+ # XXX: Delete doesn't return anything
+ my ( $oid, $msg ) = $ObjectCF->Delete;
- return ( $id, $msg );
+ return ( $oid, $msg );
}
# {{{ AddValueForObject
Index: Tickets_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Tickets_Overlay.pm,v
retrieving revision 1.1.1.6
retrieving revision 1.1.1.6.2.1
diff -u -d -r1.1.1.6 -r1.1.1.6.2.1
--- Tickets_Overlay.pm 17 Oct 2006 08:49:55 -0000 1.1.1.6
+++ Tickets_Overlay.pm 3 Mar 2008 23:07:46 -0000 1.1.1.6.2.1
@@ -272,7 +272,7 @@
or $op eq "!=";
my $meta = $FIELDS{$field};
- if ( defined $meta->[1] ) {
+ if ( defined $meta->[1] && defined $value && $value !~ /^\d+$/ ) {
my $class = "RT::" . $meta->[1];
my $o = $class->new( $sb->CurrentUser );
$o->Load($value);
@@ -450,11 +450,8 @@
die "Incorrect Meta Data for $field"
unless ( defined $meta->[1] );
- use POSIX 'strftime';
-
my $date = RT::Date->new( $sb->CurrentUser );
$date->Set( Format => 'unknown', Value => $value );
- my $time = $date->Unix;
if ( $op eq "=" ) {
@@ -462,10 +459,10 @@
# particular single day. in the database, we need to check for >
# and < the edges of that day.
- my $daystart = strftime( "%Y-%m-%d %H:%M",
- gmtime( $time - ( $time % 86400 ) ) );
- my $dayend = strftime( "%Y-%m-%d %H:%M",
- gmtime( $time + ( 86399 - $time % 86400 ) ) );
+ $date->SetToMidnight( Timezone => 'server' );
+ my $daystart = $date->ISO;
+ $date->AddDay;
+ my $dayend = $date->ISO;
$sb->_OpenParen;
@@ -488,11 +485,10 @@
}
else {
- $value = strftime( "%Y-%m-%d %H:%M", gmtime($time) );
$sb->_SQLLimit(
FIELD => $meta->[1],
OPERATOR => $op,
- VALUE => $value,
+ VALUE => $date->ISO,
@rest,
);
}
@@ -545,7 +541,6 @@
my $date = RT::Date->new( $sb->CurrentUser );
$date->Set( Format => 'unknown', Value => $value );
- my $time = $date->Unix;
$sb->_OpenParen;
if ( $op eq "=" ) {
@@ -554,10 +549,10 @@
# particular single day. in the database, we need to check for >
# and < the edges of that day.
- my $daystart = strftime( "%Y-%m-%d %H:%M",
- gmtime( $time - ( $time % 86400 ) ) );
- my $dayend = strftime( "%Y-%m-%d %H:%M",
- gmtime( $time + ( 86399 - $time % 86400 ) ) );
+ $date->SetToMidnight( Timezone => 'server' );
+ my $daystart = $date->ISO;
+ $date->AddDay;
+ my $dayend = $date->ISO;
$sb->_SQLLimit(
ALIAS => $sb->{_sql_transalias},
@@ -587,7 +582,7 @@
ALIAS => $sb->{_sql_transalias},
FIELD => 'Created',
OPERATOR => $op,
- VALUE => $value,
+ VALUE => $date->ISO,
CASESENSITIVE => 0,
@rest
);
@@ -918,7 +913,7 @@
# RT doesn't allow to add groups as members of the
# ticket roles, so we just hide entries in CGM table
# with MemberId == GroupId from results
- my $groupmembers = $self->SUPER::Limit(
+ $self->SUPER::Limit(
LEFTJOIN => $groupmembers,
FIELD => 'GroupId',
OPERATOR => '!=',
@@ -1413,12 +1408,11 @@
@_
);
- #TODO VALUE should also take queue names and queue objects
- #TODO FIXME why are we canonicalizing to name, not id, robrt?
- if ( $args{VALUE} =~ /^\d+$/ ) {
+ #TODO VALUE should also take queue objects
+ if ( defined $args{'VALUE'} && $args{'VALUE'} !~ /^\d+$/ ) {
my $queue = new RT::Queue( $self->CurrentUser );
$queue->Load( $args{'VALUE'} );
- $args{VALUE} = $queue->Name;
+ $args{'VALUE'} = $queue->Id;
}
# What if they pass in an Id? Check for isNum() and convert to
@@ -1428,10 +1422,10 @@
$self->Limit(
FIELD => 'Queue',
- VALUE => $args{VALUE},
+ VALUE => $args{'VALUE'},
OPERATOR => $args{'OPERATOR'},
DESCRIPTION => join(
- ' ', $self->loc('Queue'), $args{'OPERATOR'}, $args{VALUE},
+ ' ', $self->loc('Queue'), $args{'OPERATOR'}, $args{'VALUE'},
),
);
Index: Ticket_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Ticket_Overlay.pm,v
retrieving revision 1.1.1.6
retrieving revision 1.1.1.6.2.1
diff -u -d -r1.1.1.6 -r1.1.1.6.2.1
--- Ticket_Overlay.pm 17 Oct 2006 08:49:52 -0000 1.1.1.6
+++ Ticket_Overlay.pm 3 Mar 2008 23:07:46 -0000 1.1.1.6.2.1
@@ -240,7 +240,7 @@
#If it's a local URI, turn it into a ticket id
- if ( $id =~ /^$RT::TicketBaseURI(\d+)$/ ) {
+ if ( $RT::TicketBaseURI && $id =~ /^$RT::TicketBaseURI(\d+)$/ ) {
$id = $1;
}
@@ -440,9 +440,9 @@
if ( $args{'Due'} ) {
$Due->Set( Format => 'ISO', Value => $args{'Due'} );
}
- elsif ( $QueueObj->DefaultDueIn ) {
+ elsif ( my $due_in = $QueueObj->DefaultDueIn ) {
$Due->SetToNow;
- $Due->AddDays( $QueueObj->DefaultDueIn );
+ $Due->AddDays( $due_in );
}
my $Starts = new RT::Date( $self->CurrentUser );
@@ -1315,6 +1315,10 @@
@_
);
+ # XXX, FIXME, BUG: if only email is provided then we only check
+ # for ModifyTicket right, but must try to get PrincipalId and
+ # check Watch* rights too if user exist
+
# {{{ Check ACLS
#If the watcher we're trying to add is for the current user
if ( $self->CurrentUser->PrincipalId eq $args{'PrincipalId'}) {
@@ -1979,11 +1983,16 @@
)
)
{
- $self->Untake();
+ my $clone = RT::Ticket->new( $RT::SystemUser );
+ $clone->Load( $self->Id );
+ unless ( $clone->Id ) {
+ return ( 0, $self->loc("Couldn't load copy of ticket #[_1].", $self->Id) );
+ }
+ my ($status, $msg) = $clone->SetOwner( $RT::Nobody->Id, 'Force' );
+ $RT::Logger->error("Couldn't set owner on queue change: $msg") unless $status;
}
return ( $self->_Set( Field => 'Queue', Value => $NewQueueObj->Id() ) );
-
}
# }}}
@@ -3018,21 +3027,21 @@
$RT::Handle->Commit();
- my ( $trans, $msg, undef ) = $self->_NewTransaction(
- Type => $Type,
- Field => 'Owner',
- NewValue => $NewOwnerObj->Id,
- OldValue => $OldOwnerObj->Id,
- TimeTaken => 0 );
+ ($val, $msg) = $self->_NewTransaction(
+ Type => $Type,
+ Field => 'Owner',
+ NewValue => $NewOwnerObj->Id,
+ OldValue => $OldOwnerObj->Id,
+ TimeTaken => 0,
+ );
- if ($trans) {
+ if ( $val ) {
$msg = $self->loc( "Owner changed from [_1] to [_2]",
$OldOwnerObj->Name, $NewOwnerObj->Name );
# TODO: make sure the trans committed properly
}
- return ( $trans, $msg );
-
+ return ( $val, $msg );
}
# }}}
@@ -3679,15 +3688,15 @@
my $field = shift;
if ( $field and $field !~ /^\d+$/ ) {
my $cf = RT::CustomField->new( $self->CurrentUser );
- $cf->LoadByNameAndQueue( Name => $field, Queue => $self->QueueObj->Id );
+ $cf->LoadByNameAndQueue( Name => $field, Queue => $self->Queue );
unless ( $cf->id ) {
- $cf->LoadByNameAndQueue( Name => $field, Queue => '0' );
+ $cf->LoadByNameAndQueue( Name => $field, Queue => 0 );
}
- $field = $cf->id;
- unless ( $field =~ /^\d+$/ ) {
- # If we didn't find a valid cfid, give up.
- return RT::CustomFieldValues->new($self->CurrentUser);
+ unless ( $cf->id ) {
+ # If we didn't find a valid cfid, give up.
+ return RT::CustomFieldValues->new($self->CurrentUser);
}
+ $field = $cf->id;
}
return $self->SUPER::CustomFieldValues($field);
}
Index: Transaction_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Transaction_Overlay.pm,v
retrieving revision 1.1.1.6
retrieving revision 1.1.1.6.2.1
diff -u -d -r1.1.1.6 -r1.1.1.6.2.1
--- Transaction_Overlay.pm 17 Oct 2006 08:50:04 -0000 1.1.1.6
+++ Transaction_Overlay.pm 3 Mar 2008 23:07:46 -0000 1.1.1.6.2.1
@@ -149,7 +149,13 @@
my $id = $self->SUPER::Create(%params);
$self->Load($id);
- $self->_Attach( $args{'MIMEObj'} ) if defined $args{'MIMEObj'};
+ if ( defined $args{'MIMEObj'} ) {
+ my ($id, $msg) = $self->_Attach( $args{'MIMEObj'} );
+ unless ( $id ) {
+ $RT::Logger->error("Couldn't add attachment: $msg");
+ return ( 0, $self->loc("Couldn't add attachment") );
+ }
+ }
#Provide a way to turn off scrips if we need to
@@ -471,11 +477,11 @@
}
my $Attachment = new RT::Attachment( $self->CurrentUser );
- $Attachment->Create(
+ my ($id, $msg) = $Attachment->Create(
TransactionId => $self->Id,
Attachment => $MIMEObject
);
- return ( $Attachment, $self->loc("Attachment created") );
+ return ( $Attachment, $msg || $self->loc("Attachment created") );
}
@@ -934,25 +940,29 @@
sub OldValue {
my $self = shift;
- if (my $type = $self->__Value('ReferenceType')) {
- my $Object = $type->new($self->CurrentUser);
- $Object->Load($self->__Value('OldReference'));
- return $Object->Content;
+ if ( my $type = $self->__Value('ReferenceType')
+ and my $id = $self->__Value('OldReference') )
+ {
+ my $Object = $type->new($self->CurrentUser);
+ $Object->Load( $id );
+ return $Object->Content;
}
else {
- return $self->__Value('OldValue');
+ return $self->__Value('OldValue');
}
}
sub NewValue {
my $self = shift;
- if (my $type = $self->__Value('ReferenceType')) {
- my $Object = $type->new($self->CurrentUser);
- $Object->Load($self->__Value('NewReference'));
- return $Object->Content;
+ if ( my $type = $self->__Value('ReferenceType')
+ and my $id = $self->__Value('NewReference') )
+ {
+ my $Object = $type->new($self->CurrentUser);
+ $Object->Load( $id );
+ return $Object->Content;
}
else {
- return $self->__Value('NewValue');
+ return $self->__Value('NewValue');
}
}
Index: I18N.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/I18N.pm,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.2.1
diff -u -d -r1.1.1.5 -r1.1.1.5.2.1
--- I18N.pm 17 Oct 2006 08:49:55 -0000 1.1.1.5
+++ I18N.pm 3 Mar 2008 23:07:46 -0000 1.1.1.5.2.1
@@ -289,11 +289,13 @@
my $str = shift;
my $enc = shift;
-
- @_ = $str =~ m/([^=]*)=\?([^?]+)\?([QqBb])\?([^?]+)\?=([^=]*)/g;
-
+ @_ = $str =~ m/(.*?)=\?([^?]+)\?([QqBb])\?([^?]+)\?=([^=]*)/gc;
return ($str) unless (@_);
+ # add everything that hasn't matched to the end of the latest
+ # string in array this happen when we have 'key="=?encoded?="; key="plain"'
+ $_[-1] .= substr($str, pos $str);
+
$str = "";
while (@_) {
my ($prefix, $charset, $encoding, $enc_str, $trailing) =
Index: Links_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Links_Overlay.pm,v
retrieving revision 1.1.1.3
retrieving revision 1.1.1.3.4.1
diff -u -d -r1.1.1.3 -r1.1.1.3.4.1
--- Links_Overlay.pm 15 Oct 2005 09:10:29 -0000 1.1.1.3
+++ Links_Overlay.pm 3 Mar 2008 23:07:46 -0000 1.1.1.3.4.1
@@ -154,19 +154,17 @@
my $self = shift;
my $Link = $self->SUPER::Next();
- if ((defined($Link)) and (ref($Link))) {
- # Skip links to local objects thast are deleted
- if ($Link->TargetURI->IsLocal and UNIVERSAL::isa($Link->TargetObj,"RT::Ticket")
- and $Link->TargetObj->__Value('status') eq "deleted") {
- return $self->Next;
- } elsif ($Link->BaseURI->IsLocal and UNIVERSAL::isa($Link->BaseObj,"RT::Ticket")
- and $Link->BaseObj->__Value('status') eq "deleted") {
- return $self->Next;
- } else {
- return $Link;
- }
+ return $Link unless $Link && ref $Link;
+
+ # Skip links to local objects thast are deleted
+ if ( $Link->TargetURI->IsLocal and UNIVERSAL::isa($Link->TargetObj,"RT::Ticket")
+ and $Link->TargetObj->__Value('status') eq "deleted") {
+ return $self->Next;
+ } elsif ($Link->BaseURI->IsLocal and UNIVERSAL::isa($Link->BaseObj,"RT::Ticket")
+ and $Link->BaseObj->__Value('status') eq "deleted") {
+ return $self->Next;
} else {
- return undef;
+ return $Link;
}
}
Index: Attachment_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Attachment_Overlay.pm,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.4.1
diff -u -d -r1.1.1.5 -r1.1.1.5.4.1
--- Attachment_Overlay.pm 15 Oct 2005 09:10:28 -0000 1.1.1.5
+++ Attachment_Overlay.pm 3 Mar 2008 23:07:46 -0000 1.1.1.5.4.1
@@ -296,7 +296,7 @@
eval {return( Encode::decode_utf8($content))} || return ($content);
}
- eval { Encode::from_to($content, 'utf8' => $enc);};
+ eval { Encode::from_to($content, 'utf8' => $enc) } if $enc;
if ($@) {
$RT::Logger->error("Could not convert attachment from assumed utf8 to '$enc' :".$@);
}
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Record.pm,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.2.1
diff -u -d -r1.1.1.5 -r1.1.1.5.2.1
--- Record.pm 17 Oct 2006 08:50:03 -0000 1.1.1.5
+++ Record.pm 3 Mar 2008 23:07:46 -0000 1.1.1.5.2.1
@@ -748,7 +748,7 @@
sub _ClassAccessible {
my $self = shift;
- return $_TABLE_ATTR->{ref($self)};
+ return $_TABLE_ATTR->{ ref($self) || $self };
}
=head2 _Accessible COLUMN ATTRIBUTE
@@ -817,7 +817,10 @@
elsif ($RT::DropLongAttachments) {
# drop the attachment on the floor
- $RT::Logger->info( "$self: Dropped an attachment of size " . length($Body) . "\n" . "It started: " . substr( $Body, 0, 60 ) . "\n" );
+ $RT::Logger->info( "$self: Dropped an attachment of size "
+ . length($Body) . "\n"
+ . "It started: " . substr( $Body, 0, 60 ) . "\n"
+ );
return ("none", "Large attachment dropped" );
}
}
@@ -1459,7 +1462,7 @@
$self->_SetLastUpdated;
- if ( defined $args{'TimeTaken'} ) {
+ if ( defined $args{'TimeTaken'} and $self->can('_UpdateTimeTaken')) {
$self->_UpdateTimeTaken( $args{'TimeTaken'} );
}
if ( $RT::UseTransactionBatch and $transaction ) {
@@ -1634,10 +1637,11 @@
);
}
}
+ $values->RedoSearch if $i; # redo search if have deleted at least one value
}
my ( $old_value, $old_content );
- if ( $old_value = $cf->ValuesForObject($self)->First ) {
+ if ( $old_value = $values->First ) {
$old_content = $old_value->Content();
return (1) if( $old_content eq $args{'Value'} && $old_value->LargeContent eq $args{'LargeContent'});;
}
Index: Group_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Group_Overlay.pm,v
retrieving revision 1.1.1.4
retrieving revision 1.1.1.4.4.1
diff -u -d -r1.1.1.4 -r1.1.1.4.4.1
--- Group_Overlay.pm 15 Oct 2005 09:10:28 -0000 1.1.1.4
+++ Group_Overlay.pm 3 Mar 2008 23:07:46 -0000 1.1.1.4.4.1
@@ -497,7 +497,7 @@
# If we couldn't create a principal Id, get the fuck out.
unless ($principal_id) {
$RT::Handle->Rollback() unless ($args{'InsideTransaction'});
- $self->crit( "Couldn't create a Principal on new user create. Strange things are afoot at the circle K" );
+ $RT::Logger->crit( "Couldn't create a Principal on new user create. Strange things are afoot at the circle K" );
return ( 0, $self->loc('Could not create group') );
}
Index: Link_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Link_Overlay.pm,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.2.1
diff -u -d -r1.1.1.5 -r1.1.1.5.2.1
--- Link_Overlay.pm 17 Oct 2006 08:50:05 -0000 1.1.1.5
+++ Link_Overlay.pm 3 Mar 2008 23:07:46 -0000 1.1.1.5.2.1
@@ -268,8 +268,8 @@
=cut
sub TargetObj {
- my $self = shift;
- return $self->TargetURI->Object;
+ my $self = shift;
+ return $self->TargetURI->Object;
}
# }}}
Index: Template_Overlay.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/Template_Overlay.pm,v
retrieving revision 1.1.1.5
retrieving revision 1.1.1.5.4.1
diff -u -d -r1.1.1.5 -r1.1.1.5.4.1
--- Template_Overlay.pm 15 Oct 2005 09:10:22 -0000 1.1.1.5
+++ Template_Overlay.pm 3 Mar 2008 23:07:46 -0000 1.1.1.5.4.1
@@ -103,23 +103,11 @@
sub _Set {
my $self = shift;
-
- # use super::value or we get acl blocked
- if ( ( defined $self->SUPER::_Value('Queue') )
- && ( $self->SUPER::_Value('Queue') == 0 ) )
- {
- unless ( $self->CurrentUser->HasRight( Object => $RT::System, Right => 'ModifyTemplate') ) {
- return ( 0, $self->loc('Permission Denied') );
- }
- }
- else {
-
- unless ( $self->CurrentUserHasQueueRight('ModifyTemplate') ) {
- return ( 0, $self->loc('Permission Denied') );
- }
+
+ unless ( $self->CurrentUserHasQueueRight('ModifyTemplate') ) {
+ return ( 0, $self->loc('Permission Denied') );
}
- return ( $self->SUPER::_Set(@_) );
-
+ return $self->SUPER::_Set( @_ );
}
# }}}
@@ -147,26 +135,12 @@
=cut
sub _Value {
-
my $self = shift;
- my $field = shift;
-
- #If the current user doesn't have ACLs, don't let em at it.
- #use super::value or we get acl blocked
- if ( ( !defined $self->__Value('Queue') )
- || ( $self->__Value('Queue') == 0 ) )
- {
- unless ( $self->CurrentUser->HasRight( Object => $RT::System, Right => 'ShowTemplate') ) {
- return (undef);
- }
- }
- else {
- unless ( $self->CurrentUserHasQueueRight('ShowTemplate') ) {
- return (undef);
- }
+ unless ( $self->CurrentUserHasQueueRight('ShowTemplate') ) {
+ return undef;
}
- return ( $self->__Value($field) );
+ return $self->__Value( @_ );
}
@@ -183,18 +157,12 @@
sub Load {
my $self = shift;
my $identifier = shift;
+ return undef unless $identifier;
- if ( !$identifier ) {
- return (undef);
- }
-
- if ( $identifier !~ /\D/ ) {
- $self->SUPER::LoadById($identifier);
- }
- else {
- $self->LoadByCol( 'Name', $identifier );
-
+ if ( $identifier =~ /\D/ ) {
+ return $self->LoadByCol( 'Name', $identifier );
}
+ return $self->LoadById( $identifier );
}
# }}}
@@ -260,32 +228,32 @@
Content => undef,
Queue => 0,
Description => '[no description]',
- Type => 'Action', #By default, template are 'Action' templates
- Name => undef,
+ Type => 'Action', #By default, template are 'Action' templates
+ Name => undef,
@_
);
- if ( !$args{'Queue'} ) {
+ unless ( $args{'Queue'} ) {
unless ( $self->CurrentUser->HasRight(Right =>'ModifyTemplate', Object => $RT::System) ) {
- return (undef);
+ return ( undef, $self->loc('Permission denied') );
}
$args{'Queue'} = 0;
}
else {
my $QueueObj = new RT::Queue( $self->CurrentUser );
- $QueueObj->Load( $args{'Queue'} ) || return ( 0, $self->loc('Invalid queue') );
+ $QueueObj->Load( $args{'Queue'} ) || return ( undef, $self->loc('Invalid queue') );
unless ( $QueueObj->CurrentUserHasRight('ModifyTemplate') ) {
- return (undef);
+ return ( undef, $self->loc('Permission denied') );
}
$args{'Queue'} = $QueueObj->Id;
}
my $result = $self->SUPER::Create(
- Content => $args{'Content'},
- Queue => $args{'Queue'},
+ Content => $args{'Content'},
+ Queue => $args{'Queue'},
Description => $args{'Description'},
- Name => $args{'Name'}
+ Name => $args{'Name'},
);
return ($result);
@@ -340,15 +308,16 @@
my $self = shift;
#We're passing in whatever we were passed. it's destined for _ParseContent
- my $content = $self->_ParseContent(@_);
+ my ($content, $msg) = $self->_ParseContent(@_);
+ return ( 0, $msg ) unless defined $content;
#Lets build our mime Entity
my $parser = MIME::Parser->new();
- # On some situations TMPDIR is non-writable. sad but true.
- $parser->output_to_core(1);
- $parser->tmp_to_core(1);
+ # On some situations TMPDIR is non-writable. sad but true.
+ $parser->output_to_core(1);
+ $parser->tmp_to_core(1);
#If someone includes a message, don't extract it
$parser->extract_nested_messages(1);
@@ -363,15 +332,13 @@
### Should we forgive normally-fatal errors?
$parser->ignore_errors(1);
$self->{'MIMEObj'} = eval { $parser->parse_data($content) };
- my $error = ( $@ || $parser->last_error );
-
- if ($error) {
- $RT::Logger->error("$error");
+ if ( my $error = $@ || $parser->last_error ) {
+ $RT::Logger->error( "$error" );
return ( 0, $error );
}
# Unfold all headers
- $self->{'MIMEObj'}->head->unfold();
+ $self->{'MIMEObj'}->head->unfold;
return ( 1, $self->loc("Template parsed") );
@@ -400,9 +367,13 @@
$T::rtname = $RT::rtname;
*T::loc = sub { $T::Ticket->loc(@_) };
+ my $content = $self->Content;
+ unless ( defined $content ) {
+ return ( undef, $self->loc("Permissions denied") );
+ }
+
# We need to untaint the content of the template, since we'll be working
# with it
- my $content = $self->Content();
$content =~ s/^(.*)$/$1/;
my $template = Text::Template->new(
TYPE => 'STRING',
@@ -413,11 +384,11 @@
my $retval = $template->fill_in( PACKAGE => 'T', BROKEN => sub {
my (%args) = @_;
$RT::Logger->error("Template parsing error: $args{error}")
- unless $args{error} =~ /^Died at /; # ignore intentional die()
+ unless $args{error} =~ /^Died at /; # ignore intentional die()
$is_broken++;
- return undef;
+ return undef;
} );
- return undef if $is_broken;
+ return ( undef, $self->loc('Template parsing error') ) if $is_broken;
# MIME::Parser has problems dealing with high-bit utf8 data.
Encode::_utf8_off($retval);
Index: URI.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/rt/lib/RT/URI.pm,v
retrieving revision 1.1.1.4
retrieving revision 1.1.1.4.4.1
diff -u -d -r1.1.1.4 -r1.1.1.4.4.1
--- URI.pm 15 Oct 2005 09:10:34 -0000 1.1.1.4
+++ URI.pm 3 Mar 2008 23:07:46 -0000 1.1.1.4.4.1
@@ -143,7 +143,7 @@
unless ($self->Resolver->ParseURI($uri)) {
$RT::Logger->warning("Resolver ".ref($self->Resolver)." could not parse $uri");
- $self->{resolver} = undef; # clear resolver
+ $self->{resolver} = RT::URI::base->new( $self->CurrentUser ); # clear resolver
return (undef);
}
More information about the freeside-commits
mailing list