Commit a45de44f4bb078c3d69b3bc1f988eb231930d131
1 parent
cca12eee
fix for KTS-977: saved searches don't take is/is not into account properly.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5420 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
15 additions
and
12 deletions
lib/browse/Criteria.inc
| ... | ... | @@ -175,15 +175,18 @@ class BrowseCriterion { |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | function getNotWidget($aPreValue=null) { |
| 178 | - if (is_null($aPreValue)) { | |
| 179 | - $is_positive = true; | |
| 180 | - } | |
| 181 | 178 | if (!$this->bHandleNot) { return ''; } |
| 182 | 179 | |
| 183 | 180 | // not perfect, but acceptable. |
| 184 | 181 | $form_name = $this->getWidgetBase() . '_not'; |
| 185 | 182 | $pos_select = ''; |
| 186 | 183 | $neg_select = ''; |
| 184 | + if (is_null($aPreValue)) { | |
| 185 | + $is_positive = true; | |
| 186 | + } else { | |
| 187 | + $preval = KTUtil::arrayGet($aPreValue, $form_name, "0"); // by default, use "is" not "is not" | |
| 188 | + $is_positive = ($preval == "0"); // 0 or empty or similar. | |
| 189 | + } | |
| 187 | 190 | if ($is_positive) { |
| 188 | 191 | $pos_select = ' selected="true"'; |
| 189 | 192 | } else { |
| ... | ... | @@ -220,7 +223,7 @@ class BrowseCriterion { |
| 220 | 223 | if ($handle_not) { |
| 221 | 224 | $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); |
| 222 | 225 | |
| 223 | - if (is_null($want_invert)) { | |
| 226 | + if (is_null($want_invert) || ($want_invert == "0")) { // use explicit "0" check | |
| 224 | 227 | return $val; |
| 225 | 228 | } else { |
| 226 | 229 | $val[0] = '(NOT (' . $val[0] . '))'; |
| ... | ... | @@ -394,7 +397,7 @@ class DateCreatedCriterion extends BrowseCriterion { |
| 394 | 397 | // handle the boolean "not" stuff. |
| 395 | 398 | $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); |
| 396 | 399 | |
| 397 | - if (is_null($want_invert)) { | |
| 400 | + if (is_null($want_invert) || ($want_invert == "0")) { | |
| 398 | 401 | return $val; |
| 399 | 402 | } else { |
| 400 | 403 | $val[0] = '(NOT (' . $val[0] . '))'; |
| ... | ... | @@ -519,7 +522,7 @@ class GenericMetadataCriterion extends BrowseCriterion { |
| 519 | 522 | |
| 520 | 523 | // handle the boolean "not" stuff. |
| 521 | 524 | $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); |
| 522 | - if (is_null($want_invert)) { | |
| 525 | + if (is_null($want_invert) || ($want_invert == "0")) { | |
| 523 | 526 | return $p; |
| 524 | 527 | } else { |
| 525 | 528 | $p[0] = '(NOT (' . $p[0] . '))'; |
| ... | ... | @@ -600,7 +603,7 @@ class ContentCriterion extends BrowseCriterion { |
| 600 | 603 | |
| 601 | 604 | // handle the boolean "not" stuff. |
| 602 | 605 | $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); |
| 603 | - if (is_null($want_invert)) { | |
| 606 | + if (is_null($want_invert) || ($want_invert == "0")) { | |
| 604 | 607 | return $p; |
| 605 | 608 | } else { |
| 606 | 609 | $p[0] = '(NOT (' . $p[0] . '))'; |
| ... | ... | @@ -637,7 +640,7 @@ class WorkflowStateCriterion extends BrowseCriterion { |
| 637 | 640 | |
| 638 | 641 | // handle the boolean "not" stuff. |
| 639 | 642 | $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); |
| 640 | - if (is_null($want_invert)) { | |
| 643 | + if (is_null($want_invert) || ($want_invert == "0")) { | |
| 641 | 644 | return $p; |
| 642 | 645 | } else { |
| 643 | 646 | $p[0] = '(NOT (' . $p[0] . '))'; |
| ... | ... | @@ -710,7 +713,7 @@ class TransactionTextCriterion extends BrowseCriterion { |
| 710 | 713 | |
| 711 | 714 | // handle the boolean "not" stuff. |
| 712 | 715 | $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); |
| 713 | - if (is_null($want_invert)) { | |
| 716 | + if (is_null($want_invert) || ($want_invert == "0")) { | |
| 714 | 717 | return $p; |
| 715 | 718 | } else { |
| 716 | 719 | $p[0] = '(NOT (' . $p[0] . '))'; |
| ... | ... | @@ -767,7 +770,7 @@ class SearchableTextCriterion extends BrowseCriterion { |
| 767 | 770 | |
| 768 | 771 | // handle the boolean "not" stuff. |
| 769 | 772 | $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); |
| 770 | - if (is_null($want_invert)) { | |
| 773 | + if (is_null($want_invert) || ($want_invert == "0")) { | |
| 771 | 774 | return $p; |
| 772 | 775 | } else { |
| 773 | 776 | $p[0] = '(NOT (' . $p[0] . '))'; | ... | ... |
plugins/ktcore/admin/savedSearch.php
| ... | ... | @@ -98,11 +98,11 @@ class KTSavedSearchDispatcher extends KTAdminDispatcher { |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $aSearch = $oSearch->getSearch(); |
| 101 | - | |
| 101 | + /* | |
| 102 | 102 | print '<pre>'; |
| 103 | 103 | print_r($aSearch); |
| 104 | 104 | exit(0); |
| 105 | - | |
| 105 | + */ | |
| 106 | 106 | |
| 107 | 107 | $oTemplating =& KTTemplating::getSingleton(); |
| 108 | 108 | $oTemplate = $oTemplating->loadTemplate("ktcore/boolean_search_edit"); | ... | ... |