示例#1
0
function removeSelectedGroups($http, &$groups, $base)
{
    if ($http->hasPostVariable("DeleteGroupButton")) {
        if (eZHTTPPersistence::splitSelected($base, $groups, $http, "id", $keepers, $rejects)) {
            $groups = $keepers;
            foreach ($rejects as $reject) {
                $group_id = $reject->attribute("id");
                // Remove all workflows in current group
                $list_in_group = eZWorkflowGroupLink::fetchWorkflowList(0, $group_id, $asObject = true);
                $workflow_list = eZWorkflow::fetchList();
                $list = array();
                foreach ($workflow_list as $workflow) {
                    foreach ($list_in_group as $group) {
                        $id = $workflow->attribute("id");
                        $workflow_id = $group->attribute("workflow_id");
                        if ($id === $workflow_id) {
                            $list[] = $workflow;
                        }
                    }
                }
                foreach ($list as $workFlow) {
                    eZTrigger::removeTriggerForWorkflow($workFlow->attribute('id'));
                    $workFlow->remove();
                }
                $reject->remove();
                eZWorkflowGroupLink::removeGroupMembers($group_id);
            }
        }
    }
}
    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;
    }
示例#3
0
 public function getReport()
 {
     // quick and dirty: use same data as for the web
     $tpl = sysInfoTools::eZTemplateFactory();
     $tpl->setVariable('title', 'Workflows Report');
     $workflows = eZWorkflow::fetchList();
     $triggers = eZTrigger::fetchList();
     $tpl->setVariable('workflows', $workflows);
     $tpl->setVariable('triggers', $triggers);
     $htmlReport = $tpl->fetch("design:sysinfo/workflowsreport.tpl");
     return $htmlReport;
 }
示例#4
0
    $workflowList[$workflow->attribute( 'id' )] = $workflow;
}
*/
$user = eZUser::currentUser();
$list_in_group = eZWorkflowGroupLink::fetchWorkflowList(0, $WorkflowGroupID, $asObject = true);
$workflow_list = eZWorkflow::fetchList();
$list = array();
foreach ($workflow_list as $workflow) {
    foreach ($list_in_group as $inGroup) {
        if ($workflow->attribute('id') === $inGroup->attribute('workflow_id')) {
            $list[] = $workflow;
        }
    }
}
$templist_in_group = eZWorkflowGroupLink::fetchWorkflowList(1, $WorkflowGroupID, $asObject = true);
$tempworkflow_list = eZWorkflow::fetchList(1);
$temp_list = array();
foreach ($tempworkflow_list as $tmpWorkflow) {
    foreach ($templist_in_group as $tmpInGroup) {
        if ($tmpWorkflow->attribute('id') === $tmpInGroup->attribute('workflow_id')) {
            $temp_list[] = $tmpWorkflow;
        }
    }
}
$Module->setTitle(ezpI18n::tr('kernel/workflow', 'Workflow list of group') . ' ' . $WorkflowGroupID);
$WorkflowgroupInfo = eZWorkflowGroup::fetch($WorkflowGroupID);
if (!$WorkflowgroupInfo) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$tpl = eZTemplate::factory();
$tpl->setVariable("temp_workflow_list", $temp_list);
 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
0
}
$WorkflowProcessID = $Params["WorkflowProcessID"];
$process = eZWorkflowProcess::fetch($WorkflowProcessID);
if ($process === null) {
    $Module->redirectTo($Module->functionURI("list"));
    return;
}
$http = eZHTTPTool::instance();
if ($http->hasPostVariable("Reset")) {
    $process->reset();
    $process->setAttribute("modified", time());
    $process->store();
}
// Template handling
$tpl = eZTemplate::factory();
$workflow = eZWorkflow::fetch($process->attribute("workflow_id"));
$workflowEvent = false;
if ($process->attribute("event_id") != 0) {
    $workflowEvent = eZWorkflowEvent::fetch($process->attribute("event_id"));
}
$lastEventStatus = $process->attribute("last_event_status");
if ($http->hasPostVariable("RunProcess")) {
    //     $Module->redirectTo( $Module->functionURI( "process" ) . "/" . $WorkflowProcessID );
    //     return;
    if ($workflowEvent instanceof eZWorkflowEvent) {
        $eventType = $workflowEvent->eventType();
        $lastEventStatus = $eventType->execute($process, $workflowEvent);
    }
    $event_pos = $process->attribute("event_position");
    $next_event_pos = $event_pos + 1;
    $next_event_id = $workflow->fetchEventIndexed($next_event_pos);
示例#7
0
 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);
 }
    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' );
                    $workflow = eZWorkflow::create( $userID );
                    $workflow->setAttribute( "name",  $workflowName );
                    if ( $workflowTypeString )
                    {
                        $workflow->setAttribute( "workflow_type_string",  $workflowTypeString );
                    }
                    $workflow->store();
                    $ingroup = eZWorkflowGroupLink::create( $workflow->attribute( "id" ), $workflow->attribute( "version" ), $WorkflowGroupID, $groupName );
                    $ingroup->store();
                }
                else
                {
                    $hasWorkflowDraft = true;
                    switch ( $workflowExistAction )
                    {
                        case 'extend':
                        {
                            $this->writeMessage( "\tExtending existing workflow '" . $workflow->attribute( 'name' ) . "'." , 'notice' );
                        }
                        break;
                        case 'replace':
                        {
                            $this->writeMessage( "\tReplacing existing workflow '" . $workflow->attribute( 'name' ) . "'." , 'notice' );
                            eZWorkflow::removeEvents( false, $workflow->attribute( "id" ), $workflow->attribute( "version" ) );
                        }
                        break;
                        default:
                        {
                            $this->writeMessage( "\tUnknown workflowExistAction '" . $workflowExistAction . "'." , 'notice' );
                        }
                    }
                }

                $WorkflowID      = $workflow->attribute( "id" );
                $WorkflowVersion = $workflow->attribute( "version" );

                $db->commit();

                if ( $referenceID )
                {
                    $refArray[$referenceID] = $WorkflowID;
                }

                $eventList     = $workflow->fetchEvents();
                $eventNodeList = $workflowNode->getElementsByTagName( 'Event' );
                $maxPlacement  = -1;

                foreach ( $eventList as $event )
                {
                    if ( $event->attribute( 'placement' ) > $maxPlacement )
                    {
                        $maxPlacement = $event->attribute( 'placement' );
                    }
                }

                foreach ( $eventNodeList as $eventNode )
                {
                    $description        = $eventNode->getAttribute( 'description' );
                    $workflowTypeString = $eventNode->getAttribute( 'workflowTypeString' );
                    $placement          = $eventNode->getAttribute( 'placement' );
                    $event              = eZWorkflowEvent::create( $WorkflowID, $workflowTypeString );
                    $eventType          = $event->eventType();

                    $db->begin();

                    $workflow->store( $eventList );
                    $eventType->initializeEvent( $event );

                    if ( is_numeric( $placement ) )
                    {
                        $eventType->setAttribute( 'placement', (int)$placement );
                    }
                    else
                    {
                        ++$maxPlacement;
                        $eventType->setAttribute( 'placement', $maxPlacement );
                    }

                    $eventDataNode = $eventNode->getElementsByTagName( 'Data' )->item( 0 );

                    if ( $eventDataNode )
                    {
                        $attributes = $eventDataNode->childNodes;
                        foreach ( $attributes as $attribute )
                        {
                            if ( $event->hasAttribute( $attribute->nodeName ) )
                            {
                                $data = $this->parseAndReplaceStringReferences( $attribute->textContent );
                                $event->setAttribute( $attribute->nodeName, $data );
                            }
                        }
                    }
                    $event->store();

                    $db->commit();

                    $eventList[] = $event;

                }

                // Discard existing events, workflow version 1 and store version 0
                $db->begin();

                $workflow->store( $eventList ); // store changes.

                // Remove old version 0 first
                eZWorkflowGroupLink::removeWorkflowMembers( $WorkflowID, 0 );

                $workflowgroups = eZWorkflowGroupLink::fetchGroupList( $WorkflowID, 1 );
                foreach( $workflowgroups as $workflowgroup )
                {
                    $workflowgroup->setAttribute("workflow_version", 0 );
                    $workflowgroup->store();
                }
                // Remove version 1
                eZWorkflowGroupLink::removeWorkflowMembers( $WorkflowID, 1 );

                eZWorkflow::removeEvents( false, $WorkflowID, 0 );
                $workflow->removeThis( true );
                $workflow->setVersion( 0, $eventList );
                $workflow->adjustEventPlacements( $eventList );
                $workflow->storeDefined( $eventList );
                $workflow->cleanupWorkFlowProcess();

                $db->commit();


                if ( $referenceID )
                {
                    $refArray[$referenceID] = $WorkflowID;
                }
                $this->addReference( $refArray );
            }
        }

        $triggerList = $xml->getElementsByTagName( 'Trigger' );
        foreach ( $triggerList as $triggerNode )
        {
            $module      = $triggerNode->getAttribute( 'module' );
            $operation   = $triggerNode->getAttribute( 'operation' );
            $connectType = $triggerNode->getAttribute( 'connectType' );
            $workflowID  = $this->getReferenceID( $triggerNode->getAttribute( 'workflowID' ) );

            $this->writeMessage( "\tTrigger '$module/$operation/$connectType' will be created/updated." , 'notice' );

            if ( $connectType == 'before' )
            {
                $connectType = 'b';
            }
            else
            {
                $connectType = 'a';
            }

            $parameters = array();
            $parameters['module']      = $module;
            $parameters['function']    = $operation;
            $parameters['connectType'] = $connectType;

            $triggerList = eZTrigger::fetchList( $parameters );

            if ( count( $triggerList ) )
            {
                $trigger = $triggerList[0];
                $trigger->setAttribute( 'workflow_id', $workflowID );
                $trigger->store();
            }
            else
            {
                $db = eZDB::instance();
                $db->begin();
                $newTrigger = eZTrigger::createNew( $module, $operation, $connectType, $workflowID );
                $db->commit();
            }
        }
    }
示例#9
0
        ++$removedProcessCount;
        $process->removeThis();
    }

    $db->commit();

    eZStaticCache::executeActions();
}
if ( !$isQuiet )
{
    $cli->output( $cli->stylize( 'emphasize', "Status list" ) );
    $statusTextList = array();
    $maxStatusTextLength = 0;
    foreach ( $statusMap as $statusID => $statusCount )
    {
        $statusName = eZWorkflow::statusName( $statusID );
        $statusText = "$statusName($statusID)";
        $statusTextList[] = array( 'text' => $statusText,
                                   'count' => $statusCount );
        if ( strlen( $statusText ) > $maxStatusTextLength )
            $maxStatusTextLength = strlen( $statusText );
    }
    foreach ( $statusTextList as $item )
    {
        $text = $item['text'];
        $count = $item['count'];
        $cli->output( $cli->stylize( 'success', $text ) . ': ' . str_repeat( ' ', $maxStatusTextLength - strlen( $text ) ) . $cli->stylize( 'emphasize', $count )  );
    }
    $cli->output();
    $cli->output( $cli->stylize( 'emphasize', $removedProcessCount ) . " out of " . $cli->stylize( 'emphasize', $processCount ) . " processes was finished"  );
}
 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) {
                             $childProcess->removeThis();
                             return eZWorkflowType::STATUS_ACCEPTED;
                         } else {
                             if ($childStatus == eZWorkflow::STATUS_CANCELLED) {
                                 $childProcess->removeThis();
                                 return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
                             } else {
                                 if ($childStatus == eZWorkflow::STATUS_FAILED) {
                                     $childProcess->removeThis();
                                     return eZWorkflowType::STATUS_REJECTED;
                                 }
                             }
                         }
                     }
                 }
             }
             return $childProcess->attribute('event_status');
         }
     }
     return eZWorkflowType::STATUS_ACCEPTED;
 }
 function attribute($attr)
 {
     switch ($attr) {
         case 'workflow_list':
             $workflows = eZWorkflow::fetchList();
             $workflowList = array();
             for ($i = 0; $i < count($workflows); $i++) {
                 $workflowList[$i]['Name'] = $workflows[$i]->attribute('name');
                 $workflowList[$i]['value'] = $workflows[$i]->attribute('id');
             }
             return $workflowList;
     }
     return eZWorkflowEventType::attribute($attr);
 }
 function workflow()
 {
     if (isset($this->WorkflowID) and $this->WorkflowID) {
         return eZWorkflow::fetch($this->WorkflowID);
     }
     return null;
 }
示例#13
0
$workflows = array();
$extensions = eZModuleLister::getModuleList();
// ...
if ($Params['extensionname'] != '' && !array_key_exists($Params['extensionname'], $extensions)) {
    /// @todo
} else {
    foreach ($eventTypeList as $typeString => $type) {
        $workflows[$typeString] = array();
        $filter = array('workflow_type_string' => $typeString);
        $events = eZWorkflowEvent::fetchFilteredList($filter);
        foreach ($events as $event) {
            $workflowId = $event->attribute('workflow_id');
            if (isset($workflows[$typeString][$workflowId])) {
                $workflows[$typeString][$workflowId]['events'][] = $event;
            } else {
                $workflow = eZWorkflow::fetch($workflowId);
                $workflows[$typeString][$workflowId] = array('workflow' => $workflow, 'events' => array($event));
            }
            $workflowEvents[$typeString][$event->attribute('id')] = $event;
        }
    }
}
$title = 'List of available workflow event types';
if ($Params['extensionname'] != '') {
    $title .= ' in extension "' . $Params['extensionname'] . '"';
    $extra_path = $Params['extensionname'];
}
$ezgeshi_available = sysInfoTools::ezgeshiAvailable();
$tpl->setVariable('title', $title);
$tpl->setVariable('eventtypelist', $eventTypeList);
$tpl->setVariable('workflows', $workflows);
 /**
  * Helper function used to remove a workflow.
  * Will remove the workflow, its events, its triggers and its group link.
  *
  * @param eZWorkflow $workflow
  * @return void
  */
 protected function removeWorkflow(eZWorkflow $workflow)
 {
     // Remove trigger
     eZTrigger::removeTriggerForWorkflow($workflow->attribute('id'));
     // remove the workflow, its events and the group link
     eZWorkflow::removeEvents(false, $workflow->attribute('id'), $workflow->attribute('version'));
     eZWorkflow::removeWorkflow($this->workflow->attribute('id'), $workflow->attribute('version'));
     eZWorkflowGroupLink::removeWorkflowMembers($workflow->attribute('id'), $workflow->attribute('version'));
 }
示例#15
0
    $workflow->store( $event_list ); // store changes.

    // Remove old version 0 first
    eZWorkflowGroupLink::removeWorkflowMembers( $WorkflowID, 0 );

    $workflowgroups = eZWorkflowGroupLink::fetchGroupList( $WorkflowID, 1 );
    foreach( $workflowgroups as $workflowgroup )
    {
        $workflowgroup->setAttribute("workflow_version", 0 );
        $workflowgroup->store();
    }
    // Remove version 1
    eZWorkflowGroupLink::removeWorkflowMembers( $WorkflowID, 1 );

    eZWorkflow::removeEvents( false, $WorkflowID, 0 );
    $workflow->removeThis( true );
    $workflow->setVersion( 0, $event_list );
    $workflow->adjustEventPlacements( $event_list );
//    $workflow->store( $event_list );
    $workflow->storeDefined( $event_list );
    $workflow->cleanupWorkFlowProcess();

    $db->commit();

    $workflowGroups= eZWorkflowGroupLink::fetchGroupList( $WorkflowID, 0, true );
    $groupID = false;
    if ( count( $workflowGroups ) > 0 )
        $groupID = $workflowGroups[0]->attribute( 'group_id' );
    if ( $groupID )
        return $Module->redirectToView( 'workflowlist', array( $groupID ) );
 function fetchWorkflowStatuses()
 {
     return array('result' => eZWorkflow::statusNameMap());
 }
示例#17
0
 * @package kernel
 */
$Module = $Params['Module'];
// $execStack = eZExecutionStack::instance();
// $execStack->clear();
// $execStack->addEntry( $Module->functionURI( 'list' ),
//                       $Module->attribute( 'name' ), 'list' );
$http = eZHTTPTool::instance();
if ($http->hasPostVariable('NewGroupButton')) {
    return $Module->run('groupedit', array());
}
if ($http->hasPostVariable('NewWorkflowButton')) {
    return $Module->run('edit', array());
}
if ($http->hasPostVariable('DeleteButton') and $http->hasPostVariable('Workflow_id_checked')) {
    eZWorkflow::setIsEnabled(false, $http->postVariable('Workflow_id_checked'));
}
$groupList = eZWorkflowGroup::fetchList();
$workflows = eZWorkflow::fetchList();
$workflowList = array();
foreach ($workflows as $workflow) {
    $workflowList[$workflow->attribute('id')] = $workflow;
}
$Module->setTitle('Workflow list');
$tpl = eZTemplate::factory();
$tpl->setVariable('workflow_list', $workflowList);
$tpl->setVariable('group_list', $groupList);
$tpl->setVariable('module', $Module);
$Result = array();
$Result['content'] = $tpl->fetch('design:workflow/list.tpl');
$Result['path'] = array(array('url' => '/workflow/list/', 'text' => ezpI18n::tr('kernel/workflow', 'Workflow list')));
示例#18
0
 static function fetchListCount($version = 0, $enabled = 1)
 {
     $list = eZPersistentObject::fetchObjectList(eZWorkflow::definition(), array(), array('version' => $version, 'is_enabled' => $enabled), false, null, false, null, array(array('operation' => 'count( id )', 'name' => 'count')));
     return $list[0]["count"];
 }
示例#19
0
    if ($dbUser !== false) {
        $params['user'] = $dbUser;
        $params['password'] = '';
    }
    if ($dbPassword !== false) {
        $params['password'] = $dbPassword;
    }
    if ($dbName !== false) {
        $params['database'] = $dbName;
    }
    $db = eZDB::instance($dbImpl, $params, true);
    eZDB::setInstance($db);
}
$db->setIsSQLOutputEnabled($showSQL);
if ($flatten['contentobject']) {
    $cli->output("Removing non-published content object versions");
    eZContentObjectVersion::removeVersions();
}
if ($flatten['contentclass']) {
    $cli->output("Removing temporary content classes");
    eZContentClass::removeTemporary();
}
if ($flatten['workflow']) {
    $cli->output("Removing temporary workflows");
    eZWorkflow::removeTemporary();
}
if ($flatten['role']) {
    $cli->output("Removing temporary roles");
    eZRole::removeTemporary();
}
$script->shutdown();
示例#20
0
文件: list.php 项目: nfrp/ezpublish
    $explodedOperation = explode('_', $operation);
    $i = 0;
    if (sizeof($explodedOperation) >= 3) {
        if (strcmp($explodedOperation[$i], "before") == 0 || strcmp($explodedOperation[$i], "after") == 0) {
            $moduleParts = array($explodedOperation[$i++]);
        }
    } else {
        $moduleParts = array("before", "after");
    }
    foreach ($moduleParts as $trigger['connect_type']) {
        $trigger['module'] = $explodedOperation[$i];
        // $i is either 0 or 1
        $trigger['operation'] = $explodedOperation[$i + 1];
        $trigger['workflow_id'] = 0;
        $trigger['key'] = $trigger['module'] . '_' . $trigger['operation'] . '_' . $trigger['connect_type'][0];
        $trigger['allowed_workflows'] = eZWorkflow::fetchLimited($trigger['module'], $trigger['operation'], $trigger['connect_type']);
        foreach ($triggers as $existendTrigger) {
            if ($existendTrigger->attribute('module_name') == $trigger['module'] && $existendTrigger->attribute('function_name') == $trigger['operation'] && $existendTrigger->attribute('connect_type') == $trigger['connect_type'][0]) {
                $trigger['workflow_id'] = $existendTrigger->attribute('workflow_id');
            }
        }
        $possibleTriggers[] = $trigger;
    }
}
if ($http->hasPostVariable('StoreButton')) {
    $db = eZDB::instance();
    $db->begin();
    foreach ($possibleTriggers as $trigger) {
        if ($http->hasPostVariable('WorkflowID_' . $trigger['key'])) {
            $workflowID = $http->postVariable('WorkflowID_' . $trigger['key']);
            if ($workflowID != -1) {
示例#21
0
/**
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.07.0
 * @package kernel
 */
$Module = $Params['Module'];
$http = eZHTTPTool::instance();
$validation = array('processed' => false, 'groups' => array());
$WorkflowID = $Params["WorkflowID"];
$WorkflowID = (int) $WorkflowID;
if (!is_int($WorkflowID)) {
    $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$workflow = eZWorkflow::fetch($WorkflowID);
if (!$workflow) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
if ($http->hasPostVariable("AddGroupButton") && $http->hasPostVariable("Workflow_group")) {
    $selectedGroup = $http->postVariable("Workflow_group");
    eZWorkflowFunctions::addGroup($WorkflowID, 0, $selectedGroup);
}
if ($http->hasPostVariable("DeleteGroupButton") && $http->hasPostVariable("group_id_checked")) {
    $selectedGroup = $http->postVariable("group_id_checked");
    if (!eZWorkflowFunctions::removeGroup($WorkflowID, 0, $selectedGroup)) {
        $validation['groups'][] = array('text' => ezpI18n::tr('kernel/workflow', 'You have to have at least one group that the workflow belongs to!'));
        $validation['processed'] = true;
    }
}
$event_list = $workflow->fetchEvents();