Commit ec6094fe96272909a32de0e2cc411cb1417b009b
1 parent
6bdfa053
KTS-673
"The search algorithm needs some work" Implementation. Committed By: Conrad Vermeulen Reviewed By: Kevin Fourie git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7170 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
23 additions
and
21 deletions
lib/browse/browseutil.inc.php
| ... | ... | @@ -8,7 +8,7 @@ |
| 8 | 8 | * License Version 1.1.2 ("License"); You may not use this file except in |
| 9 | 9 | * compliance with the License. You may obtain a copy of the License at |
| 10 | 10 | * http://www.knowledgetree.com/KPL |
| 11 | - * | |
| 11 | + * | |
| 12 | 12 | * Software distributed under the License is distributed on an "AS IS" |
| 13 | 13 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. |
| 14 | 14 | * See the License for the specific language governing rights and |
| ... | ... | @@ -19,9 +19,9 @@ |
| 19 | 19 | * (ii) the KnowledgeTree copyright notice |
| 20 | 20 | * in the same form as they appear in the distribution. See the License for |
| 21 | 21 | * requirements. |
| 22 | - * | |
| 22 | + * | |
| 23 | 23 | * The Original Code is: KnowledgeTree Open Source |
| 24 | - * | |
| 24 | + * | |
| 25 | 25 | * The Initial Developer of the Original Code is The Jam Warehouse Software |
| 26 | 26 | * (Pty) Ltd, trading as KnowledgeTree. |
| 27 | 27 | * Portions created by The Jam Warehouse Software (Pty) Ltd are Copyright |
| ... | ... | @@ -37,9 +37,9 @@ class KTBrowseUtil { |
| 37 | 37 | function folderOrDocument($sPath, $bAction = false) { |
| 38 | 38 | $sFileName = basename($sPath); |
| 39 | 39 | $sFolderPath = dirname($sPath); |
| 40 | - | |
| 40 | + | |
| 41 | 41 | $aFolderInfo = KTBrowseUtil::_folderOrDocument($sFolderPath); |
| 42 | - | |
| 42 | + | |
| 43 | 43 | if ($aFolderInfo === false) { |
| 44 | 44 | return $aFolderInfo; |
| 45 | 45 | } |
| ... | ... | @@ -67,18 +67,18 @@ class KTBrowseUtil { |
| 67 | 67 | |
| 68 | 68 | $sQuery = sprintf('SELECT d.id FROM %s AS d' . |
| 69 | 69 | ' LEFT JOIN %s AS dm ON (d.metadata_version_id = dm.id) LEFT JOIN %s AS dc ON (dm.content_version_id = dc.id)' . |
| 70 | - ' WHERE d.folder_id = ? AND dc.filename = ?', | |
| 70 | + ' WHERE d.folder_id = ? AND dc.filename = ?', | |
| 71 | 71 | KTUtil::getTableName(documents), |
| 72 | 72 | KTUtil::getTableName('document_metadata_version'), |
| 73 | 73 | KTUtil::getTableName('document_content_version')); |
| 74 | 74 | $aParams = array($iFolderID, $sFileName); |
| 75 | 75 | $iDocumentID = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id'); |
| 76 | - | |
| 76 | + | |
| 77 | 77 | if (PEAR::isError($iDocumentID)) { |
| 78 | 78 | // XXX: log error |
| 79 | 79 | return false; |
| 80 | 80 | } |
| 81 | - | |
| 81 | + | |
| 82 | 82 | if ($iDocumentID) { |
| 83 | 83 | return array($iFolderID, $iDocumentID, null); |
| 84 | 84 | } |
| ... | ... | @@ -99,7 +99,7 @@ class KTBrowseUtil { |
| 99 | 99 | $sFolderPath = dirname($sPath); |
| 100 | 100 | |
| 101 | 101 | $aFolderNames = split('/', $sFolderPath); |
| 102 | - | |
| 102 | + | |
| 103 | 103 | $iFolderID = 0; |
| 104 | 104 | |
| 105 | 105 | $aRemaining = $aFolderNames; |
| ... | ... | @@ -126,23 +126,23 @@ class KTBrowseUtil { |
| 126 | 126 | |
| 127 | 127 | $sQuery = sprintf('SELECT d.id FROM %s AS d' . |
| 128 | 128 | ' LEFT JOIN %s AS dm ON (d.metadata_version_id = dm.id) LEFT JOIN %s AS dc ON (dm.content_version_id = dc.id)' . |
| 129 | - ' WHERE d.folder_id = ? AND dc.filename = ?', | |
| 129 | + ' WHERE d.folder_id = ? AND dc.filename = ?', | |
| 130 | 130 | KTUtil::getTableName(documents), |
| 131 | 131 | KTUtil::getTableName('document_metadata_version'), |
| 132 | 132 | KTUtil::getTableName('document_content_version')); |
| 133 | 133 | $aParams = array($iFolderID, $sFileName); |
| 134 | 134 | $iDocumentID = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id'); |
| 135 | - | |
| 135 | + | |
| 136 | 136 | if (PEAR::isError($iDocumentID)) { |
| 137 | 137 | // XXX: log error |
| 138 | 138 | return false; |
| 139 | 139 | } |
| 140 | - | |
| 140 | + | |
| 141 | 141 | if ($iDocumentID === null) { |
| 142 | 142 | $sQuery = 'SELECT id FROM folders WHERE parent_id = ? AND name = ?'; |
| 143 | 143 | $aParams = array($iFolderID, $sFileName); |
| 144 | 144 | $id = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id'); |
| 145 | - | |
| 145 | + | |
| 146 | 146 | if (PEAR::isError($id)) { |
| 147 | 147 | // XXX: log error |
| 148 | 148 | return false; |
| ... | ... | @@ -165,7 +165,7 @@ class KTBrowseUtil { |
| 165 | 165 | function breadcrumbsForFolder($oFolder, $aOptions = null) { |
| 166 | 166 | $oFolder =& KTUtil::getObject('Folder', $oFolder); |
| 167 | 167 | $sAction = KTUtil::arrayGet($aOptions, 'folderaction'); |
| 168 | - | |
| 168 | + | |
| 169 | 169 | if(PEAR::isError($oFolder)) { |
| 170 | 170 | $url = KTUtil::addQueryStringSelf('fFolderId=1'); |
| 171 | 171 | if(!empty($sAction)) { |
| ... | ... | @@ -178,7 +178,7 @@ class KTBrowseUtil { |
| 178 | 178 | $bFinal = KTUtil::arrayGet($aOptions, 'final', true, false); |
| 179 | 179 | $bFolderBrowseBase = KTUtil::arrayGet($aOptions, 'folderbase', ''); |
| 180 | 180 | $aBreadcrumbs = array(); |
| 181 | - | |
| 181 | + | |
| 182 | 182 | // skip root. |
| 183 | 183 | $folder_path_names = array_slice($oFolder->getPathArray(), 1); |
| 184 | 184 | $folder_path_ids = array_slice(explode(',', $oFolder->getParentFolderIds()), 1); |
| ... | ... | @@ -193,7 +193,7 @@ class KTBrowseUtil { |
| 193 | 193 | } |
| 194 | 194 | $aBreadcrumbs[] = array('url' => $url, 'name' => _kt('Folders')); |
| 195 | 195 | $oUser = User::get($_SESSION['userID']); |
| 196 | - | |
| 196 | + | |
| 197 | 197 | if ($parents != 0) { |
| 198 | 198 | foreach (range(0, $parents - 1) as $index) { |
| 199 | 199 | $id = $folder_path_ids[$index]; |
| ... | ... | @@ -337,7 +337,9 @@ class KTBrowseUtil { |
| 337 | 337 | function getBooleanSearchBaseUrl() { |
| 338 | 338 | return KTBrowseUtil::buildBaseUrl('search/booleanSearch'); |
| 339 | 339 | } |
| 340 | - | |
| 340 | + function getSearchResultURL() { | |
| 341 | + return KTBrowseUtil::buildBaseUrl('search2'); | |
| 342 | + } | |
| 341 | 343 | // {{{ inAdminMode |
| 342 | 344 | /** |
| 343 | 345 | * Determines whether the user is in administrator mode, including |
| ... | ... | @@ -348,7 +350,7 @@ class KTBrowseUtil { |
| 348 | 350 | if (KTUtil::arrayGet($_SESSION, 'adminmode', false) !== true) { |
| 349 | 351 | return false; |
| 350 | 352 | } |
| 351 | - | |
| 353 | + | |
| 352 | 354 | if (Permission::userIsSystemAdministrator($oUser)) { |
| 353 | 355 | return true; |
| 354 | 356 | } |
| ... | ... | @@ -366,13 +368,13 @@ class KTBrowseUtil { |
| 366 | 368 | */ |
| 367 | 369 | function getBrowseableFolders($oUser) { |
| 368 | 370 | $aPermissionDescriptors = KTPermissionUtil::getPermissionDescriptorsForUser($oUser); |
| 369 | - | |
| 370 | - | |
| 371 | + | |
| 372 | + | |
| 371 | 373 | if (empty($aPermissionDescriptors)) { |
| 372 | 374 | return array(); |
| 373 | 375 | } |
| 374 | 376 | $sPermissionDescriptors = DBUtil::paramArray($aPermissionDescriptors); |
| 375 | - | |
| 377 | + | |
| 376 | 378 | $sFoldersTable = KTUtil::getTableName('folders'); |
| 377 | 379 | $sPLTable = KTUtil::getTableName('permission_lookups'); |
| 378 | 380 | $sPLATable = KTUtil::getTableName('permission_lookup_assignments'); | ... | ... |