mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-29 09:46:44 +03:00
Added untested KolabAddressBook autocreate contacts #812
This commit is contained in:
parent
5ff8b28a12
commit
a9c60137da
1 changed files with 29 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use RainLoop\Providers\AddressBook\Classes\Contact;
|
||||
use Sabre\VObject\Component\VCard;
|
||||
|
||||
class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInterface
|
||||
{
|
||||
|
|
@ -53,7 +54,7 @@ class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInt
|
|||
return false;
|
||||
}
|
||||
|
||||
protected function fetchXCardFromMessage(\MailSo\Mail\Message $oMessage) : ?\Sabre\VObject\Component\VCard
|
||||
protected function fetchXCardFromMessage(\MailSo\Mail\Message $oMessage) : ?VCard
|
||||
{
|
||||
$xCard = null;
|
||||
try {
|
||||
|
|
@ -353,6 +354,33 @@ class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInt
|
|||
|
||||
public function IncFrec(array $aEmails, bool $bCreateAuto = true) : bool
|
||||
{
|
||||
if ($bCreateAuto) {
|
||||
foreach ($aEmails as $sEmail => $sAddress) {
|
||||
$sSearch = \MailSo\Imap\SearchCriterias::escapeSearchString($this->ImapClient(), $sEmail);
|
||||
if (!$this->ImapClient()->MessageSimpleSearch("FROM {$sSearch}")) {
|
||||
$oVCard = new VCard;
|
||||
$oVCard->add('EMAIL', $sEmail);
|
||||
$sFullName = \trim(\MailSo\Mime\Email::Parse(\trim($sAddress))->GetDisplayName());
|
||||
if ('' !== $sFullName) {
|
||||
$sFirst = $sLast = '';
|
||||
if (false !== \strpos($sFullName, ' ')) {
|
||||
$aNames = \explode(' ', $sFullName, 2);
|
||||
$sFirst = isset($aNames[0]) ? $aNames[0] : '';
|
||||
$sLast = isset($aNames[1]) ? $aNames[1] : '';
|
||||
} else {
|
||||
$sFirst = $sFullName;
|
||||
}
|
||||
if (\strlen($sFirst) || \strlen($sLast)) {
|
||||
$oVCard->N = array($sLast, $sFirst, '', '', '');
|
||||
}
|
||||
}
|
||||
$oContact = new Contact();
|
||||
$oContact->setVCard($oVCard);
|
||||
$this->ContactSave($oContact);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue