mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-08 00:47:04 +03:00
CardDAV second look :)
This commit is contained in:
parent
7648000521
commit
a46d6832d9
20 changed files with 852 additions and 468 deletions
|
|
@ -11,6 +11,11 @@ class Contact
|
|||
*/
|
||||
public $IdContact;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $IdContactStr;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -59,6 +64,7 @@ class Contact
|
|||
public function Clear()
|
||||
{
|
||||
$this->IdContact = '';
|
||||
$this->IdContactStr = '';
|
||||
$this->IdUser = 0;
|
||||
$this->Display = '';
|
||||
$this->DisplayName = '';
|
||||
|
|
@ -95,6 +101,11 @@ class Contact
|
|||
}
|
||||
}
|
||||
|
||||
if (empty($this->IdContactStr))
|
||||
{
|
||||
$this->IdContactStr = \Sabre\DAV\UUIDUtil::getUUID();
|
||||
}
|
||||
|
||||
$this->DisplayName = $sDisplayName;
|
||||
$this->DisplayEmail = $sDisplayEmail;
|
||||
|
||||
|
|
@ -123,6 +134,8 @@ class Contact
|
|||
*/
|
||||
public function ToVCardObject()
|
||||
{
|
||||
$this->UpdateDependentValues();
|
||||
|
||||
$oVCard = new \Sabre\VObject\Component\VCard('VCARD');
|
||||
|
||||
$oVCard->VERSION = '3.0';
|
||||
|
|
@ -141,6 +154,32 @@ class Contact
|
|||
case PropertyType::NICK:
|
||||
$oVCard->NICKNAME = $oProperty->Value;
|
||||
break;
|
||||
case PropertyType::EMAIl_PERSONAL:
|
||||
case PropertyType::EMAIl_OTHER:
|
||||
$oVCard->add('EMAIL', $oProperty->Value, array('TYPE' => 'INTERNET', 'TYPE' => 'HOME'));
|
||||
break;
|
||||
case PropertyType::EMAIl_BUSSINES:
|
||||
$oVCard->add('EMAIL', $oProperty->Value, array('TYPE' => 'INTERNET', 'TYPE' => 'WORK'));
|
||||
break;
|
||||
case PropertyType::PHONE_PERSONAL:
|
||||
case PropertyType::PHONE_OTHER:
|
||||
$oVCard->add('TEL', $oProperty->Value, array('TYPE' => 'VOICE', 'TYPE' => 'HOME'));
|
||||
break;
|
||||
case PropertyType::PHONE_BUSSINES:
|
||||
$oVCard->add('TEL', $oProperty->Value, array('TYPE' => 'VOICE', 'TYPE' => 'WORK'));
|
||||
break;
|
||||
case PropertyType::MOBILE_PERSONAL:
|
||||
case PropertyType::MOBILE_BUSSINES:
|
||||
case PropertyType::MOBILE_OTHER:
|
||||
$oVCard->add('TEL', $oProperty->Value, array('TYPE' => 'VOICE', 'TYPE' => 'CELL'));
|
||||
break;
|
||||
case PropertyType::FAX_PERSONAL:
|
||||
case PropertyType::FAX_OTHER:
|
||||
$oVCard->add('TEL', $oProperty->Value, array('TYPE' => 'FAX', 'TYPE' => 'HOME'));
|
||||
break;
|
||||
case PropertyType::FAX_BUSSINES:
|
||||
$oVCard->add('TEL', $oProperty->Value, array('TYPE' => 'FAX', 'TYPE' => 'WORK'));
|
||||
break;
|
||||
case PropertyType::FIRST_NAME:
|
||||
$sFirstName = $oProperty->Value;
|
||||
break;
|
||||
|
|
@ -148,15 +187,10 @@ class Contact
|
|||
$sSurName = $oProperty->Value;
|
||||
break;
|
||||
}
|
||||
|
||||
if (PropertyType::FULLNAME === $oProperty->Type)
|
||||
{
|
||||
$oVCard->FN = $oProperty->Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oVCard->UID = ((string) $this->IdContact).'.vcf';
|
||||
$oVCard->UID = $this->VCardUID();
|
||||
|
||||
// $oVCard->N = array(
|
||||
// $sSurName,
|
||||
|
|
@ -169,4 +203,14 @@ class Contact
|
|||
|
||||
return $oVCard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function VCardUID()
|
||||
{
|
||||
return $this->IdContactStr.'.vcf';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue