Share » Forums » Developer » Opposite of...

Opposite of eZContentObject::addLocation() ?

Opposite of eZContentObject::addLocation() ?

Wednesday 09 March 2011 7:43:24 am - 3 replies

Author Message

Sebastiaan van der Vliet

Wednesday 09 March 2011 8:14:51 am

A long time ago I wrote some code to remove users from user groups. Don't know if it is still useful. $groupID would be the nodeID of the assigned node.

$object = eZContentObject::fetch( $userObjectID );
if ($object)
{
$nodeID = $object->attribute('main_node_id');
$version = $object->currentVersion();
$versionNumber = $version->attribute('version');
$newVersion = $object->createNewVersion();
//TODO: make sure this is not the main node.
$newVersion->removeAssignment($groupID);
$newVersionNr = $newVersion->attribute( 'version' );
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute(
'content', 'publish', array(
'object_id' => $userObjectID,
'version' => $newVersionNr
)
);
}

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Damien Pobel

Wednesday 09 March 2011 1:44:36 pm

Hi,

I think the right method to use is eZContentObjectTreeNode::removeNodeFromTree(). if the node you're removing is the only assignment of a content object it also removes the associated content object, otherwise, it just removes the location.

@Sebastiaan : you're code seems a bit complicated, you don't need to create a new version to remove a location

Cheers

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Heiko Irrgang

Wednesday 09 March 2011 11:38:54 pm

thanx, removeNodeFromTree does the trick

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

36 542 Users on board!

Forums menu