Commit b9e7d8f2d34e044370521d8bf833cdce0888ba36

Authored by kevin_fourie
1 parent 67d9f73c

Merged in from DEV trunk...

KTS-3043
"On reread of plugins the quicklinks plugin is set to disabled"
Fixed. Moved the checks on the end version after an upgrade into the if statement containing the upgrade.

Committed By: Megan Watson
Reviewed By: Conrad Vermeulen

KTS-2913
"Search2: A search query for a FOLDER returns no results"
Fixed. Also ensured that wildcards are catered for correctly for LIKE operations.

Committed By: Conrad Vermeulen
Reviewed By: Kevin Fourie

git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@8078 c91229c3-7414-0410-bfa2-8a42b809f60b
search2/search/expr.inc.php
@@ -585,9 +585,30 @@ class ValueExpr extends Expr @@ -585,9 +585,30 @@ class ValueExpr extends Expr
585 } 585 }
586 } 586 }
587 587
  588 +
  589 +
  590 +
588 public function getSQL($field, $fieldname, $op, $not=false) 591 public function getSQL($field, $fieldname, $op, $not=false)
589 { 592 {
590 - $val = $field->modifyValue($this->getValue()); 593 + $val = $this->getValue();
  594 + switch($op)
  595 + {
  596 + case ExprOp::LIKE:
  597 +
  598 + break;
  599 + case ExprOp::CONTAINS:
  600 + $val = "%$val%";
  601 + break;
  602 + case ExprOp::STARTS_WITH:
  603 + $val = "$val%";
  604 + break;
  605 + case ExprOp::ENDS_WITH:
  606 + $val = "%$val";
  607 + break;
  608 + }
  609 +
  610 +
  611 + $val = $field->modifyValue($val);
591 $quote = ''; 612 $quote = '';
592 if ($field->isValueQuoted()) 613 if ($field->isValueQuoted())
593 { 614 {
@@ -598,19 +619,19 @@ class ValueExpr extends Expr @@ -598,19 +619,19 @@ class ValueExpr extends Expr
598 switch($op) 619 switch($op)
599 { 620 {
600 case ExprOp::LIKE: 621 case ExprOp::LIKE:
601 - $sql = "$fieldname LIKE '$val'"; 622 + $sql = "$fieldname LIKE $quote$val$quote";
602 if ($not) $sql = "not ($sql)"; 623 if ($not) $sql = "not ($sql)";
603 break; 624 break;
604 case ExprOp::CONTAINS: 625 case ExprOp::CONTAINS:
605 - $sql = "$fieldname LIKE '%$val%'"; 626 + $sql = "$fieldname LIKE $quote$val$quote";
606 if ($not) $sql = "not ($sql)"; 627 if ($not) $sql = "not ($sql)";
607 break; 628 break;
608 case ExprOp::STARTS_WITH: 629 case ExprOp::STARTS_WITH:
609 - $sql = "$fieldname LIKE '$val%'"; 630 + $sql = "$fieldname LIKE $quote$val$quote";
610 if ($not) $sql = "not ($sql)"; 631 if ($not) $sql = "not ($sql)";
611 break; 632 break;
612 case ExprOp::ENDS_WITH: 633 case ExprOp::ENDS_WITH:
613 - $sql = "$fieldname LIKE '%$val'"; 634 + $sql = "$fieldname LIKE $quote$val$quote";
614 if ($not) $sql = "not ($sql)"; 635 if ($not) $sql = "not ($sql)";
615 break; 636 break;
616 case ExprOp::IS: 637 case ExprOp::IS:
search2/search/fields/FolderField.inc.php
@@ -42,6 +42,7 @@ class FolderField extends DBFieldExpr @@ -42,6 +42,7 @@ class FolderField extends DBFieldExpr
42 { 42 {
43 parent::__construct('full_path', 'documents', _kt('Folder')); 43 parent::__construct('full_path', 'documents', _kt('Folder'));
44 $this->setAlias('Folder'); 44 $this->setAlias('Folder');
  45 + $this->isValueQuoted(false);
45 } 46 }
46 47
47 public function getInputRequirements() 48 public function getInputRequirements()
@@ -53,6 +54,19 @@ class FolderField extends DBFieldExpr @@ -53,6 +54,19 @@ class FolderField extends DBFieldExpr
53 { 54 {
54 return DefaultOpCollection::validateParent($this, DefaultOpCollection::$is); 55 return DefaultOpCollection::validateParent($this, DefaultOpCollection::$is);
55 } 56 }
  57 +
  58 + public function modifyName($sql)
  59 + {
  60 + $this->path = $sql;
  61 + return "case when position('/' in $sql) = 0 then '/' else reverse(substring(reverse($sql) from position('/' in reverse($sql)) + 1 )) end";
  62 + }
  63 +
  64 +
  65 + public function modifyValue($value)
  66 + {
  67 + return "case when position('/' in $this->path) = 0 then '/' else '$value' end";
  68 + }
  69 +
56 } 70 }
57 71
58 ?> 72 ?>
59 \ No newline at end of file 73 \ No newline at end of file