From 738cf656d58d84586cba742d2c1dfb1363a2b803 Mon Sep 17 00:00:00 2001 From: Megan Watson Date: Mon, 22 Oct 2007 11:30:45 +0000 Subject: [PATCH] KTS-2521 "No notifications when you are subscribed to a folder" Fixed. Added notifications to the functions in document util. Refactored archive into documentutil. Added notifications to export. --- lib/documentmanagement/documentutil.inc.php | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- lib/subscriptions/subscriptions.inc.php | 196 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------- plugins/ktcore/KTBulkActions.php | 59 +++++++++++++++++++++++++++++++---------------------------- plugins/ktcore/KTDocumentActions.php | 39 ++++++++++++++------------------------- plugins/ktstandard/KTBulkExportPlugin.php | 9 +++++++++ 5 files changed, 231 insertions(+), 122 deletions(-) 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/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); } } -- libgit2 0.21.4