4 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
5 // SOFTWARE NAME: eZ Publish
6 // SOFTWARE RELEASE: 4.1.x
7 // COPYRIGHT NOTICE: Copyright (C) 1999-2010 eZ Systems AS
8 // SOFTWARE LICENSE: GNU General Public License v2.0
10 // This program is free software; you can redistribute it and/or
11 // modify it under the terms of version 2.0 of the GNU General
12 // Public License as published by the Free Software Foundation.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of version 2.0 of the GNU General
20 // Public License along with this program; if not, write to the Free
21 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 // MA 02110-1301, USA.
25 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
28 $Module = $Params['Module'];
29 $GroupIdentifier = $Params['GroupIdentifier'];
30 $StateIdentifier = $Params['StateIdentifier'];
32 $group = eZContentObjectStateGroup::fetchByIdentifier( $GroupIdentifier );
34 if ( !is_object( $group ) )
36 return $Module->handleError( eZError::KERNEL_NOT_FOUND, 'kernel' );
39 if ( $group->isInternal() )
41 return $Module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );
44 $state = $StateIdentifier ? $group->stateByIdentifier( $StateIdentifier ) : $group->newState();
46 if ( !is_object( $state ) )
48 return $Module->handleError( eZError::KERNEL_NOT_FOUND, 'kernel' );
51 $redirectUrl = "state/group/$GroupIdentifier";
52 require_once( 'kernel/common/template.php' );
54 $tpl = templateInit();
56 $currentAction = $Module->currentAction();
58 if ( $currentAction == 'Cancel' )
60 return $Module->redirectTo( $redirectUrl );
62 else if ( $currentAction == 'Store' )
64 $state->fetchHTTPPersistentVariables();
67 $isValid = $state->isValid( $messages );
72 return $Module->redirectTo( $redirectUrl );
75 $tpl->setVariable( 'is_valid', $isValid );
76 $tpl->setVariable( 'validation_messages', $messages );
79 $tpl->setVariable( 'state', $state );
80 $tpl->setVariable( 'group', $group );
82 if ( $StateIdentifier === null )
85 array( 'url' => false, 'text' => ezpI18n::translate( 'kernel/state', 'State' ) ),
86 array( 'url' => false, 'text' => ezpI18n::translate( 'kernel/state', 'New' ) ),
87 array( 'url' => false, 'text' => $GroupIdentifier )
93 array( 'url' => false, 'text' => ezpI18n::translate( 'kernel/state', 'State' ) ),
94 array( 'url' => false, 'text' => ezpI18n::translate( 'kernel/state', 'Edit' ) ),
95 array( 'url' => false, 'text' => $GroupIdentifier ),
96 array( 'url' => false, 'text' => $StateIdentifier ),
102 'content' => $tpl->fetch( 'design:state/edit.tpl' )