From 1d17bd21adae39687be8c00de8b05208604994b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20L=C3=BCtzenkirchen?= Date: Thu, 20 Aug 2015 12:30:02 +0200 Subject: [PATCH] ADT: search fixes --- .../Enum/class.ilADTEnumSearchBridgeMulti.php | 17 +++++++++++++++-- .../class.ilADTIntegerSearchBridgeSingle.php | 2 ++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Services/ADT/classes/Types/Enum/class.ilADTEnumSearchBridgeMulti.php b/Services/ADT/classes/Types/Enum/class.ilADTEnumSearchBridgeMulti.php index 21ca3cc19865..985f94926558 100644 --- a/Services/ADT/classes/Types/Enum/class.ilADTEnumSearchBridgeMulti.php +++ b/Services/ADT/classes/Types/Enum/class.ilADTEnumSearchBridgeMulti.php @@ -4,7 +4,16 @@ class ilADTEnumSearchBridgeMulti extends ilADTSearchBridgeMulti { - protected $multi_source; // [boo] + protected $multi_source; // [bool] + protected $search_mode; // [int] + + const SEARCH_MODE_ALL = 1; + const SEARCH_MODE_ANY = 2; + + public function setSearchMode($a_mode) + { + $this->search_mode = (int)$a_mode; + } protected function isValidADTDefinition(ilADTDefinition $a_adt_def) { @@ -107,6 +116,10 @@ public function getSQLCondition($a_element_id) { include_once "Services/ADT/classes/Types/MultiEnum/class.ilADTMultiEnumDBBridge.php"; + $mode_concat = ($this->search_mode == self::SEARCH_MODE_ANY) + ? " OR " + : " AND "; + $parts = array(); foreach($this->getADT()->getSelections() as $item) { @@ -115,7 +128,7 @@ public function getSQLCondition($a_element_id) ilADTMultiEnumDBBridge::SEPARATOR."%"; $parts[] = $ilDB->like($a_element_id, "text", $item, false); } - return "(".implode(" AND ", $parts).")"; + return "(".implode($mode_concat, $parts).")"; } return $ilDB->in($a_element_id, $this->getADT()->getSelections(), "", $type); diff --git a/Services/ADT/classes/Types/Integer/class.ilADTIntegerSearchBridgeSingle.php b/Services/ADT/classes/Types/Integer/class.ilADTIntegerSearchBridgeSingle.php index a34560d1c273..89e5fda44ac3 100644 --- a/Services/ADT/classes/Types/Integer/class.ilADTIntegerSearchBridgeSingle.php +++ b/Services/ADT/classes/Types/Integer/class.ilADTIntegerSearchBridgeSingle.php @@ -47,6 +47,8 @@ public function addToForm() $number->setMaxLength($length); } + $number->setValue($this->getADT()->getNumber()); + $this->addToParentElement($number); }