mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 08:23:12 +01:00
* emailadmin: use connection timeout preference in openConnection calls, and increase defaulttimeout if applicable;
This commit is contained in:
parent
7f3e8b6ce8
commit
f51f5f50f3
@ -31,10 +31,10 @@ class defaultimap extends Net_IMAP
|
|||||||
* Capabilities of this class (pipe-separated): default, sieve, admin, logintypeemail
|
* Capabilities of this class (pipe-separated): default, sieve, admin, logintypeemail
|
||||||
*/
|
*/
|
||||||
const CAPABILITIES = 'default|sieve';
|
const CAPABILITIES = 'default|sieve';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ImapServerId
|
* ImapServerId
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
var $ImapServerId;
|
var $ImapServerId;
|
||||||
@ -45,35 +45,35 @@ class defaultimap extends Net_IMAP
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $adminPassword;
|
var $adminPassword;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the username to be used for admin connections
|
* the username to be used for admin connections
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $adminUsername;
|
var $adminUsername;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* enable encryption
|
* enable encryption
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
var $encryption;
|
var $encryption;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the hostname/ip address of the imap server
|
* the hostname/ip address of the imap server
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $host;
|
var $host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the password for the user
|
* the password for the user
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $password;
|
var $password;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the port of the imap server
|
* the port of the imap server
|
||||||
*
|
*
|
||||||
@ -101,7 +101,7 @@ class defaultimap extends Net_IMAP
|
|||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
var $validatecert;
|
var $validatecert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the mailbox delimiter
|
* the mailbox delimiter
|
||||||
*
|
*
|
||||||
@ -122,7 +122,7 @@ class defaultimap extends Net_IMAP
|
|||||||
* @var unknown_type
|
* @var unknown_type
|
||||||
*/
|
*/
|
||||||
var $mbAvailable;
|
var $mbAvailable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mailboxes which get automatic created for new accounts (INBOX == '')
|
* Mailboxes which get automatic created for new accounts (INBOX == '')
|
||||||
*
|
*
|
||||||
@ -130,8 +130,8 @@ class defaultimap extends Net_IMAP
|
|||||||
*/
|
*/
|
||||||
var $imapLoginType;
|
var $imapLoginType;
|
||||||
var $defaultDomain;
|
var $defaultDomain;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* disable internal conversion from/to ut7
|
* disable internal conversion from/to ut7
|
||||||
* get's used by Net_IMAP
|
* get's used by Net_IMAP
|
||||||
@ -144,24 +144,24 @@ class defaultimap extends Net_IMAP
|
|||||||
* a debug switch
|
* a debug switch
|
||||||
*/
|
*/
|
||||||
var $debug = false;
|
var $debug = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sieve available
|
* Sieve available
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
var $enableSieve = false;
|
var $enableSieve = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hostname / IP of sieve host
|
* Hostname / IP of sieve host
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $sieveHost;
|
var $sieveHost;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Port of Sieve service
|
* Port of Sieve service
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
var $sievePort = 2000;
|
var $sievePort = 2000;
|
||||||
@ -171,14 +171,14 @@ class defaultimap extends Net_IMAP
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
if (function_exists('mb_convert_encoding')) {
|
if (function_exists('mb_convert_encoding')) {
|
||||||
$this->mbAvailable = TRUE;
|
$this->mbAvailable = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->restoreSessionData();
|
$this->restoreSessionData();
|
||||||
|
|
||||||
// construtor for Net_IMAP stuff
|
// construtor for Net_IMAP stuff
|
||||||
$this->Net_IMAPProtocol();
|
$this->Net_IMAPProtocol();
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ class defaultimap extends Net_IMAP
|
|||||||
{
|
{
|
||||||
#$this->openConnection($this->isAdminConnection); // we need to re-connect
|
#$this->openConnection($this->isAdminConnection); // we need to re-connect
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a account on the imap server
|
* adds a account on the imap server
|
||||||
*
|
*
|
||||||
@ -223,7 +223,7 @@ class defaultimap extends Net_IMAP
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function disconnect()
|
function disconnect()
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__.function_backtrace());
|
//error_log(__METHOD__.function_backtrace());
|
||||||
@ -231,7 +231,7 @@ class defaultimap extends Net_IMAP
|
|||||||
if( PEAR::isError($retval)) error_log(__METHOD__.$retval->message);
|
if( PEAR::isError($retval)) error_log(__METHOD__.$retval->message);
|
||||||
$this->_connected = false;
|
$this->_connected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* converts a foldername from current system charset to UTF7
|
* converts a foldername from current system charset to UTF7
|
||||||
*
|
*
|
||||||
@ -248,38 +248,38 @@ class defaultimap extends Net_IMAP
|
|||||||
// we can encode only from ISO 8859-1
|
// we can encode only from ISO 8859-1
|
||||||
return imap_utf7_encode($_folderName);
|
return imap_utf7_encode($_folderName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the supported capabilities of the imap server
|
* returns the supported capabilities of the imap server
|
||||||
* return false if the imap server does not support capabilities
|
* return false if the imap server does not support capabilities
|
||||||
*
|
*
|
||||||
* @return array the supported capabilites
|
* @return array the supported capabilites
|
||||||
*/
|
*/
|
||||||
function getCapabilities()
|
function getCapabilities()
|
||||||
{
|
{
|
||||||
if(!is_array($this->sessionData['capabilities'][$this->host])) {
|
if(!is_array($this->sessionData['capabilities'][$this->host])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->sessionData['capabilities'][$this->host];
|
return $this->sessionData['capabilities'][$this->host];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the delimiter used by the current imap server
|
* return the delimiter used by the current imap server
|
||||||
*
|
*
|
||||||
* @return string the delimimiter
|
* @return string the delimimiter
|
||||||
*/
|
*/
|
||||||
function getDelimiter()
|
function getDelimiter()
|
||||||
{
|
{
|
||||||
return isset($this->sessionData['delimiter'][$this->host]) ? $this->sessionData['delimiter'][$this->host] : $this->mailboxDelimiter;
|
return isset($this->sessionData['delimiter'][$this->host]) ? $this->sessionData['delimiter'][$this->host] : $this->mailboxDelimiter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create transport string
|
* Create transport string
|
||||||
*
|
*
|
||||||
* @return string the transportstring
|
* @return string the transportstring
|
||||||
*/
|
*/
|
||||||
function _getTransportString()
|
function _getTransportString()
|
||||||
{
|
{
|
||||||
if($this->encryption == 2) {
|
if($this->encryption == 2) {
|
||||||
$connectionString = "tls://". $this->host;
|
$connectionString = "tls://". $this->host;
|
||||||
@ -289,7 +289,7 @@ class defaultimap extends Net_IMAP
|
|||||||
// no tls
|
// no tls
|
||||||
$connectionString = $this->host;
|
$connectionString = $this->host;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $connectionString;
|
return $connectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ class defaultimap extends Net_IMAP
|
|||||||
*
|
*
|
||||||
* @return string the transportstring
|
* @return string the transportstring
|
||||||
*/
|
*/
|
||||||
function _getTransportOptions()
|
function _getTransportOptions()
|
||||||
{
|
{
|
||||||
if($this->validatecert === false) {
|
if($this->validatecert === false) {
|
||||||
if($this->encryption == 2) {
|
if($this->encryption == 2) {
|
||||||
@ -333,7 +333,7 @@ class defaultimap extends Net_IMAP
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -360,7 +360,7 @@ class defaultimap extends Net_IMAP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'uidNumber':
|
case 'uidNumber':
|
||||||
$_username = 'u'.$GLOBALS['egw']->accounts->name2id($_username);
|
$_username = 'u'.$GLOBALS['egw']->accounts->name2id($_username);
|
||||||
break;
|
break;
|
||||||
@ -371,24 +371,24 @@ class defaultimap extends Net_IMAP
|
|||||||
/**
|
/**
|
||||||
* Create mailbox string from given mailbox-name and user-name
|
* Create mailbox string from given mailbox-name and user-name
|
||||||
*
|
*
|
||||||
* @param string $_folderName=''
|
* @param string $_folderName=''
|
||||||
* @return string utf-7 encoded (done in getMailboxName)
|
* @return string utf-7 encoded (done in getMailboxName)
|
||||||
*/
|
*/
|
||||||
function getUserMailboxString($_username, $_folderName='')
|
function getUserMailboxString($_username, $_folderName='')
|
||||||
{
|
{
|
||||||
$nameSpaces = $this->getNameSpaces();
|
$nameSpaces = $this->getNameSpaces();
|
||||||
|
|
||||||
if(!isset($nameSpaces['others'])) {
|
if(!isset($nameSpaces['others'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$_username = $this->getMailBoxUserName($_username);
|
$_username = $this->getMailBoxUserName($_username);
|
||||||
if($this->loginType == 'vmailmgr' || $this->loginType == 'email' || $this->loginType == 'uidNumber') {
|
if($this->loginType == 'vmailmgr' || $this->loginType == 'email' || $this->loginType == 'uidNumber') {
|
||||||
$_username .= '@'. $this->domainName;
|
$_username .= '@'. $this->domainName;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mailboxString = $nameSpaces['others'][0]['name'] . $_username . (!empty($_folderName) ? $nameSpaces['others'][0]['delimiter'] . $_folderName : '');
|
$mailboxString = $nameSpaces['others'][0]['name'] . $_username . (!empty($_folderName) ? $nameSpaces['others'][0]['delimiter'] . $_folderName : '');
|
||||||
|
|
||||||
return $mailboxString;
|
return $mailboxString;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -396,7 +396,7 @@ class defaultimap extends Net_IMAP
|
|||||||
*
|
*
|
||||||
* @return array array containing information about namespace
|
* @return array array containing information about namespace
|
||||||
*/
|
*/
|
||||||
function getNameSpaces()
|
function getNameSpaces()
|
||||||
{
|
{
|
||||||
if(!$this->_connected) {
|
if(!$this->_connected) {
|
||||||
return false;
|
return false;
|
||||||
@ -420,12 +420,12 @@ class defaultimap extends Net_IMAP
|
|||||||
if(is_array($lNameSpace['others'])) {
|
if(is_array($lNameSpace['others'])) {
|
||||||
$result['others'] = $lNameSpace['others'];
|
$result['others'] = $lNameSpace['others'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_array($lNameSpace['shared'])) {
|
if(is_array($lNameSpace['shared'])) {
|
||||||
$result['shared'] = $lNameSpace['shared'];
|
$result['shared'] = $lNameSpace['shared'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$this->hasCapability('NAMESPACE') || $retrieveDefault) {
|
if (!$this->hasCapability('NAMESPACE') || $retrieveDefault) {
|
||||||
$delimiter = $this->getHierarchyDelimiter();
|
$delimiter = $this->getHierarchyDelimiter();
|
||||||
if( PEAR::isError($delimiter)) $delimiter = '/';
|
if( PEAR::isError($delimiter)) $delimiter = '/';
|
||||||
@ -440,7 +440,7 @@ class defaultimap extends Net_IMAP
|
|||||||
$nameSpace[$this->ImapServerId] = $result;
|
$nameSpace[$this->ImapServerId] = $result;
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the quota for given foldername
|
* returns the quota for given foldername
|
||||||
* gets quota for the current user only
|
* gets quota for the current user only
|
||||||
@ -448,22 +448,22 @@ class defaultimap extends Net_IMAP
|
|||||||
* @param string $_folderName
|
* @param string $_folderName
|
||||||
* @return string the current quota for this folder
|
* @return string the current quota for this folder
|
||||||
*/
|
*/
|
||||||
# function getQuota($_folderName)
|
# function getQuota($_folderName)
|
||||||
# {
|
# {
|
||||||
# if(!is_resource($this->mbox)) {
|
# if(!is_resource($this->mbox)) {
|
||||||
# $this->openConnection();
|
# $this->openConnection();
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# if(function_exists('imap_get_quotaroot') && $this->supportsCapability('QUOTA')) {
|
# if(function_exists('imap_get_quotaroot') && $this->supportsCapability('QUOTA')) {
|
||||||
# $quota = @imap_get_quotaroot($this->mbox, $this->encodeFolderName($_folderName));
|
# $quota = @imap_get_quotaroot($this->mbox, $this->encodeFolderName($_folderName));
|
||||||
# if(is_array($quota) && isset($quota['STORAGE'])) {
|
# if(is_array($quota) && isset($quota['STORAGE'])) {
|
||||||
# return $quota['STORAGE'];
|
# return $quota['STORAGE'];
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
#
|
#
|
||||||
# return false;
|
# return false;
|
||||||
# }
|
# }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the quota for another user
|
* return the quota for another user
|
||||||
* used by admin connections only
|
* used by admin connections only
|
||||||
@ -471,11 +471,11 @@ class defaultimap extends Net_IMAP
|
|||||||
* @param string $_username
|
* @param string $_username
|
||||||
* @return string the quota for specified user
|
* @return string the quota for specified user
|
||||||
*/
|
*/
|
||||||
function getQuotaByUser($_username)
|
function getQuotaByUser($_username)
|
||||||
{
|
{
|
||||||
$mailboxName = $this->getUserMailboxString($_username);
|
$mailboxName = $this->getUserMailboxString($_username);
|
||||||
//error_log(__METHOD__.$mailboxName);
|
//error_log(__METHOD__.$mailboxName);
|
||||||
$storageQuota = $this->getStorageQuota($mailboxName);
|
$storageQuota = $this->getStorageQuota($mailboxName);
|
||||||
//error_log(__METHOD__.$_username);
|
//error_log(__METHOD__.$_username);
|
||||||
//error_log(__METHOD__.$mailboxName);
|
//error_log(__METHOD__.$mailboxName);
|
||||||
if ( PEAR::isError($storageQuota)) error_log(__METHOD__.$storageQuota->message);
|
if ( PEAR::isError($storageQuota)) error_log(__METHOD__.$storageQuota->message);
|
||||||
@ -485,20 +485,20 @@ class defaultimap extends Net_IMAP
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns information about a user
|
* returns information about a user
|
||||||
*
|
*
|
||||||
* Only a stub, as admin connection requires, which is only supported for Cyrus
|
* Only a stub, as admin connection requires, which is only supported for Cyrus
|
||||||
*
|
*
|
||||||
* @param string $_username
|
* @param string $_username
|
||||||
* @return array userdata
|
* @return array userdata
|
||||||
*/
|
*/
|
||||||
function getUserData($_username)
|
function getUserData($_username)
|
||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* opens a connection to a imap server
|
* opens a connection to a imap server
|
||||||
*
|
*
|
||||||
@ -511,8 +511,14 @@ class defaultimap extends Net_IMAP
|
|||||||
static $supportedAuthMethods;
|
static $supportedAuthMethods;
|
||||||
//error_log(__METHOD__.function_backtrace());
|
//error_log(__METHOD__.function_backtrace());
|
||||||
//error_log(__METHOD__.__LINE__.($_adminConnection?' Adminconnection':' ').array2string($this));
|
//error_log(__METHOD__.__LINE__.($_adminConnection?' Adminconnection':' ').array2string($this));
|
||||||
|
$timeout = felamimail_bo::getTimeOut();
|
||||||
|
// either there is a $_timeout given with the openConnection call, or not, if there is a timeout
|
||||||
|
// set in prefs greater then the timeout given, use this one
|
||||||
|
// basically this means you may increase timeouts, but cannot decrease it below 20
|
||||||
|
if ($timeout>$_timeout) $_timeout = $timeout;
|
||||||
|
|
||||||
unset($this->_connectionErrorObject);
|
unset($this->_connectionErrorObject);
|
||||||
|
|
||||||
if($_adminConnection) {
|
if($_adminConnection) {
|
||||||
$username = $this->adminUsername;
|
$username = $this->adminUsername;
|
||||||
$password = $this->adminPassword;
|
$password = $this->adminPassword;
|
||||||
@ -524,7 +530,7 @@ class defaultimap extends Net_IMAP
|
|||||||
$options = $_options;
|
$options = $_options;
|
||||||
$this->isAdminConnection = false;
|
$this->isAdminConnection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setStreamContextOptions($this->_getTransportOptions());
|
$this->setStreamContextOptions($this->_getTransportOptions());
|
||||||
$this->_timeout = $_timeout;
|
$this->_timeout = $_timeout;
|
||||||
if( PEAR::isError($status = parent::connect($this->_getTransportString(), $this->port, $this->encryption == 1)) ) {
|
if( PEAR::isError($status = parent::connect($this->_getTransportString(), $this->port, $this->encryption == 1)) ) {
|
||||||
@ -558,26 +564,26 @@ class defaultimap extends Net_IMAP
|
|||||||
//error_log(__METHOD__.__LINE__.' ImapServerID:'.$this->ImapServerId.' supported:'.array2string($this->supportedAuthMethods));
|
//error_log(__METHOD__.__LINE__.' ImapServerID:'.$this->ImapServerId.' supported:'.array2string($this->supportedAuthMethods));
|
||||||
//error_log(__METHOD__.__LINE__.' ImapServerID:'.$this->ImapServerId.' ServerMethods:'.array2string($this->_serverAuthMethods));
|
//error_log(__METHOD__.__LINE__.' ImapServerID:'.$this->ImapServerId.' ServerMethods:'.array2string($this->_serverAuthMethods));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restore session variable
|
* restore session variable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function restoreSessionData()
|
function restoreSessionData()
|
||||||
{
|
{
|
||||||
$this->sessionData = $GLOBALS['egw']->session->appsession('imap_session_data');
|
$this->sessionData = $GLOBALS['egw']->session->appsession('imap_session_data');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* save session variable
|
* save session variable
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function saveSessionData()
|
function saveSessionData()
|
||||||
{
|
{
|
||||||
$GLOBALS['egw']->session->appsession('imap_session_data','',$this->sessionData);
|
$GLOBALS['egw']->session->appsession('imap_session_data','',$this->sessionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set userdata
|
* set userdata
|
||||||
*
|
*
|
||||||
@ -585,7 +591,7 @@ class defaultimap extends Net_IMAP
|
|||||||
* @param int $_quota quota in bytes
|
* @param int $_quota quota in bytes
|
||||||
* @return bool true on success, false on failure
|
* @return bool true on success, false on failure
|
||||||
*/
|
*/
|
||||||
function setUserData($_username, $_quota)
|
function setUserData($_username, $_quota)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -596,26 +602,26 @@ class defaultimap extends Net_IMAP
|
|||||||
* @param string $_capability the capability to check for
|
* @param string $_capability the capability to check for
|
||||||
* @return bool true if capability is supported, false if not
|
* @return bool true if capability is supported, false if not
|
||||||
*/
|
*/
|
||||||
function supportsCapability($_capability)
|
function supportsCapability($_capability)
|
||||||
{
|
{
|
||||||
return $this->hasCapability($_capability);
|
return $this->hasCapability($_capability);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instance of emailadmin_sieve
|
* Instance of emailadmin_sieve
|
||||||
*
|
*
|
||||||
* @var emailadmin_sieve
|
* @var emailadmin_sieve
|
||||||
*/
|
*/
|
||||||
private $sieve;
|
private $sieve;
|
||||||
|
|
||||||
public $scriptName;
|
public $scriptName;
|
||||||
public $error;
|
public $error;
|
||||||
|
|
||||||
//public $error;
|
//public $error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proxy former felamimail bosieve methods to internal emailadmin_sieve instance
|
* Proxy former felamimail bosieve methods to internal emailadmin_sieve instance
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param array $params
|
* @param array $params
|
||||||
*/
|
*/
|
||||||
|
@ -16,7 +16,7 @@ include_once('Net/Sieve.php');
|
|||||||
/**
|
/**
|
||||||
* Support for Sieve scripts
|
* Support for Sieve scripts
|
||||||
*/
|
*/
|
||||||
class emailadmin_sieve extends Net_Sieve
|
class emailadmin_sieve extends Net_Sieve
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var object $icServer object containing the information about the imapserver
|
* @var object $icServer object containing the information about the imapserver
|
||||||
@ -32,7 +32,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
* @var object $error the last PEAR error object
|
* @var object $error the last PEAR error object
|
||||||
*/
|
*/
|
||||||
var $error;
|
var $error;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch on some error_log debug messages
|
* Switch on some error_log debug messages
|
||||||
*
|
*
|
||||||
@ -42,17 +42,17 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param defaultimap $_icServer
|
* @param defaultimap $_icServer
|
||||||
*/
|
*/
|
||||||
function __construct(defaultimap $_icServer=null)
|
function __construct(defaultimap $_icServer=null)
|
||||||
{
|
{
|
||||||
parent::Net_Sieve();
|
parent::Net_Sieve();
|
||||||
|
|
||||||
$this->scriptName = !empty($GLOBALS['egw_info']['user']['preferences']['felamimail']['sieveScriptName']) ? $GLOBALS['egw_info']['user']['preferences']['felamimail']['sieveScriptName'] : 'felamimail';
|
$this->scriptName = !empty($GLOBALS['egw_info']['user']['preferences']['felamimail']['sieveScriptName']) ? $GLOBALS['egw_info']['user']['preferences']['felamimail']['sieveScriptName'] : 'felamimail';
|
||||||
|
|
||||||
$this->displayCharset = $GLOBALS['egw']->translation->charset();
|
$this->displayCharset = $GLOBALS['egw']->translation->charset();
|
||||||
|
|
||||||
if (!is_null($_icServer) && $this->_connect($_icServer) === 'die') {
|
if (!is_null($_icServer) && $this->_connect($_icServer) === 'die') {
|
||||||
die('Sieve not activated');
|
die('Sieve not activated');
|
||||||
}
|
}
|
||||||
@ -71,11 +71,11 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
static $sieveAuthMethods;
|
static $sieveAuthMethods;
|
||||||
$_icServerID = $_icServer->ImapServerId;
|
$_icServerID = $_icServer->ImapServerId;
|
||||||
if (is_null($isConError)) $isConError =& egw_cache::getCache(egw_cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*15);
|
if (is_null($isConError)) $isConError =& egw_cache::getCache(egw_cache::INSTANCE,'email','icServerSIEVE_connectionError'.trim($GLOBALS['egw_info']['user']['account_id']),$callback=null,$callback_params=array(),$expiration=60*15);
|
||||||
if ( isset($isConError[$_icServerID]) )
|
if ( isset($isConError[$_icServerID]) )
|
||||||
{
|
{
|
||||||
error_log(__METHOD__.__LINE__.' failed for Reason:'.$isConError[$_icServerID]);
|
error_log(__METHOD__.__LINE__.' failed for Reason:'.$isConError[$_icServerID]);
|
||||||
//$this->errorMessage = $isConError[$_icServerID];
|
//$this->errorMessage = $isConError[$_icServerID];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.array2string($euser));
|
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.array2string($euser));
|
||||||
@ -104,6 +104,9 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
return 'die';
|
return 'die';
|
||||||
}
|
}
|
||||||
$this->_timeout = 10; // socket::connect sets the/this timeout on connection
|
$this->_timeout = 10; // socket::connect sets the/this timeout on connection
|
||||||
|
$timeout = felamimail_bo::getTimeOut('SIEVE');
|
||||||
|
if ($timeout>$this->_timeout) $this->_timeout = $timeout;
|
||||||
|
|
||||||
if(PEAR::isError($this->error = $this->connect($sieveHost , $sievePort, null, $useTLS) ) ){
|
if(PEAR::isError($this->error = $this->connect($sieveHost , $sievePort, null, $useTLS) ) ){
|
||||||
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": error in connect($sieveHost,$sievePort): ".$this->error->getMessage());
|
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.": error in connect($sieveHost,$sievePort): ".$this->error->getMessage());
|
||||||
$isConError[$_icServerID] = "SIEVE: error in connect($sieveHost,$sievePort): ".$this->error->getMessage();
|
$isConError[$_icServerID] = "SIEVE: error in connect($sieveHost,$sievePort): ".$this->error->getMessage();
|
||||||
@ -123,7 +126,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRules($_scriptName) {
|
function getRules($_scriptName) {
|
||||||
return $this->rules;
|
return $this->rules;
|
||||||
}
|
}
|
||||||
@ -136,7 +139,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
return $this->emailNotification;
|
return $this->emailNotification;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRules($_scriptName, $_rules)
|
function setRules($_scriptName, $_rules)
|
||||||
{
|
{
|
||||||
if (!$_scriptName) $_scriptName = $this->scriptName;
|
if (!$_scriptName) $_scriptName = $this->scriptName;
|
||||||
$script = new emailadmin_script($_scriptName);
|
$script = new emailadmin_script($_scriptName);
|
||||||
@ -145,14 +148,14 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
if($script->retrieveRules($this)) {
|
if($script->retrieveRules($this)) {
|
||||||
$script->rules = $_rules;
|
$script->rules = $_rules;
|
||||||
$script->updateScript($this);
|
$script->updateScript($this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVacation($_scriptName, $_vacation)
|
function setVacation($_scriptName, $_vacation)
|
||||||
{
|
{
|
||||||
if (!$_scriptName) $_scriptName = $this->scriptName;
|
if (!$_scriptName) $_scriptName = $this->scriptName;
|
||||||
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__."($_scriptName,".print_r($_vacation,true).')');
|
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__."($_scriptName,".print_r($_vacation,true).')');
|
||||||
@ -162,7 +165,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
if($script->retrieveRules($this)) {
|
if($script->retrieveRules($this)) {
|
||||||
$script->vacation = $_vacation;
|
$script->vacation = $_vacation;
|
||||||
$script->updateScript($this);
|
$script->updateScript($this);
|
||||||
/*
|
/*
|
||||||
// setting up an async job to enable/disable the vacation message
|
// setting up an async job to enable/disable the vacation message
|
||||||
$async = new asyncservice();
|
$async = new asyncservice();
|
||||||
$user = $GLOBALS['egw_info']['user']['account_id'];
|
$user = $GLOBALS['egw_info']['user']['account_id'];
|
||||||
@ -180,10 +183,10 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set vacation with admin right for an other user, used to async enable/disable vacation
|
* Set vacation with admin right for an other user, used to async enable/disable vacation
|
||||||
*
|
*
|
||||||
* @param string $_euser
|
* @param string $_euser
|
||||||
* @param string $_scriptName
|
* @param string $_scriptName
|
||||||
* @param string $_vaction
|
* @param string $_vaction
|
||||||
@ -193,7 +196,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
{
|
{
|
||||||
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
|
if ($this->debug) error_log(__CLASS__.'::'.__METHOD__.' User:'.array2string($_euser).' Scriptname:'.array2string($_scriptName).' VacationMessage:'.array2string($_vacation));
|
||||||
if (!$_scriptName) $_scriptName = $this->scriptName;
|
if (!$_scriptName) $_scriptName = $this->scriptName;
|
||||||
if ($this->_connect($this->icServer,$_euser) === true) {
|
if ($this->_connect($this->icServer,$_euser) === true) {
|
||||||
$this->setVacation($_scriptName,$_vacation);
|
$this->setVacation($_scriptName,$_vacation);
|
||||||
// we need to logout, so further vacation's get processed
|
// we need to logout, so further vacation's get processed
|
||||||
$error = $this->_cmdLogout();
|
$error = $this->_cmdLogout();
|
||||||
@ -202,7 +205,7 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setEmailNotification($_scriptName, $_emailNotification) {
|
function setEmailNotification($_scriptName, $_emailNotification) {
|
||||||
if (!$_scriptName) $_scriptName = $this->scriptName;
|
if (!$_scriptName) $_scriptName = $this->scriptName;
|
||||||
if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) {
|
if ($_emailNotification['externalEmail'] == '' || !preg_match("/\@/",$_emailNotification['externalEmail'])) {
|
||||||
@ -221,14 +224,14 @@ class emailadmin_sieve extends Net_Sieve
|
|||||||
function retrieveRules($_scriptName) {
|
function retrieveRules($_scriptName) {
|
||||||
if (!$_scriptName) $_scriptName = $this->scriptName;
|
if (!$_scriptName) $_scriptName = $this->scriptName;
|
||||||
$script = new emailadmin_script($_scriptName);
|
$script = new emailadmin_script($_scriptName);
|
||||||
|
|
||||||
if($script->retrieveRules($this)) {
|
if($script->retrieveRules($this)) {
|
||||||
$this->rules = $script->rules;
|
$this->rules = $script->rules;
|
||||||
$this->vacation = $script->vacation;
|
$this->vacation = $script->vacation;
|
||||||
$this->emailNotification = $script->emailNotification; // Added email notifications
|
$this->emailNotification = $script->emailNotification; // Added email notifications
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user