Forums / Developer / Limiting within ViewList, possible? / Comment44347
Piotrek Karaś
Thursday 20 November 2008 4:49:35 am
Hi there,
I've just written a wrapper that I intend to take care of two things: - include calling for user object,- provide slightly simplified/aggregated limitation array, so that it can be faster, easier and cleaner to verify limited access.
public static function getSimplifiedUserAccess( string $module, string $function ) { $user = eZUser::currentUser(); $userAccess = $user->hasAccessTo( $module, $function ); $userAccess['simplifiedLimitations'] = array(); if( $userAccess['accessWord'] == 'limited' ) { foreach( $userAccess['policies'] as $policy ) { foreach( $policy as $limitationName => $limitationList ) { foreach( $limitationList as $limitationValue ) { $userAccess['simplifiedLimitations'][$limitationName][] = $limitationValue; } } } } return $userAccess; }
1) Do you think the above approach is a good one?2) Have I reinvented the wheel? Is there a ready solution for that?
Thanks,Piotrek
-- Company: mediaSELF Sp. z o.o., http://www.mediaself.pl eZ references: http://ez.no/partners/worldwide_partners/mediaself eZ certified developer: http://ez.no/certification/verify/272585 eZ blog: http://ez.ryba.eu