Skip to content
minhaz edited this page Jun 9, 2015 · 1 revision

###Access Control List implementation

lets say we have a user object which has an associative array for maintaining all access for that user in memory. It may look like:

$userObj->access = array(
    'AdminAdd' => true,
    'AdminView' => true,
    'AdminEdit' => true
);

Now the code for testing the access for logged in user with active $userObj would look like:

if (isset($userObj->access['AdminView'])) {
    // Code to print the UI element
}

Code to deny access to a functionality if access doesn't exist but service requested

if (!isset($userObj->access['AdminDelete'])) {
    // Code to print the error message
    die ("you do not have appropriate access");
}
// Code to delete the required admin....
Clone this wiki locally