本文整理汇总了PHP中api_Utils::ConvertEncoding方法的典型用法代码示例。如果您正苦于以下问题:PHP api_Utils::ConvertEncoding方法的具体用法?PHP api_Utils::ConvertEncoding怎么用?PHP api_Utils::ConvertEncoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_Utils
的用法示例。
在下文中一共展示了api_Utils::ConvertEncoding方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateSieveFilters
/**
* @param CAcount $oAccount
* @param array $aFilters
*
* @return bool
*/
public function updateSieveFilters($oAccount, $aFilters)
{
$sFilters = "#sieve filter\n\n";
if ($oAccount) {
foreach ($aFilters as $oFilter) {
if ('' === trim($oFilter->Filter)) {
continue;
}
if (EFilterAction::MoveToFolder === $oFilter->Action && '' === trim($oFilter->FolderFullName)) {
continue;
}
$aFields = array();
switch ($oFilter->Field) {
default:
case EFilterFiels::From:
$aFields[] = 'From';
break;
case EFilterFiels::To:
$aFields[] = 'To';
$aFields[] = 'CC';
break;
case EFilterFiels::Subject:
$aFields[] = 'Subject';
break;
}
// condition
foreach ($aFields as $iIndex => $sField) {
$aFields[$iIndex] = '"' . $this->_quoteValue($sField) . '"';
}
$sCondition = '';
$sFields = implode(',', $aFields);
switch ($oFilter->Condition) {
case EFilterCondition::ContainSubstring:
$sCondition = 'if header :contains [' . $sFields . '] "' . $this->_quoteValue($oFilter->Filter) . '" {';
break;
case EFilterCondition::ContainExactPhrase:
$sCondition = 'if header :is [' . $sFields . '] "' . $this->_quoteValue($oFilter->Filter) . '" {';
break;
case EFilterCondition::NotContainSubstring:
$sCondition = 'if not header :contains [' . $sFields . '] "' . $this->_quoteValue($oFilter->Filter) . '" {';
break;
}
// folder
$sFolderFullName = '';
if (EFilterAction::MoveToFolder === $oFilter->Action) {
$sFolderFullName = api_Utils::ConvertEncoding($oFilter->FolderFullName, 'utf7-imap', $this->sSieveFolderCharset);
}
// action
$sAction = '';
switch ($oFilter->Action) {
case EFilterAction::DeleteFromServerImmediately:
$sAction = 'discard ;';
$sAction .= 'stop ;';
break;
case EFilterAction::MoveToFolder:
$sAction = 'fileinto "' . $this->_quoteValue($sFolderFullName) . '" ;' . "\n";
$sAction .= 'stop ;';
break;
}
$sEnd = '}';
if (!$oFilter->Enable) {
$sCondition = '#' . $sCondition;
$sAction = '#' . $sAction;
$sEnd = '#' . $sEnd;
}
$sFilters .= "\n" . '#sieve_filter:' . implode(';', array($oFilter->Enable ? '1' : '0', $oFilter->Condition, $oFilter->Field, $oFilter->Filter, $oFilter->Action, $sFolderFullName)) . "\n";
$sFilters .= $sCondition . "\n";
$sFilters .= $sAction . "\n";
$sFilters .= $sEnd . "\n";
}
$sFilters = $sFilters . "\n" . '#end sieve filter' . "\n";
return $this->setFiltersRawData($oAccount, $sFilters);
}
return false;
}