remove the too complicated thing for menu, use a good old template
[platal.git] / classes / Platal.php
index 098c0d8..a052193 100644 (file)
@@ -19,8 +19,6 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-define('PL_OK', 0);
-define('PL_NEEDLOGIN', 1);
 define('PL_FORBIDDEN', 403);
 define('PL_NOT_FOUND', 404);
 
@@ -86,22 +84,38 @@ class Platal
         $args    = $this->argv;
         $args[0] = &$page;
 
-        if ($hook['auth'] > Session::get('auth', AUTH_PUBLIC)) {
-            $_SESSION['session']->doAuth($page);
+        if ($hook['auth'] > S::v('auth', AUTH_PUBLIC)) {
+            // FIXME: don't use 'session' object anymore
+            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;
 
-        new_skinned_page('index.tpl', AUTH_PUBLIC);
+        new_skinned_page('index.tpl');
 
         if (empty($this->path)) {
-            $this->__mods['core']->handler_index($page);
-        } else
+            $this->path = 'index';
+        }
+
         switch ($this->call_hook($page)) {
           case PL_FORBIDDEN:
             $this->__mods['core']->handler_403($page);