]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/WikiUser/IMAP.php
Remove rcs_id
[SourceForge/phpwiki.git] / lib / WikiUser / IMAP.php
1 <?php //-*-php-*-
2 // $Id$
3 /*
4  * Copyright (C) 2004 $ThePhpWikiProgrammingTeam
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 class _IMAPPassUser
24 extends _PassUser
25 /**
26  * Define the var IMAP_AUTH_HOST in config/config.ini (with port probably)
27  *
28  * Preferences are handled in _PassUser
29  */
30 {
31     function checkPass($submitted_password) {
32         if (!$this->isValidName()) {
33             if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => failed isValidName", E_USER_WARNING);
34             trigger_error(_("Invalid username."),E_USER_WARNING);
35             return $this->_tryNextPass($submitted_password);
36         }
37         if (!$this->_checkPassLength($submitted_password)) {
38             if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => failed checkPassLength", E_USER_WARNING);
39             return WIKIAUTH_FORBIDDEN;
40         }
41         $userid = $this->_userid;
42         $mbox = @imap_open( "{" . IMAP_AUTH_HOST . "}",
43                             $userid, $submitted_password, OP_HALFOPEN );
44         if ($mbox) {
45             imap_close($mbox);
46             $this->_authmethod = 'IMAP';
47             if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => ok", E_USER_WARNING);
48             $this->_level = WIKIAUTH_USER;
49             return $this->_level;
50         } else {
51             if ($submitted_password != "") { // if LENGTH 0 is allowed
52                 trigger_error(_("Unable to connect to IMAP server "). IMAP_AUTH_HOST,
53                               E_USER_WARNING);
54             }
55         }
56         if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::checkPass => wrong", E_USER_WARNING);
57
58         return $this->_tryNextPass($submitted_password);
59     }
60
61     //CHECKME: this will not be okay for the auth policy strict
62     function userExists() {
63         return true;
64
65         if ($this->checkPass($this->_prefs->get('passwd'))) {
66             if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::userExists => true (pass ok)", E_USER_WARNING);
67             return true;
68         }
69         if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::userExists => false (pass wrong)", E_USER_WARNING);
70         return $this->_tryNextUser();
71     }
72
73     function mayChangePass() {
74         if (DEBUG & _DEBUG_LOGIN) trigger_error(get_class($this)."::mayChangePass => false", E_USER_WARNING);
75         return false;
76     }
77 }
78
79 // Local Variables:
80 // mode: php
81 // tab-width: 8
82 // c-basic-offset: 4
83 // c-hanging-comment-ender-p: nil
84 // indent-tabs-mode: nil
85 // End:
86 ?>