Limit a role to section programmatically?

Author Message

Clemens T

Thursday 06 October 2005 7:01:32 am

Heya all,
I'd like to know how I can assign a role to my user with $userid, limited to a section (that role).
Thanks a lot!
Clemens

Kristof Coomans

Thursday 06 October 2005 7:23:42 am

This is some code from <i>kernel/role/assign.php</i>:

include_once( 'kernel/classes/ezrole.php' );
$role =& eZRole::fetch( $roleID );
$role->assignToUser( $userID, $limitIdent, $limitValue );

// Clear role caches.
eZRole::expireCache();

include_once( 'kernel/classes/ezcontentcachemanager.php' );
      eZContentCacheManager::clearAllContentCache();

/* Clean up policy cache */
include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
eZUser::cleanupCache();

where $limitIdent is 'subtree' or 'section', and $limitValue is the top node of the subtree or the section id.

Don't be afraid to dig into the kernel code ;-) In there you will find almost everything you need.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Clemens T

Thursday 06 October 2005 8:59:18 am

Great coding, thanks a lot.. helping me to reach my deadline here:)!
Greetz,
Clemens

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.