mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-30 12:39:20 +03:00
This commit is contained in:
parent
324c7121cc
commit
b09c5d586c
3 changed files with 17 additions and 32 deletions
|
|
@ -58,7 +58,7 @@ trait Filters
|
|||
$aFilters = array();
|
||||
foreach ($aIncFilters as $aFilter)
|
||||
{
|
||||
if (is_array($aFilter))
|
||||
if (\is_array($aFilter))
|
||||
{
|
||||
$oFilter = new \RainLoop\Providers\Filters\Classes\Filter();
|
||||
if ($oFilter->FromJSON($aFilter))
|
||||
|
|
|
|||
|
|
@ -199,10 +199,9 @@ class Filter implements \JsonSerializable
|
|||
$this->bStop = isset($aFilter['Stop']) ? '1' === (string) $aFilter['Stop'] : true;
|
||||
$this->bMarkAsRead = isset($aFilter['MarkAsRead']) ? '1' === (string) $aFilter['MarkAsRead'] : false;
|
||||
|
||||
$this->aConditions = FilterCondition::CollectionFromJSON(
|
||||
isset($aFilter['Conditions']) ? $aFilter['Conditions'] : array());
|
||||
$this->aConditions = empty($aFilter['Conditions']) ? array() : FilterCondition::CollectionFromJSON($aFilter['Conditions']);
|
||||
|
||||
return true;
|
||||
return !empty($this->aConditions);
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
|
|
|
|||
|
|
@ -7,35 +7,22 @@ class FilterCondition implements \JsonSerializable
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sField;
|
||||
private $sField = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sType;
|
||||
private $sType = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sValue;
|
||||
private $sValue = '';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sValueSecond;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->Clear();
|
||||
}
|
||||
|
||||
public function Clear()
|
||||
{
|
||||
$this->sField = \RainLoop\Providers\Filters\Enumerations\ConditionField::FROM;
|
||||
$this->sType = \RainLoop\Providers\Filters\Enumerations\ConditionType::EQUAL_TO;
|
||||
$this->sValue = '';
|
||||
$this->sValueSecond = '';
|
||||
}
|
||||
private $sValueSecond = '';
|
||||
|
||||
public function Field() : string
|
||||
{
|
||||
|
|
@ -59,13 +46,12 @@ class FilterCondition implements \JsonSerializable
|
|||
|
||||
public function FromJSON(array $aData) : bool
|
||||
{
|
||||
$this->sField = isset($aData['Field']) ? $aData['Field'] :
|
||||
\RainLoop\Providers\Filters\Enumerations\ConditionField::FROM;
|
||||
|
||||
$this->sType = isset($aData['Type']) ? $aData['Type'] :
|
||||
\RainLoop\Providers\Filters\Enumerations\ConditionType::EQUAL_TO;
|
||||
|
||||
$this->sValue = isset($aData['Value']) ? (string) $aData['Value'] : '';
|
||||
if (empty($aData['Field']) || empty($aData['Type']) || empty($aData['Value'])) {
|
||||
return false;
|
||||
}
|
||||
$this->sField = $aData['Field'];
|
||||
$this->sType = $aData['Type'];
|
||||
$this->sValue = (string) $aData['Value'];
|
||||
$this->sValueSecond = isset($aData['ValueSecond']) ? (string) $aData['ValueSecond'] : '';
|
||||
|
||||
return true;
|
||||
|
|
@ -92,10 +78,10 @@ class FilterCondition implements \JsonSerializable
|
|||
{
|
||||
return array(
|
||||
'@Object' => 'Object/FilterCondition',
|
||||
'field' => $this->Field(),
|
||||
'type' => $this->Type(),
|
||||
'value' => $this->Value(),
|
||||
'valueSecond' => $this->ValueSecond()
|
||||
'Field' => $this->Field(),
|
||||
'Type' => $this->Type(),
|
||||
'Value' => $this->Value(),
|
||||
'ValueSecond' => $this->ValueSecond()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue