]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/PersonalPage.php
Remove history
[SourceForge/phpwiki.git] / lib / WikiUser / PersonalPage.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  * 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     /* Very loose checking, since we properly quote the PageName. 
17        Just trim spaces, ... See lib/stdlib.php
18     */
19     function isValidName ($userid = false) {
20         if (!$userid) $userid = $this->_userid;
21         $WikiPageName = new WikiPageName($userid);
22         return $WikiPageName->isValid() and ($userid === $WikiPageName->name);
23     }
24
25     function userExists() {
26         return $this->_HomePagehandle and $this->_HomePagehandle->exists();
27     }
28
29     /** A PersonalPagePassUser requires PASSWORD_LENGTH_MINIMUM.
30      *  BUT if the user already has a homepage with an empty password 
31      *  stored, allow login but warn him to change it.
32      */
33     function checkPass($submitted_password) {
34         if ($this->userExists()) {
35             $stored_password = $this->_prefs->get('passwd');
36             if (empty($stored_password)) {
37                 if (PASSWORD_LENGTH_MINIMUM > 0) {
38                   trigger_error(sprintf(
39                     _("PersonalPage login method:")."\n".
40                     _("You stored an empty password in your '%s' page.")."\n".
41                     _("Your access permissions are only for a BogoUser.")."\n".
42                     _("Please set a password in UserPreferences."),
43                                         $this->_userid), E_USER_WARNING);
44                   $this->_level = WIKIAUTH_BOGO;
45                 } else {
46                   if (!empty($submitted_password))
47                     trigger_error(sprintf(
48                       _("PersonalPage login method:")."\n".
49                       _("You stored an empty password in your '%s' page.")."\n".
50                       _("Given password ignored.")."\n".
51                       _("Please set a password in UserPreferences."),
52                                         $this->_userid), E_USER_WARNING);
53                   $this->_level = WIKIAUTH_USER;
54                 }
55                 return $this->_level;
56             }
57             if ($this->_checkPass($submitted_password, $stored_password))
58                 return ($this->_level = WIKIAUTH_USER);
59             return _PassUser::checkPass($submitted_password);
60         } else {
61             return WIKIAUTH_ANON;
62         }
63     }
64 }
65
66 // Local Variables:
67 // mode: php
68 // tab-width: 8
69 // c-basic-offset: 4
70 // c-hanging-comment-ender-p: nil
71 // indent-tabs-mode: nil
72 // End:
73 ?>