Use a subclass of Perm to provide parameters for your permission class
and to implement your own perm_invalid function.
class My_Perm extends Perm {
var $classname = "My_Perm";
var $permissions = array (
"user" => 1,
"author" => 2,
"editor" => 4,
"moderator" => 8,
"admin" => 16
);
function perm_invalid($does_have, $must_have) {
global $perm, $auth, $sess;
include("perminvalid.ihtml");
}
}
Use the page management functions (see above) to use your
permission subclass. The feature name for permission management is perm;
provide the name of your Perm subclass as a parameter to the perm feature.
The perm feature requires the sess feature and the auth feature:
page_open(array("sess" => "My_Session", "auth" => "My_Auth", "perm" => "My_Perm"));
Use the check() instance method to protect your page:
$perm->check("admin"); ## This page is for users with admin rights only.
Use have_perm() to create protected functionality on a page:
<?php
if ($perm->have_perm("admin")):
?>
<h1>Admin only functionality</h1>
<?php
endif;
?>