Thursday 19 June 2008 9:13:41 am
If this can be of any help to others, I came up with the following code: It definitively could need some improvement, but works for me. If anyone knows a better way, please feel free to post it here. Once the section of the contentobect has been determined with
$contentobject->attribute( 'section_id' );
you can then check if the section ID is contained in the array returned by this method:
/* for a given array of user or group contentobject_id,
return an array of the Section IDs this user or group has access to.
TBD: does not take class-level access restrictions per sections into account */
function getSectionsByUserIDArray( $userID_array )
{
$accessPolicies = eZRole::accessArrayByUserID( $userID_array );
$sectionsByUserID = array();
foreach ( $accessPolicies['content']['read'] as $key => $ap ) {
foreach( $ap as $k => $sections ) {
if ( strtolower($k)=="section") {
foreach ( $sections as $s) {
$sectionsByUserID[]=$s;
}
}
}
}
$sectionsByUserID=array_unique($sectionsByUserID);
return $sectionsByUserID;
}
|