Add imap and authimap support
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2370 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
83
authimap.php
Normal file
83
authimap.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
/** DomFramework
|
||||
@package domframework
|
||||
@author Dominique Fournier <dominique@fournier38.fr> */
|
||||
|
||||
require_once ("domframework/auth.php");
|
||||
require_once ("domframework/imap.php");
|
||||
|
||||
/** User authentication against IMAP server */
|
||||
class authimap extends auth
|
||||
{
|
||||
/** IMAP server */
|
||||
public $imapServer = "localhost";
|
||||
/** IMAP TCP port (143 by default) */
|
||||
public $imapPort = 143;
|
||||
/** IMAP SSL connection */
|
||||
public $imapSSL = false;
|
||||
/** IMAP SSL CheckCertificate */
|
||||
public $imapSSLCheckCertificates = true;
|
||||
|
||||
/** Check the availablity of the IMAP support in PHP */
|
||||
function __construct ()
|
||||
{
|
||||
if (!function_exists ("imap_open"))
|
||||
throw new Exception ("IMAP support unavailable in PHP", 500);
|
||||
}
|
||||
|
||||
/** Establish the connection to IMAP server. Don't do anything as the
|
||||
needed parameters are username and password */
|
||||
public function connect ()
|
||||
{
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
/** Try to authenticate the email/password of the user
|
||||
@param string $email Email to authenticate
|
||||
@param string $password Password to authenticate */
|
||||
public function authentication ($email, $password)
|
||||
{
|
||||
$imap = new imap ($this->imapServer, $this->imapPort,
|
||||
$email, $password,
|
||||
$this->imapSSL, $this->imapSSLCheckCertificates);
|
||||
// Let the throw Exception be catched by the parent
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Return all the parameters recorded for the authenticate user */
|
||||
public function getdetails ()
|
||||
{
|
||||
throw new Exception (dgettext("domframework",
|
||||
"Can't get details for IMAP users"), 405);
|
||||
}
|
||||
|
||||
/** Method to change the password
|
||||
@param string $oldpassword The old password (to check if the user have the
|
||||
rights to change the password)
|
||||
@param string $newpassword The new password to be recorded */
|
||||
public function changepassword ($oldpassword, $newpassword)
|
||||
{
|
||||
throw new Exception (dgettext("domframework",
|
||||
"The password can't be change for IMAP users"), 405);
|
||||
}
|
||||
|
||||
/** Method to overwrite the password (without oldpassword check)
|
||||
Must be reserved to the administrators. For the users, use changepassword
|
||||
method
|
||||
@param string $email the user identifier to select
|
||||
@param string $newpassword The new password to be recorded */
|
||||
public function overwritepassword ($email, $newpassword)
|
||||
{
|
||||
throw new exception (dgettext("domframework",
|
||||
"The password can't be overwrite for IMAP users"),
|
||||
405);
|
||||
}
|
||||
|
||||
/** List all the users available in the database
|
||||
Return firstname, lastname, mail, with mail is an array */
|
||||
public function listusers ()
|
||||
{
|
||||
throw new Exception (dgettext("domframework",
|
||||
"Can't get list of users for IMAP server"), 405);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user