本文整理汇总了PHP中api_Utils::ClearPhone方法的典型用法代码示例。如果您正苦于以下问题:PHP api_Utils::ClearPhone方法的具体用法?PHP api_Utils::ClearPhone怎么用?PHP api_Utils::ClearPhone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_Utils
的用法示例。
在下文中一共展示了api_Utils::ClearPhone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNamesByCallersNumbers
/**
* @param CAccount $oAccount
* @param array $aNumbers
* @param bool $bUseCache = true
* @return array
*/
public function getNamesByCallersNumbers($oAccount, $aNumbers, $bUseCache = true)
{
$mResult = false;
$oApiContactsManager = CApi::Manager('contactsmain');
if (is_array($aNumbers) && 0 < count($aNumbers) && $oAccount && $oApiContactsManager) {
$bFromCache = false;
$sCacheKey = '';
$mNamesResult = null;
$oApiFileCache = $bUseCache ? CApi::Manager('filecache') : false;
if ($oApiFileCache) {
$sCacheKey = $this->_generateCacheFileName($oAccount->IdUser);
if (!empty($sCacheKey)) {
$sData = $oApiFileCache->get($oAccount, $sCacheKey);
if (!empty($sData)) {
$mNamesResult = @json_decode($sData, true);
if (!is_array($mNamesResult)) {
$mNamesResult = null;
} else {
$bFromCache = true;
CApi::Log('Cache: get contacts names from cache (count:' . count($mNamesResult) . ')');
}
}
}
}
if (!is_array($mNamesResult)) {
$mNamesResult = $oApiContactsManager->GetAllContactsNamesWithPhones($oAccount);
}
if (is_array($mNamesResult)) {
if (!$bFromCache && $oApiFileCache && 0 < strlen($sCacheKey)) {
$oApiFileCache->put($oAccount, $sCacheKey, @json_encode($mNamesResult));
CApi::Log('Cache: save contacts names to cache (count:' . count($mNamesResult) . ')');
}
$aNormNumbers = array();
foreach ($aNumbers as $sNumber) {
$aNormNumbers[$sNumber] = api_Utils::ClearPhone($sNumber);
}
foreach ($aNormNumbers as $sInputNumber => $sClearNumber) {
$aNormNumbers[$sInputNumber] = isset($mNamesResult[$sClearNumber]) ? $mNamesResult[$sClearNumber] : '';
}
$mResult = $aNormNumbers;
}
} else {
if (is_array($aNumbers)) {
$mResult = array();
}
}
return $mResult;
}
示例2: GetAllContactsNamesWithPhones
/**
* @param int $iUserId
* @param int $iTenantId = 0
* @param bool $bAddGlobal = true
* @return bool|array
*/
public function GetAllContactsNamesWithPhones($iUserId, $iTenantId = 0, $bAddGlobal = true)
{
$mNames = false;
if ($this->oConnection->Execute($this->oCommandCreator->GetAllContactsNamesWithPhones($iUserId, $iTenantId, $bAddGlobal))) {
$mNames = array();
while (false !== ($oRow = $this->oConnection->GetNextRecord())) {
$sName = trim($oRow->fullname);
if (0 === strlen($sName)) {
$sName = trim($oRow->firstname);
$sName .= ' ' . trim($oRow->surname);
$sName = trim($sName);
}
if (0 === strlen($sName)) {
$sName = trim($oRow->view_email);
}
if (0 < strlen($sName)) {
$sPhone = trim($oRow->b_phone);
if (0 < strlen($sPhone)) {
$sPhone = api_Utils::ClearPhone($sPhone);
if (0 < strlen($sPhone)) {
$mNames[$sPhone] = $sName;
}
}
$sPhone = trim($oRow->h_phone);
if (0 < strlen($sPhone)) {
$sPhone = api_Utils::ClearPhone($sPhone);
if (0 < strlen($sPhone)) {
$mNames[$sPhone] = $sName;
}
}
$sPhone = trim($oRow->h_mobile);
if (0 < strlen($sPhone)) {
$sPhone = api_Utils::ClearPhone($sPhone);
if (0 < strlen($sPhone)) {
$mNames[$sPhone] = $sName;
}
}
}
}
}
return $mNames;
}