static function continueWorkflow($workflowProcessID)
 {
     $operationResult = null;
     $theProcess = eZWorkflowProcess::fetch($workflowProcessID);
     if ($theProcess != null) {
         //restore memento and run it
         $bodyMemento = eZOperationMemento::fetchChild($theProcess->attribute('memento_key'));
         if ($bodyMemento === null) {
             eZDebug::writeError($bodyMemento, "Empty body memento in workflow.php");
             return $operationResult;
         }
         $bodyMementoData = $bodyMemento->data();
         $mainMemento = $bodyMemento->attribute('main_memento');
         if (!$mainMemento) {
             return $operationResult;
         }
         $mementoData = $bodyMemento->data();
         $mainMementoData = $mainMemento->data();
         $mementoData['main_memento'] = $mainMemento;
         $mementoData['skip_trigger'] = false;
         $mementoData['memento_key'] = $theProcess->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);
     }
     return $operationResult;
 }
Exemplo n.º 2
0
    $offset = 0;
}
$limitList = array(1 => 10, 2 => 25, 3 => 50, 4 => 100);
$limit = 10;
$limitId = eZPreferences::value('admin_workflow_processlist_limit');
if ($limitId and isset($limitList[$limitId])) {
    $limit = $limitList[$limitId];
}
$viewParameters = array('offset' => $offset);
$plist = eZWorkflowProcess::fetchList($conds, true, $offset, $limit);
$plistCount = eZWorkflowProcess::count(eZWorkflowProcess::definition(), $conds);
$totalProcessCount = 0;
$outList2 = array();
foreach ($plist as $p) {
    $mementoMain = eZOperationMemento::fetchMain($p->attribute('memento_key'));
    $mementoChild = eZOperationMemento::fetchChild($p->attribute('memento_key'));
    if (!$mementoMain or !$mementoChild) {
        continue;
    }
    $mementoMainData = $mementoMain->data();
    $mementoChildData = $mementoChild->data();
    $triggers = eZTrigger::fetchList(array('module_name' => $mementoChildData['module_name'], 'function_name' => $mementoChildData['operation_name'], 'name' => $mementoChildData['name']));
    if (count($triggers) > 0) {
        $trigger = $triggers[0];
        if (is_object($trigger)) {
            $nkey = $trigger->attribute('module_name') . '/' . $trigger->attribute('function_name') . '/' . $trigger->attribute('name');
            if (!isset($outList2[$nkey])) {
                $outList2[$nkey] = array('trigger' => $trigger, 'process_list' => array());
            }
            $outList2[$nkey]['process_list'][] = $p;
            $totalProcessCount++;
Exemplo n.º 3
0
            }
        }

        if ( $process->attribute( 'status' ) == eZWorkflow::STATUS_CANCELLED )
        {
            ++$removedProcessCount;
            $process->removeThis();
        }
        else
        {
            $process->store();
        }
    }
    else
    {   //restore memento and run it
        $bodyMemento = eZOperationMemento::fetchChild( $process->attribute( 'memento_key' ) );
        if ( $bodyMemento === null )
        {
            eZDebug::writeError( $bodyMemento, "Empty body memento in workflow.php" );
            $db->commit();
            continue;
        }
        $bodyMementoData = $bodyMemento->data();
        $mainMemento = $bodyMemento->attribute( 'main_memento' );
        if ( !$mainMemento )
        {
            $db->commit();
            continue;
        }

        $mementoData = $bodyMemento->data();
 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();
         }
     }
 }