$object =& eZContentObject::fetch( $userID );
// Need to unpublish the user to be able to add it to the new location.
include_once('kernel/classes/ezcontentobject.php');
$object =& eZContentObject::fetch( $userID );
$version =& eZContentObjectVersion::fetchVersion( $object->attribute('current_version'), $userID );
$version->unpublish();
// Add the location to the user
$object->createNodeAssignment($groupID, false);
// Finally, publish the user again.
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $userID,
'version' => $object->attribute('current_version') ) );
I found a problem: I need to check for permissions in the php code. Now it is possible to add any user to any group as ling as you know the nodeid of the group.
How do I check permissions? I have template code to do it, bit I need to do the check in the php code.
{* Check permissions *}
{def $groupobject = fetch('content', 'node', hash('node_id', $groupID))}
{if not($groupobject.can_edit)}
You do not have the proper permissions to add people to group {$groupID}.
{else}
User has been added. Thank you!
{/if}
Mikael Johansson, Sweden
You must be logged in to post messages in this topic!