mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 14:07:04 +03:00
Added export contacts (vCard)
This commit is contained in:
parent
c25b5bfef7
commit
c248292f07
37 changed files with 489 additions and 237 deletions
|
|
@ -362,6 +362,57 @@ class PdoAddressBook
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
* @param string $sType = 'vcf'
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function Export($sEmail, $sType = 'vcf')
|
||||
{
|
||||
$this->SyncDatabase();
|
||||
|
||||
$iUserID = $this->getUserId($sEmail);
|
||||
if (0 >= $iUserID)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$bVcf = 'vcf' === $sType;
|
||||
$bCsvHeader = false;
|
||||
|
||||
$aDatabaseSyncData = $this->prepearDatabaseSyncData($iUserID);
|
||||
if (\is_array($aDatabaseSyncData) && 0 < \count($aDatabaseSyncData))
|
||||
{
|
||||
foreach ($aDatabaseSyncData as $mData)
|
||||
{
|
||||
if ($mData && isset($mData['id_contact'], $mData['deleted']) && !$mData['deleted'])
|
||||
{
|
||||
$oContact = $this->GetContactByID($sEmail, $mData['id_contact']);
|
||||
if ($oContact)
|
||||
{
|
||||
if ($bVcf)
|
||||
{
|
||||
echo $oContact->ToVCard();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$bCsvHeader)
|
||||
{
|
||||
$bCsvHeader = true;
|
||||
echo $oContact->ToCsvHeader();
|
||||
}
|
||||
|
||||
echo $oContact->ToCsvLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
* @param \RainLoop\Providers\AddressBook\Classes\Contact $oContact
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue