[otrs-cvs] ImportExport/Kernel/Modules AdminImportExport.pm, 1.7, 1.8

cvs-log at otrs.org cvs-log at otrs.org
Mon Feb 4 12:19:59 GMT 2008


Comments:
Update of /home/cvs/ImportExport/Kernel/Modules
In directory lancelot:/tmp/cvs-serv6382/Kernel/Modules

Modified Files:
	AdminImportExport.pm 
Log Message:
Improved modularisation of import and export functions.

Author: mh

Index: AdminImportExport.pm
===================================================================
RCS file: /home/cvs/ImportExport/Kernel/Modules/AdminImportExport.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** AdminImportExport.pm	31 Jan 2008 19:28:47 -0000	1.7
--- AdminImportExport.pm	4 Feb 2008 12:19:54 -0000	1.8
***************
*** 25,29 ****
  
      # allocate new hash for object
!     my $Self = { %Param };
      bless( $Self, $Type );
  
--- 25,29 ----
  
      # allocate new hash for object
!     my $Self = {%Param};
      bless( $Self, $Type );
  
***************
*** 65,69 ****
          if ( $TemplateData->{TemplateID} eq 'NEW' ) {
  
!             # get object and format
              $TemplateData->{Object} = $Self->{ParamObject}->GetParam( Param => 'Object' );
              $TemplateData->{Format} = $Self->{ParamObject}->GetParam( Param => 'Format' );
--- 65,70 ----
          if ( $TemplateData->{TemplateID} eq 'NEW' ) {
  
!             # get needed data
!             $TemplateData->{Type}   = $Self->{ParamObject}->GetParam( Param => 'Type' );
              $TemplateData->{Object} = $Self->{ParamObject}->GetParam( Param => 'Object' );
              $TemplateData->{Format} = $Self->{ParamObject}->GetParam( Param => 'Format' );
***************
*** 71,75 ****
              # redirect to overview
              return $Self->{LayoutObject}->Redirect( OP => "Action=$Self->{Action}" )
!                 if !$TemplateData->{Object} || !$TemplateData->{Format};
          }
          else {
--- 72,76 ----
              # redirect to overview
              return $Self->{LayoutObject}->Redirect( OP => "Action=$Self->{Action}" )
!                 if !$TemplateData->{Object} || !$TemplateData->{Format} || !$TemplateData->{Type};
          }
          else {
***************
*** 82,85 ****
--- 83,95 ----
          }
  
+         # generate TypeOptionStrg
+         my $TypeOptionStrg = $Self->{LayoutObject}->BuildSelection(
+             Data => [ 'Import', 'Export' ],
+             Name => 'Type',
+             SelectedID   => $TemplateData->{Type},
+             PossibleNone => 1,
+             Translation  => 1,
+         );
+ 
          # generate ObjectOptionStrg
          my $ObjectOptionStrg = $Self->{LayoutObject}->BuildSelection(
***************
*** 105,108 ****
--- 115,119 ----
              Data => {
                  %Param,
+                 TypeOptionStrg   => $TypeOptionStrg,
                  ObjectOptionStrg => $ObjectOptionStrg,
                  FormatOptionStrg => $FormatOptionStrg,
***************
*** 151,155 ****
  
          # get params
!         for my $Param (qw(TemplateID Object Format Name ValidID Comment)) {
              $TemplateData->{$Param} = $Self->{ParamObject}->GetParam( Param => $Param ) || '';
          }
--- 162,166 ----
  
          # get params
!         for my $Param (qw(TemplateID Type Object Format Name ValidID Comment)) {
              $TemplateData->{$Param} = $Self->{ParamObject}->GetParam( Param => $Param ) || '';
          }
***************
*** 225,228 ****
--- 236,248 ----
          );
  
+         # generate TypeOptionStrg
+         my $TypeOptionStrg = $Self->{LayoutObject}->BuildSelection(
+             Data => [ 'Import', 'Export' ],
+             Name => 'Type',
+             SelectedID   => $TemplateData->{Type},
+             PossibleNone => 1,
+             Translation  => 1,
+         );
+ 
          # generate ObjectOptionStrg
          my $ObjectOptionStrg = $Self->{LayoutObject}->BuildSelection(
***************
*** 248,251 ****
--- 268,272 ----
              Data => {
                  %Param,
+                 TypeOptionStrg   => $TypeOptionStrg,
                  ObjectOptionStrg => $ObjectOptionStrg,
                  FormatOptionStrg => $FormatOptionStrg,
***************
*** 386,389 ****
--- 407,419 ----
          );
  
+         # generate TypeOptionStrg
+         my $TypeOptionStrg = $Self->{LayoutObject}->BuildSelection(
+             Data => [ 'Import', 'Export' ],
+             Name => 'Type',
+             SelectedID   => $TemplateData->{Type},
+             PossibleNone => 1,
+             Translation  => 1,
+         );
+ 
          # generate ObjectOptionStrg
          my $ObjectOptionStrg = $Self->{LayoutObject}->BuildSelection(
***************
*** 409,412 ****
--- 439,443 ----
              Data => {
                  %Param,
+                 TypeOptionStrg   => $TypeOptionStrg,
                  ObjectOptionStrg => $ObjectOptionStrg,
                  FormatOptionStrg => $FormatOptionStrg,
***************
*** 448,452 ****
                  Name => 'TemplateEdit3Row',
                  Data => {
!                     Name      => $Item->{Name} || '',
                      InputStrg => $InputString,
                  },
--- 479,483 ----
                  Name => 'TemplateEdit3Row',
                  Data => {
!                     Name => $Item->{Name} || '',
                      InputStrg => $InputString,
                  },
***************
*** 479,483 ****
              SubmitNext => 'TemplateEdit4',
              SubmitBack => 'TemplateEdit2',
!             Reload     => 'TemplateEdit1',
          );
  
--- 510,514 ----
              SubmitNext => 'TemplateEdit4',
              SubmitBack => 'TemplateEdit2',
!             Reload     => 'TemplateEdit3',
          );
  
***************
*** 521,524 ****
--- 552,726 ----
  
      # ------------------------------------------------------------ #
+     # template edit (mapping)
+     # ------------------------------------------------------------ #
+     if ( $Self->{Subaction} eq 'TemplateEdit4' ) {
+ 
+         # get object list
+         my $ObjectList = $Self->{ImportExportObject}->ObjectList();
+ 
+         return $Self->{LayoutObject}->FatalError( Message => 'No object backend found!' )
+             if !$ObjectList;
+ 
+         # get format list
+         my $FormatList = $Self->{ImportExportObject}->FormatList();
+ 
+         return $Self->{LayoutObject}->FatalError( Message => 'No format backend found!' )
+             if !$FormatList;
+ 
+         # get params
+         my $TemplateData = {};
+         $TemplateData->{TemplateID} = $Self->{ParamObject}->GetParam( Param => 'TemplateID' );
+ 
+         # get template data
+         $TemplateData = $Self->{ImportExportObject}->TemplateGet(
+             TemplateID => $TemplateData->{TemplateID},
+             UserID     => $Self->{UserID},
+         );
+ 
+         # generate TypeOptionStrg
+         my $TypeOptionStrg = $Self->{LayoutObject}->BuildSelection(
+             Data => [ 'Import', 'Export' ],
+             Name => 'Type',
+             SelectedID   => $TemplateData->{Type},
+             PossibleNone => 1,
+             Translation  => 1,
+         );
+ 
+         # generate ObjectOptionStrg
+         my $ObjectOptionStrg = $Self->{LayoutObject}->BuildSelection(
+             Data         => $ObjectList,
+             Name         => 'Object',
+             SelectedID   => $TemplateData->{Object},
+             PossibleNone => 1,
+             Translation  => 1,
+         );
+ 
+         # generate FormatOptionStrg
+         my $FormatOptionStrg = $Self->{LayoutObject}->BuildSelection(
+             Data         => $FormatList,
+             Name         => 'Format',
+             SelectedID   => $TemplateData->{Format},
+             PossibleNone => 1,
+             Translation  => 1,
+         );
+ 
+         # output overview
+         $Self->{LayoutObject}->Block(
+             Name => 'Overview',
+             Data => {
+                 %Param,
+                 TypeOptionStrg   => $TypeOptionStrg,
+                 ObjectOptionStrg => $ObjectOptionStrg,
+                 FormatOptionStrg => $FormatOptionStrg,
+             },
+         );
+ 
+         # output list
+         $Self->{LayoutObject}->Block(
+             Name => 'TemplateEdit4',
+             Data => {
+                 %{$TemplateData},
+                 ObjectName => $ObjectList->{ $TemplateData->{Object} },
+                 FormatName => $FormatList->{ $TemplateData->{Format} },
+             },
+         );
+ 
+ #        # get format attributes
+ #        my $FormatAttributeList = $Self->{ImportExportObject}->FormatAttributesGet(
+ #            TemplateID => $TemplateData->{TemplateID},
+ #            UserID     => $Self->{UserID},
+ #        );
+ #
+ #        # get format data
+ #        my $FormatData = $Self->{ImportExportObject}->FormatDataGet(
+ #            TemplateID => $TemplateData->{TemplateID},
+ #            UserID     => $Self->{UserID},
+ #        );
+ #
+ #        # output format attributes
+ #        for my $Item ( @{$FormatAttributeList} ) {
+ #
+ #            # create form input
+ #            my $InputString = $Self->{LayoutObject}->ImportExportFormInputCreate(
+ #                Item  => $Item,
+ #                Value => $FormatData->{ $Item->{Key} },
+ #            );
+ #
+ #            # output attribute row
+ #            $Self->{LayoutObject}->Block(
+ #                Name => 'TemplateEdit4Row',
+ #                Data => {
+ #                    Name      => $Item->{Name} || '',
+ #                    InputStrg => $InputString,
+ #                },
+ #            );
+ #        }
+ 
+         # output header and navbar
+         my $Output = $Self->{LayoutObject}->Header();
+         $Output .= $Self->{LayoutObject}->NavigationBar();
+ 
+         # start template output
+         $Output .= $Self->{LayoutObject}->Output(
+             TemplateFile => 'AdminImportExport',
+             Data         => \%Param,
+         );
+ 
+         $Output .= $Self->{LayoutObject}->Footer();
+         return $Output;
+     }
+ 
+     # ------------------------------------------------------------ #
+     # template save (mapping)
+     # ------------------------------------------------------------ #
+     elsif ( $Self->{Subaction} eq 'TemplateSave4' ) {
+ 
+         # get template id
+         my $TemplateID = $Self->{ParamObject}->GetParam( Param => 'TemplateID' );
+ 
+         my %Submit = (
+             SubmitBack => 'TemplateEdit3',
+             Reload     => 'TemplateEdit4',
+         );
+ 
+         # get submit action
+         my $Subaction = $Submit{Reload};
+ 
+         PARAM:
+         for my $SubmitKey ( keys %Submit ) {
+             next PARAM if !$Self->{ParamObject}->GetParam( Param => $SubmitKey );
+ 
+             $Subaction = $Submit{$SubmitKey};
+             last PARAM;
+         }
+ 
+ #        # get format attributes
+ #        my $FormatAttributeList = $Self->{ImportExportObject}->FormatAttributesGet(
+ #            TemplateID => $TemplateID,
+ #            UserID     => $Self->{UserID},
+ #        );
+ #
+ #        # get attribute values from form
+ #        my %AttributeValues;
+ #        for my $Item ( @{$FormatAttributeList} ) {
+ #
+ #            # get form data
+ #            $AttributeValues{ $Item->{Key} } = $Self->{LayoutObject}->ImportExportFormDataGet(
+ #                Item => $Item,
+ #            );
+ #        }
+ #
+ #        $Self->{ImportExportObject}->FormatDataSave(
+ #            TemplateID => $TemplateID,
+ #            FormatData => \%AttributeValues,
+ #            UserID     => $Self->{UserID},
+ #        );
+ 
+         return $Self->{LayoutObject}->Redirect(
+             OP => "Action=$Self->{Action}&Subaction=$Subaction&TemplateID=$TemplateID",
+         );
+     }
+ 
+     # ------------------------------------------------------------ #
      # template delete
      # ------------------------------------------------------------ #
***************
*** 555,558 ****
--- 757,768 ----
              if !$FormatList;
  
+         # generate TypeOptionStrg
+         my $TypeOptionStrg = $Self->{LayoutObject}->BuildSelection(
+             Data => [ 'Import', 'Export' ],
+             Name => 'Type',
+             PossibleNone => 1,
+             Translation  => 1,
+         );
+ 
          # generate ObjectOptionStrg
          my $ObjectOptionStrg = $Self->{LayoutObject}->BuildSelection(
***************
*** 576,579 ****
--- 786,790 ----
              Data => {
                  %Param,
+                 TypeOptionStrg   => $TypeOptionStrg,
                  ObjectOptionStrg => $ObjectOptionStrg,
                  FormatOptionStrg => $FormatOptionStrg,
***************
*** 661,663 ****
  }
  
! 1;
\ No newline at end of file
--- 872,874 ----
  }
  
! 1;


More information about the cvs-log mailing list