本文整理汇总了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;
}
示例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;
}