]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/Session.php
Activated Id substitution for Subversion
[SourceForge/phpwiki.git] / lib / WikiUser / Session.php
1 <?php //-*-php-*-
2 rcs_id('$Id$');
3 /* Copyright (C) 2004 ReiniUrban
4  * This file is part of PhpWiki. Terms and Conditions see LICENSE. (GPL2)
5  */
6
7 /** 
8  * Support reuse of existing user session from another application.
9  * You have to define which session variable holds the userid, and 
10  * at what level is that user then. 1: BogoUser, 2: PassUser
11  *   define('AUTH_SESS_USER','userid');
12  *   define('AUTH_SESS_LEVEL',2);
13  */
14 class _SessionPassUser
15 extends _PassUser
16 {
17     function _SessionPassUser($UserName='',$prefs=false) {
18         if ($prefs) $this->_prefs = $prefs;
19         if (!defined("AUTH_SESS_USER") or !defined("AUTH_SESS_LEVEL")) {
20             trigger_error(
21                 "AUTH_SESS_USER or AUTH_SESS_LEVEL is not defined for the SessionPassUser method",
22                 E_USER_ERROR);
23             exit;
24         }
25         $sess =& $GLOBALS['HTTP_SESSION_VARS'];
26         // user hash: "[user][userid]" or object "user->id"
27         if (strstr(AUTH_SESS_USER,"][")) {
28             $sess = $GLOBALS['HTTP_SESSION_VARS'];
29             // recurse into hashes: "[user][userid]", sess = sess[user] => sess = sess[userid]
30             foreach (split("][",AUTH_SESS_USER) as $v) {
31                 $v = str_replace(array("[","]"),'',$v);
32                 $sess = $sess[$v];
33             }
34             $this->_userid = $sess;
35         } elseif (strstr(AUTH_SESS_USER,"->")) {
36             // object "user->id" (no objects inside hashes supported!)
37             list($obj,$key) = split("->",AUTH_SESS_USER);
38             $this->_userid = $sess[$obj]->$key;
39         } else {
40             $this->_userid = $sess[AUTH_SESS_USER];
41         }
42         if (!isset($this->_prefs->_method))
43            _PassUser::_PassUser($this->_userid);
44         $this->_level = AUTH_SESS_LEVEL;
45         $this->_authmethod = 'Session';
46     }
47     function userExists() {
48         return !empty($this->_userid);
49     }
50     function checkPass($submitted_password) {
51         return $this->userExists() and $this->_level > -1;
52     }
53     function mayChangePass() {
54         return false;
55     }
56 }
57
58 // $Log: not supported by cvs2svn $
59 // Revision 1.2  2004/12/19 00:58:02  rurban
60 // Enforce PASSWORD_LENGTH_MINIMUM in almost all PassUser checks,
61 // Provide an errormessage if so. Just PersonalPage and BogoLogin not.
62 // Simplify httpauth logout handling and set sessions for all methods.
63 // fix main.php unknown index "x" getLevelDescription() warning.
64 //
65 // Revision 1.1  2004/11/01 10:43:58  rurban
66 // seperate PassUser methods into seperate dir (memory usage)
67 // fix WikiUser (old) overlarge data session
68 // remove wikidb arg from various page class methods, use global ->_dbi instead
69 // ...
70 //
71
72 // Local Variables:
73 // mode: php
74 // tab-width: 8
75 // c-basic-offset: 4
76 // c-hanging-comment-ender-p: nil
77 // indent-tabs-mode: nil
78 // End:
79 ?>