X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplmodule.php;h=697b4efec8ef47e4a4ab429c9f073f405e6d6263;hb=41e0835d1792f362e6c1e1289df000a1a9475092;hp=8a5e6ca3915dfe649b5533ee7f9d5040eddfe3bd;hpb=2b1ee50b0196216dbe4f37e3b039469d6003ca23;p=platal.git diff --git a/classes/plmodule.php b/classes/plmodule.php index 8a5e6ca..697b4ef 100644 --- a/classes/plmodule.php +++ b/classes/plmodule.php @@ -19,11 +19,26 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -class PLModule +abstract class PLModule { - function handlers() { die("implement me"); } + abstract function handlers(); - public function make_hook($fun, $auth, $perms = '', $type = DO_AUTH) + /** Register a hook + * @param fun name of the handler (the exact name will be handler_$fun) + * @param auth authentification level of needed to run this handler + * @param perms permission required to run this handler + * @param type additionnal flags + * + * Perms syntax is the following: + * perms = rights(,rights)* + * rights = right(:right)* + * right is an atomic right permission (like 'admin', 'user', 'groupadmin', 'groupmember'...) + * + * If type is set to NO_AUTH, the system will return 403 instead of asking auth data + * this is useful for Ajax handler + * If type is not set to NO_SKIN, the system will consider redirecting the user to https + */ + public function make_hook($fun, $auth, $perms = 'user', $type = DO_AUTH) { return array('hook' => array($this, 'handler_'.$fun), 'auth' => $auth, @@ -35,8 +50,8 @@ class PLModule public static function factory($modname) { - $mod_path = dirname(__FILE__).'/../modules/'.strtolower($modname).'.php'; - $class = ucfirst($modname).'Module'; + $mod_path = dirname(__FILE__) . '/../modules/' . $modname . '.php'; + $class = ucfirst($modname) . 'Module'; require_once $mod_path; return new $class();