Commit 27e9182e authored by Manfred Kutas's avatar Manfred Kutas

ZP-747 Implemented Accounts and PrimarySmtpAddress in Settings.

Released under the Affero GNU General Public License (AGPL) version 3.
parent dff360a6
...@@ -2617,7 +2617,17 @@ class BackendIMAP extends BackendDiff implements ISearchProvider { ...@@ -2617,7 +2617,17 @@ class BackendIMAP extends BackendDiff implements ISearchProvider {
*/ */
private function settingsUserInformation(&$userinformation) { private function settingsUserInformation(&$userinformation) {
$userinformation->Status = SYNC_SETTINGSSTATUS_USERINFO_SUCCESS; $userinformation->Status = SYNC_SETTINGSSTATUS_USERINFO_SUCCESS;
$userinformation->emailaddresses[] = $this->username; if (Request::GetProtocolVersion() >= 14.1) {
$account = new SyncAccount();
$emailaddresses = new SyncEmailAddresses();
$emailaddresses->smtpaddress[] = $this->username;
$emailaddresses->primarysmtpaddress = $this->username;
$account->emailaddresses = $emailaddresses;
$userinformation->accounts[] = $account;
}
else {
$userinformation->emailaddresses[] = $this->username;
}
return true; return true;
} }
......
...@@ -1853,7 +1853,17 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -1853,7 +1853,17 @@ class BackendKopano implements IBackend, ISearchProvider {
$user = mapi_zarafa_getuser($this->defaultstore, $this->mainUser); $user = mapi_zarafa_getuser($this->defaultstore, $this->mainUser);
if ($user != false) { if ($user != false) {
$userinformation->Status = SYNC_SETTINGSSTATUS_USERINFO_SUCCESS; $userinformation->Status = SYNC_SETTINGSSTATUS_USERINFO_SUCCESS;
$userinformation->emailaddresses[] = $user["emailaddress"]; if (Request::GetProtocolVersion() >= 14.1) {
$account = new SyncAccount();
$emailaddresses = new SyncEmailAddresses();
$emailaddresses->smtpaddress[] = $user["emailaddress"];
$emailaddresses->primarysmtpaddress = $user["emailaddress"];
$account->emailaddresses = $emailaddresses;
$userinformation->accounts[] = $account;
}
else {
$userinformation->emailaddresses[] = $user["emailaddress"];
}
return true; return true;
} }
ZLog::Write(LOGLEVEL_ERROR, sprintf("Getting user information failed: mapi_zarafa_getuser(%X)", mapi_last_hresult())); ZLog::Write(LOGLEVEL_ERROR, sprintf("Getting user information failed: mapi_zarafa_getuser(%X)", mapi_last_hresult()));
......
...@@ -178,8 +178,21 @@ abstract class Backend implements IBackend { ...@@ -178,8 +178,21 @@ abstract class Backend implements IBackend {
} }
} }
if ($settings instanceof SyncUserInformation) { if ($settings instanceof SyncUserInformation) {
$settings->emailaddresses = array(ZPush::GetBackend()->GetUserDetails(Request::GetAuthUser())['emailaddress']);
$settings->Status = SYNC_SETTINGSSTATUS_SUCCESS; $settings->Status = SYNC_SETTINGSSTATUS_SUCCESS;
if (Request::GetProtocolVersion() >= 14.1) {
$account = new SyncAccount();
$emailaddresses = new SyncEmailAddresses();
$emailaddresses->smtpaddress[] = ZPush::GetBackend()->GetUserDetails(Request::GetAuthUser())['emailaddress'];
$emailaddresses->primarysmtpaddress = ZPush::GetBackend()->GetUserDetails(Request::GetAuthUser())['emailaddress'];
$account->emailaddresses = $emailaddresses;
$userinformation->accounts[] = $account;
}
else {
$userinformation->emailaddresses = array(ZPush::GetBackend()->GetUserDetails(Request::GetAuthUser())['emailaddress']);
}
$settings->emailaddresses = array(ZPush::GetBackend()->GetUserDetails(Request::GetAuthUser())['emailaddress']);
} }
return $settings; return $settings;
} }
......
<?php
/***********************************************
* File : syncaccount.php
* Project : Z-Push
* Descr : WBXML account entities that can be
* parsed directly (as a stream) from WBXML.
* It is automatically decoded
* according to $mapping,
* and the Sync WBXML mappings
*
* Created : 18.05.2017
*
* Copyright 2017 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
class SyncAccount extends SyncObject {
public $accountid;
public $accountname;
public $userdisplayname;
public $senddisabled;
public $emailaddresses;
public function __construct() {
$mapping = array (
SYNC_SETTINGS_ACCOUNTID => array ( self::STREAMER_VAR => "accountid"),
SYNC_SETTINGS_ACCOUNTNAME => array ( self::STREAMER_VAR => "accountname"),
SYNC_SETTINGS_USERDISPLAYNAME => array ( self::STREAMER_VAR => "userdisplayname"),
SYNC_SETTINGS_SENDDISABLED => array ( self::STREAMER_VAR => "senddisabled"),
SYNC_SETTINGS_EMAILADDRESSES => array ( self::STREAMER_VAR => "emailaddresses",
self::STREAMER_TYPE => "SyncEmailAddresses")
);
parent::__construct($mapping);
}
}
\ No newline at end of file
<?php
/***********************************************
* File : syncemailaddresses.php
* Project : Z-Push
* Descr : WBXML email adresses entities that can be
* parsed directly (as a stream) from WBXML.
* It is automatically decoded
* according to $mapping,
* and the Sync WBXML mappings
*
* Created : 18.05.2017
*
* Copyright 2017 Zarafa Deutschland GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Consult LICENSE file for details
************************************************/
class SyncEmailAddresses extends SyncObject {
public $smtpaddress;
public $primarysmtpaddress;
public function __construct() {
$mapping = array (
SYNC_SETTINGS_SMPTADDRESS => array ( self::STREAMER_VAR => "smtpaddress",
self::STREAMER_PROP => self::STREAMER_TYPE_NO_CONTAINER,
self::STREAMER_ARRAY => SYNC_SETTINGS_SMPTADDRESS),
SYNC_SETTINGS_PRIMARYSMTPADDRESS => array ( self::STREAMER_VAR => "primarysmtpaddress"));
parent::__construct($mapping);
}
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/*********************************************** /***********************************************
* File : syncuserinformation.php * File : syncuserinformation.php
* Project : Z-Push * Project : Z-Push
* Descr : WBXML appointment entities that can be * Descr : WBXML user information entities that can be
* parsed directly (as a stream) from WBXML. * parsed directly (as a stream) from WBXML.
* It is automatically decoded * It is automatically decoded
* according to $mapping, * according to $mapping,
...@@ -28,30 +28,26 @@ ...@@ -28,30 +28,26 @@
************************************************/ ************************************************/
class SyncUserInformation extends SyncObject { class SyncUserInformation extends SyncObject {
public $accountid;
public $accountname;
public $userdisplayname;
public $senddisabled;
public $emailaddresses; public $emailaddresses;
public $accounts;
public $Status; public $Status;
public function __construct() { public function __construct() {
$mapping = array ( $mapping = array(SYNC_SETTINGS_PROP_STATUS => array ( self::STREAMER_VAR => "Status",
SYNC_SETTINGS_ACCOUNTID => array ( self::STREAMER_VAR => "accountid"), self::STREAMER_TYPE => self::STREAMER_TYPE_IGNORE));
SYNC_SETTINGS_ACCOUNTNAME => array ( self::STREAMER_VAR => "accountname"),
SYNC_SETTINGS_EMAILADDRESSES => array ( self::STREAMER_VAR => "emailaddresses",
self::STREAMER_ARRAY => SYNC_SETTINGS_SMPTADDRESS),
SYNC_SETTINGS_PROP_STATUS => array ( self::STREAMER_VAR => "Status", // In AS protocoll versions 12.0, 12.1 and 14.0 EmailAddresses element is child of Get in UserSettings
self::STREAMER_TYPE => self::STREAMER_TYPE_IGNORE) // Since AS protocoll version 14.1 EmailAddresses element is child of Account element of Get in UserSettings
); if (Request::GetProtocolVersion() >= 12.0) {
$mapping[SYNC_SETTINGS_EMAILADDRESSES] = array ( self::STREAMER_VAR => "emailaddresses",
if (Request::GetProtocolVersion() >= 12.1) { self::STREAMER_ARRAY => SYNC_SETTINGS_SMPTADDRESS);
$mapping[SYNC_SETTINGS_USERDISPLAYNAME] = array ( self::STREAMER_VAR => "userdisplayname");
} }
if (Request::GetProtocolVersion() >= 14.0) { if (Request::GetProtocolVersion() >= 14.1) {
$mapping[SYNC_SETTINGS_SENDDISABLED] = array ( self::STREAMER_VAR => "senddisabled"); unset($mapping[SYNC_SETTINGS_EMAILADDRESSES]);
$mapping[SYNC_SETTINGS_ACCOUNTS] = array ( self::STREAMER_VAR => "accounts",
self::STREAMER_TYPE => "SyncAccount",
self::STREAMER_ARRAY => SYNC_SETTINGS_ACCOUNT);
} }
parent::__construct($mapping); parent::__construct($mapping);
......
...@@ -127,6 +127,7 @@ return array( ...@@ -127,6 +127,7 @@ return array(
'Streamer' => $baseDir . '/lib/core/streamer.php', 'Streamer' => $baseDir . '/lib/core/streamer.php',
'StringStreamWrapper' => $baseDir . '/lib/utils/stringstreamwrapper.php', 'StringStreamWrapper' => $baseDir . '/lib/utils/stringstreamwrapper.php',
'Sync' => $baseDir . '/lib/request/sync.php', 'Sync' => $baseDir . '/lib/request/sync.php',
'SyncAccount' => $baseDir . '/lib/syncobjects/syncaccount.php',
'SyncAppointment' => $baseDir . '/lib/syncobjects/syncappointment.php', 'SyncAppointment' => $baseDir . '/lib/syncobjects/syncappointment.php',
'SyncAppointmentException' => $baseDir . '/lib/syncobjects/syncappointmentexception.php', 'SyncAppointmentException' => $baseDir . '/lib/syncobjects/syncappointmentexception.php',
'SyncAttachment' => $baseDir . '/lib/syncobjects/syncattachment.php', 'SyncAttachment' => $baseDir . '/lib/syncobjects/syncattachment.php',
...@@ -137,6 +138,7 @@ return array( ...@@ -137,6 +138,7 @@ return array(
'SyncContact' => $baseDir . '/lib/syncobjects/synccontact.php', 'SyncContact' => $baseDir . '/lib/syncobjects/synccontact.php',
'SyncDeviceInformation' => $baseDir . '/lib/syncobjects/syncdeviceinformation.php', 'SyncDeviceInformation' => $baseDir . '/lib/syncobjects/syncdeviceinformation.php',
'SyncDevicePassword' => $baseDir . '/lib/syncobjects/syncdevicepassword.php', 'SyncDevicePassword' => $baseDir . '/lib/syncobjects/syncdevicepassword.php',
'SyncEmailAddresses' => $baseDir . '/lib/syncobjects/syncemailaddresses.php',
'SyncFolder' => $baseDir . '/lib/syncobjects/syncfolder.php', 'SyncFolder' => $baseDir . '/lib/syncobjects/syncfolder.php',
'SyncItemOperationsAttachment' => $baseDir . '/lib/syncobjects/syncitemoperationsattachment.php', 'SyncItemOperationsAttachment' => $baseDir . '/lib/syncobjects/syncitemoperationsattachment.php',
'SyncMail' => $baseDir . '/lib/syncobjects/syncmail.php', 'SyncMail' => $baseDir . '/lib/syncobjects/syncmail.php',
......
...@@ -134,6 +134,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f ...@@ -134,6 +134,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f
'Streamer' => __DIR__ . '/../..' . '/lib/core/streamer.php', 'Streamer' => __DIR__ . '/../..' . '/lib/core/streamer.php',
'StringStreamWrapper' => __DIR__ . '/../..' . '/lib/utils/stringstreamwrapper.php', 'StringStreamWrapper' => __DIR__ . '/../..' . '/lib/utils/stringstreamwrapper.php',
'Sync' => __DIR__ . '/../..' . '/lib/request/sync.php', 'Sync' => __DIR__ . '/../..' . '/lib/request/sync.php',
'SyncAccount' => __DIR__ . '/../..' . '/lib/syncobjects/syncaccount.php',
'SyncAppointment' => __DIR__ . '/../..' . '/lib/syncobjects/syncappointment.php', 'SyncAppointment' => __DIR__ . '/../..' . '/lib/syncobjects/syncappointment.php',
'SyncAppointmentException' => __DIR__ . '/../..' . '/lib/syncobjects/syncappointmentexception.php', 'SyncAppointmentException' => __DIR__ . '/../..' . '/lib/syncobjects/syncappointmentexception.php',
'SyncAttachment' => __DIR__ . '/../..' . '/lib/syncobjects/syncattachment.php', 'SyncAttachment' => __DIR__ . '/../..' . '/lib/syncobjects/syncattachment.php',
...@@ -144,6 +145,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f ...@@ -144,6 +145,7 @@ class ComposerStaticInitd6749fc2fb9944bbe86b2b7d79a7852f
'SyncContact' => __DIR__ . '/../..' . '/lib/syncobjects/synccontact.php', 'SyncContact' => __DIR__ . '/../..' . '/lib/syncobjects/synccontact.php',
'SyncDeviceInformation' => __DIR__ . '/../..' . '/lib/syncobjects/syncdeviceinformation.php', 'SyncDeviceInformation' => __DIR__ . '/../..' . '/lib/syncobjects/syncdeviceinformation.php',
'SyncDevicePassword' => __DIR__ . '/../..' . '/lib/syncobjects/syncdevicepassword.php', 'SyncDevicePassword' => __DIR__ . '/../..' . '/lib/syncobjects/syncdevicepassword.php',
'SyncEmailAddresses' => __DIR__ . '/../..' . '/lib/syncobjects/syncemailaddresses.php',
'SyncFolder' => __DIR__ . '/../..' . '/lib/syncobjects/syncfolder.php', 'SyncFolder' => __DIR__ . '/../..' . '/lib/syncobjects/syncfolder.php',
'SyncItemOperationsAttachment' => __DIR__ . '/../..' . '/lib/syncobjects/syncitemoperationsattachment.php', 'SyncItemOperationsAttachment' => __DIR__ . '/../..' . '/lib/syncobjects/syncitemoperationsattachment.php',
'SyncMail' => __DIR__ . '/../..' . '/lib/syncobjects/syncmail.php', 'SyncMail' => __DIR__ . '/../..' . '/lib/syncobjects/syncmail.php',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment