Commit b9e7d8f2d34e044370521d8bf833cdce0888ba36
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
Showing
2 changed files
with
40 additions
and
5 deletions
search2/search/expr.inc.php
| ... | ... | @@ -585,9 +585,30 @@ class ValueExpr extends Expr |
| 585 | 585 | } |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 588 | 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 | 612 | $quote = ''; |
| 592 | 613 | if ($field->isValueQuoted()) |
| 593 | 614 | { |
| ... | ... | @@ -598,19 +619,19 @@ class ValueExpr extends Expr |
| 598 | 619 | switch($op) |
| 599 | 620 | { |
| 600 | 621 | case ExprOp::LIKE: |
| 601 | - $sql = "$fieldname LIKE '$val'"; | |
| 622 | + $sql = "$fieldname LIKE $quote$val$quote"; | |
| 602 | 623 | if ($not) $sql = "not ($sql)"; |
| 603 | 624 | break; |
| 604 | 625 | case ExprOp::CONTAINS: |
| 605 | - $sql = "$fieldname LIKE '%$val%'"; | |
| 626 | + $sql = "$fieldname LIKE $quote$val$quote"; | |
| 606 | 627 | if ($not) $sql = "not ($sql)"; |
| 607 | 628 | break; |
| 608 | 629 | case ExprOp::STARTS_WITH: |
| 609 | - $sql = "$fieldname LIKE '$val%'"; | |
| 630 | + $sql = "$fieldname LIKE $quote$val$quote"; | |
| 610 | 631 | if ($not) $sql = "not ($sql)"; |
| 611 | 632 | break; |
| 612 | 633 | case ExprOp::ENDS_WITH: |
| 613 | - $sql = "$fieldname LIKE '%$val'"; | |
| 634 | + $sql = "$fieldname LIKE $quote$val$quote"; | |
| 614 | 635 | if ($not) $sql = "not ($sql)"; |
| 615 | 636 | break; |
| 616 | 637 | case ExprOp::IS: | ... | ... |
search2/search/fields/FolderField.inc.php
| ... | ... | @@ -42,6 +42,7 @@ class FolderField extends DBFieldExpr |
| 42 | 42 | { |
| 43 | 43 | parent::__construct('full_path', 'documents', _kt('Folder')); |
| 44 | 44 | $this->setAlias('Folder'); |
| 45 | + $this->isValueQuoted(false); | |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | public function getInputRequirements() |
| ... | ... | @@ -53,6 +54,19 @@ class FolderField extends DBFieldExpr |
| 53 | 54 | { |
| 54 | 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 | 73 | \ No newline at end of file | ... | ... |