mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
CardDAV first look
This commit is contained in:
parent
c031a946e8
commit
7648000521
217 changed files with 31899 additions and 12 deletions
|
|
@ -60,6 +60,17 @@ class PersonalAddressBook extends \RainLoop\Providers\AbstractProvider
|
|||
$this->oDriver->IsSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetUserUidByEmail($sEmail)
|
||||
{
|
||||
return $this->oDriver instanceof \RainLoop\Providers\PersonalAddressBook\PersonalAddressBookInterface &&
|
||||
$this->oDriver->GetUserUidByEmail($sEmail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $bConsiderShare = true
|
||||
*/
|
||||
|
|
@ -96,7 +107,7 @@ class PersonalAddressBook extends \RainLoop\Providers\AbstractProvider
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
* @param \RainLoop\Account|mixed $mAccountOrId
|
||||
* @param int $iOffset = 0
|
||||
* @param type $iLimit = 20
|
||||
* @param string $sSearch = ''
|
||||
|
|
@ -104,9 +115,9 @@ class PersonalAddressBook extends \RainLoop\Providers\AbstractProvider
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0)
|
||||
public function GetContacts($mAccountOrId, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0)
|
||||
{
|
||||
return $this->IsActive() ? $this->oDriver->GetContacts($oAccount,
|
||||
return $this->IsActive() ? $this->oDriver->GetContacts($mAccountOrId,
|
||||
$iOffset, $iLimit, $sSearch, $iResultCount) : array();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace RainLoop\Providers\PersonalAddressBook\Classes;
|
||||
|
||||
use RainLoop\Providers\PersonalAddressBook\Enumerations\PropertyType;
|
||||
|
||||
class Contact
|
||||
{
|
||||
/**
|
||||
|
|
@ -115,4 +117,56 @@ class Contact
|
|||
|
||||
return \array_unique($aResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function ToVCardObject()
|
||||
{
|
||||
$oVCard = new \Sabre\VObject\Component\VCard('VCARD');
|
||||
|
||||
$oVCard->VERSION = '3.0';
|
||||
$oVCard->PRODID = '-//RainLoop//'.APP_VERSION.'//EN';
|
||||
|
||||
$sFirstName = $sSurName = '';
|
||||
foreach ($this->Properties as /* @var $oProperty \RainLoop\Providers\PersonalAddressBook\Classes\Property */ &$oProperty)
|
||||
{
|
||||
if ($oProperty)
|
||||
{
|
||||
switch ($oProperty->Type)
|
||||
{
|
||||
case PropertyType::FULLNAME:
|
||||
$oVCard->FN = $oProperty->Value;
|
||||
break;
|
||||
case PropertyType::NICK:
|
||||
$oVCard->NICKNAME = $oProperty->Value;
|
||||
break;
|
||||
case PropertyType::FIRST_NAME:
|
||||
$sFirstName = $oProperty->Value;
|
||||
break;
|
||||
case PropertyType::SUR_NAME:
|
||||
$sSurName = $oProperty->Value;
|
||||
break;
|
||||
}
|
||||
|
||||
if (PropertyType::FULLNAME === $oProperty->Type)
|
||||
{
|
||||
$oVCard->FN = $oProperty->Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oVCard->UID = ((string) $this->IdContact).'.vcf';
|
||||
|
||||
// $oVCard->N = array(
|
||||
// $sSurName,
|
||||
// $sFirstName,
|
||||
// '',
|
||||
// '',
|
||||
// '',
|
||||
// ''
|
||||
// );
|
||||
|
||||
return $oVCard;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,16 @@ class PdoPersonalAddressBook
|
|||
return $this->IsConsiderShare() && $this->IsSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sEmail
|
||||
* @return mixed
|
||||
*/
|
||||
public function GetUserUidByEmail($sEmail)
|
||||
{
|
||||
$iId = $this->getUserId($sEmail);
|
||||
return 0 < $iId ? (string) $iId : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
* @param \RainLoop\Providers\PersonalAddressBook\Classes\Contact $oContact
|
||||
|
|
@ -275,7 +285,7 @@ class PdoPersonalAddressBook
|
|||
}
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
* @param \RainLoop\Account|mixed $mAccountOrId
|
||||
* @param int $iOffset = 0
|
||||
* @param int $iLimit = 20
|
||||
* @param string $sSearch = ''
|
||||
|
|
@ -283,7 +293,7 @@ class PdoPersonalAddressBook
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0)
|
||||
public function GetContacts($mAccountOrId, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0)
|
||||
{
|
||||
$this->Sync();
|
||||
|
||||
|
|
@ -291,7 +301,11 @@ class PdoPersonalAddressBook
|
|||
$iLimit = 0 < $iLimit ? (int) $iLimit : 20;
|
||||
$sSearch = \trim($sSearch);
|
||||
|
||||
$iUserID = $this->getUserId($oAccount->ParentEmailHelper());
|
||||
$iUserID = $mAccountOrId instanceof \RainLoop\Account ? $this->getUserId($mAccountOrId->ParentEmailHelper()) : (int) $mAccountOrId;
|
||||
if (0 === $iUserID)
|
||||
{
|
||||
throw new \InvalidArgumentException('Invalid Accoutn ID');
|
||||
}
|
||||
|
||||
$iCount = 0;
|
||||
$aSearchIds = array();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ interface PersonalAddressBookInterface
|
|||
public function DeleteTags($oAccount, $aTagsIds);
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
* @param \RainLoop\Account|mixed $mAccountOrId
|
||||
* @param int $iOffset = 0
|
||||
* @param int $iLimit = 20
|
||||
* @param string $sSearch = ''
|
||||
|
|
@ -42,7 +42,7 @@ interface PersonalAddressBookInterface
|
|||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetContacts($oAccount, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0);
|
||||
public function GetContacts($mAccountOrId, $iOffset = 0, $iLimit = 20, $sSearch = '', &$iResultCount = 0);
|
||||
|
||||
/**
|
||||
* @param \RainLoop\Account $oAccount
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue