本文整理汇总了PHP中eZWorkflow::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZWorkflow::fetch方法的具体用法?PHP eZWorkflow::fetch怎么用?PHP eZWorkflow::fetch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZWorkflow
的用法示例。
在下文中一共展示了eZWorkflow::fetch方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeGroup
static function removeGroup( $workflowID, $workflowVersion, $selectedGroup )
{
$workflow = eZWorkflow::fetch( $workflowID );
if ( !$workflow )
return false;
$groups = $workflow->attribute( 'ingroup_list' );
foreach ( array_keys( $groups ) as $key )
{
if ( in_array( $groups[$key]->attribute( 'group_id' ), $selectedGroup ) )
{
unset( $groups[$key] );
}
}
if ( count( $groups ) == 0 )
{
return false;
}
else
{
$db = eZDB::instance();
$db->begin();
foreach( $selectedGroup as $group_id )
{
eZWorkflowGroupLink::removeByID( $workflowID, $workflowVersion, $group_id );
}
$db->commit();
}
return true;
}
示例2: array
if ( isset( $webOutput ) )
$runInBrowser = $webOutput;
$db = eZDB::instance();
$workflowProcessList = eZWorkflowProcess::fetchForStatus( eZWorkflow::STATUS_DEFERRED_TO_CRON );
$cli->output( "Checking for workflow processes" );
$removedProcessCount = 0;
$processCount = 0;
$statusMap = array();
foreach( $workflowProcessList as $process )
{
$db->begin();
$workflow = eZWorkflow::fetch( $process->attribute( "workflow_id" ) );
if ( $process->attribute( "event_id" ) != 0 )
$workflowEvent = eZWorkflowEvent::fetch( $process->attribute( "event_id" ) );
$process->run( $workflow, $workflowEvent, $eventLog );
// Store changes to process
++$processCount;
$status = $process->attribute( 'status' );
if ( !isset( $statusMap[$status] ) )
$statusMap[$status] = 0;
++$statusMap[$status];
if ( $process->attribute( 'status' ) != eZWorkflow::STATUS_DONE )
{
if ( $process->attribute( 'status' ) == eZWorkflow::STATUS_RESET ||
示例3: isset
return;
}
}
$GroupID = ( isset( $Params["GroupID"] ) ) ? $Params["GroupID"] : false;
$GroupName = ( isset( $Params["GroupName"] ) ) ? $Params["GroupName"] : false;
if ( is_numeric( $WorkflowID ) )
{
// try to fetch temporary version of workflow
$workflow = eZWorkflow::fetch( $WorkflowID, true, 1 );
// If temporary version does not exist fetch the current
if ( !is_object( $workflow ) )
{
$workflow = eZWorkflow::fetch( $WorkflowID, true, 0 );
if ( is_object( $workflow ) )
{
$workflowGroups = eZWorkflowGroupLink::fetchGroupList( $WorkflowID, 0, true );
$db = eZDB::instance();
$db->begin();
foreach ( $workflowGroups as $workflowGroup )
{
$groupID = $workflowGroup->attribute( "group_id" );
$groupName = $workflowGroup->attribute( "group_name" );
$ingroup = eZWorkflowGroupLink::create( $WorkflowID, 1, $groupID, $groupName );
$ingroup->store();
}
$db->commit();
}
示例4: array
}
if ($http->hasPostVariable("CurrentGroupName")) {
$GroupName = $http->postVariable("CurrentGroupName");
}
$params = array(null, $GroupID, $GroupName);
$Module->run('edit', $params);
return;
}
if ($http->hasPostVariable('DeleteButton') and $http->hasPostVariable('Workflow_id_checked')) {
if ($http->hasPostVariable('CurrentGroupID')) {
// If CurrentGroupID variable exist, delete in that group only:
$groupID = $http->postVariable('CurrentGroupID');
$workflowIDs = $http->postVariable('Workflow_id_checked');
foreach ($workflowIDs as $workflowID) {
// for all workflows which are tagged for deleting:
$workflow = eZWorkflow::fetch($workflowID);
if ($workflow) {
$workflowInGroups = $workflow->attribute('ingroup_list');
if (count($workflowInGroups) == 1) {
//remove entry from eztrigger table also, if it exists there.
eZTrigger::removeTriggerForWorkflow($workflowID);
// if there is only one group which the workflow belongs to, delete (=disable) it:
eZWorkflow::setIsEnabled(false, $workflowID);
} else {
// if there is more than 1 group, remove only from the group:
eZWorkflowFunctions::removeGroup($workflowID, 0, array($groupID));
}
} else {
// just for sure :-)
eZWorkflow::setIsEnabled(false, $workflowID);
}
示例5: runWorkflow
function runWorkflow()
{
$workflowProcessList = eZWorkflowProcess::fetchForStatus(eZWorkflow::STATUS_DEFERRED_TO_CRON);
foreach ($workflowProcessList as $process) {
$workflow = eZWorkflow::fetch($process->attribute("workflow_id"));
if ($process->attribute("event_id") != 0) {
$workflowEvent = eZWorkflowEvent::fetch($process->attribute("event_id"));
}
$process->run($workflow, $workflowEvent, $eventLog);
// Store changes to process
if ($process->attribute('status') != eZWorkflow::STATUS_DONE) {
if ($process->attribute('status') == eZWorkflow::STATUS_RESET || $process->attribute('status') == eZWorkflow::STATUS_FAILED || $process->attribute('status') == eZWorkflow::STATUS_NONE || $process->attribute('status') == eZWorkflow::STATUS_CANCELLED || $process->attribute('status') == eZWorkflow::STATUS_BUSY) {
$bodyMemento = eZOperationMemento::fetchMain($process->attribute('memento_key'));
$mementoList = eZOperationMemento::fetchList($process->attribute('memento_key'));
$bodyMemento->remove();
foreach ($mementoList as $memento) {
$memento->remove();
}
}
if ($process->attribute('status') == eZWorkflow::STATUS_CANCELLED) {
$process->removeThis();
} else {
$process->store();
}
} else {
//restore memento and run it
$bodyMemento = eZOperationMemento::fetchChild($process->attribute('memento_key'));
if (is_null($bodyMemento)) {
eZDebug::writeError($bodyMemento, "Empty body memento in workflow.php");
continue;
}
$bodyMementoData = $bodyMemento->data();
$mainMemento = $bodyMemento->attribute('main_memento');
if (!$mainMemento) {
continue;
}
$mementoData = $bodyMemento->data();
$mainMementoData = $mainMemento->data();
$mementoData['main_memento'] = $mainMemento;
$mementoData['skip_trigger'] = true;
$mementoData['memento_key'] = $process->attribute('memento_key');
$bodyMemento->remove();
$operationParameters = array();
if (isset($mementoData['parameters'])) {
$operationParameters = $mementoData['parameters'];
}
$operationResult = eZOperationHandler::execute($mementoData['module_name'], $mementoData['operation_name'], $operationParameters, $mementoData);
$process->removeThis();
}
}
}
示例6: runWorkflow
static function runWorkflow($workflowProcess)
{
$workflow = eZWorkflow::fetch($workflowProcess->attribute("workflow_id"));
$workflowEvent = null;
$workflowStatus = $workflowProcess->run($workflow, $workflowEvent, $eventLog);
$db = eZDB::instance();
$db->begin();
$workflowProcess->store();
switch ($workflowStatus) {
case eZWorkflow::STATUS_FAILED:
case eZWorkflow::STATUS_CANCELLED:
case eZWorkflow::STATUS_NONE:
case eZWorkflow::STATUS_BUSY:
$workflowProcess->removeThis();
$db->commit();
return array('Status' => eZTrigger::WORKFLOW_CANCELLED, 'Result' => null);
break;
case eZWorkflow::STATUS_FETCH_TEMPLATE:
case eZWorkflow::STATUS_FETCH_TEMPLATE_REPEAT:
$tpl = eZTemplate::factory();
$result = array();
foreach (array_keys($workflowProcess->Template['templateVars']) as $key) {
$value = $workflowProcess->Template['templateVars'][$key];
$tpl->setVariable($key, $value);
}
$result['content'] = $tpl->fetch($workflowProcess->Template['templateName']);
if (isset($workflowProcess->Template['path'])) {
$result['path'] = $workflowProcess->Template['path'];
}
$db->commit();
if ($workflowStatus == eZWorkflow::STATUS_FETCH_TEMPLATE) {
$triggerStatus = eZTrigger::FETCH_TEMPLATE;
} elseif ($workflowStatus == eZWorkflow::STATUS_FETCH_TEMPLATE_REPEAT) {
$triggerStatus = eZTrigger::FETCH_TEMPLATE_REPEAT;
}
return array('Status' => $triggerStatus, 'WorkflowProcess' => $workflowProcess, 'Result' => $result);
break;
case eZWorkflow::STATUS_REDIRECT:
// var_dump( $workflowProcess->RedirectUrl );
$db->commit();
return array('Status' => eZTrigger::REDIRECT, 'WorkflowProcess' => $workflowProcess, 'Result' => $workflowProcess->RedirectUrl);
break;
case eZWorkflow::STATUS_DEFERRED_TO_CRON:
$db->commit();
return array('Status' => eZTrigger::STATUS_CRON_JOB, 'WorkflowProcess' => $workflowProcess, 'Result' => array('content' => 'Deffered to cron. Operation halted during execution. <br/>Refresh page to continue<br/><br/><b>Note: The halt is just a temporary test</b><br/>', 'path' => array(array('text' => 'Operation halt', 'url' => false))));
/*
return array( 'Status' => eZTrigger::STATUS_CRON_JOB,
'Result' => $workflowProcess->attribute( 'id') );
*/
break;
case eZWorkflow::STATUS_RESET:
$db->commit();
return array('Status' => eZTrigger::WORKFLOW_RESET, 'WorkflowProcess' => $workflowProcess, 'Result' => array('content' => 'Workflow was reset', 'path' => array(array('text' => 'Operation halt', 'url' => false))));
break;
case eZWorkflow::STATUS_DONE:
$workflowProcess->removeThis();
$db->commit();
return array('Status' => eZTrigger::WORKFLOW_DONE, 'Result' => null);
}
$db->commit();
return array('Status' => eZTrigger::WORKFLOW_CANCELLED, 'Result' => null);
}
示例7: execute
function execute($process, $event)
{
$processParameters = $process->attribute('parameter_list');
$storeProcessParameters = false;
$classID = false;
$object = false;
$sectionID = false;
$languageID = 0;
if (isset($processParameters['object_id'])) {
$object = eZContentObject::fetch($processParameters['object_id']);
} else {
if (isset($processParameters['node_id'])) {
$object = eZContentObject::fetchByNodeID($processParameters['node_id']);
}
}
if ($object instanceof eZContentObject) {
// Examine if the published version contains one of the languages we
// match for.
if (isset($processParameters['version'])) {
$versionID = $processParameters['version'];
$version = $object->version($versionID);
if (is_object($version)) {
$version_option = $event->attribute('version_option');
if ($version_option == eZMultiplexerType::VERSION_OPTION_FIRST_ONLY and $processParameters['version'] > 1 or $version_option == eZMultiplexerType::VERSION_OPTION_EXCEPT_FIRST and $processParameters['version'] == 1) {
return eZWorkflowType::STATUS_ACCEPTED;
}
// If the language ID is part of the mask the result is non-zero.
$languageID = (int) $version->attribute('initial_language_id');
}
}
$sectionID = $object->attribute('section_id');
$class = $object->attribute('content_class');
if ($class) {
$classID = $class->attribute('id');
}
}
$userArray = explode(',', $event->attribute('data_text2'));
$classArray = explode(',', $event->attribute('data_text5'));
$languageMask = $event->attribute('data_int2');
if (!isset($processParameters['user_id'])) {
$user = eZUser::currentUser();
$userID = $user->id();
$processParameters['user_id'] = $userID;
$storeProcessParameters = true;
} else {
$userID = $processParameters['user_id'];
$user = eZUser::fetch($userID);
if (!$user instanceof eZUser) {
$user = eZUser::currentUser();
$userID = $user->id();
$processParameters['user_id'] = $userID;
$storeProcessParameters = true;
}
}
$userGroups = $user->attribute('groups');
$inExcludeGroups = count(array_intersect($userGroups, $userArray)) != 0;
if ($storeProcessParameters) {
$process->setParameters($processParameters);
$process->store();
}
// All languages match by default
$hasLanguageMatch = true;
if ($languageMask != 0) {
// Match ID with mask.
$hasLanguageMatch = (bool) ($languageMask & $languageID);
}
if ($hasLanguageMatch && !$inExcludeGroups && (in_array(-1, $classArray) || in_array($classID, $classArray))) {
$sectionArray = explode(',', $event->attribute('data_text1'));
if (in_array($sectionID, $sectionArray) || in_array(-1, $sectionArray)) {
$workflowToRun = $event->attribute('data_int1');
$childParameters = array_merge($processParameters, array('workflow_id' => $workflowToRun, 'user_id' => $userID, 'parent_process_id' => $process->attribute('id')));
$childProcessKey = eZWorkflowProcess::createKey($childParameters);
$childProcessArray = eZWorkflowProcess::fetchListByKey($childProcessKey);
$childProcess =& $childProcessArray[0];
if ($childProcess == null) {
$childProcess = eZWorkflowProcess::create($childProcessKey, $childParameters);
$childProcess->store();
}
$workflow = eZWorkflow::fetch($childProcess->attribute("workflow_id"));
$workflowEvent = null;
if ($childProcess->attribute("event_id") != 0) {
$workflowEvent = eZWorkflowEvent::fetch($childProcess->attribute("event_id"));
}
$childStatus = $childProcess->run($workflow, $workflowEvent, $eventLog);
$childProcess->store();
if ($childStatus == eZWorkflow::STATUS_DEFERRED_TO_CRON) {
$this->setActivationDate($childProcess->attribute('activation_date'));
$childProcess->setAttribute("status", eZWorkflow::STATUS_WAITING_PARENT);
$childProcess->store();
return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
} else {
if ($childStatus == eZWorkflow::STATUS_FETCH_TEMPLATE or $childStatus == eZWorkflow::STATUS_FETCH_TEMPLATE_REPEAT) {
$process->Template =& $childProcess->Template;
return eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT;
} else {
if ($childStatus == eZWorkflow::STATUS_REDIRECT) {
$process->RedirectUrl =& $childProcess->RedirectUrl;
return eZWorkflowType::STATUS_REDIRECT_REPEAT;
} else {
if ($childStatus == eZWorkflow::STATUS_DONE) {
//.........这里部分代码省略.........
示例8: execute
function execute($process, $event)
{
$parameters = $process->attribute('parameter_list');
$objectId = $parameters['object_id'];
$object = eZContentObject::fetch($objectId);
$subtreeNodeID = $event->attribute('target_subtree');
$subtreeNode = eZContentObjectTreeNode::fetch($subtreeNodeID);
eZDebug::writeDebug("Event begins execution for object {$objectId}, subtree {$subtreeNodeID}", __METHOD__);
if ($object != null && $subtreeNode != null) {
$is_child = false;
$locations = $object->assignedNodes();
if ($locations == null) {
// pre-creation event: obj has no node on its own, but a putative parent
//eZDebug::writeDebug( 'Obj node is new!', __METHOD__ );
$locations = eZNodeAssignment::fetchForObject($objectId, $object->attribute("current_version"));
foreach ($locations as $key => $location) {
$locations[$key] = $location->getParentNode();
}
}
foreach ($locations as $node) {
$subtreeNodePath = $node->pathArray();
//eZDebug::writeDebug( 'Testing if obj node '.$node->NodeID.' is child of : ' . $subtreeNodeID, __METHOD__ );
if (in_array($subtreeNodeID, $subtreeNodePath)) {
eZDebug::writeDebug('Found that obj node ' . $node->NodeID . ' is child of node ' . $subtreeNodeID, __METHOD__);
$is_child = true;
break;
}
}
if ($is_child) {
$workflowToRun = $event->attribute('target_workflow');
$user = eZUser::currentUser();
$userID = $user->id();
$processParameters = $process->attribute('parameter_list');
// code copy+pasted from ez multoplexer worflow...
$childParameters = array_merge($processParameters, array('workflow_id' => $workflowToRun, 'user_id' => $userID, 'parent_process_id' => $process->attribute('id')));
$childProcessKey = eZWorkflowProcess::createKey($childParameters);
$childProcessArray = eZWorkflowProcess::fetchListByKey($childProcessKey);
$childProcess =& $childProcessArray[0];
if ($childProcess == null) {
$childProcess = eZWorkflowProcess::create($childProcessKey, $childParameters);
$childProcess->store();
}
$workflow = eZWorkflow::fetch($childProcess->attribute("workflow_id"));
$workflowEvent = null;
if ($childProcess->attribute("event_id") != 0) {
$workflowEvent = eZWorkflowEvent::fetch($childProcess->attribute("event_id"));
}
$childStatus = $childProcess->run($workflow, $workflowEvent, $eventLog);
$childProcess->store();
if ($childStatus == eZWorkflow::STATUS_DEFERRED_TO_CRON) {
$this->setActivationDate($childProcess->attribute('activation_date'));
$childProcess->setAttribute("status", eZWorkflow::STATUS_WAITING_PARENT);
$childProcess->store();
return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT;
} else {
if ($childStatus == eZWorkflow::STATUS_FETCH_TEMPLATE) {
$process->Template =& $childProcess->Template;
return eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT;
} else {
if ($childStatus == eZWorkflow::STATUS_REDIRECT) {
$process->RedirectUrl =& $childProcess->RedirectUrl;
return eZWorkflowType::STATUS_REDIRECT_REPEAT;
} else {
if ($childStatus == eZWorkflow::STATUS_DONE) {
$childProcess->removeThis();
return eZWorkflowType::STATUS_ACCEPTED;
} else {
if ($childStatus == eZWorkflow::STATUS_CANCELLED || $childStatus == eZWorkflow::STATUS_FAILED) {
$childProcess->removeThis();
return eZWorkflowType::STATUS_REJECTED;
}
}
}
}
}
return $childProcess->attribute('event_status');
}
return eZWorkflowType::STATUS_ACCEPTED;
} else {
eZDebug::writeError("Event triggered for inexisting object ({$objectId}) or subtree ({$subtreeNodeID})", __METHOD__);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
}
示例9: workflow
function workflow()
{
if (isset($this->WorkflowID) and $this->WorkflowID) {
return eZWorkflow::fetch($this->WorkflowID);
}
return null;
}
示例10: execute
function execute( $xml )
{
$workflowGroupList = $xml->getElementsByTagName( 'WorkflowGroup' );
$user = eZUser::currentUser();
$userID = $user->attribute( "contentobject_id" );
foreach ( $workflowGroupList as $workflowGroupNode )
{
$groupName = $workflowGroupNode->getAttribute( 'name' );
$referenceID = $workflowGroupNode->getAttribute( 'referenceID' );
$groupExistAction = $workflowGroupNode->getAttribute( 'groupExistAction' );
$workflowGroup = null;
if ( $groupExistAction == 'keep' )
{
$workflowGroupList = eZWorkflowGroup::fetchList();
foreach ( $workflowGroupList as $workflowGroupItem )
{
if ( $workflowGroupItem->attribute( 'name' ) == $groupName )
{
$workflowGroup = $workflowGroupItem;
break;
}
}
}
if ( $workflowGroup !== null )
{
$this->writeMessage( "\tWorkflow Group '$groupName' already exists." , 'notice' );
}
else
{
$this->writeMessage( "\tWorkflow Group '$groupName' will be created." , 'notice' );
$workflowGroup = eZWorkflowGroup::create( $userID );
$workflowGroup->setAttribute( "name", $groupName );
$workflowGroup->store();
}
$WorkflowGroupID = $workflowGroup->attribute( "id" );
$refArray = array();
if ( $referenceID )
{
$refArray[$referenceID] = $WorkflowGroupID;
}
$this->addReference( $refArray );
$workflowList = $workflowGroupNode->getElementsByTagName( 'Workflow' );
foreach ( $workflowList as $workflowNode )
{
$refArray = array();
$workflowName = $workflowNode->getAttribute( 'name' );
$workflowTypeString = $workflowNode->getAttribute( 'workflowTypeString' );
$referenceID = $workflowNode->getAttribute( 'referenceID' );
$workflowExistAction = $workflowNode->getAttribute( 'workflowExistAction' );
$WorkflowID = $workflowNode->getAttribute( 'id' );
$workflow = null;
$hasWorkflowDraft = false;
$db = eZDB::instance();
if ( !$workflowExistAction )
{
$workflowExistAction = 'extend';
}
if ( $WorkflowID )
{
$workflow = eZWorkflow::fetch( $WorkflowID, true, 1 );
if ( !is_object( $workflow ) )
{
$workflow = eZWorkflow::fetch( $WorkflowID, true, 0 );
if ( is_object( $workflow ) )
{
$workflowGroups = eZWorkflowGroupLink::fetchGroupList( $WorkflowID, 0, true );
$db->begin();
foreach ( $workflowGroups as $workflowGroup )
{
$groupID = $workflowGroup->attribute( "group_id" );
$groupName = $workflowGroup->attribute( "group_name" );
$ingroup = eZWorkflowGroupLink::create( $WorkflowID, 1, $groupID, $groupName );
$ingroup->store();
}
$db->commit();
}
else
{
$this->writeMessage( "\tFailed to fetch workflow with ID '$WorkflowID'." , 'notice' );
$workflow = null;
}
}
}
$db->begin();
if ( $workflow === null )
{
$this->writeMessage( "\tWorkflow '$workflowName' will be created." , 'notice' );
//.........这里部分代码省略.........