* EMailAdmin: always storing quota for qmailuser schema

This commit is contained in:
Ralf Becker 2012-06-20 16:17:18 +00:00
parent e996f970f4
commit a0659f5ade
3 changed files with 31 additions and 8 deletions

View File

@ -944,7 +944,8 @@ class emailadmin_bo extends so_sql
(array)$_formData['mailForwardingAddress'], (array)$_formData['mailForwardingAddress'],
$_formData['deliveryMode'], $_formData['deliveryMode'],
$_formData['accountStatus'], $_formData['accountStatus'],
$_formData['mailLocalAddress'] $_formData['mailLocalAddress'],
$_formData['quotaLimit']
); );
} }

View File

@ -68,6 +68,11 @@ class emailadmin_smtp_ldap extends defaultsmtp
*/ */
const MAILBOX_ATTR = false; const MAILBOX_ATTR = false;
/**
* Attribute for quota limit of user in MB
*/
const QUOTA_ATTR = false;
/** /**
* Log all LDAP writes / actions to error_log * Log all LDAP writes / actions to error_log
*/ */
@ -90,6 +95,7 @@ class emailadmin_smtp_ldap extends defaultsmtp
'forward_only_attr' => self::FORWARD_ONLY_ATTR, 'forward_only_attr' => self::FORWARD_ONLY_ATTR,
'forward_only' => self::FORWARD_ONLY, 'forward_only' => self::FORWARD_ONLY,
'mailbox_attr' => self::MAILBOX_ATTR, 'mailbox_attr' => self::MAILBOX_ATTR,
'quota_attr' => self::QUOTA_ATTR,
); );
/** /**
@ -271,6 +277,11 @@ class emailadmin_smtp_ldap extends defaultsmtp
{ {
unset($userData['mailAlternateAddress'][$k]); unset($userData['mailAlternateAddress'][$k]);
} }
if ($this->config['quota_attr'] && isset($allValues[0][$this->config['quota_attr']]))
{
$userData['quotaLimit'] = $allValues[0][$this->config['quota_attr']][0] / 1048576;
}
} }
} }
if ($this->debug) error_log(__METHOD__."('$_uidnumber') returning ".array2string($userData)); if ($this->debug) error_log(__METHOD__."('$_uidnumber') returning ".array2string($userData));
@ -287,9 +298,10 @@ class emailadmin_smtp_ldap extends defaultsmtp
* @param string $_deliveryMode * @param string $_deliveryMode
* @param string $_accountStatus * @param string $_accountStatus
* @param string $_mailLocalAddress * @param string $_mailLocalAddress
* @param int $_quota in MB
* @return boolean true on success, false on error writing to ldap * @return boolean true on success, false on error writing to ldap
*/ */
function setUserData($_uidnumber, $_mailAlternateAddress, $_mailForwardingAddress, $_deliveryMode, $_accountStatus, $_mailLocalAddress) function setUserData($_uidnumber, $_mailAlternateAddress, $_mailForwardingAddress, $_deliveryMode, $_accountStatus, $_mailLocalAddress, $_quota)
{ {
$filter = 'uidnumber='.(int)$_uidnumber; $filter = 'uidnumber='.(int)$_uidnumber;
@ -357,6 +369,10 @@ class emailadmin_smtp_ldap extends defaultsmtp
'account_email' => $_mailLocalAddress, 'account_email' => $_mailLocalAddress,
)); ));
} }
if ($this->config['quota_attr'])
{
$newData[$this->config['quota_attr']] = (int)$_quota >= 0 ? (int)$_quota*1048576 : array();
}
if ($this->debug) error_log(__METHOD__.'('.array2string(func_get_args()).") --> ldap_mod_replace(,'$accountDN',".array2string($newData).')'); if ($this->debug) error_log(__METHOD__.'('.array2string(func_get_args()).") --> ldap_mod_replace(,'$accountDN',".array2string($newData).')');
return ldap_mod_replace($ldap, $accountDN, $newData); return ldap_mod_replace($ldap, $accountDN, $newData);

View File

@ -57,13 +57,18 @@ class postfixldap extends emailadmin_smtp_ldap
/** /**
* Attribute value to only forward mail * Attribute value to only forward mail
*/ */
const FORWARD_ONLY = 'forwardOnly'; const FORWARD_ONLY = 'forwardonly';
/** /**
* Attribute for mailbox, to which mail gets delivered OR false if not supported * Attribute for mailbox, to which mail gets delivered OR false if not supported
*/ */
const MAILBOX_ATTR = 'mailmessagestore'; const MAILBOX_ATTR = 'mailmessagestore';
/**
* Attribute for quota limit of user in MB
*/
const QUOTA_ATTR = 'mailquota';
/** /**
* Log all LDAP writes / actions to error_log * Log all LDAP writes / actions to error_log
*/ */
@ -86,5 +91,6 @@ class postfixldap extends emailadmin_smtp_ldap
'forward_only_attr' => self::FORWARD_ONLY_ATTR, 'forward_only_attr' => self::FORWARD_ONLY_ATTR,
'forward_only' => self::FORWARD_ONLY, 'forward_only' => self::FORWARD_ONLY,
'mailbox_attr' => self::MAILBOX_ATTR, 'mailbox_attr' => self::MAILBOX_ATTR,
'quota_attr' => self::QUOTA_ATTR,
); );
} }