mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-06 23:07:56 +08:00
Kolab export contacts
This commit is contained in:
parent
01e5916bf3
commit
90b3a2155d
1 changed files with 53 additions and 14 deletions
|
@ -110,6 +110,9 @@ class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInt
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync with davClient
|
||||||
|
*/
|
||||||
public function Sync(array $oConfig) : bool
|
public function Sync(array $oConfig) : bool
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -118,8 +121,44 @@ class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInt
|
||||||
|
|
||||||
public function Export(string $sEmail, string $sType = 'vcf') : bool
|
public function Export(string $sEmail, string $sType = 'vcf') : bool
|
||||||
{
|
{
|
||||||
// TODO
|
$bVcf = 'vcf' === $sType;
|
||||||
return false;
|
$bCsvHeader = true;
|
||||||
|
|
||||||
|
if (!\strlen($this->sFolderName)) {
|
||||||
|
// return false;
|
||||||
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ImapClient();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$oParams = new \MailSo\Mail\MessageListParams;
|
||||||
|
$oParams->sFolderName = $this->sFolderName;
|
||||||
|
// $oParams->iOffset = 0;
|
||||||
|
$oParams->iLimit = 999; // Is the max
|
||||||
|
$oMessageList = $this->MailClient()->MessageList($oParams);
|
||||||
|
foreach ($oMessageList as $oMessage) {
|
||||||
|
if ($bVcf) {
|
||||||
|
$xCard = $this->fetchXCardFromMessage($oMessage);
|
||||||
|
if ($xCard instanceof \Sabre\VObject\Component\VCard) {
|
||||||
|
echo $xCard->serialize();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$oContact = $this->MessageAsContact($oMessage);
|
||||||
|
if ($oContact) {
|
||||||
|
echo $oContact->ToCsv($bCsvHeader);
|
||||||
|
$bCsvHeader = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Throwable $oException)
|
||||||
|
{
|
||||||
|
throw $oException;
|
||||||
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList, $oException);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ContactSave(string $sEmail, Contact $oContact) : bool
|
public function ContactSave(string $sEmail, Contact $oContact) : bool
|
||||||
|
@ -216,6 +255,17 @@ class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInt
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetContacts(string $sEmail, int $iOffset = 0, int $iLimit = 20, string $sSearch = '', int &$iResultCount = 0) : array
|
public function GetContacts(string $sEmail, int $iOffset = 0, int $iLimit = 20, string $sSearch = '', int &$iResultCount = 0) : array
|
||||||
|
{
|
||||||
|
if (!\strlen($this->sFolderName)) {
|
||||||
|
// return [];
|
||||||
|
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ImapClient();
|
||||||
|
|
||||||
|
$aResult = [];
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
$oParams = new \MailSo\Mail\MessageListParams;
|
$oParams = new \MailSo\Mail\MessageListParams;
|
||||||
$oParams->sFolderName = $this->sFolderName;
|
$oParams->sFolderName = $this->sFolderName;
|
||||||
|
@ -228,17 +278,6 @@ class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInt
|
||||||
// $oParams->iPrevUidNext = $this->GetActionParam('UidNext', 0);
|
// $oParams->iPrevUidNext = $this->GetActionParam('UidNext', 0);
|
||||||
// $oParams->bUseThreads = false;
|
// $oParams->bUseThreads = false;
|
||||||
|
|
||||||
if (!\strlen($oParams->sFolderName)) {
|
|
||||||
// return [];
|
|
||||||
throw new \RainLoop\Exceptions\ClientException(\RainLoop\Notifications::CantGetMessageList);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->ImapClient();
|
|
||||||
|
|
||||||
$aResult = [];
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$oMessageList = $this->MailClient()->MessageList($oParams);
|
$oMessageList = $this->MailClient()->MessageList($oParams);
|
||||||
foreach ($oMessageList as $oMessage) {
|
foreach ($oMessageList as $oMessage) {
|
||||||
$aResult[] = $this->MessageAsContact($oMessage);
|
$aResult[] = $this->MessageAsContact($oMessage);
|
||||||
|
|
Loading…
Reference in a new issue