From 801fcad813666310da1ca5b6f07f91cfed1abbee Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Tue, 18 Jul 2006 22:52:04 +0000 Subject: [PATCH] remove useless functions and stuff. 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 --- classes/Platal.php | 2 +- htdocs/wiki.php | 4 +- include/platal/page.inc.php | 13 ++--- include/rss.inc.php | 2 +- include/wiki.inc.php | 2 +- include/xnet.inc.php | 10 ---- include/xorg.inc.php | 81 ++++++++++++++++------------ include/xorg/page.inc.php | 123 ------------------------------------------ modules/carnet.php | 2 +- modules/geoloc.php | 8 ++- modules/profile.php | 2 +- modules/xnetevents.php | 2 +- plugins/pmwiki.platalAuth.php | 9 ++-- 13 files changed, 65 insertions(+), 195 deletions(-) delete mode 100644 include/xorg/page.inc.php diff --git a/classes/Platal.php b/classes/Platal.php index 88c6fd1..f5553f8 100644 --- a/classes/Platal.php +++ b/classes/Platal.php @@ -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'; diff --git a/htdocs/wiki.php b/htdocs/wiki.php index bb8615e..6db2203 100644 --- a/htdocs/wiki.php +++ b/htdocs/wiki.php @@ -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'; diff --git a/include/platal/page.inc.php b/include/platal/page.inc.php index 6238430..ccc94d8 100644 --- a/include/platal/page.inc.php +++ b/include/platal/page.inc.php @@ -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) { diff --git a/include/rss.inc.php b/include/rss.inc.php index afe4c86..5bfcffa 100644 --- a/include/rss.inc.php +++ b/include/rss.inc.php @@ -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'); diff --git a/include/wiki.inc.php b/include/wiki.inc.php index 94d8b0b..57a5f50 100644 --- a/include/wiki.inc.php +++ b/include/wiki.inc.php @@ -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) { diff --git a/include/xnet.inc.php b/include/xnet.inc.php index aea2c12..8978ab0 100644 --- a/include/xnet.inc.php +++ b/include/xnet.inc.php @@ -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) diff --git a/include/xorg.inc.php b/include/xorg.inc.php index cb86440..209de7c 100644 --- a/include/xorg.inc.php +++ b/include/xorg.inc.php @@ -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 index 5bc9e56..0000000 --- a/include/xorg/page.inc.php +++ /dev/null @@ -1,123 +0,0 @@ -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: -?> diff --git a/modules/carnet.php b/modules/carnet.php index 5241b1e..9726946 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -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( diff --git a/modules/geoloc.php b/modules/geoloc.php index fdb8289..3ea7f4f 100644 --- a/modules/geoloc.php +++ b/modules/geoloc.php @@ -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'; diff --git a/modules/profile.php b/modules/profile.php index 49a7f59..63b40b6 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -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'; diff --git a/modules/xnetevents.php b/modules/xnetevents.php index 6bb5ef5..f083f6b 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -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(); diff --git a/plugins/pmwiki.platalAuth.php b/plugins/pmwiki.platalAuth.php index e6974e7..f5a7831 100644 --- a/plugins/pmwiki.platalAuth.php +++ b/plugins/pmwiki.platalAuth.php @@ -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 { -- 2.1.4