removes wildcard handling in text filter for in/notin operators
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 28 Aug 2014 12:28:57 +0000 (14:28 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 28 Aug 2014 13:19:45 +0000 (15:19 +0200)
... as this breaks searches for strings with '_' or '*' in them

Change-Id: I5a92522b2fb672416dcf94530b43ba5adabda7b2
Reviewed-on: http://gerrit.tine20.com/customers/1060
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Model/Filter/Text.php

index ca5cb0e..9a9b3b1 100644 (file)
@@ -98,13 +98,16 @@ class Tinebase_Model_Filter_Text extends Tinebase_Model_Filter_Abstract
             throw new Tinebase_Exception_InvalidArgument('Operator "' . $this->_operator . '" not defined in sql map of ' . get_class($this));
         }
         $action = $this->_opSqlMap[$this->_operator];
-        $value = $this->_replaceWildcards($this->_value);
-
+        
+        // don't remove wildcards for certain operators
+        // TODO add an option for this?
+        $value = (! in_array($this->_operator, array('in', 'notin'))) ? $this->_replaceWildcards($this->_value) : $this->_value;
+        
         // check if group by is operator and return if this is the case
         if ($this->_operator == 'group') {
             $_select->group($this->_field);
         }
-
+        
         if (in_array($this->_operator, array('in', 'notin')) && ! is_array($value)) {
             $value = explode(' ', $value);
         }
@@ -129,8 +132,7 @@ class Tinebase_Model_Filter_Text extends Tinebase_Model_Filter_Abstract
         
         if (! in_array($this->_operator, array('in', 'notin'))) {
             $where = Tinebase_Core::getDb()->quoteInto(Tinebase_Backend_Sql_Command::factory($db)->prepareForILike($field) . ' ' . $action['sqlop'], $value);
-        }
-        else {
+        } else {
             $where = Tinebase_Core::getDb()->quoteInto($field . $action['sqlop'], $value);
         }