Add user's email address to vCard

This commit is contained in:
Thomas Müller 2015-11-30 13:41:42 +01:00
parent 079ae9b7a9
commit 7c8a84e7ac

View file

@ -34,6 +34,7 @@ class SyncSystemAddressBook extends Command {
/**
* @param IUserManager $userManager
* @param IDBConnection $dbConnection
* @param IConfig $config
*/
function __construct(IUserManager $userManager, IDBConnection $dbConnection, IConfig $config) {
parent::__construct();
@ -70,7 +71,7 @@ class SyncSystemAddressBook extends Command {
$name = $user->getBackendClassName();
$userId = $user->getUID();
$displayName = $user->getDisplayName();
//$emailAddress = $user->getEMailAddress();
$emailAddress = $user->getEMailAddress();
$image = $user->getAvatarImage(-1);
$cardId = "$name:$userId.vcf";
@ -79,7 +80,7 @@ class SyncSystemAddressBook extends Command {
$vCard = new VCard();
$vCard->add(new Text($vCard, 'UID', $userId));
$vCard->add(new Text($vCard, 'FN', $displayName));
// $vCard->add(new Text($vCard, 'EMAIL', $emailAddress));
$vCard->add(new Text($vCard, 'EMAIL', $emailAddress));
if ($image) {
$vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
}
@ -92,6 +93,10 @@ class SyncSystemAddressBook extends Command {
$vCard->FN = new Text($vCard, 'FN', $displayName);
$updated = true;
}
if($vCard->EMail !== $emailAddress) {
$vCard->FN = new Text($vCard, 'EMAIL', $emailAddress);
$updated = true;
}
if ($updated) {
$this->backend->updateCard($systemAddressBook['id'], $cardId, $vCard->serialize());
}