Date: 05/11/01
- Next message: James Johnson: "Re: [phplib] check if user is authenticated on page which dont't need authentication"
- Previous message: James Johnson: "Re: Sv: [phplib] Numeric check on permissions - interesting problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Stuart
Perhaps you're right that I'm not using it correctly, but the
code I want to write is not covered by the cases you give.
I know that I can do
if ($perm->have_perm("qa,admin"))
but I want to do lots of these tests from data stored in an
array (perhaps retrieved from a database table) and I
think it is more elegant to use numeric checks rather
that string-based ones in this case.
James
At 12:57 PM 5/11/01 +0100, Taylor, Stewart wrote:
>In your description below it sounds like you are not using the phplib perm
>class incorrectly.
>
>The perm class was designed to be used in conjunction with the phplib auth
>class (see docs for details)
>
>Basically when a user logs in to your application an auth instance called
>$auth is created storing the users authentication details plus there
>application permissions ($auth->auth[perms]). The permissions are a comma
>separated string containing that users permissions. e.g. user,qa,admin.
>
>You can then use the have_perm function of the perm object to see if the
>current user has required permissions to run some piece of code.
>e.g.
>
>// admin only
>if ($perm->have_perm("admin"))
>{
> // do stuff
>}
>
>// qa only
>if ($perm->have_perm("qa"))
>{
> // do stuff
>}
>
>// qa & admin only
>if ($perm->have_perm("qa,admin"))
>{
> // do stuff
>}
>
>The have_perm function compares the permissions passed in with those in
>$auth->auth[perm]
>
>
>Have a read through the phplib documentation for more details of this.
>
>
>-Stewart
>-----Original Message-----
>From: James Johnson [mailto:james <email protected>]
>Sent: 11 May 2001 12:11
>To: phplib <email protected>
>Subject: [phplib] Numeric check on permissions
>
>
>Dear phplibbers,
>
>I have a variable, let's called it $perm_required, which
>is a number representing the permissions required
>to do something. i.e. in the default php setup 1
>represents 'user', 16 represents 'admin', so 17 would
>mean user or admin. I want to do a test to see if the
>current user has the permissions represented by
>$perm_required.
>
>i.e.
>
>if ( user has perm represented in $perm_required )
> do_something ();
>
>What is the most elegant way to do this?
>
>Cheers,
>
>James
>
>
>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>
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>
- Next message: James Johnson: "Re: [phplib] check if user is authenticated on page which dont't need authentication"
- Previous message: James Johnson: "Re: Sv: [phplib] Numeric check on permissions - interesting problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

