array_unshift($modules, 'core');
foreach ($modules as $module) {
- $this->__mods[$module] = $m = PLModule::factory($this, $module);
+ $this->__mods[$module] = $m = PLModule::factory($module);
$this->__hooks += $m->handlers();
}
}
+ function pl_self($n = null)
+ {
+ if (is_null($n))
+ return $this->path;
+
+ if ($n >= 0)
+ return join('/', array_slice($this->argv, 0, $n + 1));
+
+ if ($n <= -count($this->argv))
+ return $this->argv[0];
+
+ return join('/', array_slice($this->argv, 0, $n));
+ }
+
function find_hook()
{
$p = $this->path;
if ($hook['auth'] > S::v('auth', AUTH_PUBLIC)) {
// FIXME: don't use 'session' object anymore
- $_SESSION['session']->doAuth();
+ if (!$_SESSION['session']->doAuth()) {
+ $this->force_login($page);
+ }
}
return call_user_func_array($hook['hook'], $args);
}
+ function force_login(&$page)
+ {
+ if (S::logged() and !$new_name) {
+ $page->changeTpl('password_prompt_logged.tpl');
+ $page->addJsLink('javascript/do_challenge_response_logged.js');
+ } else {
+ $page->changeTpl('password_prompt.tpl');
+ $page->addJsLink('javascript/do_challenge_response.js');
+ }
+ $page->run();
+ }
+
function run()
{
global $page;