[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of Runcronworflows class 4 // 5 // Created on: <02-ïËÔ-2002 14:04:21 sp> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file runcronworflows.php 30 */ 31 32 $runInBrowser = true; 33 if ( isset( $webOutput ) ) 34 $runInBrowser = $webOutput; 35 36 include_once ( "lib/ezutils/classes/ezdebug.php" ); 37 include_once ( "lib/ezutils/classes/ezini.php" ); 38 39 include_once ( "kernel/classes/ezworkflowprocess.php" ); 40 include_once ( "kernel/classes/ezcontentobject.php" ); 41 include_once ( "kernel/classes/datatypes/ezuser/ezuser.php" ); 42 include_once ( "lib/ezutils/classes/ezmodule.php" ); 43 include_once ( "lib/ezutils/classes/ezoperationmemento.php" ); 44 include_once ( "lib/ezutils/classes/ezoperationhandler.php" ); 45 include_once ( "lib/ezutils/classes/ezsession.php" ); 46 47 include_once ( "lib/ezutils/classes/ezdebug.php" ); 48 include_once ( "lib/ezutils/classes/ezini.php" ); 49 include_once ( "lib/ezutils/classes/ezdebugsetting.php" ); 50 51 $workflowProcessList = eZWorkflowProcess::fetchForStatus( EZ_WORKFLOW_STATUS_DEFERRED_TO_CRON ); 52 //var_dump( $workflowProcessList ); 53 //$user =& eZUser::instance( 14 ); 54 eZModule::setGlobalPathList( array( "kernel" ) ); 55 if ( !$isQuiet ) 56 $cli->output( "Checking for workflow processes" ); 57 $removedProcessCount = 0; 58 $processCount = 0; 59 $statusMap = array(); 60 foreach( array_keys( $workflowProcessList ) as $key ) 61 { 62 $process =& $workflowProcessList[ $key ]; 63 $workflow = eZWorkflow::fetch( $process->attribute( "workflow_id" ) ); 64 65 if ( $process->attribute( "event_id" ) != 0 ) 66 $workflowEvent = eZWorkflowEvent::fetch( $process->attribute( "event_id" ) ); 67 $process->run( $workflow, $workflowEvent, $eventLog ); 68 // Store changes to process 69 70 ++$processCount; 71 $status = $process->attribute( 'status' ); 72 if ( !isset( $statusMap[$status] ) ) 73 $statusMap[$status] = 0; 74 ++$statusMap[$status]; 75 76 if ( $process->attribute( 'status' ) != EZ_WORKFLOW_STATUS_DONE ) 77 { 78 if ( $process->attribute( 'status' ) == EZ_WORKFLOW_STATUS_CANCELLED ) 79 { 80 ++$removedProcessCount; 81 $process->remove(); 82 continue; 83 } 84 $process->store(); 85 if ( $process->attribute( 'status' ) == EZ_WORKFLOW_STATUS_RESET ) 86 { 87 $bodyMemento = eZOperationMemento::fetchMain( $process->attribute( 'memento_key' ) ); 88 $mementoList = eZOperationMemento::fetchList( $process->attribute( 'memento_key' ) ); 89 $bodyMemento->remove(); 90 for ( $i = 0; $i < count( $mementoList ); ++$i ) 91 { 92 $memento =& $mementoList[$i]; 93 $memento->remove(); 94 } 95 } 96 } 97 else 98 { //restore memento and run it 99 $bodyMemento = eZOperationMemento::fetchChild( $process->attribute( 'memento_key' ) ); 100 if ( is_null( $bodyMemento ) ) 101 { 102 eZDebug::writeError( $bodyMemento, "Empty body memento in workflow.php" ); 103 continue; 104 } 105 $bodyMementoData = $bodyMemento->data(); 106 $mainMemento =& $bodyMemento->attribute( 'main_memento' ); 107 if ( !$mainMemento ) 108 continue; 109 110 $mementoData = $bodyMemento->data(); 111 $mainMementoData = $mainMemento->data(); 112 $mementoData['main_memento'] =& $mainMemento; 113 $mementoData['skip_trigger'] = true; 114 $mementoData['memento_key'] = $process->attribute( 'memento_key' ); 115 $bodyMemento->remove(); 116 $operationParameters = array(); 117 if ( isset( $mementoData['parameters'] ) ) 118 $operationParameters = $mementoData['parameters']; 119 $operationResult = eZOperationHandler::execute( $mementoData['module_name'], $mementoData['operation_name'], $operationParameters, $mementoData ); 120 ++$removedProcessCount; 121 $process->remove(); 122 } 123 124 } 125 if ( !$isQuiet ) 126 { 127 $cli->output( $cli->stylize( 'emphasize', "Status list" ) ); 128 $statusTextList = array(); 129 $maxStatusTextLength = 0; 130 foreach ( $statusMap as $statusID => $statusCount ) 131 { 132 $statusName = eZWorkflow::statusName( $statusID ); 133 $statusText = "$statusName($statusID)"; 134 $statusTextList[] = array( 'text' => $statusText, 135 'count' => $statusCount ); 136 if ( strlen( $statusText ) > $maxStatusTextLength ) 137 $maxStatusTextLength = strlen( $statusText ); 138 } 139 foreach ( $statusTextList as $item ) 140 { 141 $text = $item['text']; 142 $count = $item['count']; 143 $cli->output( $cli->stylize( 'success', $text ) . ': ' . str_repeat( ' ', $maxStatusTextLength - strlen( $text ) ) . $cli->stylize( 'emphasize', $count ) ); 144 } 145 $cli->output(); 146 $cli->output( $cli->stylize( 'emphasize', $removedProcessCount ) . " out of " . $cli->stylize( 'emphasize', $processCount ) . " processes was finished" ); 147 } 148 149 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |