summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Ticket_Overlay.pm
diff options
context:
space:
mode:
authorivan <ivan>2006-10-17 08:51:01 +0000
committerivan <ivan>2006-10-17 08:51:01 +0000
commita513c0bef534d05f03c1242831b6f3be19b97dae (patch)
tree2f2a88caf104fef31a3a8dc190ac3fe41dd017c1 /rt/lib/RT/Ticket_Overlay.pm
parentd4d0590bef31071e8809ec046717444b95b3f30a (diff)
import rt 3.4.5
Diffstat (limited to 'rt/lib/RT/Ticket_Overlay.pm')
-rw-r--r--rt/lib/RT/Ticket_Overlay.pm89
1 files changed, 36 insertions, 53 deletions
diff --git a/rt/lib/RT/Ticket_Overlay.pm b/rt/lib/RT/Ticket_Overlay.pm
index d04ecec..1ab91e2 100644
--- a/rt/lib/RT/Ticket_Overlay.pm
+++ b/rt/lib/RT/Ticket_Overlay.pm
@@ -750,7 +750,7 @@ sub Create {
$RT::Handle->Commit();
$ErrStr = $self->loc( "Ticket [_1] created in queue '[_2]'", $self->Id, $QueueObj->Name );
$ErrStr = join( "\n", $ErrStr, @non_fatal_errors );
- return ( $self->Id, $0, $ErrStr );
+ return ( $self->Id, 0, $ErrStr );
}
}
@@ -2501,8 +2501,11 @@ sub DeleteLink {
$direction='Base';
}
- if ( $val ) {
- my $remote_uri = RT::URI->new( $RT::SystemUser );
+ if ( $args{'Silent'} ) {
+ return ( $val, $Msg );
+ }
+ else {
+ my $remote_uri = RT::URI->new( $self->CurrentUser );
$remote_uri->FromURI( $remote_link );
my ( $Trans, $Msg, $TransObj ) = $self->_NewTransaction(
@@ -2512,6 +2515,17 @@ sub DeleteLink {
TimeTaken => 0
);
+ if ( $remote_uri->IsLocal ) {
+
+ my $OtherObj = $remote_uri->Object;
+ my ( $val, $Msg ) = $OtherObj->_NewTransaction(Type => 'DeleteLink',
+ Field => $direction eq 'Target' ? $LINKDIRMAP{$args{'Type'}}->{Base}
+ : $LINKDIRMAP{$args{'Type'}}->{Target},
+ OldValue => $self->URI,
+ ActivateScrips => ! $RT::LinkTransactionsRun1Scrip,
+ TimeTaken => 0 );
+ }
+
return ( $Trans, $Msg );
}
}
@@ -2524,52 +2538,6 @@ sub DeleteLink {
Takes a paramhash of Type and one of Base or Target. Adds that link to this ticket.
-=begin testing
-
-my $q1 = RT::Queue->new($RT::SystemUser);
-my ($id,$msg) = $q1->Create(Name => 'LinkTest1');
-ok ($id,$msg);
-my $q2 = RT::Queue->new($RT::SystemUser);
-($id,$msg) = $q2->Create(Name => 'LinkTest2');
-ok ($id,$msg);
-
-my $u1 = RT::User->new($RT::SystemUser);
-($id,$msg) =$u1->Create(Name => 'LinkTestUser');
-
-ok ($id,$msg);
-
-($id,$msg) = $u1->PrincipalObj->GrantRight ( Object => $q1, Right => 'CreateTicket');
-ok ($id,$msg);
-($id,$msg) = $u1->PrincipalObj->GrantRight ( Object => $q1, Right => 'ModifyTicket');
-ok ($id,$msg);
-
-my $tid;
-
-my $creator = RT::CurrentUser->new($u1->id);
-
-my $ticket = RT::Ticket->new( $creator);
-ok($ticket->isa('RT::Ticket'));
-($id,$tid, $msg) = $ticket->Create(Subject => 'Link test 1', Queue => $q1->id);
-ok ($id,$msg);
-
-
-my $ticket2 = RT::Ticket->new($RT::SystemUser);
-($id, $tid, $msg) = $ticket2->Create(Subject => 'Link test 2', Queue => $q2->id);
-ok ($id, $msg);
-
-($id,$msg) =$ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id);
-ok(!$id,$msg);
-($id,$msg) = $u1->PrincipalObj->GrantRight ( Object => $q2, Right => 'CreateTicket');
-ok ($id,$msg);
-($id,$msg) = $u1->PrincipalObj->GrantRight ( Object => $q2, Right => 'ModifyTicket');
-ok ($id,$msg);
-($id,$msg) =$ticket->AddLink(Type => 'RefersTo', Target => $ticket2->id);
-ok($id,$msg);
-($id,$msg) =$ticket->AddLink(Type => 'RefersTo', Target => -1);
-ok(!$id,$msg);
-
-=end testing
-
=cut
sub AddLink {
@@ -2657,7 +2625,7 @@ sub _AddLink {
return ( $val, $Msg );
}
else {
- my $remote_uri = RT::URI->new( $RT::SystemUser );
+ my $remote_uri = RT::URI->new( $self->CurrentUser );
$remote_uri->FromURI( $remote_link );
#Write the transaction
@@ -2666,6 +2634,17 @@ sub _AddLink {
Field => $LINKDIRMAP{$args{'Type'}}->{$direction},
NewValue => $remote_uri->URI || $remote_link,
TimeTaken => 0 );
+
+ if ( $remote_uri->IsLocal ) {
+
+ my $OtherObj = $remote_uri->Object;
+ my ( $val, $Msg ) = $OtherObj->_NewTransaction(Type => 'AddLink',
+ Field => $direction eq 'Target' ? $LINKDIRMAP{$args{'Type'}}->{Base}
+ : $LINKDIRMAP{$args{'Type'}}->{Target},
+ NewValue => $self->URI,
+ ActivateScrips => ! $RT::LinkTransactionsRun1Scrip,
+ TimeTaken => 0 );
+ }
return ( $val, $Msg );
}
@@ -3239,7 +3218,7 @@ Takes no arguments. Marks this ticket for garbage collection
sub Kill {
my $self = shift;
- $RT::Logger->crit("'Kill' is deprecated. use 'Delete' instead.");
+ $RT::Logger->crit("'Kill' is deprecated. use 'Delete' instead at (". join(":",caller).").");
return $self->Delete;
}
@@ -3482,7 +3461,7 @@ sub _Set {
#If we can't actually set the field to the value, don't record
# a transaction. instead, get out of here.
- if ( $ret == 0 ) { return ( 0, $msg ); }
+ return ( 0, $msg ) unless $ret;
}
if ( $args{'RecordTransaction'} == 1 ) {
@@ -3698,13 +3677,17 @@ See L<RT::Record>
sub CustomFieldValues {
my $self = shift;
my $field = shift;
- unless ( $field =~ /^\d+$/ ) {
+ if ( $field and $field !~ /^\d+$/ ) {
my $cf = RT::CustomField->new( $self->CurrentUser );
$cf->LoadByNameAndQueue( Name => $field, Queue => $self->QueueObj->Id );
unless ( $cf->id ) {
$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);
+ }
}
return $self->SUPER::CustomFieldValues($field);
}