From b74384cde43b5561fd76919ec805d18ab673ac5c Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 4 Mar 2003 10:36:46 +0000 Subject: [PATCH] Added search by document type --- presentation/lookAndFeel/knowledgeTree/search/standardSearchBL.php | 40 +++++++++++++++++++++++----------------- presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc | 47 ++++++++++++----------------------------------- 2 files changed, 35 insertions(+), 52 deletions(-) diff --git a/presentation/lookAndFeel/knowledgeTree/search/standardSearchBL.php b/presentation/lookAndFeel/knowledgeTree/search/standardSearchBL.php index b0c6e46..f5c52c7 100644 --- a/presentation/lookAndFeel/knowledgeTree/search/standardSearchBL.php +++ b/presentation/lookAndFeel/knowledgeTree/search/standardSearchBL.php @@ -71,7 +71,7 @@ if (checkSession()) { case "documentType" : //user was browsing by document type - search all documents in that doc type - if (!$fDocumentTypeID) { + if (!$fDocTypeID) { //no document type specified, so just start at the root folder $fFolderID = 0; $sFolderString = getApprovedFolderString($fFolderID); @@ -81,7 +81,12 @@ if (checkSession()) { $main->setCentralPayload($oPatternCustom); $main->render(); } else { - //TODO ONCE DOC TYPE/FOLDERS HAVE BEEN CHANGED + $sDocumentString = getApprovedDocsDocType($fDocTypeID); + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); + $oPatternCustom = & new PatternCustom(); + $oPatternCustom->setHtml(getPage($fStandardSearchString, $fBrowseType, $fFolderID, $fDocumentID, $fCategoryName, $fDocType, $sDocumentString, $fStartIndex, getSQLSearchString($fStandardSearchString), true)); + $main->setCentralPayload($oPatternCustom); + $main->render(); } break; default: @@ -118,16 +123,6 @@ if (checkSession()) { } } - -function searchByFolder($iFolderID, $sSearchText) { - global $default; - //get a list of documents in the folder - //TODO - CHECK THAT USER HAS READ RIGHTS TO THIS FOLDER - echo getSearchByFolderPage($iFolderID, $sSearchText); - - -} - function getApprovedFolderString($iFolderID) { $aChildren = Folder::getChildren($iFolderID); $aApprovedChildren = array(); @@ -231,13 +226,24 @@ function searchByCategory($sCategoryName) { } -function searchByDocType($iDocTypeID) { +function getApprovedDocsDocType($iDocTypeID) { + global $default; + $sQuery = "SELECT D.id " . + "FROM $default->owl_documents_table AS D " . + "WHERE D.document_type_id = $iDocTypeID"; + $sql = $default->db; + $sql->query($sQuery); + while ($sql->next_record()) { + if (Permission::userHasDocumentReadPermission($sql->f("id"))) { + $aDocuments[count($aDocuments)] = $sql->f("id"); + } + if (count($aDocuments) > 0) { + return implode(",", $aDocuments); + } + } + return "0"; } - - - - ?> diff --git a/presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc b/presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc index ba3789e..8d72afe 100644 --- a/presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc @@ -8,47 +8,24 @@ * @package presentation.lookAndFeel.documentmanagement */ -function getSearchByFolderPage($iFolderID, $sSearchText) { - global $default; - //get the individual words in the search text - $aSearchWords = explode(" ", $sSearchText); - $sQuery = "SELECT D.id, D.name, COUNT(D.id) AS cnt " . - "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_document_words_table AS DWL ON DWL.document_id = D.ID " . - "INNER JOIN $default->owl_words_table AS WLU ON WLU.id = DWL.word_id" . - "WHERE D.folderID = $iFolderID " . - "AND WLU.word IN ("; - for ($i = 0; $i < count($aSearchWords) -1; $i++) { - $sQuery .= $aSearchWords[$i] . ", "; - } - $sQuery .= $aSearchWords[count($aSearchWords) -1] . ") " . - "GROUP BY D.id, D.name " . - "ORDER BY D.name, cnt DESC"; - - $aColums = array("name"); - $aColumnTypes = array(3); - $aColumnHeaders = array("Document Name"); - $aLinkURLs = array("$default->owl_root_url/control.php?action=viewDocument"); - $aTmpDBQueryStringColumns = array("id"); - $aNewQueryStringVariableNames = array("fDocumentID"); - - $oPatternTableSqlQuery = & PatternBrowseableSearchResults($sQuery, 10, $aColumns, $aColumnTypes, $aColumnHeaders, $aLinkURLs, $aDBQueryStringColumns, $aQueryStringVariableNames); - - return $oPatternTableSqlQuery->render(); +function getPage($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType, $sFolderIDs, $iStartIndex, $sSQLSearchString, $bSearchByDocument = false) { + return getSearchResults($sFolderIDs, $sSQLSearchString, $iStartIndex, $bSearchByDocument) . getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType); } -function getPage($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType, $sFolderIDs, $iStartIndex, $sSQLSearchString) { - return getSearchResults($sFolderIDs, $sSQLSearchString, $iStartIndex) . getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType); -} - -function getSearchResults($sFolderIDs,$sSQLSearchString, $iStartIndex) { +function getSearchResults($sIDs,$sSQLSearchString, $iStartIndex, $bSearchByDocument = false) { global $default; $sQuery = "SELECT DISTINCT '" . "$default->graphicsUrl/widgets/dfolder.gif" . "' AS folder_image_url, F.id folder_id, D.id document_id, D.name AS document_name " . "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_folders_table AS F ON D.folder_id = F.id " . "INNER JOIN $default->owl_document_words_table AS DWL ON DWL.document_id = D.id " . - "INNER JOIN $default->owl_words_lookup_table AS WL ON WL.id = DWL.word_id " . - "WHERE F.id IN ($sFolderIDs) " . - "AND ($sSQLSearchString)"; - "ORDER BY D.name ASC"; + "INNER JOIN $default->owl_words_lookup_table AS WL ON WL.id = DWL.word_id "; + if ($bSearchByDocument) { + $sQuery .= "WHERE D.id IN ($sIDs) "; + } else { + $sQuery .= "WHERE F.id IN ($sIDs) "; + } + $sQuery .= "AND ($sSQLSearchString)"; + $sQuery .= "ORDER BY D.name ASC"; + $aColumns = array("folder_image_url", "document_name"); $aColumnTypes = array(4,3); $aColumnHeaders = array("","Document"); -- libgit2 0.21.4