Forums / Setup & design / Workflow help

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

eZ debug

Timing: Jan 18 2025 01:01:11
Script start
Timing: Jan 18 2025 01:01:11
Module start 'content'
Timing: Jan 18 2025 01:01:13
Module end 'content'
Timing: Jan 18 2025 01:01:13
Script end

Main resources:

Total runtime1.4252 sec
Peak memory usage4,096.0000 KB
Database Queries207

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 587.5859180.8594
Module start 'content' 0.00551.2786 768.4453601.6563
Module end 'content' 1.28410.1410 1,370.1016341.0938
Script end 1.4251  1,711.1953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.2846210.0002
Check MTime0.00150.1086210.0001
Mysql Total
Database connection0.00060.043610.0006
Mysqli_queries1.348994.64622070.0065
Looping result0.00210.14652050.0000
Template Total1.383997.120.6919
Template load0.00230.161220.0011
Template processing1.381596.938620.6908
Template load and register function0.00020.015610.0002
states
state_id_array0.00240.168610.0024
state_identifier_array0.00180.126020.0009
Override
Cache load0.00190.1359370.0001
Sytem overhead
Fetch class attribute can translate value0.00090.064130.0003
Fetch class attribute name0.00120.081880.0001
XML
Image XML parsing0.00070.047330.0002
class_abstraction
Instantiating content class attribute0.00000.000980.0000
General
dbfile0.00670.4675270.0002
String conversion0.00000.000330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 8

Time used to render debug report: 0.0003 secs