]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/PersonalPage.php
Remove rcs_id
[SourceForge/phpwiki.git] / lib / WikiUser / PersonalPage.php
1 <?php //-*-php-*-
2 // $Id$
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
19  * along with PhpWiki; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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     var $_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         if (!$userid) $userid = $this->_userid;
37         $WikiPageName = new WikiPageName($userid);
38         return $WikiPageName->isValid() and ($userid === $WikiPageName->name);
39     }
40
41     function userExists() {
42         return $this->_HomePagehandle and $this->_HomePagehandle->exists();
43     }
44
45     /** A PersonalPagePassUser requires PASSWORD_LENGTH_MINIMUM.
46      *  BUT if the user already has a homepage with an empty password
47      *  stored, allow login but warn him to change it.
48      */
49     function checkPass($submitted_password) {
50         if ($this->userExists()) {
51             $stored_password = $this->_prefs->get('passwd');
52             if (empty($stored_password)) {
53                     if (PASSWORD_LENGTH_MINIMUM > 0) {
54                   trigger_error(sprintf(
55                     _("PersonalPage login method:")."\n".
56                     _("You stored an empty password in your '%s' page.")."\n".
57                     _("Your access permissions are only for a BogoUser.")."\n".
58                     _("Please set a password in UserPreferences."),
59                                         $this->_userid), E_USER_WARNING);
60                   $this->_level = WIKIAUTH_BOGO;
61                     } else {
62                       if (!empty($submitted_password))
63                     trigger_error(sprintf(
64                       _("PersonalPage login method:")."\n".
65                       _("You stored an empty password in your '%s' page.")."\n".
66                       _("Given password ignored.")."\n".
67                       _("Please set a password in UserPreferences."),
68                                         $this->_userid), E_USER_WARNING);
69                   $this->_level = WIKIAUTH_USER;
70                     }
71                 return $this->_level;
72             }
73             if ($this->_checkPass($submitted_password, $stored_password))
74                 return ($this->_level = WIKIAUTH_USER);
75             return _PassUser::checkPass($submitted_password);
76         } else {
77             return WIKIAUTH_ANON;
78         }
79     }
80 }
81
82 // Local Variables:
83 // mode: php
84 // tab-width: 8
85 // c-basic-offset: 4
86 // c-hanging-comment-ender-p: nil
87 // indent-tabs-mode: nil
88 // End:
89 ?>