[otrs-cvs] otrs/Kernel/Modules AdminProcessManagement.pm, 1.41, 1.42

"CVS commits notifications of OTRS.org" <[email protected]>
Newsgroups gmane.comp.otrs.cvs
Message-ID <[email protected]>
Comments:
Update of /home/cvs/otrs/Kernel/Modules
In directory lancelot:/tmp/cvs-serv25353/Kernel/Modules

Modified Files:
	AdminProcessManagement.pm 
Log Message:
Added ProcessCopy subaction.

Author: cr

Index: AdminProcessManagement.pm
===================================================================
RCS file: /home/cvs/otrs/Kernel/Modules/AdminProcessManagement.pm,v
retrieving revision 1.41
retrieving revision 1.42
diff -2 -u -d -r1.41 -r1.42
--- AdminProcessManagement.pm	20 Nov 2012 14:41:47 -0000	1.41
+++ AdminProcessManagement.pm	13 Dec 2012 15:54:00 -0000	1.42
@@ -530,4 +530,93 @@
 
     # ------------------------------------------------------------ #
+    # ProcessCopy
+    # ------------------------------------------------------------ #
+    elsif ( $Self->{Subaction} eq 'ProcessCopy' ) {
+
+        # challenge token check for write action
+        $Self->{LayoutObject}->ChallengeTokenCheck();
+
+        # get Process data
+        my $ProcessData = $Self->{ProcessObject}->ProcessGet(
+            ID     => $ProcessID,
+            UserID => $Self->{UserID},
+        );
+        if ( !$ProcessData ) {
+            return $Self->{LayoutObject}->ErrorScreen(
+                Message => "Unknown Process $ProcessID!",
+            );
+        }
+
+        # create new process name
+        my $ProcessName =
+            $ProcessData->{Name}
+            . ' ('
+            . $Self->{LayoutObject}->{LanguageObject}->Get('Copy')
+            . ')';
+
+        # generate entity ID
+        my $EntityID = $Self->{EntityObject}->EntityIDGenerate(
+            EntityType => 'Process',
+            UserID     => $Self->{UserID},
+        );
+
+        # show error if can't generate a new EntityID
+        if ( !$EntityID ) {
+            return $Self->{LayoutObject}->ErrorScreen(
+                Message => "There was an error generating a new EntityID for this Process",
+            );
+        }
+
+        # check if Inactive state estity exists
+        my $StateList = $Self->{StateObject}->StateList( UserID => $Self->{UserID} );
+        my %StateLookup = reverse %{$StateList};
+
+        my $StateEntityID = $StateLookup{'Inactive'};
+
+        # show error if  StateEntityID for Inactive does not exist
+        if ( !$EntityID ) {
+            return $Self->{LayoutObject}->ErrorScreen(
+                Message => "The StateEntityID for for state Inactive does not exists",
+            );
+        }
+
+        # otherwise save configuration and return to overview screen
+        my $ProcessID = $Self->{ProcessObject}->ProcessAdd(
+            Name          => $ProcessName,
+            EntityID      => $EntityID,
+            StateEntityID => $StateEntityID,
+            Layout        => $ProcessData->{Layout},
+            Config        => $ProcessData->{Config},
+            UserID        => $Self->{UserID},
+        );
+
+        # show error if can't create
+        if ( !$ProcessID ) {
+            return $Self->{LayoutObject}->ErrorScreen(
+                Message => "There was an error creating the Process",
+            );
+        }
+
+        # set entitty sync state
+        my $Success = $Self->{EntityObject}->EntitySyncStateSet(
+            EntityType => 'Process',
+            EntityID   => $EntityID,
+            SyncState  => 'not_sync',
+            UserID     => $Self->{UserID},
+        );
+
+        # show error if can't set
+        if ( !$Success ) {
+            return $Self->{LayoutObject}->ErrorScreen(
+                Message => "There was an error setting the entity sync status for Process "
+                    . "entity:$EntityID",
+            );
+        }
+
+        # return to overview
+        return $Self->{LayoutObject}->Redirect( OP => "Action=$Self->{Action}" );
+    }
+
+    # ------------------------------------------------------------ #
     # ProcessNew
     # ------------------------------------------------------------ #
---------------------------------------------------------------------
OTRS mailing list: cvs-log - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/cvs-log
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/cvs-log
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.