diff --git a/bin/win32/installScheduler.php b/bin/win32/installScheduler.php index c5a28f8..b1393f3 100644 --- a/bin/win32/installScheduler.php +++ b/bin/win32/installScheduler.php @@ -1,11 +1,19 @@ 'ktscheduler', - 'display' => 'KnowledgeTree Scheduler Service', - 'params' => $dir - )); +win32_create_service(array( + 'service' => 'ktscheduler', + 'display' => 'ktdmsScheduler', + 'params' => $scriptPath, + 'path' => $phpPath + )); -?> \ No newline at end of file +?> diff --git a/bin/win32/schedulerService.php b/bin/win32/schedulerService.php index af4aa48..1d75762 100644 --- a/bin/win32/schedulerService.php +++ b/bin/win32/schedulerService.php @@ -1,22 +1,39 @@ \ No newline at end of file +?> diff --git a/lib/documentmanagement/documentutil.inc.php b/lib/documentmanagement/documentutil.inc.php index 90d3ba8..6a9e5b7 100644 --- a/lib/documentmanagement/documentutil.inc.php +++ b/lib/documentmanagement/documentutil.inc.php @@ -178,13 +178,52 @@ class KTDocumentUtil { $oDocumentTransaction = new DocumentTransaction($oDocument, $sCheckoutComment, 'ktcore.transactions.check_out'); $oDocumentTransaction->create(); - // fire subscription alerts for the checked in document + // fire subscription alerts for the downloaded document $oSubscriptionEvent = new SubscriptionEvent(); $oFolder = Folder::get($oDocument->getFolderID()); $oSubscriptionEvent->CheckOutDocument($oDocument, $oFolder); return true; } + + function archive($oDocument, $sReason) { + + $this->startTransaction(); + $oDocument->setStatusID(ARCHIVED); + $res = $oDocument->update(); + + if (PEAR::isError($res) || ($res === false)) { + return PEAR::raiseError(_kt('There was a database error while trying to archive this file')); + } + + $oDocumentTransaction = & new DocumentTransaction($oDocument, sprintf(_kt('Document archived: %s'), $sReason), 'ktcore.transactions.update'); + $oDocumentTransaction->create(); + + $this->commitTransaction(); + + $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); + $aTriggers = $oKTTriggerRegistry->getTriggers('archive', 'postValidate'); + foreach ($aTriggers as $aTrigger) { + $sTrigger = $aTrigger[0]; + $oTrigger = new $sTrigger; + $aInfo = array( + 'document' => $oDocument, + ); + $oTrigger->setInfo($aInfo); + $ret = $oTrigger->postValidate(); + if (PEAR::isError($ret)) { + $oDocument->delete(); + return $ret; + } + } + + // fire subscription alerts for the archived document + $oSubscriptionEvent = new SubscriptionEvent(); + $oFolder = Folder::get($oDocument->getFolderID()); + $oSubscriptionEvent->ArchivedDocument($oDocument, $oFolder); + + return true; + } function &_add($oFolder, $sFilename, $oUser, $aOptions) { global $default; @@ -922,6 +961,11 @@ class KTDocumentUtil { return $ret; } } + + // fire subscription alerts for the copied document + $oSubscriptionEvent = new SubscriptionEvent(); + $oFolder = Folder::get($oDocument->getFolderID()); + $oSubscriptionEvent->MoveDocument($oDocument, $oDestinationFolder, $oSrcFolder, 'CopiedDocument'); return $oNewDocument; } @@ -1027,6 +1071,10 @@ class KTDocumentUtil { return $ret; } } + + // fire subscription alerts for the moved document + $oSubscriptionEvent = new SubscriptionEvent(); + $oSubscriptionEvent->MoveDocument($oDocument, $oFolder, $oOriginalFolder); return KTPermissionUtil::updatePermissionLookup($oDocument); } diff --git a/lib/subscriptions/subscriptions.inc.php b/lib/subscriptions/subscriptions.inc.php index 45c7139..bad824a 100644 --- a/lib/subscriptions/subscriptions.inc.php +++ b/lib/subscriptions/subscriptions.inc.php @@ -57,8 +57,10 @@ class SubscriptionEvent { "CheckInDocument", "CheckOutDocument", "MovedDocument", + "CopiedDocument", "ArchivedDocument", "RestoredArchivedDocument", + "DownloadDocument", ); var $subscriptionTypes = array( @@ -480,82 +482,83 @@ class SubscriptionEvent { } } - function MoveDocument($oMovedDocument, $oToFolder, $oFromFolder) { + function MoveDocument($oMovedDocument, $oToFolder, $oFromFolder, $moveOrCopy = "MovedDocument") { $content = new SubscriptionContent(); // needed for i18n - // OK: two actions: document registrants, folder registrants. + // OK: two actions: document registrants, folder registrants. $aUsers = $this->_getSubscribers($oMovedDocument->getId(), $this->subscriptionTypes["Document"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. - - foreach ($aUsers as $oSubscriber) { - // notification object first. - $aNotificationOptions = array(); - $aNotificationOptions['target_user'] = $oSubscriber->getID(); - $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. - $aNotificationOptions['target_name'] = $oMovedDocument->getName(); - $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oToFolder->getId()); - $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "MovedDocument"; - $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); - - // now the email content. - // FIXME this needs to be handled entirely within notifications from now on. - if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { - $emailContent = $content->getEmailAlertContent($oNotification); - $emailSubject = $content->getEmailAlertSubject($oNotification); - $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); - $oEmail->send(); - } - } + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. + + foreach ($aUsers as $oSubscriber) { + // notification object first. + $aNotificationOptions = array(); + $aNotificationOptions['target_user'] = $oSubscriber->getID(); + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. + $aNotificationOptions['target_name'] = $oMovedDocument->getName(); + $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oToFolder->getId()); + $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. + $aNotificationOptions['event_type'] = $moveOrCopy; + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); + + // now the email content. + // FIXME this needs to be handled entirely within notifications from now on. + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { + $emailContent = $content->getEmailAlertContent($oNotification); + $emailSubject = $content->getEmailAlertSubject($oNotification); + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); + $oEmail->send(); + } + } $aUsers = $this->_getSubscribers($oFromFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. - foreach ($aUsers as $oSubscriber) { - - // notification object first. - $aNotificationOptions = array(); - $aNotificationOptions['target_user'] = $oSubscriber->getID(); - $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. - $aNotificationOptions['target_name'] = $oMovedDocument->getName(); - $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oToFolder->getId()); - $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "MovedDocument"; - $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); - - // now the email content. - // FIXME this needs to be handled entirely within notifications from now on. - if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { - $emailContent = $content->getEmailAlertContent($oNotification); - $emailSubject = $content->getEmailAlertSubject($oNotification); - $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); - $oEmail->send(); - } - } + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. + foreach ($aUsers as $oSubscriber) { + + // notification object first. + $aNotificationOptions = array(); + $aNotificationOptions['target_user'] = $oSubscriber->getID(); + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. + $aNotificationOptions['target_name'] = $oMovedDocument->getName(); + $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oToFolder->getId()); + $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. + $aNotificationOptions['event_type'] = $moveOrCopy; + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); + + // now the email content. + // FIXME this needs to be handled entirely within notifications from now on. + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { + $emailContent = $content->getEmailAlertContent($oNotification); + $emailSubject = $content->getEmailAlertSubject($oNotification); + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); + $oEmail->send(); + } + } $aUsers = $this->_getSubscribers($oToFolder->getId(), $this->subscriptionTypes["Folder"]); - $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. - foreach ($aUsers as $oSubscriber) { - - // notification object first. - $aNotificationOptions = array(); - $aNotificationOptions['target_user'] = $oSubscriber->getID(); - $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. - $aNotificationOptions['target_name'] = $oMovedDocument->getName(); - $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); - $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. - $aNotificationOptions['event_type'] = "MovedDocument"; - $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); - - // now the email content. - // FIXME this needs to be handled entirely within notifications from now on. - if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { - $emailContent = $content->getEmailAlertContent($oNotification); - $emailSubject = $content->getEmailAlertSubject($oNotification); - $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); - $oEmail->send(); - } - } + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. + foreach ($aUsers as $oSubscriber) { + + // notification object first. + $aNotificationOptions = array(); + $aNotificationOptions['target_user'] = $oSubscriber->getID(); + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. + $aNotificationOptions['target_name'] = $oMovedDocument->getName(); + $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oToFolder->getId()); + $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. + $aNotificationOptions['event_type'] = $moveOrCopy; + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); + + // now the email content. + // FIXME this needs to be handled entirely within notifications from now on. + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { + $emailContent = $content->getEmailAlertContent($oNotification); + $emailSubject = $content->getEmailAlertSubject($oNotification); + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); + $oEmail->send(); + } + } } + function ArchivedDocument($oModifiedDocument, $oParentFolder) { $content = new SubscriptionContent(); // needed for i18n // OK: two actions: document registrants, folder registrants. @@ -662,6 +665,59 @@ class SubscriptionEvent { } } + function DownloadDocument($oDocument, $oParentFolder) { + $content = new SubscriptionContent(); // needed for i18n + // OK: two actions: document registrants, folder registrants. + $aUsers = $this->_getSubscribers($oDocument->getId(), $this->subscriptionTypes["Document"]); + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. + foreach ($aUsers as $oSubscriber) { + + // notification object first. + $aNotificationOptions = array(); + $aNotificationOptions['target_user'] = $oSubscriber->getID(); + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. + $aNotificationOptions['target_name'] = $oDocument->getName(); + $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); + $aNotificationOptions['object_id'] = $oDocument->getId(); // parent folder_id, in this case. + $aNotificationOptions['event_type'] = "DownloadDocument"; + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); + + // now the email content. + // FIXME this needs to be handled entirely within notifications from now on. + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { + $emailContent = $content->getEmailAlertContent($oNotification); + $emailSubject = $content->getEmailAlertSubject($oNotification); + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); + $oEmail->send(); + } + } + + + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. + foreach ($aUsers as $oSubscriber) { + + // notification object first. + $aNotificationOptions = array(); + $aNotificationOptions['target_user'] = $oSubscriber->getID(); + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. + $aNotificationOptions['target_name'] = $oDocument->getName(); + $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); + $aNotificationOptions['object_id'] = $oDocument->getId(); // parent folder_id, in this case. + $aNotificationOptions['event_type'] = "DownloadDocument"; + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); + + // now the email content. + // FIXME this needs to be handled entirely within notifications from now on. + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { + $emailContent = $content->getEmailAlertContent($oNotification); + $emailSubject = $content->getEmailAlertSubject($oNotification); + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); + $oEmail->send(); + } + } + } + // small helper function to assist in identifying the numeric id. function _getKeyForType($sEventType) { foreach ($this->eventTypes as $key => $val) { @@ -733,7 +789,9 @@ class SubscriptionContent { "CheckInDocument" => _kt('Document checked in'), "CheckOutDocument" => _kt('Document checked out'), "MovedDocument" => _kt('Document moved'), + "CopiedDocument" => _kt('Document copied'), "ArchivedDocument" => _kt('Document archived'), // can go through and request un-archival (?) + "DownloadDocument" => _kt('Document downloaded'), "RestoredArchivedDocument" => _kt('Document restored'), "DiscussDocument" => _kt('Document Discussions updated'), ); @@ -786,7 +844,9 @@ class SubscriptionContent { "CheckInDocument" => 'document', "CheckOutDocument" => 'document', "MovedDocument" => 'document', + "CopiedDocument" => 'document', "ArchivedDocument" => 'document', // can go through and request un-archival (?) + "DownloadDocument" => 'document', "RestoredArchivedDocument" => 'document', "DiscussDocument" => 'document'); diff --git a/plugins/ktcore/KTBulkActions.php b/plugins/ktcore/KTBulkActions.php index 513dc38..d744308 100644 --- a/plugins/ktcore/KTBulkActions.php +++ b/plugins/ktcore/KTBulkActions.php @@ -32,6 +32,7 @@ require_once(KT_LIB_DIR . '/actions/bulkaction.php'); require_once(KT_LIB_DIR . '/widgets/forms.inc.php'); require_once(KT_LIB_DIR . '/foldermanagement/compressionArchiveUtil.inc.php'); +require_once(KT_LIB_DIR . '/subscriptions/Subscription.inc'); class KTBulkDeleteAction extends KTBulkAction { @@ -477,25 +478,14 @@ class KTBulkArchiveAction extends KTBulkAction { function perform_action($oEntity) { if(is_a($oEntity, 'Document')) { - DBUtil::startTransaction(); - - $document = $oEntity; - - $document->setStatusID(ARCHIVED); - $res = $document->update(); - if (($res === false) || PEAR::isError($res)) { - DBUtil::rollback(); - return false; + + $res = KTDocumentUtil::archive($oEntity, $this->sReason); + + if(PEAR::isError($res)){ + return $res; } - - $oDocumentTransaction = & new DocumentTransaction($document, sprintf(_kt('Document archived: %s'), $this->sReason), 'ktcore.transactions.update'); - $oDocumentTransaction->create(); - - DBUtil::commit(); return true; }else if(is_a($oEntity, 'Folder')) { - DBUtil::startTransaction(); - $aDocuments = array(); $aChildFolders = array(); $oFolder = $oEntity; @@ -520,7 +510,6 @@ class KTBulkArchiveAction extends KTBulkAction { $sChildId = $oChild->getID(); $sChildDocs = $oChild->getDocumentIDs($sChildId); if (PEAR::isError($res)) { - DBUtil::rollback(); return false; } @@ -535,19 +524,14 @@ class KTBulkArchiveAction extends KTBulkAction { if(!empty($aDocuments)){ foreach($aDocuments as $sDocumentId){ $oDocument = Document::get($sDocumentId); - - $oDocument->setStatusID(ARCHIVED); - $res = $oDocument->update(); - if (($res === false) || PEAR::isError($res)) { - DBUtil::rollback(); - return false; + + $res = KTDocumentUtil::archive($oEntity, $this->sReason); + + if(PEAR::isError($res)){ + return $res; } - - $oDocumentTransaction = & new DocumentTransaction($oDocument, sprintf(_kt('Document archived: %s'), $this->sReason), 'ktcore.transactions.update'); - $oDocumentTransaction->create(); } } - DBUtil::commit(); return true; } } @@ -557,7 +541,8 @@ class KTBrowseBulkExportAction extends KTBulkAction { var $sName = 'ktcore.actions.bulk.export'; var $_sPermission = 'ktcore.permissions.read'; var $_bMutator = true; - + var $bNotifications = true; + function getDisplayName() { return _kt('Export'); } @@ -589,6 +574,8 @@ class KTBrowseBulkExportAction extends KTBulkAction { $this->startTransaction(); $oKTConfig =& KTConfig::getSingleton(); $this->bNoisy = $oKTConfig->get("tweaks/noisyBulkOperations"); + + $this->bNotifications = ($oKTConfig->get('export/enablenotifications', 'on') == 'on') ? true : false; $result = parent::do_performaction(); $sExportCode = $this->oZip->createZipFile(); @@ -634,6 +621,14 @@ class KTBrowseBulkExportAction extends KTBulkAction { $oDocumentTransaction = new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array()); $oDocumentTransaction->create(); } + + // fire subscription alerts for the downloaded document - if global config is set + if($this->bNotifications){ + $oSubscriptionEvent = new SubscriptionEvent(); + $oFolder = Folder::get($oDocument->getFolderID()); + $oSubscriptionEvent->DownloadDocument($oDocument, $oFolder); + } + $this->oZip->addDocumentToZip($oDocument); }else if(is_a($oEntity, 'Folder')) { @@ -677,6 +672,14 @@ class KTBrowseBulkExportAction extends KTBulkAction { $oDocumentTransaction = new DocumentTransaction($oDocument, "Document part of bulk export", 'ktstandard.transactions.bulk_export', array()); $oDocumentTransaction->create(); } + + // fire subscription alerts for the downloaded document + if($this->bNotifications){ + $oSubscriptionEvent = new SubscriptionEvent(); + $oFolder = Folder::get($oDocument->getFolderID()); + $oSubscriptionEvent->DownloadDocument($oDocument, $oFolder); + } + $this->oZip->addDocumentToZip($oDocument); } } diff --git a/plugins/ktcore/KTDocumentActions.php b/plugins/ktcore/KTDocumentActions.php index a1735fa..bb107f4 100644 --- a/plugins/ktcore/KTDocumentActions.php +++ b/plugins/ktcore/KTDocumentActions.php @@ -296,6 +296,16 @@ class KTDocumentViewAction extends KTDocumentAction { $oDocumentTransaction = & new DocumentTransaction($this->oDocument, _kt('Document downloaded'), 'ktcore.transactions.download', $aOptions); $oDocumentTransaction->create(); + + // fire subscription alerts for the downloaded document + $oKTConfig =& KTConfig::getSingleton(); + $bNotifications = ($oKTConfig->get('export/enablenotifications', 'on') == 'on') ? true : false; + if($bNotifications){ + $oSubscriptionEvent = new SubscriptionEvent(); + $oFolder = Folder::get($this->oDocument->getFolderID()); + $oSubscriptionEvent->DownloadDocument($this->oDocument, $oFolder); + } + exit(0); } } @@ -1319,34 +1329,13 @@ class KTDocumentArchiveAction extends KTDocumentAction { $sReason = $data['reason']; - $this->startTransaction(); - $this->oDocument->setStatusID(ARCHIVED); - $res = $this->oDocument->update(); - if (PEAR::isError($res) || ($res === false)) { - $_SESSION['KTErrorMessage'][] = _kt('There was a database error while trying to archive this file'); + $res = KTDocumentUtil::archive($this->oDocument, $sReason); + + if(PEAR::isError($res)){ + $_SESSION['KTErrorMessage'][] = $res->getMessage(); controllerRedirect('viewDocument', 'fDocumentId=' . $this->oDocument->getId()); exit(0); } - $oDocumentTransaction = & new DocumentTransaction($this->oDocument, sprintf(_kt('Document archived: %s'), $sReason), 'ktcore.transactions.update'); - $oDocumentTransaction->create(); - - $this->commitTransaction(); - - $oKTTriggerRegistry = KTTriggerRegistry::getSingleton(); - $aTriggers = $oKTTriggerRegistry->getTriggers('archive', 'postValidate'); - foreach ($aTriggers as $aTrigger) { - $sTrigger = $aTrigger[0]; - $oTrigger = new $sTrigger; - $aInfo = array( - 'document' => $this->oDocument, - ); - $oTrigger->setInfo($aInfo); - $ret = $oTrigger->postValidate(); - if (PEAR::isError($ret)) { - $this->oDocument->delete(); - return $ret; - } - } $_SESSION['KTInfoMessage'][] = _kt('Document archived.'); controllerRedirect('browse', 'fFolderId=' . $this->oDocument->getFolderID()); diff --git a/plugins/ktcore/folder/BulkUpload.php b/plugins/ktcore/folder/BulkUpload.php index 6173270..8543613 100644 --- a/plugins/ktcore/folder/BulkUpload.php +++ b/plugins/ktcore/folder/BulkUpload.php @@ -46,7 +46,7 @@ class KTBulkUploadFolderAction extends KTFolderAction { var $bAutomaticTransaction = true; function getDisplayName() { - return _kt('Bulk upload'); + return _kt('Bulk Upload'); } function check() { @@ -70,7 +70,7 @@ class KTBulkUploadFolderAction extends KTFolderAction { $this->oPage->setBreadcrumbDetails(_kt("bulk upload")); $oTemplate =& $this->oValidator->validateTemplate('ktcore/folder/bulkUpload'); $add_fields = array(); - $add_fields[] = new KTFileUploadWidget(_kt('Archive file'), _kt('The archive file containing the documents you wish to add to the document management system.'), 'file', "", $this->oPage, true); + $add_fields[] = new KTFileUploadWidget(_kt('Archive file'), _kt('The archive file containing the documents you wish to add to the document management system.'), 'file', "", $this->oPage, true, "file"); $aVocab = array('' => _kt('- Please select a document type -')); foreach (DocumentType::getListForUserAndFolder($this->oUser, $this->oFolder) as $oDocumentType) { @@ -126,10 +126,10 @@ class KTBulkUploadFolderAction extends KTFolderAction { $bm =& new KTBulkImportManager($this->oFolder, $fs, $this->oUser, $aOptions); $this->startTransaction(); $res = $bm->import(); - $aErrorOptions['message'] = _kt("Bulk upload failed"); + $aErrorOptions['message'] = _kt("Bulk Upload failed"); $this->oValidator->notError($res, $aErrorOptions); - $this->addInfoMessage(_kt("Bulk upload successful")); + $this->addInfoMessage(_kt("Bulk Upload successful")); $this->commitTransaction(); controllerRedirect("browse", 'fFolderId=' . $this->oFolder->getID()); exit(0); diff --git a/plugins/ktstandard/KTBulkExportPlugin.php b/plugins/ktstandard/KTBulkExportPlugin.php index 8fb0ccc..1ce73f9 100644 --- a/plugins/ktstandard/KTBulkExportPlugin.php +++ b/plugins/ktstandard/KTBulkExportPlugin.php @@ -32,6 +32,7 @@ require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); +require_once(KT_LIB_DIR . '/subscriptions/Subscription.inc'); require_once(KT_LIB_DIR . '/config/config.inc.php'); require_once(KT_LIB_DIR . '/foldermanagement/compressionArchiveUtil.inc.php'); @@ -90,6 +91,7 @@ class KTBulkExportAction extends KTFolderAction { $oKTConfig =& KTConfig::getSingleton(); $bNoisy = $oKTConfig->get("tweaks/noisyBulkOperations"); + $bNotifications = ($oKTConfig->get('export/enablenotifications', 'on') == 'on') ? true : false; // Redirect if there are no documents and no folders to export if (empty($aDocumentIds) && empty($aFolderList)) { @@ -112,6 +114,13 @@ class KTBulkExportAction extends KTFolderAction { $oDocumentTransaction->create(); } + // fire subscription alerts for the downloaded document + if($bNotifications){ + $oSubscriptionEvent = new SubscriptionEvent(); + $oFolder = Folder::get($oDocument->getFolderID()); + $oSubscriptionEvent->DownloadDocument($oDocument, $oFolder); + } + $this->oZip->addDocumentToZip($oDocument); } } diff --git a/search2/indexing/extractorCore.inc.php b/search2/indexing/extractorCore.inc.php index 897055f..b75c9fc 100644 --- a/search2/indexing/extractorCore.inc.php +++ b/search2/indexing/extractorCore.inc.php @@ -408,7 +408,7 @@ abstract class ApplicationExtractor extends ExternalDocumentExtractor { $sources = array('{source}','{target}'); $target = array($this->sourcefile, $this->targetfile); - $cmdline = $this->command . ' ' . str_replace($sources,$target, $params); + $cmdline = $this->command . ' ' . str_replace($sources,$target, $this->params); return $cmdline; } diff --git a/search2/indexing/indexerCore.inc.php b/search2/indexing/indexerCore.inc.php index 9a68c1e..6d88b4a 100644 --- a/search2/indexing/indexerCore.inc.php +++ b/search2/indexing/indexerCore.inc.php @@ -252,6 +252,8 @@ abstract class Indexer */ private $hookPath; + private $enabledExtractors; + /** * Initialise the indexer * @@ -267,6 +269,29 @@ abstract class Indexer $this->extractorPath = $config->get('indexer/extractorPath', 'extractors'); $this->hookPath = $config->get('indexer/extractorHookPath','extractorHooks'); + + + $this->loadExtractorStatus(); + } + + /** + * Get the list if enabled extractors + * + */ + private function loadExtractorStatus() + { + $sql = "SELECT id, name FROM mime_extractors WHERE active=1"; + $rs = DBUtil::getResultArray($sql); + $this->enabledExtractors = array(); + foreach($rs as $item) + { + $this->enabledExtractors[] = $item['name']; + } + } + + private function isExtractorEnabled($extractor) + { + return in_array($extractor, $this->enabledExtractors); } /** @@ -599,6 +624,7 @@ abstract class Indexer { global $default; + $default->log->info('indexDocuments: start'); if (!$this->doesDiagnosticsPass()) { return; @@ -618,13 +644,14 @@ abstract class Indexer // identify the indexers that must run // mysql specific limit! $sql = "SELECT - iff.document_id, mt.filetypes, mt.mimetypes, mt.extractor, iff.what + iff.document_id, mt.filetypes, mt.mimetypes, me.name as extractor, iff.what FROM index_files iff INNER JOIN documents d ON iff.document_id=d.id INNER JOIN document_metadata_version dmv ON d.metadata_version_id=dmv.id INNER JOIN document_content_version dcv ON dmv.content_version_id=dcv.id INNER JOIN mime_types mt ON dcv.mime_id=mt.id + INNER JOIN mime_extractors me ON mt.extractor_id=me.id WHERE (iff.processdate IS NULL or iff.processdate < cast(cast('$date' as date) -1 as date)) AND dmv.status_id=1 ORDER BY indexdate @@ -674,6 +701,12 @@ abstract class Indexer $default->log->debug(sprintf(_kt("Indexing docid: %d extension: '%s' mimetype: '%s' extractor: '%s'"), $docId, $extension,$mimeType,$extractorClass)); } + if (!$this->isExtractorEnabled($extractorClass)) + { + $default->log->info(sprintf(_kt("diagnose: Not indexing docid: %d because extractor '%s' is disabled."), $docId, $extractorClass)); + continue; + } + if (empty($extractorClass)) { if ($this->debug) @@ -835,10 +868,7 @@ abstract class Indexer } } - if ($this->debug) - { - $default->log->debug(_kt("Done.")); - } + $default->log->info('indexDocuments: done'); } public function migrateDocuments($max=null) @@ -1032,6 +1062,12 @@ abstract class Indexer continue; } + if (!$this->isExtractorEnabled($class)) + { + $default->log->info(sprintf(_kt("diagnose: extractor '%s' is disabled."), $class)); + continue; + } + $extractor = new $class(); if (!is_a($extractor, $baseclass)) { diff --git a/templates/ktcore/search2/adv_query_builder.smarty b/templates/ktcore/search2/adv_query_builder.smarty index 70920b3..5fca80a 100644 --- a/templates/ktcore/search2/adv_query_builder.smarty +++ b/templates/ktcore/search2/adv_query_builder.smarty @@ -3,7 +3,6 @@ {$context->oPage->requireJSResource("thirdpartyjs/extjs/adapter/ext/ext-base.js")} {$context->oPage->requireJSResource("thirdpartyjs/extjs/ext-all.js")} -