Filter improvements

This commit is contained in:
RainLoop Team 2015-05-13 02:53:01 +04:00
parent f91f74fe7c
commit 05b1c1dfe5
14 changed files with 222 additions and 68 deletions

View file

@ -128,7 +128,7 @@
'FLAGGED': 11, 'FLAGGED': 11,
'ALL': 12 'ALL': 12
}; };
/** /**
* @enum {string} * @enum {string}
*/ */
@ -321,7 +321,9 @@
Enums.FilterConditionField = { Enums.FilterConditionField = {
'From': 'From', 'From': 'From',
'Recipient': 'Recipient', 'Recipient': 'Recipient',
'Subject': 'Subject' 'Subject': 'Subject',
'Header': 'Header',
'Size': 'Size'
}; };
/** /**
@ -331,7 +333,9 @@
'Contains': 'Contains', 'Contains': 'Contains',
'NotContains': 'NotContains', 'NotContains': 'NotContains',
'EqualTo': 'EqualTo', 'EqualTo': 'EqualTo',
'NotEqualTo': 'NotEqualTo' 'NotEqualTo': 'NotEqualTo',
'Over': 'Over',
'Under': 'Under'
}; };
/** /**

View file

@ -25,11 +25,20 @@
this.value = ko.observable(''); this.value = ko.observable('');
this.value.error = ko.observable(false); this.value.error = ko.observable(false);
this.valueSecond = ko.observable('');
this.valueSecond.error = ko.observable(false);
this.template = ko.computed(function () { this.template = ko.computed(function () {
var sTemplate = ''; var sTemplate = '';
switch (this.type()) switch (this.field())
{ {
case Enums.FilterConditionField.Size:
sTemplate = 'SettingsFiltersConditionSize';
break;
case Enums.FilterConditionField.Header:
sTemplate = 'SettingsFiltersConditionMore';
break;
default: default:
sTemplate = 'SettingsFiltersConditionDefault'; sTemplate = 'SettingsFiltersConditionDefault';
break; break;
@ -39,6 +48,11 @@
}, this); }, this);
this.field.subscribe(function () {
this.value('');
this.valueSecond('');
}, this);
this.regDisposables([this.template]); this.regDisposables([this.template]);
} }
@ -52,6 +66,12 @@
return false; return false;
} }
if (Enums.FilterConditionField.Header === this.field() && '' === this.valueSecond())
{
this.valueSecond.error(true);
return false;
}
return true; return true;
}; };
@ -62,6 +82,7 @@
this.field(Utils.pString(oItem['Field'])); this.field(Utils.pString(oItem['Field']));
this.type(Utils.pString(oItem['Type'])); this.type(Utils.pString(oItem['Type']));
this.value(Utils.pString(oItem['Value'])); this.value(Utils.pString(oItem['Value']));
this.valueSecond(Utils.pString(oItem['ValueSecond']));
return true; return true;
} }
@ -74,7 +95,8 @@
return { return {
'Field': this.field(), 'Field': this.field(),
'Type': this.type(), 'Type': this.type(),
'Value': this.value() 'Value': this.value(),
'ValueSecond': this.valueSecond()
}; };
}; };
@ -85,6 +107,7 @@
oClone.field(this.field()); oClone.field(this.field());
oClone.type(this.type()); oClone.type(this.type());
oClone.value(this.value()); oClone.value(this.value());
oClone.valueSecond(this.valueSecond());
return oClone; return oClone;
}; };

View file

@ -78,6 +78,7 @@
this.actionTypeOptions = ko.observableArray([]); this.actionTypeOptions = ko.observableArray([]);
this.fieldOptions = ko.observableArray([]); this.fieldOptions = ko.observableArray([]);
this.typeOptions = ko.observableArray([]); this.typeOptions = ko.observableArray([]);
this.typeOptionsSize = ko.observableArray([]);
Translator.initOnStartOrLangChange(this.populateOptions, this); Translator.initOnStartOrLangChange(this.populateOptions, this);
@ -136,7 +137,9 @@
this.fieldOptions([ this.fieldOptions([
{'id': Enums.FilterConditionField.From, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_FROM')}, {'id': Enums.FilterConditionField.From, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_FROM')},
{'id': Enums.FilterConditionField.Recipient, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_RECIPIENTS')}, {'id': Enums.FilterConditionField.Recipient, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_RECIPIENTS')},
{'id': Enums.FilterConditionField.Subject, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')} {'id': Enums.FilterConditionField.Subject, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SUBJECT')},
{'id': Enums.FilterConditionField.Size, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_SIZE')},
{'id': Enums.FilterConditionField.Header, 'name': Translator.i18n('POPUPS_FILTER/SELECT_FIELD_HEADER')}
]); ]);
this.typeOptions([ this.typeOptions([
@ -145,6 +148,11 @@
{'id': Enums.FilterConditionType.EqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_EQUAL_TO')}, {'id': Enums.FilterConditionType.EqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_EQUAL_TO')},
{'id': Enums.FilterConditionType.NotEqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')} {'id': Enums.FilterConditionType.NotEqualTo, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_NOT_EQUAL_TO')}
]); ]);
this.typeOptionsSize([
{'id': Enums.FilterConditionType.Over, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_OVER')},
{'id': Enums.FilterConditionType.Under, 'name': Translator.i18n('POPUPS_FILTER/SELECT_TYPE_UNDER')}
]);
}; };

View file

@ -47,6 +47,11 @@ abstract class Driver
*/ */
protected $bTypedPrefix; protected $bTypedPrefix;
/**
* @var string
*/
protected $sNewLine;
/** /**
* @var int * @var int
*/ */
@ -79,6 +84,7 @@ abstract class Driver
{ {
$this->sDatePattern = 'H:i:s'; $this->sDatePattern = 'H:i:s';
$this->sName = 'INFO'; $this->sName = 'INFO';
$this->sNewLine = "\r\n";
$this->bTimePrefix = true; $this->bTimePrefix = true;
$this->bTypedPrefix = true; $this->bTypedPrefix = true;
$this->bGuidPrefix = true; $this->bGuidPrefix = true;
@ -246,15 +252,44 @@ abstract class Driver
return isset($this->aPrefixes[$iType]) ? $sName.$this->aPrefixes[$iType].': ' : ''; return isset($this->aPrefixes[$iType]) ? $sName.$this->aPrefixes[$iType].': ' : '';
} }
/**
* @param string|array $mDesc
* @param bool $bDiplayCrLf = false
*
* @return string
*/
protected function localWriteImplementation($mDesc, $bDiplayCrLf = false)
{
if ($bDiplayCrLf)
{
if (\is_array($mDesc))
{
foreach ($mDesc as &$sLine)
{
$sLine = \strtr($sLine, array("\r" => '\r', "\n" => '\n'.$this->sNewLine));
$sLine = \rtrim($mDesc);
}
}
else
{
$mDesc = \strtr($mDesc, array("\r" => '\r', "\n" => '\n'.$this->sNewLine));
$mDesc = \rtrim($mDesc);
}
}
return $this->writeImplementation($mDesc);
}
/** /**
* @final * @final
* @param string $sDesc * @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO * @param int $iType = \MailSo\Log\Enumerations\Type::INFO
* @param string $sName = '' * @param string $sName = ''
* @param bool $bDiplayCrLf = false
* *
* @return bool * @return bool
*/ */
final public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '') final public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '', $bDiplayCrLf = false)
{ {
$bResult = true; $bResult = true;
if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || 0 < $this->iWriteOnTimeoutOnly)) if (!$this->bFlushCache && ($this->bWriteOnErrorOnly || $this->bWriteOnPhpErrorOnly || 0 < $this->iWriteOnTimeoutOnly))
@ -285,18 +320,18 @@ abstract class Driver
if (isset($this->aCache[0]) && empty($this->aCache[0])) if (isset($this->aCache[0]) && empty($this->aCache[0]))
{ {
$this->aCache[0] = $sFlush; $this->aCache[0] = $sFlush;
array_unshift($this->aCache, ''); \array_unshift($this->aCache, '');
} }
else else
{ {
array_unshift($this->aCache, $sFlush); \array_unshift($this->aCache, $sFlush);
} }
$this->aCache[] = '--- FlushLogCache: Trigger'; $this->aCache[] = '--- FlushLogCache: Trigger';
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName); $this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
$this->bFlushCache = true; $this->bFlushCache = true;
$bResult = $this->writeImplementation($this->aCache); $bResult = $this->localWriteImplementation($this->aCache, $bDiplayCrLf);
$this->aCache = array(); $this->aCache = array();
} }
else if (0 < $this->iWriteOnTimeoutOnly && \time() - APP_START_TIME > $this->iWriteOnTimeoutOnly) else if (0 < $this->iWriteOnTimeoutOnly && \time() - APP_START_TIME > $this->iWriteOnTimeoutOnly)
@ -305,18 +340,18 @@ abstract class Driver
if (isset($this->aCache[0]) && empty($this->aCache[0])) if (isset($this->aCache[0]) && empty($this->aCache[0]))
{ {
$this->aCache[0] = $sFlush; $this->aCache[0] = $sFlush;
array_unshift($this->aCache, ''); \array_unshift($this->aCache, '');
} }
else else
{ {
array_unshift($this->aCache, $sFlush); \array_unshift($this->aCache, $sFlush);
} }
$this->aCache[] = '--- FlushLogCache: Trigger'; $this->aCache[] = '--- FlushLogCache: Trigger';
$this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName); $this->aCache[] = $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName);
$this->bFlushCache = true; $this->bFlushCache = true;
$bResult = $this->writeImplementation($this->aCache); $bResult = $this->localWriteImplementation($this->aCache, $bDiplayCrLf);
$this->aCache = array(); $this->aCache = array();
} }
else else
@ -326,13 +361,21 @@ abstract class Driver
} }
else else
{ {
$bResult = $this->writeImplementation( $bResult = $this->localWriteImplementation(
$this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName)); $this->loggerLineImplementation($this->getTimeWithMicroSec(), $sDesc, $iType, $sName), $bDiplayCrLf);
} }
return $bResult; return $bResult;
} }
/**
* @return string
*/
public function GetNewLine()
{
return $this->sNewLine;
}
/** /**
* @final * @final
* @return bool * @return bool

View file

@ -23,23 +23,18 @@ class File extends \MailSo\Log\Driver
*/ */
private $sLoggerFileName; private $sLoggerFileName;
/**
* @var string
*/
private $sCrLf;
/** /**
* @access protected * @access protected
* *
* @param string $sLoggerFileName * @param string $sLoggerFileName
* @param string $sCrLf = "\r\n" * @param string $sNewLine = "\r\n"
*/ */
protected function __construct($sLoggerFileName, $sCrLf = "\r\n") protected function __construct($sLoggerFileName, $sNewLine = "\r\n")
{ {
parent::__construct(); parent::__construct();
$this->sLoggerFileName = $sLoggerFileName; $this->sLoggerFileName = $sLoggerFileName;
$this->sCrLf = $sCrLf; $this->sNewLine = $sNewLine;
} }
/** /**
@ -52,13 +47,13 @@ class File extends \MailSo\Log\Driver
/** /**
* @param string $sLoggerFileName * @param string $sLoggerFileName
* @param string $sCrLf = "\r\n" * @param string $sNewLine = "\r\n"
* *
* @return \MailSo\Log\Drivers\File * @return \MailSo\Log\Drivers\File
*/ */
public static function NewInstance($sLoggerFileName, $sCrLf = "\r\n") public static function NewInstance($sLoggerFileName, $sNewLine = "\r\n")
{ {
return new self($sLoggerFileName, $sCrLf); return new self($sLoggerFileName, $sNewLine);
} }
/** /**
@ -86,11 +81,11 @@ class File extends \MailSo\Log\Driver
*/ */
private function writeToLogFile($mDesc) private function writeToLogFile($mDesc)
{ {
if (is_array($mDesc)) if (\is_array($mDesc))
{ {
$mDesc = \implode($this->sCrLf, $mDesc); $mDesc = \implode($this->sNewLine, $mDesc);
} }
return \error_log($mDesc.$this->sCrLf, 3, $this->sLoggerFileName); return \error_log($mDesc.$this->sNewLine, 3, $this->sLoggerFileName);
} }
} }

View file

@ -18,11 +18,6 @@ namespace MailSo\Log\Drivers;
*/ */
class Inline extends \MailSo\Log\Driver class Inline extends \MailSo\Log\Driver
{ {
/**
* @var string
*/
private $sNewLine;
/** /**
* @var bool * @var bool
*/ */

View file

@ -296,11 +296,13 @@ class Logger extends \MailSo\Base\Collection
* @param string $sDesc * @param string $sDesc
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO * @param int $iType = \MailSo\Log\Enumerations\Type::INFO
* @param string $sName = '' * @param string $sName = ''
* @param bool $bSearchWords = false * @param bool $bSearchSecretWords = true
* @param bool $bDiplayCrLf = false
* *
* @return bool * @return bool
*/ */
public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '', $bSearchWords = false) public function Write($sDesc, $iType = \MailSo\Log\Enumerations\Type::INFO,
$sName = '', $bSearchSecretWords = true, $bDiplayCrLf = false)
{ {
if (isset($this->aForbiddenTypes[$iType]) && true === $this->aForbiddenTypes[$iType]) if (isset($this->aForbiddenTypes[$iType]) && true === $this->aForbiddenTypes[$iType])
{ {
@ -313,7 +315,7 @@ class Logger extends \MailSo\Base\Collection
$aLoggers = array(); $aLoggers = array();
$iResult = 1; $iResult = 1;
if ($bSearchWords && !$this->bShowSecter && 0 < \count($this->aSecretWords)) if ($bSearchSecretWords && !$this->bShowSecter && 0 < \count($this->aSecretWords))
{ {
$sDesc = \str_replace($this->aSecretWords, '*******', $sDesc); $sDesc = \str_replace($this->aSecretWords, '*******', $sDesc);
} }
@ -321,7 +323,7 @@ class Logger extends \MailSo\Base\Collection
$aLoggers =& $this->GetAsArray(); $aLoggers =& $this->GetAsArray();
foreach ($aLoggers as /* @var $oLogger \MailSo\Log\Driver */ $oLogger) foreach ($aLoggers as /* @var $oLogger \MailSo\Log\Driver */ $oLogger)
{ {
$iResult &= $oLogger->Write($sDesc, $iType, $sName); $iResult &= $oLogger->Write($sDesc, $iType, $sName, $bDiplayCrLf);
} }
return (bool) $iResult; return (bool) $iResult;
@ -332,12 +334,14 @@ class Logger extends \MailSo\Base\Collection
* @param int $iType = \MailSo\Log\Enumerations\Type::INFO * @param int $iType = \MailSo\Log\Enumerations\Type::INFO
* @param string $sName = '' * @param string $sName = ''
* @param bool $bSearchSecretWords = false * @param bool $bSearchSecretWords = false
* @param bool $bDiplayCrLf = false
* *
* @return bool * @return bool
*/ */
public function WriteDump($oValue, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '', $bSearchSecretWords = false) public function WriteDump($oValue, $iType = \MailSo\Log\Enumerations\Type::INFO, $sName = '',
$bSearchSecretWords = false, $bDiplayCrLf = false)
{ {
return $this->Write(\print_r($oValue, true), $iType, $sName, $bSearchSecretWords); return $this->Write(\print_r($oValue, true), $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
} }
/** /**
@ -345,10 +349,12 @@ class Logger extends \MailSo\Base\Collection
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE * @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
* @param string $sName = '' * @param string $sName = ''
* @param bool $bSearchSecretWords = true * @param bool $bSearchSecretWords = true
* @param bool $bDiplayCrLf = false
* *
* @return bool * @return bool
*/ */
public function WriteException($oException, $iType = \MailSo\Log\Enumerations\Type::NOTICE, $sName = '', $bSearchSecretWords = true) public function WriteException($oException, $iType = \MailSo\Log\Enumerations\Type::NOTICE, $sName = '',
$bSearchSecretWords = true, $bDiplayCrLf = false)
{ {
if ($oException instanceof \Exception) if ($oException instanceof \Exception)
{ {
@ -359,7 +365,7 @@ class Logger extends \MailSo\Base\Collection
$oException->__LOGINNED__ = true; $oException->__LOGINNED__ = true;
return $this->Write((string) $oException, $iType, $sName, $bSearchSecretWords); return $this->Write((string) $oException, $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
} }
return false; return false;
@ -370,10 +376,12 @@ class Logger extends \MailSo\Base\Collection
* @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE * @param int $iType = \MailSo\Log\Enumerations\Type::NOTICE
* @param string $sName = '' * @param string $sName = ''
* @param bool $bSearchSecretWords = true * @param bool $bSearchSecretWords = true
* @param bool $bDiplayCrLf = false
* *
* @return bool * @return bool
*/ */
public function WriteMixed($mData, $iType = null, $sName = '', $bSearchSecretWords = true) public function WriteMixed($mData, $iType = null, $sName = '',
$bSearchSecretWords = true, $bDiplayCrLf = false)
{ {
$iType = null === $iType ? \MailSo\Log\Enumerations\Type::INFO : $iType; $iType = null === $iType ? \MailSo\Log\Enumerations\Type::INFO : $iType;
if (\is_array($mData) || \is_object($mData)) if (\is_array($mData) || \is_object($mData))
@ -381,16 +389,16 @@ class Logger extends \MailSo\Base\Collection
if ($mData instanceof \Exception) if ($mData instanceof \Exception)
{ {
$iType = null === $iType ? \MailSo\Log\Enumerations\Type::NOTICE : $iType; $iType = null === $iType ? \MailSo\Log\Enumerations\Type::NOTICE : $iType;
return $this->WriteException($mData, $iType, $sName, $bSearchSecretWords); return $this->WriteException($mData, $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
} }
else else
{ {
return $this->WriteDump($mData, $iType, $sName, $bSearchSecretWords); return $this->WriteDump($mData, $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
} }
} }
else else
{ {
return $this->Write($mData, $iType, $sName, $bSearchSecretWords); return $this->Write($mData, $iType, $sName, $bSearchSecretWords, $bDiplayCrLf);
} }
return false; return false;

View file

@ -557,11 +557,11 @@ abstract class NetClient
* *
* @return void * @return void
*/ */
protected function writeLog($sDesc, $iDescType = \MailSo\Log\Enumerations\Type::INFO) protected function writeLog($sDesc, $iDescType = \MailSo\Log\Enumerations\Type::INFO, $bDiplayCrLf = false)
{ {
if ($this->oLogger) if ($this->oLogger)
{ {
$this->oLogger->Write($sDesc, $iDescType, $this->getLogName()); $this->oLogger->Write($sDesc, $iDescType, $this->getLogName(), true, $bDiplayCrLf);
} }
} }
@ -573,7 +573,7 @@ abstract class NetClient
*/ */
protected function writeLogWithCrlf($sDesc, $iDescType = \MailSo\Log\Enumerations\Type::INFO) protected function writeLogWithCrlf($sDesc, $iDescType = \MailSo\Log\Enumerations\Type::INFO)
{ {
$this->writeLog(\strtr($sDesc, array("\r" => '\r', "\n" => '\n')), $iDescType); $this->writeLog($sDesc, $iDescType, true);
} }
/** /**

View file

@ -19,6 +19,11 @@ class FilterCondition
*/ */
private $sValue; private $sValue;
/**
* @var string
*/
private $sValueSecond;
public function __construct() public function __construct()
{ {
$this->Clear(); $this->Clear();
@ -29,6 +34,7 @@ class FilterCondition
$this->sField = \RainLoop\Providers\Filters\Enumerations\ConditionField::FROM; $this->sField = \RainLoop\Providers\Filters\Enumerations\ConditionField::FROM;
$this->sType = \RainLoop\Providers\Filters\Enumerations\ConditionType::EQUAL_TO; $this->sType = \RainLoop\Providers\Filters\Enumerations\ConditionType::EQUAL_TO;
$this->sValue = ''; $this->sValue = '';
$this->sValueSecond = '';
} }
/** /**
@ -55,6 +61,14 @@ class FilterCondition
return $this->sValue; return $this->sValue;
} }
/**
* @return string
*/
public function ValueSecond()
{
return $this->sValueSecond;
}
/** /**
* @param array $aData * @param array $aData
* *
@ -70,7 +84,8 @@ class FilterCondition
$this->sType = isset($aData['Type']) ? $aData['Type'] : $this->sType = isset($aData['Type']) ? $aData['Type'] :
\RainLoop\Providers\Filters\Enumerations\ConditionType::EQUAL_TO; \RainLoop\Providers\Filters\Enumerations\ConditionType::EQUAL_TO;
$this->sValue = isset($aData['Value']) ? $aData['Value'] : ''; $this->sValue = isset($aData['Value']) ? (string) $aData['Value'] : '';
$this->sValueSecond = isset($aData['ValueSecond']) ? (string) $aData['ValueSecond'] : '';
return true; return true;
} }
@ -88,7 +103,8 @@ class FilterCondition
return array( return array(
'Field' => $this->Field(), 'Field' => $this->Field(),
'Type' => $this->Type(), 'Type' => $this->Type(),
'Value' => $this->Value() 'Value' => $this->Value(),
'ValueSecond' => $this->ValueSecond()
); );
} }

View file

@ -7,4 +7,6 @@ class ConditionField
const FROM = 'From'; const FROM = 'From';
const RECIPIENT = 'Recipient'; const RECIPIENT = 'Recipient';
const SUBJECT = 'Subject'; const SUBJECT = 'Subject';
const HEADER = 'Header';
const SIZE = 'Size';
} }

View file

@ -8,4 +8,6 @@ class ConditionType
const NOT_EQUAL_TO = 'NotEqualTo'; const NOT_EQUAL_TO = 'NotEqualTo';
const CONTAINS = 'Contains'; const CONTAINS = 'Contains';
const NOT_CONTAINS = 'NotContains'; const NOT_CONTAINS = 'NotContains';
const OVER = 'Over';
const UNDER = 'Under';
} }

View file

@ -163,12 +163,23 @@ class SieveStorage implements \RainLoop\Providers\Filters\FiltersInterface
{ {
$sResult = ''; $sResult = '';
$sTypeWord = ''; $sTypeWord = '';
$bTrue = true;
$sValue = \trim($oCondition->Value()); $sValue = \trim($oCondition->Value());
if (0 < strlen($sValue)) $sValueSecond = \trim($oCondition->ValueSecond());
if (0 < \strlen($sValue) ||
(0 < \strlen($sValue) && 0 < \strlen($sValueSecond) &&
\RainLoop\Providers\Filters\Enumerations\ConditionField::HEADER === $oCondition->Field()))
{ {
switch ($oCondition->Type()) switch ($oCondition->Type())
{ {
case \RainLoop\Providers\Filters\Enumerations\ConditionType::OVER:
$sTypeWord = ':over';
break;
case \RainLoop\Providers\Filters\Enumerations\ConditionType::UNDER:
$sTypeWord = ':under';
break;
case \RainLoop\Providers\Filters\Enumerations\ConditionType::NOT_EQUAL_TO: case \RainLoop\Providers\Filters\Enumerations\ConditionType::NOT_EQUAL_TO:
$sResult .= 'not '; $sResult .= 'not ';
case \RainLoop\Providers\Filters\Enumerations\ConditionType::EQUAL_TO: case \RainLoop\Providers\Filters\Enumerations\ConditionType::EQUAL_TO:
@ -179,6 +190,10 @@ class SieveStorage implements \RainLoop\Providers\Filters\FiltersInterface
case \RainLoop\Providers\Filters\Enumerations\ConditionType::CONTAINS: case \RainLoop\Providers\Filters\Enumerations\ConditionType::CONTAINS:
$sTypeWord = ':contains'; $sTypeWord = ':contains';
break; break;
default:
$bTrue = false;
$sResult = '/* @Error: unknown type value */ false';
break;
} }
switch ($oCondition->Field()) switch ($oCondition->Field())
@ -192,26 +207,43 @@ class SieveStorage implements \RainLoop\Providers\Filters\FiltersInterface
case \RainLoop\Providers\Filters\Enumerations\ConditionField::SUBJECT: case \RainLoop\Providers\Filters\Enumerations\ConditionField::SUBJECT:
$sResult .= 'header '.$sTypeWord.' ["Subject"]'; $sResult .= 'header '.$sTypeWord.' ["Subject"]';
break; break;
case \RainLoop\Providers\Filters\Enumerations\ConditionField::HEADER:
$sResult .= 'header '.$sTypeWord.' ["'.$this->quote($sValueSecond).'"]';
break;
case \RainLoop\Providers\Filters\Enumerations\ConditionField::SIZE:
$sResult .= 'size '.$sTypeWord;
break;
default:
$bTrue = false;
$sResult = '/* @Error: unknown field value */ false';
break;
} }
if (\in_array($oCondition->Field(), array( if ($bTrue)
\RainLoop\Providers\Filters\Enumerations\ConditionField::FROM,
\RainLoop\Providers\Filters\Enumerations\ConditionField::RECIPIENT
)) && false !== \strpos($sValue, ','))
{ {
$self = $this; if (\in_array($oCondition->Field(), array(
$aValue = \array_map(function ($sValue) use ($self) { \RainLoop\Providers\Filters\Enumerations\ConditionField::FROM,
return '"'.$self->quote(\trim($sValue)).'"'; \RainLoop\Providers\Filters\Enumerations\ConditionField::RECIPIENT
}, \explode(',', $sValue)); )) && false !== \strpos($sValue, ','))
{
$self = $this;
$aValue = \array_map(function ($sValue) use ($self) {
return '"'.$self->quote(\trim($sValue)).'"';
}, \explode(',', $sValue));
$sResult .= ' ['.\trim(\implode(', ', $aValue)).']'; $sResult .= ' ['.\trim(\implode(', ', $aValue)).']';
} }
else else if (\RainLoop\Providers\Filters\Enumerations\ConditionField::SIZE === $oCondition->Field())
{ {
$sResult .= ' "'.$this->quote($sValue).'"'; $sResult .= ' '.$this->quote($sValue);
} }
else
{
$sResult .= ' "'.$this->quote($sValue).'"';
}
$sResult = \preg_replace('/[\s]+/u', ' ', $sResult); $sResult = \preg_replace('/[\s]+/u', ' ', $sResult);
}
} }
else else
{ {

View file

@ -0,0 +1,14 @@
<div class="control-group" data-bind="css: {'error': value.error}" style="margin-bottom: 0">
<select class="span2" data-bind="options: $root.fieldOptions, value: field, optionsText: 'name', optionsValue: 'id'"></select>
&nbsp;
<input class="span2" type="text" data-bind="value: valueSecond" />
&nbsp;
<select class="span2" data-bind="options: $root.typeOptions, value: type, optionsText: 'name', optionsValue: 'id'"></select>
&nbsp;
<input class="span3" type="text" data-bind="value: value" />
&nbsp;
<span class="delete-action button-delete pull-right" style="margin-top: 5px;"
data-bind="click: function (oCondition) { $root.removeCondition(oCondition); }">
<i class="icon-trash"></i>
</span>
</div>

View file

@ -0,0 +1,12 @@
<div class="control-group" data-bind="css: {'error': value.error}" style="margin-bottom: 0">
<select class="span3" data-bind="options: $root.fieldOptions, value: field, optionsText: 'name', optionsValue: 'id'"></select>
&nbsp;
<select class="span2" data-bind="options: $root.typeOptionsSize, value: type, optionsText: 'name', optionsValue: 'id'"></select>
&nbsp;
<input class="span3" type="text" data-bind="value: value" />
&nbsp;
<span class="delete-action button-delete pull-right" style="margin-top: 5px;"
data-bind="click: function (oCondition) { $root.removeCondition(oCondition); }">
<i class="icon-trash"></i>
</span>
</div>