Workflow help

Author Message

nicholas king

Tuesday 22 February 2011 1:36:07 am

Hello Guys, has anyone got any links pointers to setting up workflows, specifically to move content after it is published. I have found one really good article

http://share.ez.no/learn/ez-publish/creating-a-simple-custom-workflow-event

but am after a bit more documentation.

Thanks

Nicholas

nicholas king

Wednesday 23 February 2011 5:05:42 am

<?php
class MoveMediaType extends eZWorkflowEventType {<span> 
</span>const WORKFLOW_TYPE_STRING = "movemedia";<span> 
</span>public function __construct() {<span>  
</span><span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;"> </span>parent::__construct ( MoveMediaType::WORKFLOW_TYPE_STRING, 'Move Files into the media library' );
}<span> </span><span> 
</span>public function execute($process, $event) {<span>  
</span><span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;"> </span>$parameters = $process->attribute ( 'parameter_list' );
<span> </span>/*  YOUR CODE GOES HERE */<span>  </span><span>  
</span><span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;"> </span>$objectID = $parameters ['object_id'];<span>  
</span><span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;"> </span>$object = eZContentObject::fetch ( $objectID );<span>  
</span><span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;"> </span>$node = $object->attribute ( 'main_node' );
<span> </span>$selectedNodeID = 43;
<span> </span><span> 
</span><span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;"> </span>if( eZOperationHandler::operationIsAvailable( 'content_move' ) )
<span> </span>{<span>   
</span><span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;">  </span>$operationResult = eZOperationHandler::execute( 'content',
<span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;">  </span>'move', array( 'node_id' => $nodeToMove['node_id'],
<span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;">  </span>'object_id' => $nodeToMove['object_id'],
<span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;">  </span>'new_parent_node_id' => $selectedNodeID ),
<span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;">  </span>null,true );
<span> </span>}else{
<span> <span class="Apple-tab-span" style="white-space:pre" mce_style="white-space: pre;"> </span></span>eZContentOperationCollection::moveNode( $nodeToMove['node_id'], $nodeToMove['object_id'],$selectedNodeID );
<span> </span>}<span> 


<span class="Apple-tab-span" style="white-space:pre"> </span>return eZWorkflowType::STATUS_ACCEPTED;<span> </span>

}
}
eZWorkflowEventType::registerEventType ( MoveMediaType::WORKFLOW_TYPE_STRING, 'movemediatype' );
?>

Hello I currently have this as my workflow code, but am struggling to get the event to fire! any help appreciated.

nicholas king

Wednesday 23 February 2011 5:07:00 am

<?php
class MoveMediaType extends eZWorkflowEventType { const WORKFLOW_TYPE_STRING = "movemedia"; public function __construct() { parent::__construct ( MoveMediaType::WORKFLOW_TYPE_STRING, 'Move Files into the media library' ); } public function execute($process, $event) { $parameters = $process->attribute ( 'parameter_list' ); /* YOUR CODE GOES HERE */ $objectID = $parameters ['object_id']; $object = eZContentObject::fetch ( $objectID ); $node = $object->attribute ( 'main_node' ); $selectedNodeID = 43; if( eZOperationHandler::operationIsAvailable( 'content_move' ) ) { $operationResult = eZOperationHandler::execute( 'content', 'move', array( 'node_id' => $nodeToMove['node_id'], 'object_id' => $nodeToMove['object_id'], 'new_parent_node_id' => $selectedNodeID ), null, true ); } else { eZContentOperationCollection::moveNode( $nodeToMove['node_id'], $nodeToMove['object_id'], $selectedNodeID ); } return eZWorkflowType::STATUS_ACCEPTED; }}eZWorkflowEventType::registerEventType ( MoveMediaType::WORKFLOW_TYPE_STRING, 'movemediatype' );?><?php
class MoveMediaType extends eZWorkflowEventType { const WORKFLOW_TYPE_STRING = "movemedia"; public function __construct() { parent::__construct ( MoveMediaType::WORKFLOW_TYPE_STRING, 'Move Files into the media library' ); } public function execute($process, $event) { $parameters = $process->attribute ( 'parameter_list' ); /* YOUR CODE GOES HERE */ $objectID = $parameters ['object_id']; $object = eZContentObject::fetch ( $objectID ); $node = $object->attribute ( 'main_node' ); $selectedNodeID = 43; if( eZOperationHandler::operationIsAvailable( 'content_move' ) ) { $operationResult = eZOperationHandler::execute( 'content', 'move', array( 'node_id' => $nodeToMove['node_id'], 'object_id' => $nodeToMove['object_id'], 'new_parent_node_id' => $selectedNodeID ), null, true ); } else { eZContentOperationCollection::moveNode( $nodeToMove['node_id'], $nodeToMove['object_id'], $selectedNodeID ); } return eZWorkflowType::STATUS_ACCEPTED; }}eZWorkflowEventType::registerEventType ( MoveMediaType::WORKFLOW_TYPE_STRING, 'movemediatype' );?>

nicholas king

Wednesday 23 February 2011 9:25:52 am

solution to move a content node with a workflow:-

<?php
class MoveMediaType extends eZWorkflowEventType { const WORKFLOW_TYPE_STRING = "movemedia"; public function __construct() { parent::__construct ( MoveMediaType::WORKFLOW_TYPE_STRING, 'Move Files into the media library' ); }
public function execute($process, $event) { $parameters = $process->attribute ( 'parameter_list' ); /* YOUR CODE GOES HERE */
$objectID = $parameters ['object_id']; $object = eZContentObject::fetch ( $objectID ); $node_id = $object->attribute('main_node_id'); $selectedNodeID = 43; if ( eZOperationHandler::operationIsAvailable( 'content_move' ) ) { eZContentOperationCollection::moveNode($node_id , $objectID, $selectedNodeID ); } else { print("ERROR"); } return eZWorkflowType::STATUS_ACCEPTED; }}eZWorkflowEventType::registerEventType ( MoveMediaType::WORKFLOW_TYPE_STRING, 'movemediatype' );?>

nicholas king

Wednesday 23 February 2011 9:40:29 am

i am now looking to add a redirect in on completion if anyone has any idea how to do this please comment

Gaetano Giunta

Wednesday 23 February 2011 9:54:24 am

might make a candidate for inclusion in the ezworkflowcollection extension. wanna participate?

Principal Consultant International Business
Member of the Community Project Board

nicholas king

Wednesday 23 February 2011 11:46:16 pm

Hello Gaetano,

feel free to take any of the code that is written and include it into your extension.

i will repost here any enhancements that i make.

Thanks

Nicholas

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 04:10:59
Script start
Timing: Jan 18 2025 04:10:59
Module start 'layout'
Timing: Jan 18 2025 04:10:59
Module start 'content'
Timing: Jan 18 2025 04:11:00
Module end 'content'
Timing: Jan 18 2025 04:11:00
Script end

Main resources:

Total runtime0.6763 sec
Peak memory usage4,096.0000 KB
Database Queries70

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 587.7891152.6094
Module start 'layout' 0.00630.0029 740.398439.4219
Module start 'content' 0.00920.6655 779.8203596.5938
Module end 'content' 0.67470.0014 1,376.414120.1953
Script end 0.6762  1,396.6094 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4514160.0002
Check MTime0.00130.1906160.0001
Mysql Total
Database connection0.00080.111810.0008
Mysqli_queries0.611090.3423700.0087
Looping result0.00070.1091680.0000
Template Total0.645395.420.3227
Template load0.00200.290720.0010
Template processing0.643395.122620.3217
Template load and register function0.00020.027110.0002
states
state_id_array0.00120.181410.0012
state_identifier_array0.00150.218420.0007
Override
Cache load0.00170.2499370.0000
Sytem overhead
Fetch class attribute can translate value0.00100.148820.0005
Fetch class attribute name0.00130.190280.0002
XML
Image XML parsing0.00060.090720.0003
class_abstraction
Instantiating content class attribute0.00000.002780.0000
General
dbfile0.00090.1392160.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/link.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/link.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 8

Time used to render debug report: 0.0001 secs