00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 include_once( 'lib/ezutils/classes/ezmodule.php' );
00041 include_once( 'lib/ezutils/classes/ezdebug.php' );
00042 include_once( 'lib/ezutils/classes/ezoperationmemento.php' );
00043 include_once( 'kernel/classes/eztrigger.php' );
00044
00045 include_once( 'lib/ezutils/classes/ezmoduleoperationdefinition.php' );
00046
00047
00048 class eZModuleOperationInfo
00049 {
00050
00051
00052
00053 function eZModuleOperationInfo( $moduleName, $useTriggers = true )
00054 {
00055 $this->ModuleName = $moduleName;
00056 $this->IsValid = false;
00057 $this->OperationList = array();
00058 $this->UseOldCall = false;
00059 $this->Memento = null;
00060 $this->UseTriggers = $useTriggers;
00061 }
00062
00063 function isValid()
00064 {
00065 return $this->IsValid;
00066 }
00067
00068 function loadDefinition()
00069 {
00070 $pathList = eZModule::globalPathList();
00071 foreach ( $pathList as $path )
00072 {
00073 $definitionFile = $path . '/' . $this->ModuleName . '/operation_definition.php';
00074 if ( file_exists( $definitionFile ) )
00075 break;
00076 $definitionFile = null;
00077 }
00078 if ( $definitionFile === null )
00079 {
00080 eZDebug::writeError( 'Missing operation definition file for module: ' . $this->ModuleName,
00081 'eZModuleOperationInfo::loadDefinition' );
00082 return false;
00083 }
00084 unset( $OperationList );
00085 include( $definitionFile );
00086 if ( !isset( $OperationList ) )
00087 {
00088 eZDebug::writeError( 'Missing operation definition list for module: ' . $this->ModuleName,
00089 'eZModuleOperationInfo::loadDefinition' );
00090 return false;
00091 }
00092 $this->OperationList = $OperationList;
00093 $this->IsValid = true;
00094 return true;
00095 }
00096
00097 function makeOperationKeyArray( $operationDefinition, $operationParameters )
00098 {
00099 $keyDefinition = null;
00100 if ( array_key_exists( 'keys', $operationDefinition ) and
00101 is_array( $operationDefinition['keys'] ) )
00102 {
00103 $keyDefinition = $operationDefinition['keys'];
00104 }
00105 return $this->makeKeyArray( $keyDefinition, $operationDefinition['parameters'], $operationParameters );
00106 }
00107
00108 function makeKeyArray( $keyDefinition, $parameterDefinition, $operationParameters )
00109 {
00110 $keyArray = array();
00111 if ( $keyDefinition !== null )
00112 {
00113 foreach ( $keyDefinition as $key )
00114 {
00115 $keyArray[$key] = $operationParameters[$key];
00116 }
00117 }
00118 else
00119 {
00120 foreach ( $parameterDefinition as $operationParameter )
00121 {
00122 $keyArray[$operationParameter['name']] = $operationParameters[$operationParameter['name']];
00123 }
00124 }
00125 return $keyArray;
00126 }
00127
00128 function execute( $operationName, $operationParameters, $mementoData = null )
00129 {
00130 $moduleName = $this->ModuleName;
00131 if ( !isset( $this->OperationList[$operationName] ) )
00132 {
00133 eZDebug::writeError( "No such operation '$operationName' in module '$moduleName'",
00134 'eZModuleOperationInfo::execute' );
00135 return null;
00136 }
00137 $operationDefinition =& $this->OperationList[$operationName];
00138 if ( !isset( $operationName['default_call_method'] ) )
00139 {
00140 eZDebug::writeError( "No call method defined for operation '$operationName' in module '$moduleName'",
00141 'eZModuleOperationInfo::execute' );
00142 return null;
00143 }
00144 if ( !isset( $operationName['body'] ) )
00145 {
00146 eZDebug::writeError( "No body for operation '$operationName' in module '$moduleName'",
00147 'eZModuleOperationInfo::execute' );
00148 return null;
00149 }
00150 if ( !isset( $operationName['parameters'] ) )
00151 {
00152 eZDebug::writeError( "No parameters defined for operation '$operationName' in module '$moduleName'",
00153 'eZModuleOperationInfo::execute' );
00154 return null;
00155 }
00156 $callMethod =& $operationDefinition['default_call_method'];
00157 $resultArray = null;
00158 $this->Memento = null;
00159 if ( isset( $callMethod['include_file'] ) and
00160 isset( $callMethod['class'] ) )
00161 {
00162 $bodyCallCount = array( 'loop_run' => array() );
00163 $operationKeys = null;
00164 if ( isset( $operationDefinition['keys'] ) )
00165 $operationKeys = $operationDefinition['keys'];
00166 $operationParameterDefinitions = $operationDefinition['parameters'];
00167 $this->storeOperationMemento( $operationKeys, $operationParameterDefinitions, $operationParameters, $bodyCallCount, $operationName );
00168
00169 $runOperation = true;
00170 if ( $mementoData === null )
00171 {
00172 $keyArray = $this->makeOperationKeyArray( $operationDefinition, $operationParameters );
00173 $keyArray['session_key'] = eZHTTPTool::getSessionKey();
00174 $mainMemento = null;
00175 if ( $this->UseTriggers )
00176 $mainMemento = eZOperationMemento::fetchMain( $keyArray );
00177
00178 if ( $mainMemento !== null )
00179 {
00180 $this->Memento =& $mainMemento;
00181 $mementoOperationData = $this->Memento->data();
00182 if ( isset( $mementoOperationData['loop_run'] ) )
00183 $bodyCallCount['loop_run'] = $mementoOperationData['loop_run'];
00184 }
00185
00186
00187
00188 $mementoList = null;
00189 if ( $this->UseTriggers )
00190 $mementoList = eZOperationMemento::fetchList( $keyArray );
00191
00192 if ( count( $mementoList ) > 0 )
00193 {
00194 $lastResultArray = array();
00195 $mementoRestoreSuccess = true;
00196
00197 foreach ( array_keys( $mementoList ) as $key )
00198 {
00199 $memento =& $mementoList[$key];
00200 $mementoData = $memento->data();
00201 $memento->remove();
00202
00203 $resultArray = $this->executeBody( $callMethod['include_file'], $callMethod['class'], $operationDefinition['body'],
00204 $operationKeys, $operationParameterDefinitions, $operationParameters,
00205 $mementoData, $bodyCallCount, $operationDefinition['name'] );
00206 if ( is_array( $resultArray ) )
00207 {
00208 $lastResultArray = array_merge( $lastResultArray, $resultArray );
00209 if ( !$resultArray['status'] )
00210 $mementoRestoreSuccess = false;
00211 }
00212 }
00213 $resultArray = $lastResultArray;
00214
00215 $runOperation = false;
00216 }
00217 }
00218 if ( $runOperation )
00219 {
00220
00221 $resultArray = $this->executeBody( $callMethod['include_file'], $callMethod['class'], $operationDefinition['body'],
00222 $operationKeys, $operationParameterDefinitions, $operationParameters,
00223 $mementoData, $bodyCallCount, $operationDefinition['name'] );
00224
00225
00226 }
00227
00228 if ( is_array( $resultArray ) and
00229 isset( $resultArray['status'] ) and
00230 $resultArray['status'] == EZ_MODULE_OPERATION_HALTED )
00231 {
00232
00233 if ( $this->Memento !== null )
00234 {
00235 $this->Memento->store();
00236 }
00237 }
00238 else if ( $this->Memento !== null and
00239 $this->Memento->attribute( 'id' ) !== null )
00240 {
00241
00242 $this->Memento->remove();
00243 }
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 $this->Memento = null;
00260 }
00261 else
00262 {
00263 eZDebug::writeError( "No valid call methods found for operation '$operationName' in module '$moduleName'",
00264 'eZModuleOperationInfo::execute' );
00265 return null;
00266 }
00267 if ( !is_array( $resultArray ) )
00268 {
00269 eZDebug::writeError( "Operation '$operationName' in module '$moduleName' did not return a result array",
00270 'eZOperationHandler::execute' );
00271 return null;
00272 }
00273 if ( isset( $resultArray['internal_error'] ) )
00274 {
00275 switch ( $resultArray['internal_error'] )
00276 {
00277 case EZ_MODULE_OPERATION_ERROR_NO_CLASS:
00278 {
00279 $className = $resultArray['internal_error_class_name'];
00280 eZDebug::writeError( "No class '$className' available for operation '$operationName' in module '$moduleName'",
00281 'eZModuleOperationInfo::execute' );
00282 return null;
00283 } break;
00284 case EZ_MODULE_OPERATION_ERROR_NO_CLASS_METHOD:
00285 {
00286 $className = $resultArray['internal_error_class_name'];
00287 $classMethodName = $resultArray['internal_error_class_method_name'];
00288 eZDebug::writeError( "No method '$classMethodName' in class '$className' available for operation '$operationName' in module '$moduleName'",
00289 'eZModuleOperationInfo::execute' );
00290 return null;
00291 } break;
00292 case EZ_MODULE_OPERATION_ERROR_CLASS_INSTANTIATE_FAILED:
00293 {
00294 $className = $resultArray['internal_error_class_name'];
00295 eZDebug::writeError( "Failed instantiating class '$className' which is needed for operation '$operationName' in module '$moduleName'",
00296 'eZModuleOperationInfo::execute' );
00297 return null;
00298 } break;
00299 case EZ_MODULE_OPERATION_ERROR_MISSING_PARAMETER:
00300 {
00301 $parameterName = $resultArray['internal_error_parameter_name'];
00302 eZDebug::writeError( "Missing parameter '$parameterName' for operation '$operationName' in module '$moduleName'",
00303 'eZModuleOperationInfo::execute' );
00304 return null;
00305 } break;
00306 default:
00307 {
00308 $internalError = $resultArray['internal_error'];
00309 eZDebug::writeError( "Unknown internal error '$internalError' for operation '$operationName' in module '$moduleName'",
00310 'eZModuleOperationInfo::execute' );
00311 return null;
00312 } break;
00313 }
00314 return null;
00315 }
00316 else if ( isset( $resultArray['error'] ) )
00317 {
00318 }
00319 else if ( isset( $resultArray['status'] ) )
00320 {
00321 return $resultArray;
00322 }
00323 else
00324 {
00325 eZDebug::writeError( "Operation '$operationName' in module '$moduleName' did not return a result value",
00326 'eZOperationHandler::execute' );
00327 }
00328 return null;
00329 }
00330
00331 function executeBody( $includeFile, $className, $bodyStructure,
00332 $operationKeys, $operationParameterDefinitions, $operationParameters,
00333 &$mementoData, &$bodyCallCount, $operationName, $currentLoopData = null )
00334 {
00335 $bodyReturnValue = array( 'status' => EZ_MODULE_OPERATION_CONTINUE );
00336 foreach ( $bodyStructure as $body )
00337 {
00338 if ( !isset( $body['type'] ) )
00339 {
00340 eZDebug::writeError( 'No type for body element, skipping', 'eZModuleOperationInfo::executeBody' );
00341 continue;
00342 }
00343 if ( !isset( $body['name'] ) )
00344 {
00345 eZDebug::writeError( 'No name for body element, skipping', 'eZModuleOperationInfo::executeBody' );
00346 continue;
00347 }
00348 $bodyName = $body['name'];
00349 if ( !isset( $bodyCallCount['loop_run'][$bodyName] ) )
00350 $bodyCallCount['loop_run'][$bodyName] = 0;
00351 $type = $body['type'];
00352 switch ( $type )
00353 {
00354 case 'loop':
00355 {
00356 $children = $body['children'];
00357 $tmpOperationParameterDefinitions = $operationParameterDefinitions;
00358 if ( isset( $body['child_parameters'] ) )
00359 $tmpOperationParameterDefinitions = $body['child_parameters'];
00360 $loopName = $body['name'];
00361
00362 if ( $mementoData !== null )
00363 {
00364 $returnValue = $this->executeBody( $includeFile, $className, $children,
00365 $operationKeys, $tmpOperationParameterDefinitions, $operationParameters,
00366 $mementoData, $bodyCallCount, $operationName, null );
00367 if ( !$returnValue['status'] )
00368 return $returnValue;
00369 }
00370 else
00371 {
00372 ++$bodyCallCount['loop_run'][$bodyName];
00373
00374 $method = $body['method'];
00375 $resultArray = $this->executeClassMethod( $includeFile, $className, $method,
00376 $operationParameterDefinitions, $operationParameters );
00377 $parameters = array();
00378 if ( isset( $resultArray['parameters'] ) )
00379 {
00380 $parameters = $resultArray['parameters'];
00381 }
00382 $count = 0;
00383 $countDone = 0;
00384 $countHalted = 0;
00385 $countCanceled = 0;
00386 foreach ( $parameters as $parameterStructure )
00387 {
00388 $tmpOperationParameters = $operationParameters;
00389 foreach ( $parameterStructure as $parameterName => $parameterValue )
00390 {
00391 $tmpOperationParameters[$parameterName] = $parameterValue;
00392 }
00393
00394 ++$count;
00395 $returnValue = $this->executeBody( $includeFile, $className, $children,
00396 $operationKeys, $tmpOperationParameterDefinitions, $tmpOperationParameters,
00397 $mementoData, $bodyCallCount, $operationName, array( 'name' => $loopName,
00398 'count' => count( $parameters ),
00399 'index' => $count ) );
00400 switch( $returnValue['status'] )
00401 {
00402 case EZ_MODULE_OPERATION_CANCELED:
00403 {
00404 $bodyReturnValue = $returnValue;
00405 ++$countCanceled;
00406 }break;
00407 case EZ_MODULE_OPERATION_CONTINUE:
00408 {
00409 $bodyReturnValue = $returnValue;
00410
00411 ++$countDone;
00412 }break;
00413 case EZ_MODULE_OPERATION_HALTED:
00414 {
00415 $bodyReturnValue = $returnValue;
00416 ++$countHalted;
00417 }break;
00418 }
00419 }
00420 if ( $body['continue_operation'] == 'all' )
00421 {
00422 if ( $count == $countDone )
00423 {
00424
00425 }
00426 if ( $countCanceled > 0 )
00427 {
00428 return $bodyReturnValue;
00429
00430 }
00431 if ( $countHalted > 0 )
00432 {
00433 return $bodyReturnValue;
00434 }
00435
00436 }
00437 }
00438 } break;
00439 case 'trigger':
00440 {
00441 if ( !$this->UseTriggers )
00442 {
00443 $bodyReturnValue['status'] = EZ_MODULE_OPERATION_CONTINUE;
00444 continue;
00445
00446 }
00447
00448 $triggerName = $body['name'];
00449 $triggerRestored = false;
00450 $executeTrigger = true;
00451 if ( $mementoData !== null )
00452 {
00453 if ( $mementoData['name'] == $triggerName )
00454 {
00455 $executeTrigger = $this->restoreBodyMementoData( $bodyName, $mementoData,
00456 $operationParameters, $bodyCallCount, $currentLoopData );
00457 $triggerRestored = true;
00458 }
00459 else
00460 {
00461 $executeTrigger = false;
00462 }
00463 }
00464 if ( $executeTrigger )
00465 {
00466 $status = $this->executeTrigger( $bodyReturnValue, $body,
00467 $operationParameterDefinitions, $operationParameters,
00468 $bodyCallCount, $currentLoopData,
00469 $triggerRestored, $operationName, $operationKeys );
00470
00471 switch( $status )
00472 {
00473 case EZ_MODULE_OPERATION_CONTINUE:
00474 {
00475 $bodyReturnValue['status'] = EZ_MODULE_OPERATION_CONTINUE;
00476 }break;
00477 case EZ_MODULE_OPERATION_CANCELED:
00478 {
00479 $bodyReturnValue['status'] = EZ_MODULE_OPERATION_CANCELED;
00480 return $bodyReturnValue;
00481 }break;
00482 case EZ_MODULE_OPERATION_HALTED:
00483 {
00484
00485 $bodyReturnValue['status'] = EZ_MODULE_OPERATION_HALTED;
00486 return $bodyReturnValue;
00487 }
00488 }
00489 }else
00490 {
00491 $bodyReturnValue['status'] = EZ_MODULE_OPERATION_CONTINUE;
00492 }
00493 } break;
00494 case 'method':
00495 {
00496 if ( $mementoData === null )
00497 {
00498 $method = $body['method'];
00499 $frequency = $body['frequency'];
00500 $executeMethod = true;
00501 if ( $frequency == 'once' and
00502 $bodyCallCount['loop_run'][$bodyName] != 0 )
00503 $executeMethod = false;
00504 $tmpOperationParameterDefinitions = $operationParameterDefinitions;
00505 if ( isset( $body['parameters'] ) )
00506 $tmpOperationParameterDefinitions = $body['parameters'];
00507 if ( $executeMethod )
00508 {
00509 ++$bodyCallCount['loop_run'][$bodyName];
00510 $result = $this->executeClassMethod( $includeFile, $className, $method,
00511 $tmpOperationParameterDefinitions, $operationParameters );
00512 if ( $result && array_key_exists( 'status', $result ) )
00513 {
00514 switch( $result['status'] )
00515 {
00516 case EZ_MODULE_OPERATION_CONTINUE:
00517 default:
00518 {
00519 $result['status'] = EZ_MODULE_OPERATION_CONTINUE;
00520 $bodyReturnValue = $result;
00521 } break;
00522
00523 case EZ_MODULE_OPERATION_CANCELED:
00524 case EZ_MODULE_OPERATION_HALTED:
00525 {
00526 return $result;
00527 } break;
00528 }
00529 }
00530 }
00531 }
00532 } break;
00533 default:
00534 {
00535 eZDebug::writeError( "Unknown operation type $type", 'eZModuleOperationInfo::executeBody' );
00536 }
00537 }
00538 }
00539
00540 return $bodyReturnValue;
00541 }
00542
00543 function executeTrigger( &$bodyReturnValue, $body,
00544 $operationParameterDefinitions, $operationParameters,
00545 &$bodyCallCount, $currentLoopData,
00546 $triggerRestored, $operationName, &$operationKeys )
00547 {
00548 $triggerName = $body['name'];
00549 $triggerKeys = $body['keys'];
00550
00551 $status = eZTrigger::runTrigger( $triggerName, $this->ModuleName, $operationName, $operationParameters, $triggerKeys );
00552
00553
00554 if ( $status['Status'] == EZ_TRIGGER_WORKFLOW_DONE ||
00555 $status['Status'] == EZ_TRIGGER_NO_CONNECTED_WORKFLOWS )
00556 {
00557 ++$bodyCallCount['loop_run'][$triggerName];
00558 return EZ_MODULE_OPERATION_CONTINUE;
00559 }
00560 else if ( $status['Status'] == EZ_TRIGGER_STATUS_CRON_JOB ||
00561 $status['Status'] == EZ_TRIGGER_FETCH_TEMPLATE ||
00562 $status['Status'] == EZ_TRIGGER_REDIRECT )
00563 {
00564 $bodyMemento =& $this->storeBodyMemento( $triggerName, $triggerKeys,
00565 $operationKeys, $operationParameterDefinitions, $operationParameters,
00566 $bodyCallCount, $currentLoopData, $operationName );
00567 $workflowProcess =& $status['WorkflowProcess'];
00568 if ( ! is_null( $workflowProcess ) )
00569 {
00570 $workflowProcess->setAttribute( 'memento_key', $bodyMemento->attribute( 'memento_key' ) );
00571 $workflowProcess->store();
00572 }
00573
00574 $bodyReturnValue['result'] =& $status['Result'];
00575 if ( $status['Status'] == EZ_TRIGGER_REDIRECT )
00576 {
00577 $bodyReturnValue['redirect_url'] =& $status['Result'];
00578 }
00579 return EZ_MODULE_OPERATION_HALTED;
00580 }
00581 else if ( $status['Status'] == EZ_TRIGGER_WORKFLOW_CANCELED or
00582 $status['Status'] == EZ_TRIGGER_WORKFLOW_RESET )
00583 {
00584 return EZ_MODULE_OPERATION_CANCELED;
00585 $bodyReturnValue['result'] =& $status['Result'];
00586 }
00587 }
00588
00589 function storeOperationMemento( $operationKeys, $operationParameterDefinitions, $operationParameters,
00590 &$bodyCallCount, $operationName )
00591 {
00592 $mementoData = array();
00593 $mementoData['module_name'] = $this->ModuleName;
00594 $mementoData['operation_name'] = $operationName;
00595 if ( $this->Memento === null )
00596 {
00597 $keyArray = $this->makeKeyArray( $operationKeys, $operationParameterDefinitions, $operationParameters );
00598 $keyArray['session_key'] = eZHTTPTool::getSessionKey();
00599 $mementoData['loop_run'] = $bodyCallCount['loop_run'];
00600 $memento = eZOperationMemento::create( $keyArray, $mementoData, true );
00601 $this->Memento =& $memento;
00602 }
00603 else
00604 {
00605 $mementoData = $this->Memento->data();
00606 $mementoData['loop_run'] = $bodyCallCount['loop_run'];
00607 $this->Memento->setData( $mementoData );
00608 }
00609 }
00610
00611 function removeBodyMemento( $bodyName, $bodyKeys,
00612 $operationKeys, $operationParameterDefinitions, $operationParameters,
00613 &$bodyCallCount, $currentLoopData, $operationName )
00614 {
00615 $keyArray = $this->makeKeyArray( $operationKeys, $operationParameterDefinitions, $operationParameters );
00616 }
00617 function &storeBodyMemento( $bodyName, $bodyKeys,
00618 $operationKeys, $operationParameterDefinitions, $operationParameters,
00619 &$bodyCallCount, $currentLoopData, $operationName )
00620 {
00621 $this->storeOperationMemento( $operationKeys, $operationParameterDefinitions, $operationParameters, $bodyCallCount, $operationName );
00622
00623 $keyArray = $this->makeKeyArray( $operationKeys, $operationParameterDefinitions, $operationParameters );
00624 $keyArray['session_key'] = eZHTTPTool::getSessionKey();
00625 $mementoData = array();
00626 $mementoData['name'] = $bodyName;
00627 $mementoData['parameters'] = $operationParameters;
00628 $mementoData['loop_data'] = $currentLoopData;
00629 $mementoData['module_name'] = $this->ModuleName;
00630 $mementoData['operation_name'] = $operationName;
00631 $memento = eZOperationMemento::create( $keyArray, $mementoData, false, $this->Memento->attribute( 'memento_key' ) );
00632 $memento->store();
00633 return $memento;
00634 }
00635
00636 function restoreBodyMementoData( $bodyName, &$mementoData,
00637 &$operationParameters, &$bodyCallCount, &$currentLoopData )
00638 {
00639 $operationParameters = array();
00640 if ( isset( $mementoData['parameters'] ) )
00641 $operationParameters = $mementoData['parameters'];
00642 if ( isset( $mementoData[ 'main_memento' ] ) )
00643 {
00644 $this->Memento =& $mementoData[ 'main_memento' ];
00645 $mainMementoData = $this->Memento->data();
00646 if ( isset( $mainMementoData['loop_run'] ) )
00647 {
00648 $bodyCallCount['loop_run'] = $mainMementoData['loop_run'];
00649 }
00650
00651 }
00652
00653
00654
00655
00656
00657
00658
00659 if ( isset( $mementoData['loop_data'] ) )
00660 $currentLoopData = $mementoData['loop_data'];
00661
00662 if ( isset( $mementoData['skip_trigger'] ) && $mementoData['skip_trigger'] == true )
00663 {
00664 $mementoData = null;
00665 return false;
00666 }
00667 else
00668 {
00669 $mementoData = null;
00670 return true;
00671 }
00672
00673 return true;
00674 }
00675
00676 function executeClassMethod( $includeFile, $className, $methodName,
00677 $operationParameterDefinitions, $operationParameters )
00678 {
00679 include_once( $includeFile );
00680 if ( !class_exists( $className ) )
00681 {
00682 return array( 'internal_error' => EZ_MODULE_OPERATION_ERROR_NO_CLASS,
00683 'internal_error_class_name' => $className );
00684 }
00685 $classObject =& $this->objectForClass( $className );
00686 if ( $classObject === null )
00687 {
00688 return array( 'internal_error' => EZ_MODULE_OPERATION_ERROR_CLASS_INSTANTIATE_FAILED,
00689 'internal_error_class_name' => $className );
00690 }
00691 if ( !method_exists( $classObject, $methodName ) )
00692 {
00693 return array( 'internal_error' => EZ_MODULE_OPERATION_ERROR_NO_CLASS_METHOD,
00694 'internal_error_class_name' => $className,
00695 'internal_error_class_method_name' => $methodName );
00696 }
00697 $parameterArray = array();
00698
00699 foreach ( $operationParameterDefinitions as $operationParameterDefinition )
00700 {
00701 $parameterName = $operationParameterDefinition['name'];
00702 if ( isset( $operationParameterDefinition['constant'] ) )
00703 {
00704 $constantValue = $operationParameterDefinition['constant'];
00705 $parameterArray[] = $constantValue;
00706 }
00707 else if ( isset( $operationParameters[$parameterName] ) )
00708 {
00709
00710 $parameterArray[] = $operationParameters[$parameterName];
00711 }
00712 else
00713 {
00714 if ( $operationParameterDefinition['required'] )
00715 {
00716
00717 return array( 'internal_error' => EZ_MODULE_OPERATION_ERROR_MISSING_PARAMETER,
00718 'internal_error_parameter_name' => $parameterName );
00719 }
00720 else if ( isset( $operationParameterDefinition['default'] ) )
00721 {
00722 $parameterArray[] = $operationParameterDefinition['default'];
00723 }
00724 else
00725 {
00726 $parameterArray[] = null;
00727 }
00728 }
00729 }
00730
00731 return $this->callClassMethod( $methodName, $classObject, $parameterArray );
00732 }
00733
00734 function &objectForClass( $className )
00735 {
00736 $classObjectList =& $GLOBALS['eZModuleOperationClassObjectList'];
00737 if ( !isset( $classObjectList ) )
00738 $classObjectList = array();
00739 if ( isset( $classObjectList[$className] ) )
00740 return $classObjectList[$className];
00741 $classObject = new $className();
00742 $classObjectList[$className] =& $classObject;
00743 return $classObject;
00744 }
00745
00746 function callClassMethod( $methodName, &$classObject, $parameterArray )
00747 {
00748 if ( $this->UseOldCall )
00749 return call_user_method_array( $methodName, $classObject, $parameterArray );
00750 else
00751 return call_user_func_array( array( $classObject, $methodName ), $parameterArray );
00752 }
00753
00754
00755
00756 var $ModuleName;
00757 var $FunctionList;
00758 var $IsValid;
00759 var $UseOldCall;
00760 var $UseTriggers = false;
00761 }
00762
00763 ?>