Friday 21 August 2009 9:03:13 am
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();
$db->begin();
$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
$db->commit();
...
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?
---
ROCK ON
Dirk
|