-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
17 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* @package Tinebase | ||
* @subpackage Filter | ||
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3 | ||
* @copyright Copyright (c) 2009-2017 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* @copyright Copyright (c) 2009-2024 Metaways Infosystems GmbH (http://www.metaways.de) | ||
* @author Philipp Schuele <[email protected]> | ||
*/ | ||
|
||
|
@@ -131,13 +131,6 @@ public function __construct($_fieldOrData, $_operator = NULL, $_value = NULL, ar | |
$filterClass = Tinebase_Model_Filter_Text::class; | ||
break; | ||
case 'textarea': | ||
// TODO is this still needed? | ||
// $forceFullText = isset($_fieldOrData['value'][self::OPT_FORCE_FULLTEXT]) ? | ||
// (bool)$_fieldOrData['value'][self::OPT_FORCE_FULLTEXT] : false; | ||
// if ($forceFullText) { | ||
// $filterClass = Tinebase_Model_Filter_FullText::class; | ||
// } | ||
|
||
$filterClass = Tinebase_Model_Filter_FullText::class; | ||
break; | ||
case 'date' : | ||
|
@@ -168,6 +161,7 @@ public function __construct($_fieldOrData, $_operator = NULL, $_value = NULL, ar | |
'controller' => get_class(Tinebase_Core::getApplicationInstance($modelName)), | ||
'filtergroup' => $filterGroup, | ||
]; | ||
$passThroughData['value'] = $this->_sanitizePassThroughFilter($passThroughData['value']); | ||
$this->_passThroughFilter = new Tinebase_Model_Filter_ForeignId($passThroughData); | ||
} else { | ||
$filterClass = Tinebase_Model_Filter_Id::class; | ||
|
@@ -176,7 +170,6 @@ public function __construct($_fieldOrData, $_operator = NULL, $_value = NULL, ar | |
case 'records': | ||
// TODO support recordset | ||
throw new Tinebase_Exception_NotImplemented('filter for records type not implemented yet'); | ||
break; | ||
case 'keyField': | ||
$filterClass = Tinebase_Model_Filter_Id::class; | ||
break; | ||
|
@@ -199,6 +192,21 @@ public function __construct($_fieldOrData, $_operator = NULL, $_value = NULL, ar | |
parent::__construct($_fieldOrData, $_operator, $_value, $_options); | ||
} | ||
|
||
protected function _sanitizePassThroughFilter(array $value): array | ||
{ | ||
$result = []; | ||
foreach ($value as $filterData) { | ||
if ($filterData['operator'] === 'AND' && (! isset($filterData['value']) || empty($filterData['value']))) { | ||
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice( | ||
__METHOD__ . '::' . __LINE__ . ' Skip invalid filter: ' . print_r($filterData, true)); | ||
} else { | ||
$result[] = $filterData; | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* sets operator | ||
* | ||
|