2 rcs_id('$Id: Db.php,v 1.1 2004-11-01 10:43:58 rurban Exp $');
3 /* Copyright (C) 2004 $ThePhpWikiProgrammingTeam
7 * Baseclass for PearDB and ADODB PassUser's
8 * Authenticate against a database, to be able to use shared users.
9 * internal: no different $DbAuthParams['dsn'] defined, or
10 * external: different $DbAuthParams['dsn']
11 * The magic is done in the symbolic SQL statements in config/config.ini, similar to
14 * We support only the SQL and ADODB backends.
15 * The other WikiDB backends (flat, cvs, dba, ...) should be used for pages,
16 * not for auth stuff. If one would like to use e.g. dba for auth, he should
17 * use PearDB (SQL) with the right $DBAuthParam['auth_dsn'].
18 * (Not supported yet, since we require SQL. SQLite would make since when
19 * it will come to PHP)
23 * Preferences are handled in the parent class _PassUser, because the
24 * previous classes may also use DB pref_select and pref_update.
26 * Flat files auth is handled by the auth method "File".
31 var $_authselect, $_authupdate, $_authcreate;
33 // This can only be called from _PassUser, because the parent class
34 // sets the auth_dbi and pref methods, before this class is initialized.
35 function _DbPassUser($UserName='',$prefs=false) {
37 if ($prefs) $this->_prefs = $prefs;
39 if (!isset($this->_prefs->_method))
40 _PassUser::_PassUser($UserName);
41 elseif (!$this->isValidName($UserName)) {
42 trigger_error(_("Invalid username."),E_USER_WARNING);
45 $this->_authmethod = 'Db';
46 //$this->getAuthDbh();
47 //$this->_auth_crypt_method = @$GLOBALS['DBAuthParams']['auth_crypt_method'];
48 $dbi =& $GLOBALS['request']->_dbi;
49 $dbtype = $dbi->getParam('dbtype');
50 if ($dbtype == 'ADODB') {
51 include_once("lib/WikiUser/AdoDb.php");
52 if (check_php_version(5))
53 return new _AdoDbPassUser($UserName,$this->_prefs);
55 $user = new _AdoDbPassUser($UserName,$this->_prefs);
56 eval("\$this = \$user;");
60 elseif ($dbtype == 'SQL') {
61 include_once("lib/WikiUser/PearDb.php");
62 if (check_php_version(5))
63 return new _PearDbPassUser($UserName,$this->_prefs);
65 $user = new _PearDbPassUser($UserName,$this->_prefs);
66 eval("\$this = \$user;");
73 function mayChangePass() {
74 return !isset($this->_authupdate);
79 // $Log: not supported by cvs2svn $
85 // c-hanging-comment-ender-p: nil
86 // indent-tabs-mode: nil