本文整理汇总了PHP中CContact::InitBeforeChange方法的典型用法代码示例。如果您正苦于以下问题:PHP CContact::InitBeforeChange方法的具体用法?PHP CContact::InitBeforeChange怎么用?PHP CContact::InitBeforeChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContact
的用法示例。
在下文中一共展示了CContact::InitBeforeChange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Message
//.........这里部分代码省略.........
$aFetchItems[] = \MailSo\Imap\Enumerations\FetchType::BODY_PEEK . '[' . $sPartID . ']';
}
}
if (!$oBodyStructure) {
$aFetchItems[] = \MailSo\Imap\Enumerations\FetchType::BODYSTRUCTURE;
}
$aFetchResponse = $oImapClient->Fetch($aFetchItems, $iUid, true);
if (0 < count($aFetchResponse)) {
$oMessage = CApiMailMessage::NewFetchResponseInstance($sFolderFullNameRaw, $aFetchResponse[0], $oBodyStructure, $sRfc822SubMimeIndex, $aAscPartsIds);
}
if ($oMessage) {
$sFromEmail = '';
$oFromCollection = $oMessage->From();
if ($oFromCollection && 0 < $oFromCollection->Count()) {
$oFrom =& $oFromCollection->GetByIndex(0);
if ($oFrom) {
$sFromEmail = trim($oFrom->GetEmail());
}
}
if (0 < strlen($sFromEmail)) {
$oApiUsersManager = CApi::Manager('users');
$oMessage->SetSafety($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::NewInstance();
$oIcs->Uid = $mResult['UID'];
$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 = '';
}
// 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::NewInstance();
$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;
}