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


PHP CContact::InitFromVCardObject方法代码示例

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


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

示例1: import

 /**
  * Allows for importing data into user's address book.
  * 
  * @param int $iUserId User ID
  * @param string $sSyncType Data source type. Currently, "csv" and "vcf" options are supported.
  * @param string $sTempFileName Path to the file data are imported from.
  * @param int $iParsedCount
  * @param int $iGroupId
  * @param bool $bIsShared
  *
  * @return int|false If importing is successful, number of imported entries is returned. 
  */
 public function import($iUserId, $sSyncType, $sTempFileName, &$iParsedCount, $iGroupId, $bIsShared)
 {
     $oApiUsersManager = CApi::Manager('users');
     $oAccount = $oApiUsersManager->getDefaultAccount($iUserId);
     if ($sSyncType === \EContactFileType::CSV) {
         $this->inc('helpers.' . $sSyncType . '.formatter');
         $this->inc('helpers.' . $sSyncType . '.parser');
         $this->inc('helpers.sync.' . $sSyncType);
         $sSyncClass = 'CApi' . ucfirst($this->GetManagerName()) . 'Sync' . ucfirst($sSyncType);
         if (class_exists($sSyncClass)) {
             $oSync = new $sSyncClass($this);
             return $oSync->Import($iUserId, $sTempFileName, $iParsedCount, $iGroupId, $bIsShared);
         }
     } else {
         if ($sSyncType === \EContactFileType::VCF) {
             // You can either pass a readable stream, or a string.
             $oHandler = fopen($sTempFileName, 'r');
             $oSplitter = new \Sabre\VObject\Splitter\VCard($oHandler);
             while ($oVCard = $oSplitter->getNext()) {
                 $oContact = new \CContact();
                 $oContact->InitFromVCardObject($iUserId, $oVCard);
                 if ($oAccount) {
                     $oContact->IdDomain = $oAccount->IdDomain;
                     $oContact->IdTenant = $oAccount->IdTenant;
                 }
                 $oContact->SharedToAll = $bIsShared;
                 $oContact->GroupsIds = array($iGroupId);
                 if ($this->createContact($oContact)) {
                     $iParsedCount++;
                 }
             }
             return $iParsedCount;
         }
     }
     return false;
 }
开发者ID:pkdevboxy,项目名称:webmail-lite,代码行数:48,代码来源:manager.php

示例2: Import

 /**
  * @param int $iUserId
  * @param string $sSyncType
  * @param string $sTempFileName
  * @param int $iParsedCount
  * @return int | false
  */
 public function Import($iUserId, $sSyncType, $sTempFileName, &$iParsedCount)
 {
     if ($sSyncType === \EContactFileType::CSV) {
         $this->inc('helpers.' . $sSyncType . '.formatter');
         $this->inc('helpers.' . $sSyncType . '.parser');
         $this->inc('helpers.sync.' . $sSyncType);
         $sSyncClass = 'CApi' . ucfirst($this->GetManagerName()) . 'Sync' . ucfirst($sSyncType);
         if (class_exists($sSyncClass)) {
             $oSync = new $sSyncClass($this);
             return $oSync->Import($iUserId, $sTempFileName, $iParsedCount);
         }
     } else {
         if ($sSyncType === \EContactFileType::VCF) {
             // You can either pass a readable stream, or a string.
             $oHandler = fopen($sTempFileName, 'r');
             $oSplitter = new \Sabre\VObject\Splitter\VCard($oHandler);
             while ($oVCard = $oSplitter->getNext()) {
                 $oContact = new \CContact();
                 $oContact->InitFromVCardObject($iUserId, $oVCard);
                 if ($this->CreateContact($oContact)) {
                     $iParsedCount++;
                 }
             }
             return $iParsedCount;
         }
     }
     return false;
 }
开发者ID:hallnewman,项目名称:webmail-lite,代码行数:35,代码来源:manager.php


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