Commit b21620d8ecb0ee44ff9beb3f5285b4e0439b6c92

Authored by rob
1 parent 8b21d2ce

Added search by document type


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1333 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/search/standardSearchBL.php
@@ -71,7 +71,7 @@ if (checkSession()) { @@ -71,7 +71,7 @@ if (checkSession()) {
71 71
72 case "documentType" : 72 case "documentType" :
73 //user was browsing by document type - search all documents in that doc type 73 //user was browsing by document type - search all documents in that doc type
74 - if (!$fDocumentTypeID) { 74 + if (!$fDocTypeID) {
75 //no document type specified, so just start at the root folder 75 //no document type specified, so just start at the root folder
76 $fFolderID = 0; 76 $fFolderID = 0;
77 $sFolderString = getApprovedFolderString($fFolderID); 77 $sFolderString = getApprovedFolderString($fFolderID);
@@ -81,7 +81,12 @@ if (checkSession()) { @@ -81,7 +81,12 @@ if (checkSession()) {
81 $main->setCentralPayload($oPatternCustom); 81 $main->setCentralPayload($oPatternCustom);
82 $main->render(); 82 $main->render();
83 } else { 83 } else {
84 - //TODO ONCE DOC TYPE/FOLDERS HAVE BEEN CHANGED 84 + $sDocumentString = getApprovedDocsDocType($fDocTypeID);
  85 + require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc");
  86 + $oPatternCustom = & new PatternCustom();
  87 + $oPatternCustom->setHtml(getPage($fStandardSearchString, $fBrowseType, $fFolderID, $fDocumentID, $fCategoryName, $fDocType, $sDocumentString, $fStartIndex, getSQLSearchString($fStandardSearchString), true));
  88 + $main->setCentralPayload($oPatternCustom);
  89 + $main->render();
85 } 90 }
86 break; 91 break;
87 default: 92 default:
@@ -118,16 +123,6 @@ if (checkSession()) { @@ -118,16 +123,6 @@ if (checkSession()) {
118 } 123 }
119 } 124 }
120 125
121 -  
122 -function searchByFolder($iFolderID, $sSearchText) {  
123 - global $default;  
124 - //get a list of documents in the folder  
125 - //TODO - CHECK THAT USER HAS READ RIGHTS TO THIS FOLDER  
126 - echo getSearchByFolderPage($iFolderID, $sSearchText);  
127 -  
128 -  
129 -}  
130 -  
131 function getApprovedFolderString($iFolderID) { 126 function getApprovedFolderString($iFolderID) {
132 $aChildren = Folder::getChildren($iFolderID); 127 $aChildren = Folder::getChildren($iFolderID);
133 $aApprovedChildren = array(); 128 $aApprovedChildren = array();
@@ -231,13 +226,24 @@ function searchByCategory($sCategoryName) { @@ -231,13 +226,24 @@ function searchByCategory($sCategoryName) {
231 226
232 } 227 }
233 228
234 -function searchByDocType($iDocTypeID) { 229 +function getApprovedDocsDocType($iDocTypeID) {
  230 + global $default;
  231 + $sQuery = "SELECT D.id " .
  232 + "FROM $default->owl_documents_table AS D " .
  233 + "WHERE D.document_type_id = $iDocTypeID";
235 234
  235 + $sql = $default->db;
  236 + $sql->query($sQuery);
  237 + while ($sql->next_record()) {
  238 + if (Permission::userHasDocumentReadPermission($sql->f("id"))) {
  239 + $aDocuments[count($aDocuments)] = $sql->f("id");
  240 + }
  241 + if (count($aDocuments) > 0) {
  242 + return implode(",", $aDocuments);
  243 + }
  244 + }
  245 + return "0";
236 } 246 }
237 247
238 -  
239 -  
240 -  
241 -  
242 ?> 248 ?>
243 249
presentation/lookAndFeel/knowledgeTree/search/standardSearchUI.inc
@@ -8,47 +8,24 @@ @@ -8,47 +8,24 @@
8 * @package presentation.lookAndFeel.documentmanagement 8 * @package presentation.lookAndFeel.documentmanagement
9 */ 9 */
10 10
11 -function getSearchByFolderPage($iFolderID, $sSearchText) {  
12 - global $default;  
13 - //get the individual words in the search text  
14 - $aSearchWords = explode(" ", $sSearchText);  
15 - $sQuery = "SELECT D.id, D.name, COUNT(D.id) AS cnt " .  
16 - "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_document_words_table AS DWL ON DWL.document_id = D.ID " .  
17 - "INNER JOIN $default->owl_words_table AS WLU ON WLU.id = DWL.word_id" .  
18 - "WHERE D.folderID = $iFolderID " .  
19 - "AND WLU.word IN (";  
20 - for ($i = 0; $i < count($aSearchWords) -1; $i++) {  
21 - $sQuery .= $aSearchWords[$i] . ", ";  
22 - }  
23 - $sQuery .= $aSearchWords[count($aSearchWords) -1] . ") " .  
24 - "GROUP BY D.id, D.name " .  
25 - "ORDER BY D.name, cnt DESC";  
26 -  
27 - $aColums = array("name");  
28 - $aColumnTypes = array(3);  
29 - $aColumnHeaders = array("Document Name");  
30 - $aLinkURLs = array("$default->owl_root_url/control.php?action=viewDocument");  
31 - $aTmpDBQueryStringColumns = array("id");  
32 - $aNewQueryStringVariableNames = array("fDocumentID");  
33 -  
34 - $oPatternTableSqlQuery = & PatternBrowseableSearchResults($sQuery, 10, $aColumns, $aColumnTypes, $aColumnHeaders, $aLinkURLs, $aDBQueryStringColumns, $aQueryStringVariableNames);  
35 -  
36 - return $oPatternTableSqlQuery->render(); 11 +function getPage($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType, $sFolderIDs, $iStartIndex, $sSQLSearchString, $bSearchByDocument = false) {
  12 + return getSearchResults($sFolderIDs, $sSQLSearchString, $iStartIndex, $bSearchByDocument) . getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType);
37 } 13 }
38 14
39 -function getPage($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType, $sFolderIDs, $iStartIndex, $sSQLSearchString) {  
40 - return getSearchResults($sFolderIDs, $sSQLSearchString, $iStartIndex) . getSearchVariablesHtml($sSearchText, $sBrowseType, $iFolderID, $iDocumentID, $sCategoryName, $iDocType);  
41 -}  
42 -  
43 -function getSearchResults($sFolderIDs,$sSQLSearchString, $iStartIndex) { 15 +function getSearchResults($sIDs,$sSQLSearchString, $iStartIndex, $bSearchByDocument = false) {
44 global $default; 16 global $default;
45 $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 " . 17 $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 " .
46 "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_folders_table AS F ON D.folder_id = F.id " . 18 "FROM $default->owl_documents_table AS D INNER JOIN $default->owl_folders_table AS F ON D.folder_id = F.id " .
47 "INNER JOIN $default->owl_document_words_table AS DWL ON DWL.document_id = D.id " . 19 "INNER JOIN $default->owl_document_words_table AS DWL ON DWL.document_id = D.id " .
48 - "INNER JOIN $default->owl_words_lookup_table AS WL ON WL.id = DWL.word_id " .  
49 - "WHERE F.id IN ($sFolderIDs) " .  
50 - "AND ($sSQLSearchString)";  
51 - "ORDER BY D.name ASC"; 20 + "INNER JOIN $default->owl_words_lookup_table AS WL ON WL.id = DWL.word_id ";
  21 + if ($bSearchByDocument) {
  22 + $sQuery .= "WHERE D.id IN ($sIDs) ";
  23 + } else {
  24 + $sQuery .= "WHERE F.id IN ($sIDs) ";
  25 + }
  26 + $sQuery .= "AND ($sSQLSearchString)";
  27 + $sQuery .= "ORDER BY D.name ASC";
  28 +
52 $aColumns = array("folder_image_url", "document_name"); 29 $aColumns = array("folder_image_url", "document_name");
53 $aColumnTypes = array(4,3); 30 $aColumnTypes = array(4,3);
54 $aColumnHeaders = array("","Document"); 31 $aColumnHeaders = array("","Document");