Posted by ZeldorBlat on 10/13/06 02:23
tranzparency@gmail.com wrote:
> Unfortunately my math is really rusty. We have a permission system we
> are building. The permission go in value from low to high. Personal
> being what you are allowed to do with your data, Group is how you can
> interact with outher user's data.
>
> Personal - View = 1
> Personal - Add/Edit = 2
> Personal - Delete = 4
> Group - View = 8
> Group - Edit = 16
> Group - Delete = 32
>
> My question is how do I create a function that I can input the
> permission value in (example: 63 for full perms) and the require perm
> I'm checking (example 8) have it return a true or false if 8 exists in
> 63?
>
> Thanks.
function checkPerm($yourPerm, $requiredPerm) {
return ($yourPerm & $requiredPerm) > 0;
}
Navigation:
[Reply to this message]
|