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' );?>
|