remove useless functions and stuff.
authorx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 18 Jul 2006 22:52:04 +0000 (22:52 +0000)
committerx2000habouzit <x2000habouzit@839d8a87-29fc-0310-9880-83ba4fa771e5>
Tue, 18 Jul 2006 22:52:04 +0000 (22:52 +0000)
this breaks the wiki currently, but the auth scheme will soon be simplified and disconnected from the
'page' metaphore, and it will be fixed again

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@540 839d8a87-29fc-0310-9880-83ba4fa771e5

13 files changed:
classes/Platal.php
htdocs/wiki.php
include/platal/page.inc.php
include/rss.inc.php
include/wiki.inc.php
include/xnet.inc.php
include/xorg.inc.php
include/xorg/page.inc.php [deleted file]
modules/carnet.php
modules/geoloc.php
modules/profile.php
modules/xnetevents.php
plugins/pmwiki.platalAuth.php

index 88c6fd1..f5553f8 100644 (file)
@@ -96,7 +96,7 @@ class Platal
     {
         global $page;
 
-        new_skinned_page('index.tpl', AUTH_PUBLIC);
+        new_skinned_page('index.tpl');
 
         if (empty($this->path)) {
             $this->path = 'index';
index bb8615e..6db2203 100644 (file)
@@ -19,7 +19,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
-require_once("xorg.inc.php");
+require_once 'xorg.inc.php';
 
 // this page is to create a smarty template page from a wiki file
 // the wiki engine used is pmwiki.
@@ -27,7 +27,7 @@ require_once("xorg.inc.php");
 
 // some page can be seen by everybody (public), but to validate a password
 // if we arrive here before setting new access we need to try an auth
-new_skinned_page('wiki.tpl', Env::has('response') ? AUTH_MDP : AUTH_PUBLIC);
+new_skinned_page('wiki.tpl');
 
 if ($globals->wiki->wikidir) {
     $wikisite = 'xorg';
index 6238430..ccc94d8 100644 (file)
@@ -54,11 +54,6 @@ class PlatalPage extends Smarty
 
         $this->compile_check = !empty($globals->debug);
 
-        if ($type == SKINNED) {
-            $this->register_modifier('escape_html', 'escape_html');
-            $this->default_modifiers[] = '@escape_html';
-        }
-
         $this->_page_type = $type;
         $this->_tpl       = $tpl;
         $this->_errors    = array();
@@ -94,11 +89,6 @@ class PlatalPage extends Smarty
     {
        $this->_tpl       = $tpl;
        $this->_page_type = $type;
-       if ($type == SKINNED) {
-           $this->register_modifier('escape_html', 'escape_html');
-           $this->default_modifiers = Array('@escape_html');
-       }
-
         $this->_page_type = $type;
        $this->assign('xorg_tpl', $tpl);
     }
@@ -118,6 +108,9 @@ class PlatalPage extends Smarty
         if ($this->_page_type == NO_SKIN) {
             $this->display($this->_tpl);
             exit;
+        } else {
+           $this->register_modifier('escape_html', 'escape_html');
+           $this->default_modifiers = Array('@escape_html');
         }
 
         if (!$globals->debug) {
index afe4c86..5bfcffa 100644 (file)
@@ -40,7 +40,7 @@ function to_rss ($s)
 function init_rss($template, $alias, $hash)
 {
     global $page;
-    new_nonhtml_page($template, AUTH_PUBLIC);
+    $page->changeTpl($template, NO_SKIN);
     $page->register_modifier('rss_date', '_rss_encode_date');
     $page->default_modifiers = Array('@to_rss');
 
index 94d8b0b..57a5f50 100644 (file)
@@ -40,7 +40,7 @@ function wiki_pagename() {
 
 function wiki_work_dir() {
     global $globals;
-    return realpath($globals->spoolroot.'htdocs/'.$globals->wiki->workdir);
+    return dirname(__FILE__).'/../htdocs/'.$globals->wiki->workdir;
 }
 
 function wiki_template($n) {
index aea2c12..8978ab0 100644 (file)
@@ -42,16 +42,6 @@ function new_skinned_page($tpl_name)
 }
 
 // }}}
-
-function new_identification_page()
-{
-    global $page;
-
-    new_page('');
-    $page->doAuth(true);
-    $page->useMenu();
-}
-
 // {{{ function new_group_page()
 
 function new_group_page($tpl_name)
index cb86440..209de7c 100644 (file)
@@ -25,60 +25,71 @@ XorgGlobals::init();
 XorgGlobals::setlocale();
 XorgSession::init();
 
-// {{{ function _new_page()
+require_once('platal/page.inc.php');
 
-function _new_page($type, $tpl_name, $min_auth, $admin=false)
+// {{{ class XorgPage
+
+class XorgPage extends PlatalPage
 {
-    global $page, $globals;
-    require_once("xorg/page.inc.php");
-    if ($min_auth == AUTH_PUBLIC && Env::get('force_login') == '1')
-        $min_auth = AUTH_COOKIE;
-    if (!empty($admin)) {
-        $page = new XorgAdmin($tpl_name, $type);
-    } else switch($min_auth) {
-        case AUTH_PUBLIC:
-            $page = new XorgPage($tpl_name, $type);
-            break;
+    // {{{ function XorgPage()
+
+    function XorgPage($tpl, $type=SKINNED)
+    {
+        $this->PlatalPage($tpl, $type);
+    }
 
-        case AUTH_COOKIE:
-            $page = new XorgCookie($tpl_name, $type);
-            break;
+    // }}}
+    // {{{ function run()
 
-        case AUTH_MDP:
-            $page = new XorgAuth($tpl_name, $type);
+    function run()
+    {
+        global $globals;
+        if ($this->_page_type != NO_SKIN) {
+            $this->assign('menu', $globals->menu->menu());
+        }
+        $this->_run('skin/'.S::v('skin'));
     }
 
-    $page->assign('xorg_tpl', $tpl_name);
+    // }}}
 }
 
 // }}}
-function new_identification_page()
-{
-    _new_page(SKINNED, '', AUTH_MDP);
-}
-// {{{ function new_skinned_page()
+// {{{ class XorgAdmin
 
-function new_skinned_page($tpl_name, $min_auth)
+/** Une classe pour les pages réservées aux admins (authentifiés!).
+ */
+class XorgAdmin extends XorgPage
 {
-    _new_page(SKINNED, $tpl_name, $min_auth);
+    // {{{ function XorgAdmin()
+
+    function XorgAdmin($tpl, $type=SKINNED)
+    {
+        $this->XorgPage($tpl, $type);
+        check_perms();
+    }
+
+    // }}}
 }
 
 // }}}
-// {{{ function new_simple_page()
 
-function new_simple_page($tpl_name, $min_auth)
+function _new_page($type, $tpl_name, $admin=false)
 {
     global $page;
-    _new_page(SKINNED, $tpl_name, $min_auth);
-    $page->assign('simple', true);
+    if (!empty($admin)) {
+        $page = new XorgAdmin($tpl_name, $type);
+    } else {
+        $page = new XorgPage($tpl_name, $type);
+    }
+
+    $page->assign('xorg_tpl', $tpl_name);
 }
 
-// }}}
-// {{{ function new_nonhtml_page()
+// {{{ function new_skinned_page()
 
-function new_nonhtml_page($tpl_name, $min_auth)
+function new_skinned_page($tpl_name)
 {
-    _new_page(NO_SKIN, $tpl_name, $min_auth, false);
+    _new_page(SKINNED, $tpl_name);
 }
 
 // }}}
@@ -86,7 +97,7 @@ function new_nonhtml_page($tpl_name, $min_auth)
 
 function new_admin_page($tpl_name)
 {
-    _new_page(SKINNED, $tpl_name, AUTH_MDP, true);
+    _new_page(SKINNED, $tpl_name, true);
 }
 
 // }}}
@@ -101,7 +112,7 @@ function new_admin_table_editor($table, $idfield, $idedit=false)
     global $editor;
     new_admin_page('table-editor.tpl');
     require_once('xorg.table-editor.inc.php');
-    $editor = new XOrgAdminTableEditor($table,$idfield,$idedit);
+    $editor = new XOrgAdminTableEditor($table, $idfield, $idedit);
 }
 
 // }}}
diff --git a/include/xorg/page.inc.php b/include/xorg/page.inc.php
deleted file mode 100644 (file)
index 5bc9e56..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-<?php
-/***************************************************************************
- *  Copyright (C) 2003-2006 Polytechnique.org                              *
- *  http://opensource.polytechnique.org/                                   *
- *                                                                         *
- *  This program is free software; you can redistribute it and/or modify   *
- *  it under the terms of the GNU General Public License as published by   *
- *  the Free Software Foundation; either version 2 of the License, or      *
- *  (at your option) any later version.                                    *
- *                                                                         *
- *  This program is distributed in the hope that it will be useful,        *
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
- *  GNU General Public License for more details.                           *
- *                                                                         *
- *  You should have received a copy of the GNU General Public License      *
- *  along with this program; if not, write to the Free Software            *
- *  Foundation, Inc.,                                                      *
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
- ***************************************************************************/
-
-require_once('platal/page.inc.php');
-
-// {{{ class XorgPage
-
-class XorgPage extends PlatalPage
-{
-    // {{{ function XorgPage()
-
-    function XorgPage($tpl, $type=SKINNED)
-    {
-        $this->PlatalPage($tpl, $type);
-    }
-
-    // }}}
-    // {{{ function run()
-
-    function run()
-    {
-        global $globals;
-        if ($this->_page_type != NO_SKIN) {
-            $this->assign('menu', $globals->menu->menu());
-        }
-        $this->_run('skin/'.S::v('skin'));
-    }
-
-    // }}}
-}
-
-// }}}
-// {{{ class XOrgAuth
-
-/** Une classe pour les pages nécessitant l'authentification.
- * (equivalent de controlauthentification.inc.php)
- */
-class XorgAuth extends XorgPage
-{
-    // {{{ function XorgAuth()
-
-    function XorgAuth($tpl, $type=SKINNED)
-    {
-        $this->XorgPage($tpl, $type);
-    }
-
-    // }}}
-    // {{{ function doAuth()
-
-    function doAuth()
-    {
-        XorgSession::doAuth($this);
-    }
-
-    // }}}
-}
-
-// }}}
-// {{{ class XorgCookie
-
-/** Une classe pour les pages nécessitant l'authentification permanente.
- * (equivalent de controlpermanent.inc.php)
- */
-class XorgCookie extends XorgPage
-{
-    // {{{ function XorgCookie()
-
-    function XorgCookie($tpl, $type=SKINNED)
-    {
-        $this->XorgPage($tpl, $type);
-    }
-
-    // }}}
-    // {{{ function doAuth()
-
-    function doAuth()
-    {
-        XorgSession::doAuthCookie($this);
-    }
-
-    // }}}
-}
-
-// }}}
-// {{{ class XorgAdmin
-
-/** Une classe pour les pages réservées aux admins (authentifiés!).
- */
-class XorgAdmin extends XorgAuth
-{
-    // {{{ function XorgAdmin()
-
-    function XorgAdmin($tpl, $type=SKINNED)
-    {
-        $this->XorgAuth($tpl, $type);
-        check_perms();
-    }
-
-    // }}}
-}
-
-// }}}
-
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
-?>
index 5241b1e..9726946 100644 (file)
@@ -330,7 +330,7 @@ class CarnetModule extends PLModule
 
     function handler_ical(&$page, $user = null, $hash = null, $all = null)
     {
-        new_nonhtml_page('carnet/calendar.tpl', AUTH_PUBLIC);
+        $page->changeTpl('carnet/calendar.tpl', NO_SKIN);
 
         if ($alias && $hash) {
             $res = XDB::query(
index fdb8289..3ea7f4f 100644 (file)
@@ -111,7 +111,7 @@ class GeolocModule extends PLModule
     {
         global $globals;
 
-        new_nonhtml_page('geoloc/geolocInit.tpl', AUTH_COOKIE);
+        $page->changeTpl('geoloc/geolocInit.tpl', NO_SKIN);
 
         header('Content-type: text/xml');
         $page->assign('querystring', $this->_make_qs());
@@ -123,9 +123,7 @@ class GeolocModule extends PLModule
 
         header("Content-type: text/xml");
 
-        new_nonhtml_page('geoloc/getCityInfos.tpl', AUTH_COOKIE);
-        // to debug sql use the next line
-        //new_skinned_page('', AUTH_COOKIE);
+        $page->changeTpl('geoloc/getCityInfos.tpl', NO_SKIN);
 
         require_once('geoloc.inc.php');
         require_once('search.inc.php');
@@ -157,7 +155,7 @@ class GeolocModule extends PLModule
             $page->assign('simple', true);
         } else {
             header("Content-type: text/xml");
-            new_nonhtml_page('geoloc/getData.tpl', AUTH_COOKIE);
+            $page->changeTpl('geoloc/getData.tpl', NO_SKIN);
         }
 
         require_once 'geoloc.inc.php';
index 49a7f59..63b40b6 100644 (file)
@@ -660,7 +660,7 @@ class ProfileModule extends PLModule
             $x = substr($x, 0, strlen($x) - 4);
         }
 
-        new_nonhtml_page('vcard.tpl', AUTH_COOKIE);
+        $page->changeTpl('vcard.tpl', NO_SKIN);
         require_once 'xorg.misc.inc.php';
         require_once 'user.func.inc.php';
 
index 6bb5ef5..f083f6b 100644 (file)
@@ -223,7 +223,7 @@ class XnetEventsModule extends PLModule
         header('Pragma: ');
         header('Cache-Control: ');
 
-        new_nonhtml_page('xnetevents/csv.tpl');
+        $page->changeTpl('xnetevents/csv.tpl', NO_SKIN);
 
         $admin = may_update();
 
index e6974e7..f5a7831 100644 (file)
@@ -108,7 +108,7 @@ function auth_pmwiki_to_smarty($text, $pass)
 // and translate any auth from the wiki to smarty auth
 function AuthPlatal($pagename, $level, $authprompt, $since)
 {
-    global $Conditions;
+    global $Conditions, $page;
     $authUser = false;
     $authPage = false;
 
@@ -157,14 +157,15 @@ function AuthPlatal($pagename, $level, $authprompt, $since)
 
     // if we arrive here, the user doesn't have enough permission to access page
 
+    // FIXME: seems to be broken, will be better soon
+    new_skinned_page('index.tpl');
     // maybe it is because he is not identified
     if ($authprompt && !S::identified())
     {
-        new_identification_page(); 
+        XorgSession::doAuth($page);
     }
 
-    global $page;
-    new_identification_page();
+    XorgSession::doAuth($page);
     if (S::has_perms()) {
         $page->trig('Erreur : page Wiki inutilisable sur plat/al');
     } else {