Author Topic

Sebastian Sprenger

Monday 26 April 2004 12:14:07 am

Comment39973

Hi!
Here a few lines from the code. If you want I could mail the complete file.

First get some general infos:

$parameters = $process->attribute( 'parameter_list' );
$object =& eZContentObject::fetch( $parameters['object_id'] );
$objectId= $parameters['object_id'];

Status is a ezselect attribute that I use to decide, what should happen to the user object.

$status = $data_map['status']->attribute('data_text');

Depending on this attribute the following code will be executed (or not):

// get latest Version number
$maxVersion =& $object->getVersionCount();
$allVersions = $object->versions();
$latestVersion = $allVersions[$maxVersion-1];
$maxVersion= $latestVersion->attribute('version');
$version =& $object->version( $maxVersion );

// get all Nodeassignments
$nodeAssignments = $version->nodeAssignments();

// remove all assignments with main_node_id = 546
foreach ($nodeAssignments as $assignment) {
	$parentObject = $assignment->getParentNode();
	if ($parentObject->attribute('main_node_id') == 546) {
		$version->removeAssignment(546);
	} else {
		// if an assignment is 'main', remove and create a new one without 'main'
		if ($assignment->attribute( 'is_main' ) == '1') {
			$nodeId = $assignment->getParentNode();
			$version->removeAssignment($nodeId);
			$version->assignToNode($nodeId, 0);
		}
	}
}
//set new assignment, here: 12
$version->removeAssignment(12);
$version->assignToNode(12, 1, 546);
$version->store();

Hope this helps. Just post any questions.
Sebastian