[otrs-cvs] otrs/Kernel/System Ticket.pm, 1.300, 1.301 LinkObject.pm, 1.16, 1.17

cvs-log at otrs.org cvs-log at otrs.org
Thu Mar 20 22:53:08 GMT 2008


Comments:
Update of /home/cvs/otrs/Kernel/System
In directory lancelot:/tmp/cvs-serv30471/Kernel/System

Modified Files:
	Ticket.pm LinkObject.pm 
Log Message:
Fixed bug# 2772 - Dangling links to deleted tickets (ticket links get not deleted after a ticket got deleted).

Author: martin

Index: Ticket.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/Ticket.pm,v
retrieving revision 1.300
retrieving revision 1.301
diff -C2 -d -r1.300 -r1.301
*** Ticket.pm	18 Mar 2008 16:12:44 -0000	1.300
--- Ticket.pm	20 Mar 2008 22:53:03 -0000	1.301
***************
*** 549,552 ****
--- 549,586 ----
      );
  
+     # delete ticket links
+     my $LinkObject = Kernel::System::LinkObject->new(
+         %Param,
+         %{$Self},
+         TicketObject => $Self,
+     );
+     $LinkObject->LoadBackend( Module => 'Ticket' );
+ 
+     # get linked objects and ids, then delete links
+     my %Links = $LinkObject->AllLinkedObjects(
+         Object   => 'Ticket',
+         ObjectID => $Param{TicketID},
+         UserID   => $Param{UserID},
+     );
+     for my $LinkType ( qw(Normal Parent Child) ) {
+         if ( ! $Links{$LinkType} ) {
+             next;
+         }
+         my %ObjectType = %{ $Links{$LinkType} };
+         for my $Object ( sort keys %ObjectType ) {
+             my %Data = %{ $ObjectType{$Object} };
+             for my $Item ( sort keys %Data ) {
+                 $LinkObject->UnlinkObject(
+                     LinkType    => $LinkType,
+                     LinkID1     => $Data{$Item}->{ID},
+                     LinkObject1 => $Object,
+                     LinkID2     => $Param{TicketID},
+                     LinkObject2 => 'Ticket',
+                     UserID      => $Param{UserID},
+                 );
+             }
+         }
+     }
+ 
      # ticket event
      $Self->TicketEventHandlerPost(
***************
*** 5949,5959 ****
  
      # link tickets
!     $Self->{LinkObject} = Kernel::System::LinkObject->new(
          %Param,
          %{$Self},
          TicketObject => $Self,
      );
!     $Self->{LinkObject}->LoadBackend( Module => 'Ticket' );
!     $Self->{LinkObject}->LinkObject(
          LinkType    => 'Parent',
          LinkID1     => $Param{MainTicketID},
--- 5983,5993 ----
  
      # link tickets
!     my $LinkObject = Kernel::System::LinkObject->new(
          %Param,
          %{$Self},
          TicketObject => $Self,
      );
!     $LinkObject->LoadBackend( Module => 'Ticket' );
!     $LinkObject->LinkObject(
          LinkType    => 'Parent',
          LinkID1     => $Param{MainTicketID},
***************
*** 6154,6157 ****
--- 6188,6192 ----
      # check if workflows are configured, if not, just return
      if ((      !$Self->{ConfigObject}->Get('TicketAcl')
+             && !$Self->{ConfigObject}->Get('Ticket::Acl::Module')
              && !$Self->{ConfigObject}->Get('Ticket::EventModulePost')
          )

Author: martin

Index: LinkObject.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/System/LinkObject.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** LinkObject.pm	2 Oct 2007 10:38:08 -0000	1.16
--- LinkObject.pm	20 Mar 2008 22:53:03 -0000	1.17
***************
*** 1,5 ****
  # --
  # Kernel/System/LinkObject.pm - to link objects
! # Copyright (C) 2001-2007 OTRS GmbH, http://otrs.org/
  # --
  # $Id$
--- 1,5 ----
  # --
  # Kernel/System/LinkObject.pm - to link objects
! # Copyright (C) 2001-2008 OTRS AG, http://otrs.org/
  # --
  # $Id$
***************
*** 7,11 ****
  # This software comes with ABSOLUTELY NO WARRANTY. For details, see
  # the enclosed file COPYING for license information (GPL). If you
! # did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
  # --
  
--- 7,11 ----
  # This software comes with ABSOLUTELY NO WARRANTY. For details, see
  # the enclosed file COPYING for license information (GPL). If you
! # did not receive this file, see http://www.gnu.org/licenses/gpl-2.0.txt.
  # --
  
***************
*** 195,210 ****
          }
      }
!     my $SQL
!         = "DELETE FROM object_link WHERE "
!         . " (object_link_a_id = '$Param{LinkID1}' " . " AND "
!         . " object_link_b_id = '$Param{LinkID2}' " . " AND "
!         . " object_link_a_object = '$Param{LinkObject1}' " . " AND "
!         . " object_link_b_object = '$Param{LinkObject2}' " . " AND "
!         . " object_link_type = '$Param{LinkType}') " . " OR "
!         . " (object_link_a_id = '$Param{LinkID2}' " . " AND "
!         . " object_link_b_id = '$Param{LinkID1}' " . " AND "
!         . " object_link_a_object = '$Param{LinkObject2}' " . " AND "
!         . " object_link_b_object = '$Param{LinkObject1}' " . " AND "
!         . " object_link_type = '$Param{LinkType}') ";
  
      if ( $Self->{DBObject}->Do( SQL => $SQL ) ) {
--- 195,218 ----
          }
      }
! 
!     my $SQLExt = '';
!     if ( $Param{LinkType} eq 'Parent' || $Param{LinkType} eq 'Child' ) {
!         $SQLExt = "object_link_type IN ('Parent', 'Child')";
!     }
!     else {
!         $SQLExt = "object_link_type = '$Param{LinkType}'";
!     }
! 
!     my $SQL = "DELETE FROM object_link WHERE "
!         . " (object_link_a_id = '$Param{LinkID1}' AND "
!         . " object_link_b_id = '$Param{LinkID2}' AND "
!         . " object_link_a_object = '$Param{LinkObject1}' AND "
!         . " object_link_b_object = '$Param{LinkObject2}' AND "
!         . " $SQLExt ) OR "
!         . " (object_link_a_id = '$Param{LinkID2}' AND "
!         . " object_link_b_id = '$Param{LinkID1}' AND "
!         . " object_link_a_object = '$Param{LinkObject2}' AND "
!         . " object_link_b_object = '$Param{LinkObject1}' AND "
!         . " $SQLExt)";
  
      if ( $Self->{DBObject}->Do( SQL => $SQL ) ) {
***************
*** 353,356 ****
--- 361,388 ----
      for (@LinkedIDs) {
          my %Hash = $Self->FillDataMap( ID => $_, UserID => $Self->{UserID} );
+ 
+         # delete links if object exists not anymore
+         if ( !%Hash ) {
+             if ( $Param{LinkID1} ) {
+                 $Self->UnlinkObject(
+                     LinkType    => $Param{LinkType},
+                     LinkID1     => $Param{LinkID1},
+                     LinkObject1 => $Param{LinkObject1},
+                     LinkID2     => $_,
+                     LinkObject2 => $Param{LinkObject2},
+                     UserID      => 1,
+                 );
+             }
+             elsif ( $Param{LinkID2} ) {
+                 $Self->UnlinkObject(
+                     LinkType    => $Param{LinkType},
+                     LinkID1     => $_,
+                     LinkObject1 => $Param{LinkObject1},
+                     LinkID2     => $Param{LinkID2},
+                     LinkObject2 => $Param{LinkObject2},
+                     UserID      => 1,
+                 );
+             }
+         }
          $Linked{$_} = \%Hash;
      }
***************
*** 409,413 ****
  This software comes with ABSOLUTELY NO WARRANTY. For details, see
  the enclosed file COPYING for license information (GPL). If you
! did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
  
  =cut
--- 441,445 ----
  This software comes with ABSOLUTELY NO WARRANTY. For details, see
  the enclosed file COPYING for license information (GPL). If you
! did not receive this file, see http://www.gnu.org/licenses/gpl-2.0.txt.
  
  =cut


More information about the cvs-log mailing list