mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +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
|
<?php
|
||||||
|
|
||||||
use RainLoop\Providers\AddressBook\Classes\Contact;
|
use RainLoop\Providers\AddressBook\Classes\Contact;
|
||||||
|
use Sabre\VObject\Component\VCard;
|
||||||
|
|
||||||
class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInterface
|
class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInterface
|
||||||
{
|
{
|
||||||
|
|
@ -53,7 +54,7 @@ class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInt
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fetchXCardFromMessage(\MailSo\Mail\Message $oMessage) : ?\Sabre\VObject\Component\VCard
|
protected function fetchXCardFromMessage(\MailSo\Mail\Message $oMessage) : ?VCard
|
||||||
{
|
{
|
||||||
$xCard = null;
|
$xCard = null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -353,6 +354,33 @@ class KolabAddressBook implements \RainLoop\Providers\AddressBook\AddressBookInt
|
||||||
|
|
||||||
public function IncFrec(array $aEmails, bool $bCreateAuto = true) : bool
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue