eZ Community » Forums » Developer » Workflow removeSubtrees & addLocation

Workflow removeSubtrees & addLocation

Workflow removeSubtrees & addLocation

Friday 21 August 2009 6:03:13 pm - 2 replies

Hi everbody!

I have extended my user class with an optionfield User_group.
If an Editor wants to create a user, he just have to select the group in the frontend-form.

I use the createmultiplelocationrule event - Before publish.
The user is published in the default user_group 12 and in the selected location.
Works fine!

But now i run into trouble.
If an editor wants to change the selected group of an user, the old location has to be removed and the new location has to be assigned.

$db = eZDB::instance();

$nodes = $object->attribute('assigned_nodes');
$mainNodeId = $object->attribute('main_node_id');

 //remove all nodes that are not main 
foreach ($nodes as $node)
  $nodeid = $node->attribute('node_id');
  if ( $nodeid != $mainNodeId )
  $deleteIDArray[] = $nodeid;
$removeSubtrees = eZContentObjectTreeNode::removeSubtrees( $deleteIDArray, false );

//it works
$object->addLocation( $destID, false );
//it works, but only on first creation not on changing

After publishing the user-object, the new locations are not assigned.
After editing the user again, doing no changes, the user location are assigned correct.

Any hint?

Saturday 22 August 2009 1:00:09 pm

Have a look in: http://pubsvn.ez.no/nextgen/stabl...ent/ezcontentoperationcollection.php

Especially ::removeAssignment(), you can probably use that as is. (there is a ::addAssignment also).

Tuesday 25 August 2009 5:13:04 pm

Got it!
(using ezp 4.0.6)

I changed the TriggerType in the addLoactionEventWorkflow to AfterPublish and build a removeLocationEventWorkflow with TriggerType BeforePublish.


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from