当前位置: 首页>>代码示例>>PHP>>正文


PHP CContact::initBeforeChange方法代码示例

本文整理汇总了PHP中CContact::initBeforeChange方法的典型用法代码示例。如果您正苦于以下问题:PHP CContact::initBeforeChange方法的具体用法?PHP CContact::initBeforeChange怎么用?PHP CContact::initBeforeChange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CContact的用法示例。


在下文中一共展示了CContact::initBeforeChange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:pkdevboxy,项目名称:webmail-lite,代码行数:101,代码来源:manager.php


注:本文中的CContact::initBeforeChange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。