Re: user permission system (integer to small)
| From: | Marek Kilimajer | Date: | Thu, 27 Mar 2003 09:27:08 +0000 |
| Subject: | Re: user permission system (integer to small) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141191@lists.php.net to get a copy of this message | ||
I would use array
$user_perm ( 1 => false, // for admin
2 => true // for news
4 => true // news_create
8 => false // news_delete
.
.
.
)
as you can see there are gaps that you can use for other permissions, and this way all you need is to rewrite
if($user_perm & $perm == $perm )
to
if($user_perm[$perm])
You can even write a php script that will change it for you
Torsten Rosenberger wrote:
Hello I have some trouble with user permission. I build the system like the permission in the phplib.admin = 1 news = 2news_create = 4 news_delete = 8 . . . then ich can check ($user_perm & $perm == $perm ) But the problem ist that the permissions now over BIGINT. So i cann't store it in mysql (possible are varchar) But to compare the perms they must have the type integer settype ($perm,interger) brings a wrong value in case that the number is greater as the BIGINT. Someone have a better solution ? or a way out. BR/Torsten Rosenberger