Commit e57435d78c3c4dd48495c15e014e93cee2de4ba8

Authored by nbm
1 parent 9d407d23

Restrict document field value search to the document field id being

requested.  Otherwise _any_ of the document fields' values would be
acceptable.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3289 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 8 additions and 0 deletions
lib/browse/Criteria.inc
@@ -343,6 +343,7 @@ class GenericMetadataCriterion extends BrowseCriterion { @@ -343,6 +343,7 @@ class GenericMetadataCriterion extends BrowseCriterion {
343 var $bString = true; 343 var $bString = true;
344 344
345 function GenericMetadataCriterion ($sDisplay, $sDocumentField, $sSortField, $iID) { 345 function GenericMetadataCriterion ($sDisplay, $sDocumentField, $sSortField, $iID) {
  346 + $this->iID = $iID;
346 $this->BrowseCriterion($sDisplay, $sDocumentField, $sSortField, $iID); 347 $this->BrowseCriterion($sDisplay, $sDocumentField, $sSortField, $iID);
347 $this->aLookup['whereClause'] = 'document_field_id = ' . $iID; 348 $this->aLookup['whereClause'] = 'document_field_id = ' . $iID;
348 $this->oField =& DocumentField::get($iID); 349 $this->oField =& DocumentField::get($iID);
@@ -392,6 +393,13 @@ class GenericMetadataCriterion extends BrowseCriterion { @@ -392,6 +393,13 @@ class GenericMetadataCriterion extends BrowseCriterion {
392 return $sRet; 393 return $sRet;
393 } 394 }
394 395
  396 + function searchSQL ($aRequest) {
  397 + $p = parent::searchSQL($aRequest);
  398 + $p[0] = join(' AND ', array($p[0], "$this->sSearchTable.document_field_id = ?"));
  399 + $p[1] = array_merge($p[1], array($this->iID));
  400 + return $p;
  401 + }
  402 +
395 function searchJoinSQL () { 403 function searchJoinSQL () {
396 global $default; 404 global $default;
397 return "LEFT JOIN $default->document_fields_link_table AS $this->sSearchTable ON $this->sSearchTable.document_id = D.id"; 405 return "LEFT JOIN $default->document_fields_link_table AS $this->sSearchTable ON $this->sSearchTable.document_id = D.id";