X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplmodule.php;h=4e1229bb38d771c8e8e09a64dd286b99465a672c;hb=7c8d7022042ef34cbf8c16531a3b5eaecf46bfd2;hp=4cd113c1900680c1a60fc1fd22933fe128ed1cac;hpb=bf517dafc122edf6ccd86847f0626cfd0df9f340;p=platal.git diff --git a/classes/plmodule.php b/classes/plmodule.php index 4cd113c..4e1229b 100644 --- a/classes/plmodule.php +++ b/classes/plmodule.php @@ -1,6 +1,6 @@ make_hook(...), + * ...); + * @ref make_hook + */ + abstract public function handlers(); /** Register a hook * @param fun name of the handler (the exact name will be handler_$fun) @@ -35,7 +45,8 @@ abstract class PLModule * 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 handlers + * 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) { @@ -45,15 +56,36 @@ abstract class PLModule 'type' => $type); } + /** Include a 'module-specific' file. + * Module specific includes must be in the in the path modules/{modulename}. + */ + public function load($file) + { + require_once $this->modIncludePath . $file; + } + /* static functions */ + public static function path($modname) + { + global $globals; + if ($modname == 'core') { + $mod_path = $globals->spoolroot . '/core/modules/' . $modname; + } else { + $mod_path = $globals->spoolroot . '/modules/' . $modname; + } + return $mod_path; + } + public static function factory($modname) { - $mod_path = dirname(__FILE__).'/../modules/'.strtolower($modname).'.php'; - $class = ucfirst($modname).'Module'; + $mod_path = self::path($modname); + $class = ucfirst($modname) . 'Module'; - require_once $mod_path; - return new $class(); + require_once $mod_path . '.php'; + $module = new $class(); + $module->modIncludePath = $mod_path . '/'; + return $module; } }