Example #1
0
 /**
  * User access level
  */
 function getAccessGid()
 {
     static $access;
     if (!isset($access)) {
         $acl = new gacl();
         $access = $this->id > 0 ? 1 : 0;
         $access += $acl->acl_check('action', 'access', 'users', $this->usertype, 'frontend', 'special');
     }
     return $access;
 }
Example #2
0
    echo "Error creating ACL.<br>\n";
}
unset($result);
echo "<br>\n<br>\n";
echo "-- Lets test our work --<br>\n";
/*
 * Awesome, we've setup our ACL system just the way we want it. Now for the easy part,
 * the code to check ACLs.
 *
 * Keep in the mind the API class does not need to be included in scripts that just
 * check ACLs. This is for performance reasons of course.
 *
 * I'm including gacl.class.php again here just to give you the full picture of what you
 * need in each script to check ACLs.
 */
require_once AMP_PATH_PHPGACL . '/gacl.class.php';
$gacl = new gacl($gacl_options);
//Use the same options as above.
if ($gacl->acl_check('system', 'login', 'users', 'john_doe')) {
    echo "John Doe has been granted access to login!<br>\n";
} else {
    echo "John Doe has been denied access to login!<br>\n";
}
if ($gacl->acl_check('system', 'login', 'users', 'jane_doe')) {
    echo "Jane Doe has been granted access to login!<br>\n";
} else {
    echo "Jane Doe has been denied access to login!<br>\n";
}
echo "<br>\n<br>\nDone! Now how easy was that? <br>\n";
echo "Remember to check out the <a href=admin/acl_list.php>Administration Interface</a> which can do all of the above in a few simple clicks.<br>\n<br>\n";
echo "<b>If you run this script more then once, you may get some errors, as duplicate object entries can not be created.</b><br>\n";
}
/*
 * Awesome, we've setup our ACL system just the way we want it. Now for the easy part,
 * the code to check ACLs.
 *
 * Keep in the mind the API class does not need to be included in scripts that just
 * check ACLs. This is for performance reasons of course.
 *
 * I'm including gacl.class.php again here just to give you the full picture of what you
 * need in each script to check ACLs.
 */
require_once dirname(__FILE__) . '/../../../gacl.class.php';
$gacl = new gacl($gacl_options);
//Use the same options as above.
// Lets check Han has access to the cockpit
if ($gacl->acl_check('access', 'cockpit', 'crew', 'han')) {
    if ($outputDebug == TRUE) {
        echo "Han has been granted access to the cockpit!<br>\n";
    }
} else {
    if ($outputDebug == TRUE) {
        echo "Han has been denied access to the cockpit!<br>\n";
    }
}
// Lets check Luke has access to the cockpit *should fail!
if ($gacl->acl_check('access', 'cockpit', 'crew', 'Luke')) {
    if ($outputDebug == TRUE) {
        echo "Luke has been granted access to the cockpit!<br>\n";
    }
} else {
    if ($outputDebug == TRUE) {