Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Fix container update from other context (like plugins)
- Fix "not equals" search operator for dropdown `multiple`

## [1.21.19] - 2025-02-03

Expand Down
19 changes: 14 additions & 5 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,6 @@ function plugin_datainjection_populate_fields()

function plugin_fields_addWhere($link, $nott, $itemtype, $ID, $val, $searchtype)
{
/** @var \DBmysql $DB */
global $DB;

$searchopt = &Search::getOptions($itemtype);
$table = $searchopt[$ID]['table'];
$field = $searchopt[$ID]['field'];
Expand All @@ -357,12 +354,19 @@ function plugin_fields_addWhere($link, $nott, $itemtype, $ID, $val, $searchtype)
],
)
) {
return $link . $DB->quoteName("$table" . '_' . "$field") . '.' . $DB->quoteName($field) . 'LIKE ' . $DB->quoteValue("%\"$val\"%") ;
$tablefield = "$table" . '_' . "$field";
switch ($searchtype) {
case 'equals':
return PluginFieldsDropdown::multipleDropdownAddWhere($link, $tablefield, $field, $val, $nott ? 'notequals' : 'equals');
case 'notequals':
return PluginFieldsDropdown::multipleDropdownAddWhere($link, $tablefield, $field, $val, $nott ? 'equals' : 'notequals');
}
} else {
// if 'multiple' field with cleaned name is found -> 'dropdown' case
// update WHERE clause with LIKE statement
$cleanfield = str_replace('plugin_fields_', '', $field);
$cleanfield = str_replace('dropdowns_id', '', $cleanfield);
$tablefield = "$table" . '_' . "$cleanfield";
if (
$field_field->getFromDBByCrit(
[
Expand All @@ -371,7 +375,12 @@ function plugin_fields_addWhere($link, $nott, $itemtype, $ID, $val, $searchtype)
],
)
) {
return $link . $DB->quoteName("$table" . '_' . "$cleanfield") . '.' . $DB->quoteName($field) . 'LIKE ' . $DB->quoteValue("%\"$val\"%") ;
switch ($searchtype) {
case 'equals':
return PluginFieldsDropdown::multipleDropdownAddWhere($link, $tablefield, $field, $val, $nott ? 'notequals' : 'equals');
case 'notequals':
return PluginFieldsDropdown::multipleDropdownAddWhere($link, $tablefield, $field, $val, $nott ? 'equals' : 'notequals');
}
} else {
return false;
}
Expand Down
13 changes: 13 additions & 0 deletions inc/dropdown.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,17 @@ public static function getClassname($system_name)
{
return 'PluginFields' . ucfirst($system_name) . 'Dropdown';
}

public static function multipleDropdownAddWhere($link, $tablefield, $field, $val, $searchtype)
{
/** @var \DBmysql $DB */
global $DB;

switch ($searchtype) {
case 'equals':
return $link . $DB->quoteName($tablefield) . '.' . $DB->quoteName($field) . 'LIKE ' . $DB->quoteValue("%\"$val\"%") ;
case 'notequals':
return $link . $DB->quoteName($tablefield) . '.' . $DB->quoteName($field) . 'NOT LIKE ' . $DB->quoteValue("%\"$val\"%") . ' OR ' . $link . $DB->quoteName($tablefield) . '.' . $DB->quoteName($field) . 'IS NULL ';
}
}
}