diff --git a/lib/browse/Criteria.inc b/lib/browse/Criteria.inc
index b43fb46..015d37e 100644
--- a/lib/browse/Criteria.inc
+++ b/lib/browse/Criteria.inc
@@ -36,6 +36,8 @@ require_once(KT_LIB_DIR . '/workflow/workflow.inc.php');
* @package lib.browse
*/
+$RESTRICTING_SEARCH = true;
+
class BrowseCriterion {
var $sDisplay;
var $sDocumentField;
@@ -47,6 +49,7 @@ class BrowseCriterion {
var $bString = false;
var $sSearchTable = "D";
var $bVisible = true;
+ var $bContains = false;
function BrowseCriterion ($sDisplay, $sDocumentField, $sSortField, $iID) {
$this->sDisplay =& $sDisplay;
@@ -160,14 +163,28 @@ class BrowseCriterion {
function searchWidget ($aRequest, $aPreValue = null) {
if ($aPreValue != null) {
- // !#@&)*( (*&!@# *(&@!(*&!@#
+ // !#@&)*( (*&!@# *(&@NOT (*&!@#
$k = array_keys($aPreValue);
$k = $k[0];
$preval = $aPreValue[$k];
- return "getWidgetBase() . "\" value=\"" . $preval . "\"/>";
+ return $this->getNotWidget() . "getWidgetBase() . "\" value=\"" . $preval . "\"/>";
+ } else {
+ return $this->getNotWidget() . "getWidgetBase() . "\" />";
+ }
+ }
+
+ function getNotWidget() {
+ // not perfect, but acceptable.
+ $form_name = $this->getWidgetBase() . '_not';
+ if (!$this->bContains) {
+ $not_string = _kt('is not');
+ $is_string = _kt('is');
} else {
- return "getWidgetBase() . "\" />";
+ $not_string = _kt('does not contain');
+ $is_string = _kt('contains');
}
+ $widget = sprintf(' ', $form_name, $is_string, $not_string);
+ return $widget;
}
function getWidgetBase () {
@@ -178,12 +195,26 @@ class BrowseCriterion {
return $this->sSearchTable;
}
- function searchSQL ($aRequest) {
+ function searchSQL ($aRequest, $handle_not = true) {
+ $val = null;
if ($this->bString) {
- return array($this->getSearchTable() . "." . $this->getSearchField() . " LIKE '%" . DBUtil::escapeSimple($aRequest[$this->getWidgetBase()]) . "%'", array());
+ $val = array($this->getSearchTable() . "." . $this->getSearchField() . " LIKE '%" . DBUtil::escapeSimple($aRequest[$this->getWidgetBase()]) . "%'", array());
} else {
- return array($this->getSearchTable() . "." . $this->getSearchField() . " = ?", array($aRequest[$this->getWidgetBase()]));
+ $val = array($this->getSearchTable() . "." . $this->getSearchField() . " = ?", array($aRequest[$this->getWidgetBase()]));
+ }
+
+ // handle the boolean "not" stuff UNLESS our caller is doing so already.
+ if ($handle_not) {
+ $want_invert = KTUtil::arrayGet($aRequest, $this->getWidgetBase() . '_not');
+
+ if (is_null($want_invert)) {
+ return $val;
+ } else {
+ $val[0] = '(NOT (' . $val[0] . '))';
+ }
}
+
+ return $val;
}
function searchJoinSQL () {
@@ -195,6 +226,8 @@ class NameCriterion extends BrowseCriterion {
var $bFolderCriterion = true;
var $bString = true;
var $sSearchTable = "DC";
+ var $bContains = true;
+
function documentDisplay ($oDocument) {
$aOptions = $this->aOptions;
if (array_key_exists('displayFullPath', $aOptions)) {
@@ -238,6 +271,8 @@ class TitleCriterion extends BrowseCriterion {
var $bFolderCriterion = true;
var $bString = true;
var $sSearchTable = "DM";
+ var $bContains = true;
+
function documentDisplay ($oDocument) {
return $oDocument->getName();
}
@@ -257,6 +292,7 @@ class CreatorCriterion extends BrowseCriterion {
"table" => "users",
"field" => "name",
);
+
function documentDisplay ($oDocument) {
$oCreator = User::get($oDocument->getCreatorID());
if ($oCreator) {
@@ -270,12 +306,12 @@ class CreatorCriterion extends BrowseCriterion {
function searchWidget ($aRequest, $aPreValue = null) {
$preval = null;
if ($aPreValue != null) {
- // !#@&)*( (*&!@# *(&@!(*&!@#
+ // !#@&)*( (*&!@# *(&@NOT (*&!@#
$k = array_keys($aPreValue);
$k = $k[0];
$preval = $aPreValue[$k];
}
- $sRet = "