From: Geoffrey T. D. <da...@us...> - 2002-09-18 22:11:24
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv24511/lib Modified Files: Request.php WikiUser.php main.php Log Message: Minor cleanup/refactors. Index: Request.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/Request.php,v retrieving revision 1.21 retrieving revision 1.22 diff -u -2 -b -p -d -r1.21 -r1.22 --- Request.php 12 Sep 2002 20:56:29 -0000 1.21 +++ Request.php 18 Sep 2002 22:11:21 -0000 1.22 @@ -24,8 +24,5 @@ class Request { } - // Defer session_start until we decided to load DB_Session (or not). - if (! USE_DB_SESSION) { $this->session = new Request_SessionVars; - } $this->cookies = new Request_CookieVars; Index: WikiUser.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiUser.php,v retrieving revision 1.25 retrieving revision 1.26 diff -u -2 -b -p -d -r1.25 -r1.26 --- WikiUser.php 18 Sep 2002 18:35:24 -0000 1.25 +++ WikiUser.php 18 Sep 2002 22:11:21 -0000 1.26 @@ -534,5 +534,8 @@ class _UserPreference_theme extends _Use function update ($newvalue) { + global $Theme; include($this->_themefile($value)); + if (empty($Theme)) + include($this->_themefile('default')); } Index: main.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/main.php,v retrieving revision 1.84 retrieving revision 1.85 diff -u -2 -b -p -d -r1.84 -r1.85 --- main.php 18 Sep 2002 19:29:43 -0000 1.84 +++ main.php 18 Sep 2002 22:11:21 -0000 1.85 @@ -11,5 +11,5 @@ require_once('lib/WikiDB.php'); if (USE_DB_SESSION) { - require_once('lib/DB_Session.php'); + include_once('lib/DB_Session.php'); } @@ -18,11 +18,12 @@ class WikiRequest extends Request { function WikiRequest () { - $this->Request(); if (USE_DB_SESSION) { $this->_dbi = $this->getDbh(); - new DB_Session($this->_dbi->_backend->_dbh, $GLOBALS['DBParams']['db_session_table']); - $this->session = new Request_SessionVars; + new DB_Session($this->_dbi->_backend->_dbh, + $GLOBALS['DBParams']['db_session_table']); } + $this->Request(); + // Normalize args... $this->setArg('pagename', $this->_deducePagename()); @@ -35,9 +36,23 @@ class WikiRequest extends Request { } + function initializeTheme () { + global $Theme; + + // Load theme + if ($user_theme = $this->getPref('theme')) + include_once("themes/$user_theme/themeinfo.php"); + if (empty($Theme) and defined ('THEME')) + include_once("themes/" . THEME . "/themeinfo.php"); + if (empty($Theme)) + include_once("themes/default/themeinfo.php"); + assert(!empty($Theme)); + } + + // This really maybe should be part of the constructor, but since it // may involve HTML/template output, the global $request really needs // to be initialized before we do this stuff. function updateAuthAndPrefs () { - global $Theme; + // Handle preference updates, an authentication requests, if any. if ($new_prefs = $this->getArg('pref')) { @@ -45,11 +60,12 @@ class WikiRequest extends Request { if ($this->isPost() and !empty($new_prefs['passwd']) and ($new_prefs['passwd2'] != $new_prefs['passwd'])) { + // FIXME: enh? $this->_prefs->set('passwd',''); // $this->_prefs->set('passwd2',''); // This is not stored anyway - include_once("themes/" . THEME . "/themeinfo.php"); return false; } foreach ($new_prefs as $key => $val) { if ($key == 'passwd') { + // FIXME: enh? $val = crypt('passwd'); } @@ -58,8 +74,12 @@ class WikiRequest extends Request { } + // FIXME: need to move authentication request processing + // up to be before pref request processing, I think, + // since logging in may change which preferences + // we're talking about... + // Handle authentication request, if any. if ($auth_args = $this->getArg('auth')) { $this->setArg('auth', false); - include_once("themes/" . THEME . "/themeinfo.php"); $this->_handleAuthRequest($auth_args); // possible NORETURN } @@ -67,5 +87,4 @@ class WikiRequest extends Request { // If not auth request, try to sign in as saved user. if (($saved_user = $this->getPref('userid')) != false) { - include_once("themes/" . THEME . "/themeinfo.php"); $this->_signIn($saved_user); } @@ -73,22 +92,8 @@ class WikiRequest extends Request { // Save preferences in session and cookie + // FIXME: hey! what about anonymous users? Can't they have + // preferences too? $id_only = true; $this->_user->setPreferences($this->_prefs, $id_only); - /* - if ($theme = $this->getPref('theme') ) { - // Load user-defined theme - include_once("themes/$theme/themeinfo.php"); - } else { - // site theme - include_once("themes/" . THEME . "/themeinfo.php"); - } - */ - if (empty($Theme)) { - include_once("themes/" . THEME . "/themeinfo.php"); - } - if (empty($Theme)) { - include_once("themes/default/themeinfo.php"); - } - assert(!empty($Theme)); // Ensure user has permissions for action @@ -630,4 +635,5 @@ function main () { $request = new WikiRequest(); + $request->initializeTheme(); $request->updateAuthAndPrefs(); |