本文整理汇总了PHP中CContact::InitFromVCardStr方法的典型用法代码示例。如果您正苦于以下问题:PHP CContact::InitFromVCardStr方法的具体用法?PHP CContact::InitFromVCardStr怎么用?PHP CContact::InitFromVCardStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContact
的用法示例。
在下文中一共展示了CContact::InitFromVCardStr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterWriteContent
function afterWriteContent($path, \Sabre\DAV\IFile $node)
{
if ($node instanceof \Sabre\CardDAV\ICard) {
$iUserId = $this->server->getUser();
if (isset($iUserId)) {
$iTenantId = $node instanceof \Afterlogic\DAV\CardDAV\SharedCard ? 0 : null;
$sContactFileName = $node->getName();
$oContactDb = $this->oApiContactsManager->getContactByStrId($iUserId, $sContactFileName, $iTenantId);
if (!isset($oContactDb)) {
$oVCard = \Sabre\VObject\Reader::read($node->get(), \Sabre\VObject\Reader::OPTION_IGNORE_INVALID_LINES);
if ($oVCard && $oVCard->UID) {
$oContactDb = $this->oApiContactsManager->getContactByStrId($iUserId, (string) $oVCard->UID . '.vcf', $iTenantId);
}
}
$oContact = new \CContact();
$oContact->InitFromVCardStr($iUserId, $node->get());
$oContact->IdContactStr = $sContactFileName;
$oContact->IdTenant = $iTenantId;
if (isset($oContactDb)) {
$oContact->IdContact = $oContactDb->IdContact;
$oContact->IdDomain = $oContactDb->IdDomain;
$oContact->SharedToAll = !!$oContactDb->SharedToAll;
$this->oApiContactsManager->updateContact($oContact);
} else {
$this->oApiContactsManager->createContact($oContact);
}
}
}
}
示例2: AjaxContactsSaveVcf
/**
* @return array
*/
public function AjaxContactsSaveVcf()
{
$oAccount = $this->getAccountFromParam();
$mResult = false;
if (!$this->oApiCapability->isPersonalContactsSupported($oAccount)) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::ContactsNotAllowed);
}
$sTempFile = (string) $this->getParamValue('File', '');
if (empty($sTempFile)) {
throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidInputParameter);
}
$oApiFileCache = \CApi::Manager('filecache');
$sData = $oApiFileCache->get($oAccount, $sTempFile);
if (!empty($sData)) {
$oContactsApi = $this->ApiContacts();
if ($oContactsApi) {
$oContact = new \CContact();
$oContact->InitFromVCardStr($oAccount->IdUser, $sData);
if ($oContactsApi->createContact($oContact)) {
$mResult = array('Uid' => $oContact->IdContact);
}
}
}
return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult);
}
示例3: getContactById
/**
* @param int $iUserId
* @param mixed $mContactId
* @return CContact | false
*/
public function getContactById($iUserId, $mContactId)
{
$oContact = false;
if ($this->init($iUserId)) {
$oContactItem = $this->getItem($iUserId, \afterlogic\DAV\Constants::ADDRESSBOOK_DEFAULT_NAME, $mContactId);
if ($oContactItem) {
$sVCardData = $oContactItem['data'];
if ($sVCardData) {
$oContact = new CContact();
$oContact->InitFromVCardStr($iUserId, $sVCardData);
$oContact->IdContact = $mContactId;
$oContact->ETag = $oContactItem['etag'];
}
}
}
return $oContact;
}
示例4: getMessage
//.........这里部分代码省略.........
}
$aFetchResponse = $oImapClient->Fetch($aFetchItems, $iUid, true);
if (0 < count($aFetchResponse)) {
$oMessage = CApiMailMessage::createInstance($sFolderFullNameRaw, $aFetchResponse[0], $oBodyStructure, $sRfc822SubMimeIndex, $aAscPartsIds);
}
if ($oMessage) {
$sFromEmail = '';
$oFromCollection = $oMessage->getFrom();
if ($oFromCollection && 0 < $oFromCollection->Count()) {
$oFrom =& $oFromCollection->GetByIndex(0);
if ($oFrom) {
$sFromEmail = trim($oFrom->GetEmail());
}
}
if (0 < strlen($sFromEmail)) {
$oApiUsersManager = CApi::Manager('users');
$oSettings =& CApi::GetSettings();
$bAlwaysShowImagesInMessage = !!$oSettings->GetConf('WebMail/AlwaysShowImagesInMessage');
$oMessage->setSafety($bAlwaysShowImagesInMessage ? true : $oApiUsersManager->getSafetySender($oAccount->IdUser, $sFromEmail, true));
}
/*if ($bParseAsc && 0 < count($aAscPartsIds))
{
}*/
if ($bParseICalAndVcard) {
$oApiCapa = CApi::Manager('capability');
$oApiFileCache = CApi::Manager('filecache');
// ICAL
$sICal = $oMessage->getExtend('ICAL_RAW');
if (!empty($sICal) && $oApiCapa->isCalendarSupported($oAccount)) {
$oApiCalendarManager = CApi::Manager('calendar');
if ($oApiCalendarManager) {
$mResult = $oApiCalendarManager->processICS($oAccount, trim($sICal), $sFromEmail);
if (is_array($mResult) && !empty($mResult['Action']) && !empty($mResult['Body'])) {
$sTemptFile = md5($mResult['Body']) . '.ics';
if ($oApiFileCache && $oApiFileCache->put($oAccount, $sTemptFile, $mResult['Body'])) {
$oIcs = CApiMailIcs::createInstance();
$oIcs->Uid = $mResult['UID'];
$oIcs->Sequence = $mResult['Sequence'];
$oIcs->File = $sTemptFile;
$oIcs->Attendee = isset($mResult['Attendee']) ? $mResult['Attendee'] : null;
$oIcs->Type = $mResult['Action'];
$oIcs->Location = !empty($mResult['Location']) ? $mResult['Location'] : '';
$oIcs->Description = !empty($mResult['Description']) ? $mResult['Description'] : '';
$oIcs->When = !empty($mResult['When']) ? $mResult['When'] : '';
$oIcs->CalendarId = !empty($mResult['CalendarId']) ? $mResult['CalendarId'] : '';
if (!$oApiCapa->isCalendarAppointmentsSupported($oAccount)) {
$oIcs->Type = 'SAVE';
}
// TODO
// $oIcs->Calendars = array();
// if (isset($mResult['Calendars']) && is_array($mResult['Calendars']) && 0 < count($mResult['Calendars']))
// {
// foreach ($mResult['Calendars'] as $sUid => $sName)
// {
// $oIcs->Calendars[$sUid] = $sName;
// }
// }
$oMessage->addExtend('ICAL', $oIcs);
} else {
CApi::Log('Can\'t save temp file "' . $sTemptFile . '"', ELogLevel::Error);
}
}
}
}
// VCARD
$sVCard = $oMessage->getExtend('VCARD_RAW');
if (!empty($sVCard) && $oApiCapa->isContactsSupported($oAccount)) {
$oApiContactsManager = CApi::Manager('contacts');
$oContact = new CContact();
$oContact->InitFromVCardStr($oAccount->IdUser, $sVCard);
$oContact->initBeforeChange();
$oContact->IdContact = 0;
$bContactExists = false;
if (0 < strlen($oContact->ViewEmail)) {
if ($oApiContactsManager) {
$oLocalContact = $oApiContactsManager->getContactByEmail($oAccount->IdUser, $oContact->ViewEmail);
if ($oLocalContact) {
$oContact->IdContact = $oLocalContact->IdContact;
$bContactExists = true;
}
}
}
$sTemptFile = md5($sVCard) . '.vcf';
if ($oApiFileCache && $oApiFileCache->put($oAccount, $sTemptFile, $sVCard)) {
$oVcard = CApiMailVcard::createInstance();
$oVcard->Uid = $oContact->IdContact;
$oVcard->File = $sTemptFile;
$oVcard->Exists = !!$bContactExists;
$oVcard->Name = $oContact->FullName;
$oVcard->Email = $oContact->ViewEmail;
$oMessage->addExtend('VCARD', $oVcard);
} else {
CApi::Log('Can\'t save temp file "' . $sTemptFile . '"', ELogLevel::Error);
}
}
}
}
return $oMessage;
}
示例5: GetContactById
/**
* @param int $iUserId
* @param mixed $mContactId
* @param string $sAddressBookName
* @return CContact | false
*/
public function GetContactById($iUserId, $mContactId, $sAddressBookName = \afterlogic\DAV\Constants::ADDRESSBOOK_DEFAULT_NAME)
{
$oContact = false;
if ($this->Init($iUserId)) {
$oAddressBook = $this->getAddressBook($iUserId, $sAddressBookName);
$oContactItem = $this->geItem($iUserId, $oAddressBook, $mContactId);
if ($oContactItem) {
$sVCardData = $oContactItem->get();
if ($sVCardData) {
$oContact = new CContact();
$oContact->InitFromVCardStr($iUserId, $sVCardData);
$oContact->IdContact = $mContactId;
$oContact->ETag = trim($oContactItem->getETag(), '"');
}
}
}
return $oContact;
}
示例6: afterWriteContent
function afterWriteContent($path, \Sabre\DAV\IFile $node)
{
if ('sabredav' !== \CApi::GetManager()->GetStorageByType('contacts')) {
if ($node instanceof \Sabre\CardDAV\ICard) {
$oAccount = $this->server->getAccount();
if (isset($oAccount)) {
$iUserId = $oAccount->IdUser;
$iTenantId = $node instanceof \afterlogic\DAV\CardDAV\SharedCard ? $oAccount->IdTenant : null;
$sFileName = $node->getName();
$oContactDb = $this->oApiContactsManager->GetContactByStrId($iUserId, $sFileName, $iTenantId);
$oContact = new \CContact();
$oContact->InitFromVCardStr($iUserId, $node->get());
$oContact->IdContact = $oContactDb->IdContact;
$oContact->SharedToAll = !!$oContactDb->SharedToAll;
$bResult = $this->oApiContactsManager->UpdateContact($oContact);
// \CApi::LogObject($bResult, \ELogLevel::Full, 'contacts-');
}
}
}
}
示例7: afterWriteContent
function afterWriteContent($path, \Sabre\DAV\IFile $node)
{
if ('sabredav' !== \CApi::GetManager()->GetStorageByType('contacts')) {
if ($node instanceof \Sabre\CardDAV\ICard) {
$oAccount = $this->server->getAccount();
if (isset($oAccount)) {
$iUserId = $oAccount->IdUser;
$iTenantId = $node instanceof \afterlogic\DAV\CardDAV\SharedCard ? $oAccount->IdTenant : null;
$sContactFileName = $node->getName();
$oContactDb = $this->oApiContactsManager->GetContactByStrId($iUserId, $sContactFileName, $iTenantId);
if (!isset($oContactDb)) {
$oDavManager = \CApi::Manager('dav');
$oVCard = $oDavManager ? $oDavManager->VObjectReaderRead($node->get()) : null;
if ($oVCard && $oVCard->UID) {
$oContactDb = $this->oApiContactsManager->GetContactByStrId($iUserId, (string) $oVCard->UID . '.vcf', $iTenantId);
}
}
$oContact = new \CContact();
$oContact->InitFromVCardStr($iUserId, $node->get());
$oContact->IdContactStr = $sContactFileName;
$oContact->IdTenant = $iTenantId;
if (isset($oContactDb)) {
$oContact->IdContact = $oContactDb->IdContact;
$oContact->IdDomain = $oContactDb->IdDomain;
$oContact->SharedToAll = !!$oContactDb->SharedToAll;
$this->oApiContactsManager->UpdateContact($oContact);
} else {
$this->oApiContactsManager->CreateContact($oContact);
}
}
}
}
}