|
eZ Publish
[trunk]
|
00001 <?php 00002 /** 00003 * File containing the eZOperationHandler class. 00004 * 00005 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. 00006 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 00007 * @version //autogentag// 00008 * @package lib 00009 */ 00010 00011 /*! 00012 \class eZOperationHandler ezoperationhandler.php 00013 \brief The class eZOperationHandler does 00014 00015 */ 00016 00017 class eZOperationHandler 00018 { 00019 /*! 00020 Constructor 00021 */ 00022 function eZOperationHandler() 00023 { 00024 } 00025 00026 /** 00027 * Factory for modules' moduleOperationInfo objects. 00028 * 00029 * @param string $moduleName 00030 * @param bool $useTriggers* 00031 * 00032 * @return eZModuleOperationInfo 00033 */ 00034 static function moduleOperationInfo( $moduleName, $useTriggers = true ) 00035 { 00036 if ( !isset( $GLOBALS['eZGlobalModuleOperationList'] ) ) 00037 { 00038 $GLOBALS['eZGlobalModuleOperationList'] = array(); 00039 } 00040 if ( isset( $GLOBALS['eZGlobalModuleOperationList'][$moduleName] ) ) 00041 { 00042 return $GLOBALS['eZGlobalModuleOperationList'][$moduleName]; 00043 } 00044 $moduleOperationInfo = new eZModuleOperationInfo( $moduleName, $useTriggers ); 00045 $moduleOperationInfo->loadDefinition(); 00046 return $GLOBALS['eZGlobalModuleOperationList'][$moduleName] = $moduleOperationInfo; 00047 } 00048 00049 static function execute( $moduleName, $operationName, $operationParameters, $lastTriggerName = null, $useTriggers = true ) 00050 { 00051 $moduleOperationInfo = eZOperationHandler::moduleOperationInfo( $moduleName, $useTriggers ); 00052 if ( !$moduleOperationInfo->isValid() ) 00053 { 00054 eZDebug::writeError( "Cannot execute operation '$operationName' in module '$moduleName', no valid data", __METHOD__ ); 00055 return null; 00056 } 00057 return $moduleOperationInfo->execute( $operationName, $operationParameters, $lastTriggerName, $useTriggers ); 00058 } 00059 00060 /** 00061 * Checks if a trigger is defined in worklow.ini/[OperationSettings]/AvailableOperations 00062 * 00063 * @param string $name 00064 * @return boolean true if the operation is available, false otherwise 00065 */ 00066 static public function operationIsAvailable( $name ) 00067 { 00068 $workflowINI = eZINI::instance( 'workflow.ini' ); 00069 $operationList = $workflowINI->variableArray( 'OperationSettings', 'AvailableOperations' ); 00070 $operationList = array_unique( array_merge( $operationList, $workflowINI->variable( 'OperationSettings', 'AvailableOperationList' ) ) ); 00071 00072 return in_array( $name, $operationList ) || in_array( "before_{$name}", $operationList ) || in_array( "after_{$name}", $operationList ); 00073 } 00074 00075 } 00076 00077 ?>