Re: Sv: [phplib] Numeric check on permissions - interesting problem From: James Johnson (james <email protected>)
Date: 05/11/01

Thanks for pointing me in the right direction Klaus.

However, in attempting to do this I have found an
interesting problem.

I am using Default_Auth and then using logic
in the pages themselves to deal with the different
visitors with different perms.

Users who are not logged on have a permissions
value of zero. Let's say I have an action I want
performed if the user is a guest. That's easy -
$perm_required would be equal to one.
However, what if there are also instances
where I want an action performed if the user if
a guest *or* they are not logged on - the value
of $perm_required would still be one. How do
I get round this? It seems that I need to set
up a new perm value, for 'not logged on', but I
don't want to mess about with the guts of PHPLib
too much. Anyone have a neat solution?

Cheers,

James

At 02:20 PM 5/11/01 +0200, Klaus Seidenfaden wrote:
>-----Oprindelig meddelelse-----
>Fra: James Johnson <james <email protected>>
>
>
> >if ( user has perm represented in $perm_required )
> > do_something ();
> >
> >What is the most elegant way to do this?
>
>Bitwise or/bitwise and, depending on whether the user must have just one
>of the permissions in $perm_required, or all of them. Check the source
>(perm.inc) - Perm::have_perm() and Perm::permsum() contain relevant
>code. Make a subclass of Perm with a method to return a numeric
>representation of the user's permissions, then do your check. Or, better
>yet, pass $perm_required to your new method, and have it perform the check
>for you.
>
>-- KLaus.

James Johnson
Managing Director
Publitek New Media Ltd.

IMPORTANT NOTE: NEW ADDRESS

18 Brock Street, Bath, BA1 2LW, UK
T: +44 (0) 1225 780174
F: +44 (0) 1225 470047
Courier deliveries should be addressed to 'West Door'
Please amend your records and let your colleagues know

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>