Skip to content

Commit

Permalink
Merge branch '2023.11' into 2024.11
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Jan 31, 2024
2 parents 8a9a1a5 + c04ee39 commit 08404b7
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions tine20/Tinebase/Model/Filter/CustomField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
*/

Expand Down Expand Up @@ -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' :
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
*
Expand Down

0 comments on commit 08404b7

Please sign in to comment.