]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/PersonalPage.php
var --> public
[SourceForge/phpwiki.git] / lib / WikiUser / PersonalPage.php
1 <?php
2
3 /*
4  * Copyright (C) 2004 ReiniUrban
5  *
6  * This file is part of PhpWiki.
7  *
8  * PhpWiki is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * PhpWiki is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22
23 /**
24  * This class is only to simplify the auth method dispatcher.
25  * It inherits almost all all methods from _PassUser.
26  */
27 class _PersonalPagePassUser
28     extends _PassUser
29 {
30     public $_authmethod = 'PersonalPage';
31
32     /* Very loose checking, since we properly quote the PageName.
33        Just trim spaces, ... See lib/stdlib.php
34     */
35     function isValidName($userid = false)
36     {
37         if (!$userid) $userid = $this->_userid;
38         $WikiPageName = new WikiPageName($userid);
39         return $WikiPageName->isValid() and ($userid === $WikiPageName->name);
40     }
41
42     function userExists()
43     {
44         return $this->_HomePagehandle and $this->_HomePagehandle->exists();
45     }
46
47     /** A PersonalPagePassUser requires PASSWORD_LENGTH_MINIMUM.
48      *  BUT if the user already has a homepage with an empty password
49      *  stored, allow login but warn him to change it.
50      */
51     function checkPass($submitted_password)
52     {
53         if ($this->userExists()) {
54             $stored_password = $this->_prefs->get('passwd');
55             if (empty($stored_password)) {
56                 if (PASSWORD_LENGTH_MINIMUM > 0) {
57                     trigger_error(sprintf(
58                         _("PersonalPage login method:") . "\n" .
59                             _("You stored an empty password in your ā€œ%sā€ page.") . "\n" .
60                             _("Your access permissions are only for a BogoUser.") . "\n" .
61                             _("Please set a password in UserPreferences."),
62                         $this->_userid), E_USER_WARNING);
63                     $this->_level = WIKIAUTH_BOGO;
64                 } else {
65                     if (!empty($submitted_password))
66                         trigger_error(sprintf(
67                             _("PersonalPage login method:") . "\n" .
68                                 _("You stored an empty password in your ā€œ%sā€ page.") . "\n" .
69                                 _("Given password ignored.") . "\n" .
70                                 _("Please set a password in UserPreferences."),
71                             $this->_userid), E_USER_WARNING);
72                     $this->_level = WIKIAUTH_USER;
73                 }
74                 return $this->_level;
75             }
76             if ($this->_checkPass($submitted_password, $stored_password))
77                 return ($this->_level = WIKIAUTH_USER);
78             return _PassUser::checkPass($submitted_password);
79         } else {
80             return WIKIAUTH_ANON;
81         }
82     }
83 }
84
85 // Local Variables:
86 // mode: php
87 // tab-width: 8
88 // c-basic-offset: 4
89 // c-hanging-comment-ender-p: nil
90 // indent-tabs-mode: nil
91 // End: