]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/PersonalPage.php
add PdoDbPassUser
[SourceForge/phpwiki.git] / lib / WikiUser / PersonalPage.php
1 <?php //-*-php-*-
2 rcs_id('$Id: PersonalPage.php,v 1.5 2005-02-14 12:28:27 rurban Exp $');
3 /* Copyright (C) 2004 ReiniUrban
4  * This file is part of PhpWiki. Terms and Conditions see LICENSE. (GPL2)
5  */
6
7 /**
8  * This class is only to simplify the auth method dispatcher.
9  * It inherits almost all all methods from _PassUser.
10  */
11 class _PersonalPagePassUser
12 extends _PassUser
13 {
14     var $_authmethod = 'PersonalPage';
15
16     function userExists() {
17         return $this->_HomePagehandle and $this->_HomePagehandle->exists();
18     }
19
20     /** A PersonalPagePassUser requires PASSWORD_LENGTH_MINIMUM.
21      *  BUT if the user already has a homepage with an empty password 
22      *  stored, allow login but warn him to change it.
23      */
24     function checkPass($submitted_password) {
25         if ($this->userExists()) {
26             $stored_password = $this->_prefs->get('passwd');
27             if (empty($stored_password)) {
28                 if (PASSWORD_LENGTH_MINIMUM > 0) {
29                   trigger_error(sprintf(
30                     _("PersonalPage login method:")."\n".
31                     _("You stored an empty password in your '%s' page.")."\n".
32                     _("Your access permissions are only for a BogoUser.")."\n".
33                     _("Please set a password in UserPreferences."),
34                                         $this->_userid), E_USER_WARNING);
35                   $this->_level = WIKIAUTH_BOGO;
36                 } else {
37                   if (!empty($submitted_password))
38                     trigger_error(sprintf(
39                       _("PersonalPage login method:")."\n".
40                       _("You stored an empty password in your '%s' page.")."\n".
41                       _("Given password ignored.")."\n".
42                       _("Please set a password in UserPreferences."),
43                                         $this->_userid), E_USER_WARNING);
44                   $this->_level = WIKIAUTH_USER;
45                 }
46                 return $this->_level;
47             }
48             if ($this->_checkPass($submitted_password, $stored_password))
49                 return ($this->_level = WIKIAUTH_USER);
50             return _PassUser::checkPass($submitted_password);
51         } else {
52             return WIKIAUTH_ANON;
53         }
54     }
55 }
56
57 // $Log: not supported by cvs2svn $
58 // Revision 1.4  2004/12/26 17:11:17  rurban
59 // just copyright
60 //
61 // Revision 1.3  2004/11/05 22:09:39  rurban
62 // empty passwd PersonalPage case
63 //
64 // Revision 1.2  2004/11/05 20:53:36  rurban
65 // login cleanup: better debug msg on failing login,
66 // checked password less immediate login (bogo or anon),
67 // checked olduser pref session error,
68 // better PersonalPage without password warning on minimal password length=0
69 //   (which is default now)
70 //
71 // Revision 1.1  2004/11/01 10:43:58  rurban
72 // seperate PassUser methods into seperate dir (memory usage)
73 // fix WikiUser (old) overlarge data session
74 // remove wikidb arg from various page class methods, use global ->_dbi instead
75 // ...
76 //
77
78 // Local Variables:
79 // mode: php
80 // tab-width: 8
81 // c-basic-offset: 4
82 // c-hanging-comment-ender-p: nil
83 // indent-tabs-mode: nil
84 // End:
85 ?>