migrate mailbox name (mailMessageStore) when migrating mail accounts, otherwise default get created, which might differ

This commit is contained in:
Ralf Becker 2012-11-23 09:18:00 +00:00
parent 6ace26725d
commit a9766f6c82
4 changed files with 23 additions and 7 deletions

View File

@ -171,9 +171,11 @@ class emailadmin_smtp
* @param string $_mailLocalAddress
* @param int $_quota in MB
* @param boolean $_forwarding_only=false true: store only forwarding info, used internally by saveSMTPForwarding
* @param string $_setMailbox=null used only for account migration
* @return boolean true on success, false on error writing to ldap
*/
function setUserData($_uidnumber, array $_mailAlternateAddress, array $_mailForwardingAddress, $_deliveryMode, $_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only=false)
function setUserData($_uidnumber, array $_mailAlternateAddress, array $_mailForwardingAddress, $_deliveryMode,
$_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only=false, $_setMailbox=null)
{
return true;
}

View File

@ -364,7 +364,7 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
$userData['mailForwardingAddress'] = $this->config['forward_attr'] ? $values[$this->config['forward_attr']] : array();
unset($userData['mailForwardingAddress']['count']);
if ($this->config['mailbox_attr']) $userData[$this->config['mailbox_attr']] = $values[$this->config['mailbox_attr']][0];
if ($this->config['mailbox_attr']) $userData['mailMessageStore'] = $values[$this->config['mailbox_attr']][0];
if ($this->config['forward_only_attr'])
{
@ -404,9 +404,12 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
* @param string $_accountStatus
* @param string $_mailLocalAddress
* @param int $_quota in MB
* @param boolean $_forwarding_only=false not used as we have our own addAccount method
* @param string $_setMailbox=null used only for account migration
* @return boolean true on success, false on error writing to ldap
*/
function setUserData($_uidnumber, array $_mailAlternateAddress, array $_mailForwardingAddress, $_deliveryMode, $_accountStatus, $_mailLocalAddress, $_quota)
function setUserData($_uidnumber, array $_mailAlternateAddress, array $_mailForwardingAddress, $_deliveryMode,
$_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only=false, $_setMailbox=null)
{
$filter = 'uidnumber='.(int)$_uidnumber;
@ -478,6 +481,11 @@ class emailadmin_smtp_ldap extends emailadmin_smtp
{
$newData[$this->config['quota_attr']] = (int)$_quota >= 0 ? (int)$_quota*1048576 : array();
}
// does schema support an explicit mailbox name --> set it, $_setMailbox is given
if ($this->config['mailbox_attr'] && $_setMailbox)
{
$newData[$this->config['mailbox_attr']] = $_setMailbox;
}
if ($this->debug) error_log(__METHOD__.'('.array2string(func_get_args()).") --> ldap_mod_replace(,'$accountDN',".array2string($newData).')');
return ldap_mod_replace($ldap, $accountDN, $newData);

View File

@ -178,7 +178,7 @@ class emailadmin_smtp_sql extends emailadmin_smtp
break;
case self::TYPE_MAILBOX:
$userData['mailmessagestore'] = $row['mail_value'];
$userData['mailMessageStore'] = $row['mail_value'];
//error_log(__METHOD__."('$user') row=".array2string($row).', enabled[$row[account_id]]='.array2string($enabled[$row['account_id']]).', forwardOnly[$row[account_id]]='.array2string($forwardOnly[$row['account_id']]));
if ($row['account_id'] > 0 && $enabled[$row['account_id']] && !$forwardOnly[$row['account_id']])
{
@ -223,10 +223,11 @@ class emailadmin_smtp_sql extends emailadmin_smtp
* @param string $_mailLocalAddress
* @param int $_quota in MB
* @param boolean $_forwarding_only=false true: store only forwarding info, used internally by saveSMTPForwarding
* @param string $_setMailbox=null used only for account migration
* @return boolean true on success, false on error writing to ldap
*/
function setUserData($_uidnumber, array $_mailAlternateAddress, array $_mailForwardingAddress, $_deliveryMode,
$_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only=false)
$_accountStatus, $_mailLocalAddress, $_quota, $_forwarding_only=false, $_setMailbox=null)
{
if ($this->debug) error_log(__METHOD__."($_uidnumber, ".array2string($_mailAlternateAddress).', '.array2string($_mailForwardingAddress).", '$_deliveryMode', '$_accountStatus', '$_mailLocalAddress', $_quota, forwarding_only=".array2string($_forwarding_only).') '.function_backtrace());
@ -295,8 +296,13 @@ class emailadmin_smtp_sql extends emailadmin_smtp
{
$this->db->delete(self::TABLE, array('mail_id' => $delete_ids), __LINE__, __FILE__, self::APP);
}
// set mailbox address, if explicitly requested by $_setMailbox parameter
if ($_setMailbox)
{
$flags[self::TYPE_MAILBOX] = $_setMailbox;
}
// set mailbox address, if not yet set
if (!$_forwarding_only && empty($mailbox))
elseif (!$_forwarding_only && empty($mailbox))
{
$flags[self::TYPE_MAILBOX] = $this->mailbox_addr(array(
'account_id' => $_uidnumber,

View File

@ -242,7 +242,7 @@ class setup_cmd_ldap extends setup_cmd
$emailadmin_dst->setUserData($account_id, (array)$mailaccount['mailAlternateAddress'],
(array)$mailaccount['mailForwardingAddress'], $mailaccount['deliveryMode'],
$mailaccount['accountStatus'], $mailaccount['mailLocalAddress'],
$mailaccount['quotaLimit']);
$mailaccount['quotaLimit'], false, $mailaccount['mailMessageStore']);
$msg[] = lang("Mail account of %1 migraged", $account['account_lid']);
}