Commit 0d6fb8eccfa028b2e83605b1611521f06564645d
1 parent
d051d944
Merged in from DEV trunk...
KTS-3530 "Allow reindexing of folders and their contents" Implemented. Committed By: Conrad Vermeulen Reviewed By: Megan Watson git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/STABLE/trunk@8872 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
4 changed files
with
98 additions
and
16 deletions
plugins/ktcore/KTCorePlugin.php
| ... | ... | @@ -6,31 +6,31 @@ |
| 6 | 6 | * Document Management Made Simple |
| 7 | 7 | * Copyright (C) 2008 KnowledgeTree Inc. |
| 8 | 8 | * Portions copyright The Jam Warehouse Software (Pty) Limited |
| 9 | - * | |
| 9 | + * | |
| 10 | 10 | * This program is free software; you can redistribute it and/or modify it under |
| 11 | 11 | * the terms of the GNU General Public License version 3 as published by the |
| 12 | 12 | * Free Software Foundation. |
| 13 | - * | |
| 13 | + * | |
| 14 | 14 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 15 | 15 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 16 | 16 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 17 | 17 | * details. |
| 18 | - * | |
| 18 | + * | |
| 19 | 19 | * You should have received a copy of the GNU General Public License |
| 20 | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 21 | - * | |
| 22 | - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 21 | + * | |
| 22 | + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, | |
| 23 | 23 | * California 94120-7775, or email info@knowledgetree.com. |
| 24 | - * | |
| 24 | + * | |
| 25 | 25 | * The interactive user interfaces in modified source and object code versions |
| 26 | 26 | * of this program must display Appropriate Legal Notices, as required under |
| 27 | 27 | * Section 5 of the GNU General Public License version 3. |
| 28 | - * | |
| 28 | + * | |
| 29 | 29 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 30 | 30 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 31 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 31 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the | |
| 32 | 32 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 33 | - * must display the words "Powered by KnowledgeTree" and retain the original | |
| 33 | + * must display the words "Powered by KnowledgeTree" and retain the original | |
| 34 | 34 | * copyright notice. |
| 35 | 35 | * Contributor( s): ______________________________________ |
| 36 | 36 | * |
| ... | ... | @@ -75,6 +75,7 @@ class KTCorePlugin extends KTPlugin { |
| 75 | 75 | $this->registerAction('folderaction', 'KTFolderPermissionsAction', 'ktcore.actions.folder.permissions', 'folder/Permissions.php'); |
| 76 | 76 | $this->registerAction('folderaction', 'KTBulkImportFolderAction', 'ktcore.actions.folder.bulkImport', 'folder/BulkImport.php'); |
| 77 | 77 | $this->registerAction('folderaction', 'KTBulkUploadFolderAction', 'ktcore.actions.folder.bulkUpload', 'folder/BulkUpload.php'); |
| 78 | + $this->registerAction('folderaction', 'FolderIndexAction', 'ktcore.search2.index.folder.action', KT_DIR . '/plugins/search2/FolderIndexAction.php'); | |
| 78 | 79 | $this->registerAction('folderinfo', 'KTFolderTransactionsAction', 'ktcore.actions.folder.transactions', 'folder/Transactions.php'); |
| 79 | 80 | |
| 80 | 81 | $this->registerAction('documentaction', 'KTDocumentAssistAction', 'ktcore.actions.document.assist', 'KTAssist.php'); |
| ... | ... | @@ -238,7 +239,7 @@ class KTCorePlugin extends KTPlugin { |
| 238 | 239 | $this->registerAdminCategory('search', _kt('Search and Indexing'), |
| 239 | 240 | _kt('Search and Indexing Settings')); |
| 240 | 241 | $this->registerAdminCategory('config', _kt('System Configuration'), |
| 241 | - _kt('System Configuration Settings')); | |
| 242 | + _kt('System Configuration Settings')); | |
| 242 | 243 | $this->registerAdminCategory('misc', _kt('Miscellaneous'), |
| 243 | 244 | _kt('Various settings which do not fit into the other categories, including managing help and saved searches.')); |
| 244 | 245 | |
| ... | ... | @@ -320,27 +321,27 @@ class KTCorePlugin extends KTPlugin { |
| 320 | 321 | $this->registerAdminPage('emailconfigpage', 'EmailConfigPageDispatcher', 'config', |
| 321 | 322 | _kt('Email Settings'), _kt('Manage Email Settings'), |
| 322 | 323 | '/admin/configSettings.php', null); |
| 323 | - | |
| 324 | + | |
| 324 | 325 | $this->registerAdminPage('uiconfigpage', 'UIConfigPageDispatcher', 'config', |
| 325 | 326 | _kt('User Interface Settings'), _kt('Manage User Interface Settings'), |
| 326 | 327 | '/admin/configSettings.php', null); |
| 327 | - | |
| 328 | + | |
| 328 | 329 | $this->registerAdminPage('searchandindexingconfigpage', 'SearchAndIndexingConfigPageDispatcher', 'config', |
| 329 | 330 | _kt('Search and Indexing Settings'), _kt('Manage Search and Indexing Settings'), |
| 330 | 331 | '/admin/configSettings.php', null); |
| 331 | - | |
| 332 | + | |
| 332 | 333 | $this->registerAdminPage('clientconfigpage', 'ClientSettingsConfigPageDispatcher', 'config', |
| 333 | 334 | _kt('Client Tools Settings'), _kt('Manage Client Tools Settings'), |
| 334 | 335 | '/admin/configSettings.php', null); |
| 335 | - | |
| 336 | + | |
| 336 | 337 | $this->registerAdminPage('generalconfigpage', 'GeneralConfigPageDispatcher', 'config', |
| 337 | 338 | _kt('General Settings'), _kt('Manage General Settings'), |
| 338 | 339 | '/admin/configSettings.php', null); |
| 339 | - | |
| 340 | + | |
| 340 | 341 | $this->registerAdminPage('i18nconfigpage', 'i18nConfigPageDispatcher', 'config', |
| 341 | 342 | _kt('Internationalisation Settings'), _kt('Manage Internationalisation Settings'), |
| 342 | 343 | '/admin/configSettings.php', null); |
| 343 | - | |
| 344 | + | |
| 344 | 345 | // misc |
| 345 | 346 | $this->registerAdminPage('helpmanagement', 'ManageHelpDispatcher', 'misc', |
| 346 | 347 | _kt('Edit Help files'), _kt('Change the help files that are displayed to users.'), | ... | ... |
plugins/search2/DocumentIndexAction.php
| ... | ... | @@ -46,16 +46,20 @@ class DocumentIndexAction extends KTDocumentAction |
| 46 | 46 | $docid=$doc->getId(); |
| 47 | 47 | if (Permission::userIsSystemAdministrator()) |
| 48 | 48 | { |
| 49 | + $full_path = $doc->getFullPath(); | |
| 49 | 50 | if (Indexer::isDocumentScheduled($docid)) |
| 50 | 51 | { |
| 51 | 52 | Indexer::unqueueDocument($docid); |
| 53 | + $this->addInfoMessage(sprintf(_kt("Document '%s' has been removed from the indexing queue."), $full_path)); | |
| 52 | 54 | } |
| 53 | 55 | else |
| 54 | 56 | { |
| 55 | 57 | Indexer::index($doc, 'A'); |
| 58 | + $this->addInfoMessage(sprintf(_kt("Document '%s' has been added from the indexing queue."), $full_path)); | |
| 56 | 59 | } |
| 57 | 60 | } |
| 58 | 61 | redirect("view.php?fDocumentId=$docid"); |
| 62 | + exit; | |
| 59 | 63 | } |
| 60 | 64 | } |
| 61 | 65 | ... | ... |
plugins/search2/FolderIndexAction.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once(KT_LIB_DIR . '/actions/folderaction.inc.php'); | |
| 4 | +require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); | |
| 5 | +require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); | |
| 6 | + | |
| 7 | +class FolderIndexAction extends KTFolderAction | |
| 8 | +{ | |
| 9 | + var $sName = 'ktcore.search2.index.folder.action'; | |
| 10 | + var $_sShowPermission = "ktcore.permissions.write"; | |
| 11 | + | |
| 12 | + function FolderIndexAction($oDocument = null, $oUser = null, $oPlugin = null) | |
| 13 | + { | |
| 14 | + parent::KTFolderAction($oDocument, $oUser, $oPlugin); | |
| 15 | + $this->sDisplayName=_kt('Schedule Indexing'); | |
| 16 | + } | |
| 17 | + | |
| 18 | + function getName() | |
| 19 | + { | |
| 20 | + return _kt('Document Indexer'); | |
| 21 | + } | |
| 22 | + | |
| 23 | + function getDisplayName() | |
| 24 | + { | |
| 25 | + if (Permission::userIsSystemAdministrator() && $_SESSION['adminmode']) | |
| 26 | + { | |
| 27 | + if(!is_object($this->oFolder)){ | |
| 28 | + return ''; | |
| 29 | + } | |
| 30 | + return _kt('Schedule Indexing'); | |
| 31 | + } | |
| 32 | + | |
| 33 | + return ''; | |
| 34 | + } | |
| 35 | + | |
| 36 | + function do_main() | |
| 37 | + { | |
| 38 | + $folder=$this->oFolder; | |
| 39 | + $folderid=$folder->getId(); | |
| 40 | + if (Permission::userIsSystemAdministrator()) | |
| 41 | + { | |
| 42 | + if ($folderid == 1) | |
| 43 | + { | |
| 44 | + Indexer::indexAll(); | |
| 45 | + } | |
| 46 | + else | |
| 47 | + { | |
| 48 | + Indexer::indexFolder($folder); | |
| 49 | + } | |
| 50 | + } | |
| 51 | + $full_path = $folder->getFullPath(); | |
| 52 | + $this->addInfoMessage(sprintf(_kt("All documents under the folder '%s' have been scheduled for indexing."), $full_path)); | |
| 53 | + | |
| 54 | + redirect("browse.php?fFolderId=$folderid"); | |
| 55 | + exit; | |
| 56 | + } | |
| 57 | +} | |
| 58 | + | |
| 59 | +?> | |
| 0 | 60 | \ No newline at end of file | ... | ... |
search2/indexing/indexerCore.inc.php
| ... | ... | @@ -551,6 +551,22 @@ abstract class Indexer |
| 551 | 551 | DBUtil::runQuery($sql); |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | + public static function indexFolder($folder) | |
| 555 | + { | |
| 556 | + $userid=$_SESSION['userID']; | |
| 557 | + if (empty($userid)) $userid=1; | |
| 558 | + | |
| 559 | + if (!$folder instanceof Folder && !$folder instanceof FolderProxy) | |
| 560 | + { | |
| 561 | + throw new Exception('Folder expected'); | |
| 562 | + } | |
| 563 | + | |
| 564 | + $full_path = $folder->getFullPath(); | |
| 565 | + | |
| 566 | + $sql = "INSERT INTO index_files(document_id, user_id, what) SELECT id, $userid, 'A' FROM documents WHERE full_path like '{$full_path}/%' AND status_id=1 and id not in (select document_id from index_files)"; | |
| 567 | + DBUtil::runQuery($sql); | |
| 568 | + } | |
| 569 | + | |
| 554 | 570 | /** |
| 555 | 571 | * Clearout the scheduling of documents that no longer exist. |
| 556 | 572 | * |
| ... | ... | @@ -781,6 +797,8 @@ abstract class Indexer |
| 781 | 797 | $default->log->info("checkForRegisteredTypes: disabled '$extractor'"); |
| 782 | 798 | } |
| 783 | 799 | |
| 800 | + $this->loadExtractorStatus(); | |
| 801 | + | |
| 784 | 802 | if ($this->debug) $default->log->debug('checkForRegisteredTypes: done'); |
| 785 | 803 | KTUtil::setSystemSetting('mimeTypesRegistered', true); |
| 786 | 804 | } | ... | ... |