Commit 98ead1851c7f44bd50ef8c4dc809038c2567e55d
1 parent
ae92e7ca
KTS-721: Criteria should be invertable.
Also made it explicit that date widgets are ranged. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5304 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
163 additions
and
29 deletions
lib/browse/Criteria.inc
| @@ -36,6 +36,8 @@ require_once(KT_LIB_DIR . '/workflow/workflow.inc.php'); | @@ -36,6 +36,8 @@ require_once(KT_LIB_DIR . '/workflow/workflow.inc.php'); | ||
| 36 | * @package lib.browse | 36 | * @package lib.browse |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | +$RESTRICTING_SEARCH = true; | ||
| 40 | + | ||
| 39 | class BrowseCriterion { | 41 | class BrowseCriterion { |
| 40 | var $sDisplay; | 42 | var $sDisplay; |
| 41 | var $sDocumentField; | 43 | var $sDocumentField; |
| @@ -47,6 +49,7 @@ class BrowseCriterion { | @@ -47,6 +49,7 @@ class BrowseCriterion { | ||
| 47 | var $bString = false; | 49 | var $bString = false; |
| 48 | var $sSearchTable = "D"; | 50 | var $sSearchTable = "D"; |
| 49 | var $bVisible = true; | 51 | var $bVisible = true; |
| 52 | + var $bContains = false; | ||
| 50 | 53 | ||
| 51 | function BrowseCriterion ($sDisplay, $sDocumentField, $sSortField, $iID) { | 54 | function BrowseCriterion ($sDisplay, $sDocumentField, $sSortField, $iID) { |
| 52 | $this->sDisplay =& $sDisplay; | 55 | $this->sDisplay =& $sDisplay; |
| @@ -160,14 +163,28 @@ class BrowseCriterion { | @@ -160,14 +163,28 @@ class BrowseCriterion { | ||
| 160 | 163 | ||
| 161 | function searchWidget ($aRequest, $aPreValue = null) { | 164 | function searchWidget ($aRequest, $aPreValue = null) { |
| 162 | if ($aPreValue != null) { | 165 | if ($aPreValue != null) { |
| 163 | - // !#@&)*( (*&!@# *(&@!(*&!@# | 166 | + // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 164 | $k = array_keys($aPreValue); | 167 | $k = array_keys($aPreValue); |
| 165 | $k = $k[0]; | 168 | $k = $k[0]; |
| 166 | $preval = $aPreValue[$k]; | 169 | $preval = $aPreValue[$k]; |
| 167 | - return "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" value=\"" . $preval . "\"/>"; | 170 | + return $this->getNotWidget() . "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" value=\"" . $preval . "\"/>"; |
| 171 | + } else { | ||
| 172 | + return $this->getNotWidget() . "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" />"; | ||
| 173 | + } | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + function getNotWidget() { | ||
| 177 | + // not perfect, but acceptable. | ||
| 178 | + $form_name = $this->getWidgetBase() . '_not'; | ||
| 179 | + if (!$this->bContains) { | ||
| 180 | + $not_string = _kt('is not'); | ||
| 181 | + $is_string = _kt('is'); | ||
| 168 | } else { | 182 | } else { |
| 169 | - return "<input type=\"text\" size=\"50\" name=\"" . $this->getWidgetBase() . "\" />"; | 183 | + $not_string = _kt('does not contain'); |
| 184 | + $is_string = _kt('contains'); | ||
| 170 | } | 185 | } |
| 186 | + $widget = sprintf('<select name="%s"><option value="0">%s</option><option value="1">%s</option></select> ', $form_name, $is_string, $not_string); | ||
| 187 | + return $widget; | ||
| 171 | } | 188 | } |
| 172 | 189 | ||
| 173 | function getWidgetBase () { | 190 | function getWidgetBase () { |
| @@ -178,12 +195,26 @@ class BrowseCriterion { | @@ -178,12 +195,26 @@ class BrowseCriterion { | ||
| 178 | return $this->sSearchTable; | 195 | return $this->sSearchTable; |
| 179 | } | 196 | } |
| 180 | 197 | ||
| 181 | - function searchSQL ($aRequest) { | 198 | + function searchSQL ($aRequest, $handle_not = true) { |
| 199 | + $val = null; | ||
| 182 | if ($this->bString) { | 200 | if ($this->bString) { |
| 183 | - return array($this->getSearchTable() . "." . $this->getSearchField() . " LIKE '%" . DBUtil::escapeSimple($aRequest[$this->getWidgetBase()]) . "%'", array()); | 201 | + $val = array($this->getSearchTable() . "." . $this->getSearchField() . " LIKE '%" . DBUtil::escapeSimple($aRequest[$this->getWidgetBase()]) . "%'", array()); |
| 184 | } else { | 202 | } else { |
| 185 | - return array($this->getSearchTable() . "." . $this->getSearchField() . " = ?", array($aRequest[$this->getWidgetBase()])); | 203 | + $val = array($this->getSearchTable() . "." . $this->getSearchField() . " = ?", array($aRequest[$this->getWidgetBase()])); |
| 204 | + } | ||
| 205 | + | ||
| 206 | + // handle the boolean "not" stuff UNLESS our caller is doing so already. | ||
| 207 | + if ($handle_not) { | ||
| 208 | + $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); | ||
| 209 | + | ||
| 210 | + if (is_null($want_invert)) { | ||
| 211 | + return $val; | ||
| 212 | + } else { | ||
| 213 | + $val[0] = '(NOT (' . $val[0] . '))'; | ||
| 214 | + } | ||
| 186 | } | 215 | } |
| 216 | + | ||
| 217 | + return $val; | ||
| 187 | } | 218 | } |
| 188 | 219 | ||
| 189 | function searchJoinSQL () { | 220 | function searchJoinSQL () { |
| @@ -195,6 +226,8 @@ class NameCriterion extends BrowseCriterion { | @@ -195,6 +226,8 @@ class NameCriterion extends BrowseCriterion { | ||
| 195 | var $bFolderCriterion = true; | 226 | var $bFolderCriterion = true; |
| 196 | var $bString = true; | 227 | var $bString = true; |
| 197 | var $sSearchTable = "DC"; | 228 | var $sSearchTable = "DC"; |
| 229 | + var $bContains = true; | ||
| 230 | + | ||
| 198 | function documentDisplay ($oDocument) { | 231 | function documentDisplay ($oDocument) { |
| 199 | $aOptions = $this->aOptions; | 232 | $aOptions = $this->aOptions; |
| 200 | if (array_key_exists('displayFullPath', $aOptions)) { | 233 | if (array_key_exists('displayFullPath', $aOptions)) { |
| @@ -238,6 +271,8 @@ class TitleCriterion extends BrowseCriterion { | @@ -238,6 +271,8 @@ class TitleCriterion extends BrowseCriterion { | ||
| 238 | var $bFolderCriterion = true; | 271 | var $bFolderCriterion = true; |
| 239 | var $bString = true; | 272 | var $bString = true; |
| 240 | var $sSearchTable = "DM"; | 273 | var $sSearchTable = "DM"; |
| 274 | + var $bContains = true; | ||
| 275 | + | ||
| 241 | function documentDisplay ($oDocument) { | 276 | function documentDisplay ($oDocument) { |
| 242 | return $oDocument->getName(); | 277 | return $oDocument->getName(); |
| 243 | } | 278 | } |
| @@ -257,6 +292,7 @@ class CreatorCriterion extends BrowseCriterion { | @@ -257,6 +292,7 @@ class CreatorCriterion extends BrowseCriterion { | ||
| 257 | "table" => "users", | 292 | "table" => "users", |
| 258 | "field" => "name", | 293 | "field" => "name", |
| 259 | ); | 294 | ); |
| 295 | + | ||
| 260 | function documentDisplay ($oDocument) { | 296 | function documentDisplay ($oDocument) { |
| 261 | $oCreator = User::get($oDocument->getCreatorID()); | 297 | $oCreator = User::get($oDocument->getCreatorID()); |
| 262 | if ($oCreator) { | 298 | if ($oCreator) { |
| @@ -270,12 +306,12 @@ class CreatorCriterion extends BrowseCriterion { | @@ -270,12 +306,12 @@ class CreatorCriterion extends BrowseCriterion { | ||
| 270 | function searchWidget ($aRequest, $aPreValue = null) { | 306 | function searchWidget ($aRequest, $aPreValue = null) { |
| 271 | $preval = null; | 307 | $preval = null; |
| 272 | if ($aPreValue != null) { | 308 | if ($aPreValue != null) { |
| 273 | - // !#@&)*( (*&!@# *(&@!(*&!@# | 309 | + // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 274 | $k = array_keys($aPreValue); | 310 | $k = array_keys($aPreValue); |
| 275 | $k = $k[0]; | 311 | $k = $k[0]; |
| 276 | $preval = $aPreValue[$k]; | 312 | $preval = $aPreValue[$k]; |
| 277 | } | 313 | } |
| 278 | - $sRet = "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | 314 | + $sRet = $this->getNotWidget() . "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; |
| 279 | $aUsers = User::getList();/*ok*/ | 315 | $aUsers = User::getList();/*ok*/ |
| 280 | $sRet .= "<option value=\"-1\">None</option>\n"; | 316 | $sRet .= "<option value=\"-1\">None</option>\n"; |
| 281 | foreach ($aUsers as $oUser) { | 317 | foreach ($aUsers as $oUser) { |
| @@ -309,7 +345,8 @@ class DateCreatedCriterion extends BrowseCriterion { | @@ -309,7 +345,8 @@ class DateCreatedCriterion extends BrowseCriterion { | ||
| 309 | $sToRender .= " Before date: <input type=\"text\" size=\"10\" name=\"" . $sEndWidget . "\" />"; | 345 | $sToRender .= " Before date: <input type=\"text\" size=\"10\" name=\"" . $sEndWidget . "\" />"; |
| 310 | $sToRender .= " <a href=\"javascript:show_calendar('MainForm." . $sEndWidget . "',null,null,'YYYY-MM-DD', false);\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a>"; | 346 | $sToRender .= " <a href=\"javascript:show_calendar('MainForm." . $sEndWidget . "',null,null,'YYYY-MM-DD', false);\" onmouseover=\"window.status='Date Picker';return true;\" onmouseout=\"window.status='';return true;\"><img src=\"$default->graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\"></a>"; |
| 311 | */ | 347 | */ |
| 312 | - $sToRender = 'After Date: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">' . $aPreValue[$sStartWidget] . '</strong><input type="hidden" name="' . $sStartWidget . '" class="kt_calendar_value" value="' . $aPreValue[$sStartWidget] . '"/> <input type="button" onclick="init_kt_calendar(this);" value="select"></span> — '; | 348 | + $sToRender = $this->getNotWidget(); |
| 349 | + $sToRender .= 'After Date: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">' . $aPreValue[$sStartWidget] . '</strong><input type="hidden" name="' . $sStartWidget . '" class="kt_calendar_value" value="' . $aPreValue[$sStartWidget] . '"/> <input type="button" onclick="init_kt_calendar(this);" value="select"></span> and '; | ||
| 313 | $sToRender .= 'Before Date: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">' . $aPreValue[$sStartWidget] . '</strong><input type="hidden" name="' . $sEndWidget . '" class="kt_calendar_value" value="' . $aPreValue[$sEndWidget] . '"/> <input type="button" onclick="init_kt_calendar(this);" value="select"></span><br />'; | 350 | $sToRender .= 'Before Date: <span class="kt_calendar_holder"><strong class="kt_calendar_datetext">' . $aPreValue[$sStartWidget] . '</strong><input type="hidden" name="' . $sEndWidget . '" class="kt_calendar_value" value="' . $aPreValue[$sEndWidget] . '"/> <input type="button" onclick="init_kt_calendar(this);" value="select"></span><br />'; |
| 314 | return $sToRender; | 351 | return $sToRender; |
| 315 | } | 352 | } |
| @@ -328,16 +365,30 @@ class DateCreatedCriterion extends BrowseCriterion { | @@ -328,16 +365,30 @@ class DateCreatedCriterion extends BrowseCriterion { | ||
| 328 | } else { | 365 | } else { |
| 329 | $sEnd = $aRequest[$this->getWidgetBase() . "_end"]; | 366 | $sEnd = $aRequest[$this->getWidgetBase() . "_end"]; |
| 330 | } | 367 | } |
| 368 | + | ||
| 369 | + | ||
| 370 | + $val = null; | ||
| 331 | if ($sStart && $sEnd) { | 371 | if ($sStart && $sEnd) { |
| 332 | - return array($this->getSearchTable() . "." . $this->getSearchField() . " BETWEEN ? AND ?", array($sStart, $sEnd)); | ||
| 333 | - } | ||
| 334 | - if ($sStart) { | ||
| 335 | - return array($this->getSearchTable() . "." . $this->getSearchField() . " > ?", array($sStart)); | ||
| 336 | - } | ||
| 337 | - if ($sEnd) { | ||
| 338 | - return array($this->getSearchTable() . "." . $this->getSearchField() . " < ?", array($sEnd)); | 372 | + $val = array($this->getSearchTable() . "." . $this->getSearchField() . " BETWEEN ? AND ?", array($sStart, $sEnd)); |
| 373 | + } else if ($sStart) { | ||
| 374 | + $val = array($this->getSearchTable() . "." . $this->getSearchField() . " > ?", array($sStart)); | ||
| 375 | + } else if ($sEnd) { | ||
| 376 | + $val = array($this->getSearchTable() . "." . $this->getSearchField() . " < ?", array($sEnd)); | ||
| 377 | + } else { | ||
| 378 | + return null; | ||
| 379 | + } | ||
| 380 | + | ||
| 381 | + // handle the boolean "not" stuff. | ||
| 382 | + $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); | ||
| 383 | + | ||
| 384 | + if (is_null($want_invert)) { | ||
| 385 | + return $val; | ||
| 386 | + } else { | ||
| 387 | + $val[0] = '(NOT (' . $val[0] . '))'; | ||
| 339 | } | 388 | } |
| 340 | - return null; | 389 | + |
| 390 | + // finally | ||
| 391 | + return $val; | ||
| 341 | } | 392 | } |
| 342 | 393 | ||
| 343 | } | 394 | } |
| @@ -359,12 +410,13 @@ class DocumentTypeCriterion extends BrowseCriterion { | @@ -359,12 +410,13 @@ class DocumentTypeCriterion extends BrowseCriterion { | ||
| 359 | function searchWidget ($aRequest, $aPreValue = null) { | 410 | function searchWidget ($aRequest, $aPreValue = null) { |
| 360 | $preval = null; | 411 | $preval = null; |
| 361 | if ($aPreValue != null) { | 412 | if ($aPreValue != null) { |
| 362 | - // !#@&)*( (*&!@# *(&@!(*&!@# | 413 | + // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 363 | $k = array_keys($aPreValue); | 414 | $k = array_keys($aPreValue); |
| 364 | $k = $k[0]; | 415 | $k = $k[0]; |
| 365 | $preval = $aPreValue[$k]; | 416 | $preval = $aPreValue[$k]; |
| 366 | } | 417 | } |
| 367 | - $sRet = "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | 418 | + $sRet = $this->getNotWidget(); |
| 419 | + $sRet .= "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | ||
| 368 | $aUsers = DocumentType::getList();/*ok*/ | 420 | $aUsers = DocumentType::getList();/*ok*/ |
| 369 | $sRet .= "<option value=\"-1\">None</option>\n"; | 421 | $sRet .= "<option value=\"-1\">None</option>\n"; |
| 370 | foreach ($aUsers as $oUser) { | 422 | foreach ($aUsers as $oUser) { |
| @@ -422,17 +474,19 @@ class GenericMetadataCriterion extends BrowseCriterion { | @@ -422,17 +474,19 @@ class GenericMetadataCriterion extends BrowseCriterion { | ||
| 422 | function searchWidget ($aRequest, $aPreValue = null) { | 474 | function searchWidget ($aRequest, $aPreValue = null) { |
| 423 | $preval = null; | 475 | $preval = null; |
| 424 | if ($aPreValue != null) { | 476 | if ($aPreValue != null) { |
| 425 | - // !#@&)*( (*&!@# *(&@!(*&!@# | 477 | + // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 426 | $k = array_keys($aPreValue); | 478 | $k = array_keys($aPreValue); |
| 427 | $k = $k[0]; | 479 | $k = $k[0]; |
| 428 | $preval = $aPreValue[$k]; | 480 | $preval = $aPreValue[$k]; |
| 429 | } | 481 | } |
| 430 | // If there's no lookup, just use the standard text input | 482 | // If there's no lookup, just use the standard text input |
| 431 | if ($this->oField->getHasLookup() == false) { | 483 | if ($this->oField->getHasLookup() == false) { |
| 484 | + $this->bContains = true; // contains | ||
| 432 | return parent::searchWidget($aRequest, $aPreValue); | 485 | return parent::searchWidget($aRequest, $aPreValue); |
| 433 | } | 486 | } |
| 434 | - | ||
| 435 | - $sRet = "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | 487 | + $this->bContains = false; // is |
| 488 | + $sRet = $this->getNotWidget(); | ||
| 489 | + $sRet .= "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | ||
| 436 | $aSearch = array('document_field_id = ?', $this->getID()); | 490 | $aSearch = array('document_field_id = ?', $this->getID()); |
| 437 | $aMetaData = MetaData::getByDocumentField(DocumentField::get($this->getID()));/*ok*/ | 491 | $aMetaData = MetaData::getByDocumentField(DocumentField::get($this->getID()));/*ok*/ |
| 438 | $sRet .= "<option value=\"-1\">None</option>\n"; | 492 | $sRet .= "<option value=\"-1\">None</option>\n"; |
| @@ -446,9 +500,18 @@ class GenericMetadataCriterion extends BrowseCriterion { | @@ -446,9 +500,18 @@ class GenericMetadataCriterion extends BrowseCriterion { | ||
| 446 | } | 500 | } |
| 447 | 501 | ||
| 448 | function searchSQL ($aRequest) { | 502 | function searchSQL ($aRequest) { |
| 449 | - $p = parent::searchSQL($aRequest); | 503 | + $p = parent::searchSQL($aRequest, false); // handle not ourselves. |
| 450 | $p[0] = join(' AND ', array($p[0], "$this->sSearchTable.document_field_id = ?")); | 504 | $p[0] = join(' AND ', array($p[0], "$this->sSearchTable.document_field_id = ?")); |
| 451 | $p[1] = array_merge($p[1], array($this->iID)); | 505 | $p[1] = array_merge($p[1], array($this->iID)); |
| 506 | + | ||
| 507 | + // handle the boolean "not" stuff. | ||
| 508 | + $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); | ||
| 509 | + if (is_null($want_invert)) { | ||
| 510 | + return $p; | ||
| 511 | + } else { | ||
| 512 | + $p[0] = '(NOT (' . $p[0] . '))'; | ||
| 513 | + } | ||
| 514 | + | ||
| 452 | return $p; | 515 | return $p; |
| 453 | } | 516 | } |
| 454 | 517 | ||
| @@ -483,6 +546,7 @@ class SizeCriterion extends BrowseCriterion { | @@ -483,6 +546,7 @@ class SizeCriterion extends BrowseCriterion { | ||
| 483 | } | 546 | } |
| 484 | 547 | ||
| 485 | class ContentCriterion extends BrowseCriterion { | 548 | class ContentCriterion extends BrowseCriterion { |
| 549 | + var $bContains = true; | ||
| 486 | function documentDisplay ($oDocument) { | 550 | function documentDisplay ($oDocument) { |
| 487 | return "Content"; | 551 | return "Content"; |
| 488 | } | 552 | } |
| @@ -501,7 +565,32 @@ class ContentCriterion extends BrowseCriterion { | @@ -501,7 +565,32 @@ class ContentCriterion extends BrowseCriterion { | ||
| 501 | 565 | ||
| 502 | $p = array(); | 566 | $p = array(); |
| 503 | $p[0] = "MATCH(DT.document_text) AGAINST (? $boolean_mode)"; | 567 | $p[0] = "MATCH(DT.document_text) AGAINST (? $boolean_mode)"; |
| 504 | - $p[1] = $aRequest[$this->getWidgetBase()]; | 568 | + |
| 569 | + | ||
| 570 | + | ||
| 571 | + if ($RESTRICTING_SEARCH) { | ||
| 572 | + $q_set = KTUtil::phraseSplit($aRequest[$this->getWidgetBase()]); | ||
| 573 | + $temp = $q_set; | ||
| 574 | + foreach ($temp as $k => $v) { | ||
| 575 | + $t = array(); | ||
| 576 | + foreach ($v as $part) { | ||
| 577 | + $t[] = sprintf('+"%s"', $part); | ||
| 578 | + } | ||
| 579 | + $q_set[$k] = join(' ', $t); | ||
| 580 | + } | ||
| 581 | + $p[1] = implode(' ',$q_set); | ||
| 582 | + } else { | ||
| 583 | + $p[1] = $aRequest[$this->getWidgetBase()]; | ||
| 584 | + } | ||
| 585 | + | ||
| 586 | + // handle the boolean "not" stuff. | ||
| 587 | + $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); | ||
| 588 | + if (is_null($want_invert)) { | ||
| 589 | + return $p; | ||
| 590 | + } else { | ||
| 591 | + $p[0] = '(NOT (' . $p[0] . '))'; | ||
| 592 | + } | ||
| 593 | + | ||
| 505 | return $p; | 594 | return $p; |
| 506 | } | 595 | } |
| 507 | 596 | ||
| @@ -530,19 +619,27 @@ class WorkflowStateCriterion extends BrowseCriterion { | @@ -530,19 +619,27 @@ class WorkflowStateCriterion extends BrowseCriterion { | ||
| 530 | $p = array(); | 619 | $p = array(); |
| 531 | $p[0] = "D.workflow_state_id = ?"; | 620 | $p[0] = "D.workflow_state_id = ?"; |
| 532 | $p[1] = $aRequest[$this->getWidgetBase()]; | 621 | $p[1] = $aRequest[$this->getWidgetBase()]; |
| 622 | + | ||
| 623 | + // handle the boolean "not" stuff. | ||
| 624 | + $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); | ||
| 625 | + if (is_null($want_invert)) { | ||
| 626 | + return $p; | ||
| 627 | + } else { | ||
| 628 | + $p[0] = '(NOT (' . $p[0] . '))'; | ||
| 629 | + } | ||
| 533 | return $p; | 630 | return $p; |
| 534 | } | 631 | } |
| 535 | 632 | ||
| 536 | function searchWidget ($aRequest, $aPreValue = null) { | 633 | function searchWidget ($aRequest, $aPreValue = null) { |
| 537 | $preval = null; | 634 | $preval = null; |
| 538 | if ($aPreValue != null) { | 635 | if ($aPreValue != null) { |
| 539 | - // !#@&)*( (*&!@# *(&@!(*&!@# | 636 | + // !#@&)*( (*&!@# *(&@NOT (*&!@# |
| 540 | $k = array_keys($aPreValue); | 637 | $k = array_keys($aPreValue); |
| 541 | $k = $k[0]; | 638 | $k = $k[0]; |
| 542 | $preval = $aPreValue[$k]; | 639 | $preval = $aPreValue[$k]; |
| 543 | } | 640 | } |
| 544 | - | ||
| 545 | - $sRet = "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | 641 | + $sRet = $this->getNotWidget(); |
| 642 | + $sRet .= "<select size=\"1\" name=\"" . $this->getWidgetBase() . "\">\n"; | ||
| 546 | $aStates = KTWorkflowState::getList("ORDER BY workflow_id"); | 643 | $aStates = KTWorkflowState::getList("ORDER BY workflow_id"); |
| 547 | $sRet .= "<option value=\"-1\">None</option>\n"; | 644 | $sRet .= "<option value=\"-1\">None</option>\n"; |
| 548 | foreach ($aStates as $oState) { | 645 | foreach ($aStates as $oState) { |
| @@ -557,6 +654,7 @@ class WorkflowStateCriterion extends BrowseCriterion { | @@ -557,6 +654,7 @@ class WorkflowStateCriterion extends BrowseCriterion { | ||
| 557 | } | 654 | } |
| 558 | 655 | ||
| 559 | class TransactionTextCriterion extends BrowseCriterion { | 656 | class TransactionTextCriterion extends BrowseCriterion { |
| 657 | + var $bContains = true; | ||
| 560 | function documentDisplay ($oDocument) { | 658 | function documentDisplay ($oDocument) { |
| 561 | return "Transaction text"; | 659 | return "Transaction text"; |
| 562 | } | 660 | } |
| @@ -575,7 +673,32 @@ class TransactionTextCriterion extends BrowseCriterion { | @@ -575,7 +673,32 @@ class TransactionTextCriterion extends BrowseCriterion { | ||
| 575 | 673 | ||
| 576 | $p = array(); | 674 | $p = array(); |
| 577 | $p[0] = "MATCH(DTT.document_text) AGAINST (? $boolean_mode)"; | 675 | $p[0] = "MATCH(DTT.document_text) AGAINST (? $boolean_mode)"; |
| 578 | - $p[1] = $aRequest[$this->getWidgetBase()]; | 676 | + |
| 677 | + | ||
| 678 | + | ||
| 679 | + if ($RESTRICTING_SEARCH) { | ||
| 680 | + $q_set = KTUtil::phraseSplit($aRequest[$this->getWidgetBase()]); | ||
| 681 | + $temp = $q_set; | ||
| 682 | + foreach ($temp as $k => $v) { | ||
| 683 | + $t = array(); | ||
| 684 | + foreach ($v as $part) { | ||
| 685 | + $t[] = sprintf('+"%s"', $part); | ||
| 686 | + } | ||
| 687 | + $q_set[$k] = join(' ', $t); | ||
| 688 | + } | ||
| 689 | + $p[1] = implode(' ',$q_set); | ||
| 690 | + } else { | ||
| 691 | + $p[1] = $aRequest[$this->getWidgetBase()]; | ||
| 692 | + } | ||
| 693 | + | ||
| 694 | + // handle the boolean "not" stuff. | ||
| 695 | + $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); | ||
| 696 | + if (is_null($want_invert)) { | ||
| 697 | + return $p; | ||
| 698 | + } else { | ||
| 699 | + $p[0] = '(NOT (' . $p[0] . '))'; | ||
| 700 | + } | ||
| 701 | + | ||
| 579 | return $p; | 702 | return $p; |
| 580 | } | 703 | } |
| 581 | 704 | ||
| @@ -586,6 +709,7 @@ class TransactionTextCriterion extends BrowseCriterion { | @@ -586,6 +709,7 @@ class TransactionTextCriterion extends BrowseCriterion { | ||
| 586 | } | 709 | } |
| 587 | 710 | ||
| 588 | class SearchableTextCriterion extends BrowseCriterion { | 711 | class SearchableTextCriterion extends BrowseCriterion { |
| 712 | + var $bContains = true; | ||
| 589 | function documentDisplay ($oDocument) { | 713 | function documentDisplay ($oDocument) { |
| 590 | return "Searchable text"; | 714 | return "Searchable text"; |
| 591 | } | 715 | } |
| @@ -605,7 +729,7 @@ class SearchableTextCriterion extends BrowseCriterion { | @@ -605,7 +729,7 @@ class SearchableTextCriterion extends BrowseCriterion { | ||
| 605 | $p = array(); | 729 | $p = array(); |
| 606 | $p[0] = "MATCH(DST.document_text) AGAINST (? $boolean_mode)"; | 730 | $p[0] = "MATCH(DST.document_text) AGAINST (? $boolean_mode)"; |
| 607 | 731 | ||
| 608 | - $RESTRICTING_SEARCH = true; | 732 | + |
| 609 | 733 | ||
| 610 | if ($RESTRICTING_SEARCH) { | 734 | if ($RESTRICTING_SEARCH) { |
| 611 | $q_set = KTUtil::phraseSplit($aRequest[$this->getWidgetBase()]); | 735 | $q_set = KTUtil::phraseSplit($aRequest[$this->getWidgetBase()]); |
| @@ -621,6 +745,15 @@ class SearchableTextCriterion extends BrowseCriterion { | @@ -621,6 +745,15 @@ class SearchableTextCriterion extends BrowseCriterion { | ||
| 621 | } else { | 745 | } else { |
| 622 | $p[1] = $aRequest[$this->getWidgetBase()]; | 746 | $p[1] = $aRequest[$this->getWidgetBase()]; |
| 623 | } | 747 | } |
| 748 | + | ||
| 749 | + // handle the boolean "not" stuff. | ||
| 750 | + $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not'); | ||
| 751 | + if (is_null($want_invert)) { | ||
| 752 | + return $p; | ||
| 753 | + } else { | ||
| 754 | + $p[0] = '(NOT (' . $p[0] . '))'; | ||
| 755 | + } | ||
| 756 | + | ||
| 624 | return $p; | 757 | return $p; |
| 625 | } | 758 | } |
| 626 | 759 | ||
| @@ -631,6 +764,7 @@ class SearchableTextCriterion extends BrowseCriterion { | @@ -631,6 +764,7 @@ class SearchableTextCriterion extends BrowseCriterion { | ||
| 631 | } | 764 | } |
| 632 | 765 | ||
| 633 | class Criteria { | 766 | class Criteria { |
| 767 | + | ||
| 634 | function &_getBaseCriterionByNumber($iID) { | 768 | function &_getBaseCriterionByNumber($iID) { |
| 635 | global $default; | 769 | global $default; |
| 636 | switch ($iID) { | 770 | switch ($iID) { |