Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* SQL connection */
- $pdo = new PDO(/* SQL connection parameters */);
- /* RBAC class */
- $rbac = new RBAC($pdo);
- /* Read the role id from the request string (you should also sanitize it) */
- $role_id = $_REQUEST['role_id'];
- /* Array with a list of possible role permission IDs. This list can be created in different ways, either statically (from a configuration file, for example) or dynamically from a database */
- $permission_list = array('1', '2', '3', /* ... */);
- /* Now, for each permission we look for the checkbox value */
- foreach ($permission_list as $permission)
- {
- /* Check if a request string exists */
- if (array_key_exists('checkbox_' . $permission, $_REQUEST))
- {
- /* Check its value: if is 1 set the permission, otherwise remove it */
- $permission_set = $_REQUEST['checkbox_' . $permission];
- if ($permission_set == '1')
- {
- $rbac->addRolePermission($role_id, $permission);
- }
- else
- {
- $rbac->deleteRolePermission($role_id, $permission);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement