I going to implement ACL (Access control list) in my php website.
In my system user have sum a of roles and permission.
Main algorithm is as follows:
permissions = (permissions_by_role + permission_for_user) - user_banned_permission
so I have three arrays and get those values from database.
For the first part I use this
$permissions = array_unique(array_merge($permission_by_role, $permission_by_user));
How can I remove my banned permission from permission array? Now I have these two arrays:
$permissions and $permission_banned_for_user[]
sounds like a perfect use-case for array_diff:
$permissions = array_diff($permissions, $permission_banned_for_user);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With