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.

eZ debug

Timing: Jan 31 2025 03:33:59
Script start
Timing: Jan 31 2025 03:33:59
Module start 'layout'
Timing: Jan 31 2025 03:33:59
Module start 'content'
Timing: Jan 31 2025 03:33:59
Module end 'content'
Timing: Jan 31 2025 03:33:59
Script end

Main resources:

Total runtime0.0364 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0055 588.2656151.2266
Module start 'layout' 0.00550.0058 739.4922220.7188
Module start 'content' 0.01140.0236 960.2109997.9609
Module end 'content' 0.03490.0014 1,958.171929.9922
Script end 0.0364  1,988.1641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00308.1743140.0002
Check MTime0.00113.0684140.0001
Mysql Total
Database connection0.00082.112810.0008
Mysqli_queries0.003710.146430.0012
Looping result0.00000.104110.0000
Template Total0.00102.710.0010
Template load0.00071.991710.0007
Template processing0.00030.708610.0003
Override
Cache load0.00051.389810.0005
General
dbfile0.009726.758480.0012
String conversion0.00000.026940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs