[otrs-cvs] Advisory/Kernel/System Advisory.pm,1.39,1.40

cvs-log at otrs.org cvs-log at otrs.org
Sat Mar 1 21:13:00 GMT 2008


Comments:
Update of /home/cvs/Advisory/Kernel/System
In directory lancelot:/tmp/cvs-serv9022/Kernel/System

Modified Files:
	Advisory.pm 
Log Message:
Implement a more efficient overview.

Author: tr

Index: Advisory.pm
===================================================================
RCS file: /home/cvs/Advisory/Kernel/System/Advisory.pm,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** Advisory.pm	23 Jan 2008 08:36:01 -0000	1.39
--- Advisory.pm	1 Mar 2008 21:12:55 -0000	1.40
***************
*** 97,131 ****
      my ( $Self, %Param ) = @_;
  
-     my %ConfigHash;
- 
      # check params
!     for (qw(TicketID)) {
!         if ( !defined $Param{$_} ) {
!             $Self->{LogObject}->Log(
!                 Priority => 'error',
!                 Message  => "AdvisoryNew: Need TicketID = $Param{TicketID}!"
!             );
!             return;
!         }
      }
  
!     %ConfigHash = %{ $Self->{ConfigObject}->Get('Advisory::ConfigHash') };
      delete $ConfigHash{'EISPP-Advisory'}{TagHelp};
      my %Hash = $Self->_ConfigHash2XMLHash(%ConfigHash);
      $Hash{TicketID} = $Param{TicketID};
  
!     if ( $Self->AdvisoryAdd(%Hash) ) {
  
-         # add ticket type
-         $Self->{TicketObject}->TicketFreeTextSet(
-             TicketID => $Param{TicketID},
-             Key      => 'TicketType',
-             Value    => $Self->{ConfigObject}->Get('Advisory::TicketType'),
-             Counter  => 1,
-             UserID   => $Self->{UserID},
-         );
-         return 1;
-     }
-     return;
  }
  
--- 97,126 ----
      my ( $Self, %Param ) = @_;
  
      # check params
!     if ( !defined $Param{TicketID} ) {
!         $Self->{LogObject}->Log(
!             Priority => 'error',
!             Message  => 'AdvisoryNew: Need TicketID!'
!         );
!         return;
      }
  
!     my %ConfigHash = %{ $Self->{ConfigObject}->Get('Advisory::ConfigHash') };
      delete $ConfigHash{'EISPP-Advisory'}{TagHelp};
      my %Hash = $Self->_ConfigHash2XMLHash(%ConfigHash);
      $Hash{TicketID} = $Param{TicketID};
  
!     return if !$Self->AdvisoryAdd(%Hash);
! 
!     # add ticket type
!     $Self->{TicketObject}->TicketFreeTextSet(
!         TicketID => $Param{TicketID},
!         Key      => 'TicketType',
!         Value    => $Self->{ConfigObject}->Get('Advisory::TicketType'),
!         Counter  => 1,
!         UserID   => $Self->{UserID},
!     );
!     return 1;
  
  }
  
***************
*** 587,638 ****
      my ( $Self, %Param ) = @_;
  
!     my @SortedTicketList = ();
!     my @SearchResult     = $Self->{TicketObject}->TicketSearch(
!         Result  => 'ARRAY',
!         UserID  => $Self->{UserID},
!         OrderBy => 'Up',
!         SortBy  => 'Age',
      );
!     for my $Key (@SearchResult) {
!         my %SearchResultList = ();
!         my %Option           = $Self->{TicketObject}->TicketGet(
!             TicketID => $Key,
              UserID   => $Self->{UserID},
          );
-         $SearchResultList{$Key}{Title}        = $Option{Title};
-         $SearchResultList{$Key}{TicketID}     = $Key;
-         $SearchResultList{$Key}{PriorityID}   = $Option{PriorityID};
-         $SearchResultList{$Key}{Priority}     = $Option{Priority};
-         $SearchResultList{$Key}{StateType}    = $Option{StateType};
-         $SearchResultList{$Key}{TicketNumber} = $Option{TicketNumber};
-         $SearchResultList{$Key}{Queue}        = $Option{Queue};
-         $SearchResultList{$Key}{QueueID}      = $Option{QueueID};
-         $SearchResultList{$Key}{LockID}       = $Option{LockID};
  
!         if ( $Option{TicketFreeKey1} eq 'TicketType' ) {
!             $SearchResultList{$Key}{TicketType} = $Option{TicketFreeText1};
          }
  
!         if (   $SearchResultList{$Key}{TicketType}
!             && $SearchResultList{$Key}{TicketType} eq
!             $Self->{ConfigObject}->Get('Advisory::TicketType') )
!         {
!             my %AdvisoryOption = $Self->AdvisoryGet( TicketID => $Key );
!             $SearchResultList{$Key}{Created}
!                 = $AdvisoryOption{'EISPP-Advisory'}[1]{MetaTag}[1]{Created};
!             $SearchResultList{$Key}{Ref_Num}
!                 = $AdvisoryOption{'EISPP-Advisory'}[1]{Id_Data}[1]{ref_num}[1]{Content};
!             $SearchResultList{$Key}{CreatedTimeStamp} = $Self->{TimeObject}->TimeStamp2SystemTime(
!                 String => $AdvisoryOption{'EISPP-Advisory'}[1]{MetaTag}[1]{Created} );
          }
          else {
!             $SearchResultList{$Key}{Created} = $Option{Created};
!             $SearchResultList{$Key}{CreatedTimeStamp}
!                 = $Self->{TimeObject}->TimeStamp2SystemTime( String => $Option{Created} );
          }
! 
!         push( @SortedTicketList, $SearchResultList{$Key} );
      }
!     return @SortedTicketList;
  }
  
--- 582,654 ----
      my ( $Self, %Param ) = @_;
  
!     # search all tickets in advisory queues
!     my @TicketsInAdvisoryQueues = $Self->{TicketObject}->TicketSearch(
!         Result    => 'ARRAY',
!         UserID    => $Self->{UserID},
!         StateType => 'Open',
!         Queues    => $Self->{ConfigObject}->Get('Advisory::AdvisoryQueues'),
      );
! 
!     # find all exitsting advisories
!     my @ExistingAdvisories = $Self->{XMLObject}->XMLHashList(
!         Type => 'EISPP-Advisory',
!     );
! 
!     # remove double results
!     my @AllResults;
!     push @AllResults, @TicketsInAdvisoryQueues, @ExistingAdvisories;
!     my %AllAffectedTickets = map { $_ => 1;} @AllResults;
! 
!     # get the data to the advisories
!     my $AdvisoryTicketType = $Self->{ConfigObject}->Get('Advisory::TicketType');
!     my @TicketList;
!     TICKETID:
!     for my $TicketID (keys %AllAffectedTickets) {
!         my %TicketData = $Self->{TicketObject}->TicketGet(
!             TicketID => $TicketID,
              UserID   => $Self->{UserID},
          );
  
!         # the @ExistingAdvisories has closed Ticktets too, so I need this check
!         # we should search for a faster solution
!         next TICKETID if $TicketData{StateType} ne 'open';
! 
!         my %OverviewTicketData = (
!             Title        => $TicketData{Title},
!             TicketID     => $TicketID,
!             PriorityID   => $TicketData{PriorityID},
!             Priority     => $TicketData{Priority},
!             StateType    => $TicketData{StateType},
!             TicketNumber => $TicketData{TicketNumber},
!             Queue        => $TicketData{Queue},
!             QueueID      => $TicketData{QueueID},
!             LockID       => $TicketData{LockID},
!         );
! 
!         if ( $TicketData{TicketFreeKey1} eq 'TicketType' ) {
!             $OverviewTicketData{TicketType} = $TicketData{TicketFreeText1};
          }
  
!         # if advisory content is available use this
!         if ($OverviewTicketData{TicketType} && $OverviewTicketData{TicketType} eq $AdvisoryTicketType) {
!             my %Advisory =$Self->AdvisoryGet( TicketID => $TicketID );
!             %Advisory = %{$Advisory{'EISPP-Advisory'}->[1]};
!             $OverviewTicketData{Created} = $Advisory{MetaTag}[1]{Created};
!             $OverviewTicketData{Ref_Num} = $Advisory{Id_Data}[1]{ref_num}[1]{Content};
!             $OverviewTicketData{CreatedTimeStamp} = $Self->{TimeObject}->TimeStamp2SystemTime(
!                 String => $Advisory{MetaTag}[1]{Created}
!             );
          }
          else {
!             $OverviewTicketData{Created} = $TicketData{Created};
!             $OverviewTicketData{CreatedTimeStamp} = $Self->{TimeObject}->TimeStamp2SystemTime(
!                 String => $TicketData{Created},
!             );
          }
!         push( @TicketList, \%OverviewTicketData );
      }
! 
!     return sort { $b->{CreatedTimeStamp} <=>  $a->{CreatedTimeStamp} } @TicketList;
! 
  }
  
***************
*** 650,679 ****
      my ( $Self, %Param ) = @_;
  
!     for (qw(TicketID)) {
!         if ( !$Param{$_} ) {
!             $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
!             return;
!         }
      }
  
      # db delete
!     if ($Self->{XMLObject}->XMLHashDelete(
!             Type => 'EISPP-Advisory',
!             Key  => $Param{TicketID},
!         )
!         )
!     {
  
!         # reset ticket type
!         $Self->{TicketObject}->TicketFreeTextSet(
!             TicketID => $Param{TicketID},
!             Key      => 'TicketType',
!             Value    => '',
!             Counter  => 1,
!             UserID   => $Self->{UserID},
!         );
!         return 1;
!     }
!     return;
  }
  
--- 666,691 ----
      my ( $Self, %Param ) = @_;
  
!     # check needed param
!     if ( !$Param{TicketID} ) {
!         $Self->{LogObject}->Log( Priority => 'error', Message => 'Need TicketID!' );
!         return;
      }
  
      # db delete
!     return if !$Self->{XMLObject}->XMLHashDelete(
!         Type => 'EISPP-Advisory',
!         Key  => $Param{TicketID},
!     );
  
!     # reset ticket type
!     $Self->{TicketObject}->TicketFreeTextSet(
!         TicketID => $Param{TicketID},
!         Key      => 'TicketType',
!         Value    => '',
!         Counter  => 1,
!         UserID   => $Self->{UserID},
!     );
! 
!     return 1;
  }
  
***************
*** 746,758 ****
      my ( $Self, %Param ) = @_;
  
      my @SearchArray            = @{ $Param{SearchArray} };
      my %TicketOptions          = %{ $Param{TicketOptions} };
-     my @SearchResult           = ();
-     my %Option                 = ();
      my %SearchResultList       = ();
      my @SortedSearchResultList = ();
      my %OrderByHash            = ();
  
!     @SearchResult = $Self->{XMLObject}->XMLHashSearch(
          Type => 'EISPP-Advisory',
          What => \@SearchArray,
--- 758,769 ----
      my ( $Self, %Param ) = @_;
  
+     # declaration
      my @SearchArray            = @{ $Param{SearchArray} };
      my %TicketOptions          = %{ $Param{TicketOptions} };
      my %SearchResultList       = ();
      my @SortedSearchResultList = ();
      my %OrderByHash            = ();
  
!     my @SearchResult = $Self->{XMLObject}->XMLHashSearch(
          Type => 'EISPP-Advisory',
          What => \@SearchArray,
***************
*** 763,767 ****
      }
      for my $Key (@SearchResult) {
!         %Option = $Self->AdvisoryGet( TicketID => $Key, UserID => $Param{UserID} );
          if (   !$TicketOptions{Title}
              || $TicketOptions{Title} eq ''
--- 774,778 ----
      }
      for my $Key (@SearchResult) {
!         my %Option = $Self->AdvisoryGet( TicketID => $Key, UserID => $Param{UserID} );
          if (   !$TicketOptions{Title}
              || $TicketOptions{Title} eq ''


More information about the cvs-log mailing list