function eventType() { if (!isset($this->EventType)) { $this->EventType = eZWorkflowType::createType($this->TypeString); } return $this->EventType; }
function workflowType() { return eZWorkflowType::createType($this->WorkflowTypeString); }
eZWorkflowFunctions::addGroup( $WorkflowID, $WorkflowVersion, $selectedGroup ); } if ( $http->hasPostVariable( "DeleteGroupButton" ) && $http->hasPostVariable( "group_id_checked" ) ) { $selectedGroup = $http->postVariable( "group_id_checked" ); if ( !eZWorkflowFunctions::removeGroup( $WorkflowID, $WorkflowVersion, $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; } } // Fetch events and types $event_list = $workflow->fetchEvents(); $type_list = eZWorkflowType::fetchRegisteredTypes(); // Validate input $canStore = true; $requireFixup = false; foreach( $event_list as $event ) { $eventType = $event->eventType(); if ( !$eventType instanceof eZWorkflowEventType ) { // Can't find eventype. Most likely deactivated while workflow has not been cleant up eZDebug::writeError( "Couldn't load eventype '{$event->attribute( 'workflow_type_string' )}' for workflow. Is it activated ?", 'eZWorkflow edit' ); continue; } $status = $eventType->validateHTTPInput( $http, "WorkflowEvent", $event, $validation );
function fetchWorkflowTypeStatuses() { return array('result' => eZWorkflowType::statusNameMap()); }
/** * Deletes the current object, all versions and translations, and corresponding tree nodes from the database * * Transaction unsafe. If you call several transaction unsafe methods you must enclose * the calls within a db transaction; thus within db->begin and db->commit. */ function purge() { $delID = $this->ID; // Who deletes which content should be logged. eZAudit::writeAudit( 'content-delete', array( 'Object ID' => $delID, 'Content Name' => $this->attribute( 'name' ), 'Comment' => 'Purged the current object: eZContentObject::purge()' ) ); $db = eZDB::instance(); $db->begin(); $attrOffset = 0; $attrLimit = 20; while ( $contentobjectAttributes = $this->allContentObjectAttributes( $delID, true, array( 'limit' => $attrLimit, 'offset' => $attrOffset ) ) ) { foreach ( $contentobjectAttributes as $contentobjectAttribute ) { $dataType = $contentobjectAttribute->dataType(); if ( !$dataType ) continue; $dataType->deleteStoredObjectAttribute( $contentobjectAttribute ); } $attrOffset += $attrLimit; } eZInformationCollection::removeContentObject( $delID ); eZContentObjectTrashNode::purgeForObject( $delID ); $db->query( "DELETE FROM ezcontentobject_tree WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcontentobject_attribute WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcontentobject_version WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcontentobject_name WHERE contentobject_id='$delID'" ); $db->query( "DELETE FROM ezcobj_state_link WHERE contentobject_id=$delID" ); $db->query( "DELETE FROM ezcontentobject WHERE id='$delID'" ); $db->query( "DELETE FROM eznode_assignment WHERE contentobject_id = '$delID'" ); $db->query( "DELETE FROM ezuser_role WHERE contentobject_id = '$delID'" ); $db->query( "DELETE FROM ezuser_discountrule WHERE contentobject_id = '$delID'" ); eZContentObject::fixReverseRelations( $delID, 'remove' ); eZSearch::removeObjectById( $delID ); // Check if deleted object is in basket/wishlist $sql = 'SELECT DISTINCT ezproductcollection_item.productcollection_id FROM ezbasket, ezwishlist, ezproductcollection_item WHERE ( ezproductcollection_item.productcollection_id=ezbasket.productcollection_id OR ezproductcollection_item.productcollection_id=ezwishlist.productcollection_id ) AND ezproductcollection_item.contentobject_id=' . $delID; $rows = $db->arrayQuery( $sql ); if ( count( $rows ) > 0 ) { $countElements = 50; $deletedArray = array(); // Create array of productCollectionID will be removed from ezwishlist and ezproductcollection_item foreach ( $rows as $row ) { $deletedArray[] = $row['productcollection_id']; } // Split $deletedArray into several arrays with $countElements values $splitted = array_chunk( $deletedArray, $countElements ); // Remove eZProductCollectionItem and eZWishList foreach ( $splitted as $value ) { eZPersistentObject::removeObject( eZProductCollectionItem::definition(), array( 'productcollection_id' => array( $value, '' ) ) ); eZPersistentObject::removeObject( eZWishList::definition(), array( 'productcollection_id' => array( $value, '' ) ) ); } } $db->query( 'UPDATE ezproductcollection_item SET contentobject_id = 0 WHERE contentobject_id = ' . $delID ); // Cleanup relations in two steps to avoid locking table for to long $db->query( "DELETE FROM ezcontentobject_link WHERE from_contentobject_id = '$delID'" ); $db->query( "DELETE FROM ezcontentobject_link WHERE to_contentobject_id = '$delID'" ); // Cleanup properties: LastVisit, Creator, Owner $db->query( "DELETE FROM ezuservisit WHERE user_id = '$delID'" ); $db->query( "UPDATE ezcontentobject_version SET creator_id = 0 WHERE creator_id = '$delID'" ); $db->query( "UPDATE ezcontentobject SET owner_id = 0 WHERE owner_id = '$delID'" ); if ( isset( $GLOBALS["eZWorkflowTypeObjects"] ) and is_array( $GLOBALS["eZWorkflowTypeObjects"] ) ) { $registeredTypes =& $GLOBALS["eZWorkflowTypeObjects"]; } else { $registeredTypes = eZWorkflowType::fetchRegisteredTypes(); } // Cleanup ezworkflow_event etc... foreach ( array_keys( $registeredTypes ) as $registeredTypeKey ) { $registeredType = $registeredTypes[$registeredTypeKey]; $registeredType->cleanupAfterRemoving( array( 'DeleteContentObject' => $delID ) ); } $db->commit(); }
$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); if ($next_event_id !== null) { $process->advance($next_event_id, $next_event_pos, $lastEventStatus); $workflowEvent = eZWorkflowEvent::fetch($next_event_id); } else { unset($workflowEvent); $workflowEvent = false; $process->advance(); } $process->setAttribute("modified", time()); $process->store(); } $tpl->setVariable("event_status", eZWorkflowType::statusName($lastEventStatus)); $tpl->setVariable("current_workflow", $workflow); $tpl->setVariable("current_event", $workflowEvent); $Module->setTitle("Workflow process"); $tpl->setVariable("process", $process); $tpl->setVariable("module", $Module); $tpl->setVariable("http", $http); $Result = array(); $Result['content'] = $tpl->fetch("design:workflow/process.tpl");
static function registerEventType($typeString, $class_name) { eZWorkflowType::registerType("event", $typeString, $class_name); }
static function registerGroupType($typeString, $class_name) { eZWorkflowType::registerType("group", $typeString, $class_name); }
static function loadAndRegisterAllTypes() { $allowedTypes = eZWorkflowType::allowedTypes(); foreach ($allowedTypes as $type) { eZWorkflowType::loadAndRegisterType($type); } }
function run(&$workflow, &$workflowEvent, &$eventLog) { $eventLog = array(); eZDebugSetting::writeDebug('workflow-process', $workflowEvent, "workflowEvent in process->run beginning"); $runCurrentEvent = true; $done = false; $workflowStatus = $this->attribute('status'); eZDebugSetting::writeDebug('workflow-process', $workflowStatus, 'workflowStatus'); $currentEventStatus = $this->attribute('event_status'); // just temporary. needs to be removed from parameters if ($workflowEvent == null) { $workflowEvent = eZWorkflowEvent::fetch($this->attribute('event_id')); } switch ($currentEventStatus) { case eZWorkflowType::STATUS_DEFERRED_TO_CRON: case eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT: case eZWorkflowType::STATUS_FETCH_TEMPLATE: case eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT: case eZWorkflowType::STATUS_REDIRECT: case eZWorkflowType::STATUS_REDIRECT_REPEAT: case eZWorkflowType::STATUS_WORKFLOW_RESET: if ($workflowEvent !== null) { $activationDate = 0; if ($this->hasAttribute('activation_date')) { $activationDate = $this->attribute("activation_date"); } eZDebugSetting::writeDebug('workflow-process', "Checking activation date"); if ($activationDate == 0) { $eventType = $workflowEvent->eventType(); $eventLog[] = array("status" => $currentEventStatus, "status_text" => eZWorkflowType::statusName($currentEventStatus), "information" => $eventType->attribute("information"), "description" => $workflowEvent->attribute("description"), "type_name" => $eventType->attribute("name"), "type_group" => $eventType->attribute("group_name")); if ($currentEventStatus == eZWorkflowType::STATUS_DEFERRED_TO_CRON || $currentEventStatus == eZWorkflowType::STATUS_FETCH_TEMPLATE || $currentEventStatus == eZWorkflowType::STATUS_REDIRECT) { $runCurrentEvent = false; } } else { if (time() < $activationDate) { eZDebugSetting::writeDebug('workflow-process', "Date failed, not running events"); $eventType = $workflowEvent->eventType(); $eventLog[] = array("status" => $currentEventStatus, "status_text" => eZWorkflowType::statusName($currentEventStatus), "information" => $eventType->attribute("information"), "description" => $workflowEvent->attribute("description"), "type_name" => $eventType->attribute("name"), "type_group" => $eventType->attribute("group_name")); $done = true; } else { eZDebugSetting::writeDebug('workflow-process', "Date ok, running events"); eZDebugSetting::writeDebug('workflow-process', $currentEventStatus, 'WORKFLOW_TYPE_STATUS'); if ($currentEventStatus == eZWorkflowType::STATUS_DEFERRED_TO_CRON || $currentEventStatus == eZWorkflowType::STATUS_FETCH_TEMPLATE || $currentEventStatus == eZWorkflowType::STATUS_REDIRECT) { $runCurrentEvent = false; } } } } break; default: break; } while (!$done) { if ($runCurrentEvent) { eZDebugSetting::writeDebug('workflow-process', "runCurrentEvent is true"); } else { eZDebugSetting::writeDebug('workflow-process', "runCurrentEvent is false"); } if ($workflowEvent != null) { //eZDebugSetting::writeDebug( 'workflow-process', $workflowEvent ,"workflowEvent is not null" ); } else { //eZDebugSetting::writeDebug( 'workflow-process', $workflowEvent ,"workflowEvent is null" ); } if ($workflowEvent instanceof eZWorkflowEvent) { eZDebugSetting::writeDebug('workflow-process', get_class($workflowEvent), "workflowEvent class is ezworkflowevent"); } else { if ($workflowEvent !== null) { eZDebugSetting::writeDebug('workflow-process', get_class($workflowEvent), "workflowEvent class is not ezworkflowevent"); } } eZDebugSetting::writeDebug('workflow-process', $done, "in while"); if ($runCurrentEvent and $workflowEvent !== null and $workflowEvent instanceof eZWorkflowEvent) { $eventType = $workflowEvent->eventType(); if ($eventType instanceof eZWorkflowType) { $currentEventStatus = $eventType->execute($this, $workflowEvent); $this->setAttribute("event_status", $currentEventStatus); $workflowParameters = $this->attribute('parameter_list'); if (isset($workflowParameters['cleanup_list'])) { $cleanupList = $workflowParameters['cleanup_list']; } else { unset($cleanupList); $cleanupList = array(); } if ($eventType->needCleanup()) { $cleanupList[] = $workflowEvent->attribute('id'); $workflowParameters['cleanup_list'] = $cleanupList; $this->setAttribute('parameters', serialize($workflowParameters)); } eZDebugSetting::writeDebug('workflow-process', $currentEventStatus, "currentEventStatus"); switch ($currentEventStatus) { case eZWorkflowType::STATUS_ACCEPTED: $done = false; $workflowStatus = eZWorkflow::STATUS_DONE; break; case eZWorkflowType::STATUS_WORKFLOW_DONE: $done = true; $workflowStatus = eZWorkflow::STATUS_DONE; break; case eZWorkflowType::STATUS_REJECTED: $done = true; $workflowStatus = eZWorkflow::STATUS_FAILED; break; case eZWorkflowType::STATUS_DEFERRED_TO_CRON: case eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT: if ($eventType->hasAttribute("activation_date")) { $date = $eventType->attribute("activation_date"); $this->setAttribute("activation_date", $date); } $workflowStatus = eZWorkflow::STATUS_DEFERRED_TO_CRON; $done = true; break; case eZWorkflowType::STATUS_FETCH_TEMPLATE: $workflowStatus = eZWorkflow::STATUS_FETCH_TEMPLATE; $done = true; break; case eZWorkflowType::STATUS_FETCH_TEMPLATE_REPEAT: $workflowStatus = eZWorkflow::STATUS_FETCH_TEMPLATE_REPEAT; $done = true; break; case eZWorkflowType::STATUS_REDIRECT: case eZWorkflowType::STATUS_REDIRECT_REPEAT: $workflowStatus = eZWorkflow::STATUS_REDIRECT; $done = true; $this->advance(); break; case eZWorkflowType::STATUS_RUN_SUB_EVENT: eZDebug::writeWarning("Run sub event not supported yet", "eZWorkflowProcess::run"); break; case eZWorkflowType::STATUS_WORKFLOW_CANCELLED: $done = true; $this->advance(); $workflowStatus = eZWorkflow::STATUS_CANCELLED; break; case eZWorkflowType::STATUS_WORKFLOW_RESET: $done = true; $this->reset(); $workflowStatus = eZWorkflow::STATUS_RESET; break; case eZWorkflowType::STATUS_NONE: eZDebug::writeWarning("Workflow executing status is eZWorkflowType::STATUS_NONE", "eZWorkflowProcess::run"); break; default: eZDebug::writeWarning("Unknown status '{$currentEventStatus}'", "eZWorkflowProcess::run"); break; } $eventLog[] = array("status" => $currentEventStatus, "status_text" => eZWorkflowType::statusName($currentEventStatus), "information" => $eventType->attribute("information"), "description" => $workflowEvent->attribute("description"), "type_name" => $eventType->attribute("name"), "type_group" => $eventType->attribute("group_name")); } else { eZDebug::writeError("Expected an eZWorkFlowType object", "eZWorkflowProcess::run"); } } else { eZDebugSetting::writeDebug('workflow-process', "Not running current event. Trying next"); } $runCurrentEvent = true; // still not done if (!$done) { // fetch next event $event_pos = $this->attribute("event_position"); $next_event_pos = $event_pos + 1; $next_event_id = $workflow->fetchEventIndexed($next_event_pos); if ($next_event_id !== null) { eZDebugSetting::writeDebug('workflow-process', $event_pos, "workflow not done"); $this->advance($next_event_id, $next_event_pos, $currentEventStatus); $workflowEvent = eZWorkflowEvent::fetch($next_event_id); } else { $done = true; unset($workflowEvent); eZDebugSetting::writeDebug('workflow-process', $event_pos, "workflow done"); $workflowStatus = eZWorkflow::STATUS_DONE; $this->advance(); } } } $this->setAttribute("status", $workflowStatus); $this->setAttribute("modified", time()); return $workflowStatus; }
<?php /** * List all existing workflow event types * * @author G. Giunta * @copyright (C) G. Giunta 2014-2016 * @license Licensed under GNU General Public License v2.0. See file license.txt * * @todo allow filtering by extension * @todo add information: originating extension for each type */ $eventTypeList = eZWorkflowType::fetchRegisteredTypes(); ksort($eventTypeList); $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));