Commit 4e969de6b87912c61fdd9bd22cf8e65e4169c7e8

Authored by Michael Joseph
1 parent a0434159

integrated subscription firing


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1624 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentBL.php
@@ -12,6 +12,8 @@ require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); @@ -12,6 +12,8 @@ require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
12 require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc"); 12 require_once("$default->fileSystemRoot/lib/documentmanagement/PhysicalDocumentManager.inc");
13 require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); 13 require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc");
14 14
  15 +require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc");
  16 +
15 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); 17 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc");
16 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); 18 require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
17 19
@@ -32,11 +34,30 @@ if (checkSession()) { @@ -32,11 +34,30 @@ if (checkSession()) {
32 $sOldDocumentFileSystemPath = Folder::getFolderPath($iOldFolderID) . $oDocument->getFileName(); 34 $sOldDocumentFileSystemPath = Folder::getFolderPath($iOldFolderID) . $oDocument->getFileName();
33 //put the document in the new folder 35 //put the document in the new folder
34 $oDocument->setFolderID($fFolderID); 36 $oDocument->setFolderID($fFolderID);
35 - if ($oDocument->update(true)) { 37 + if ($oDocument->update(true)) {
36 //get the new document path 38 //get the new document path
37 $sNewDocumentFileSystemPath = Folder::getFolderPath($oDocument->getFolderID()) . $oDocument->getFileName(); 39 $sNewDocumentFileSystemPath = Folder::getFolderPath($oDocument->getFolderID()) . $oDocument->getFileName();
38 //move the document on the file system 40 //move the document on the file system
39 if (PhysicalDocumentManager::move($sOldDocumentFileSystemPath, $sNewDocumentFileSystemPath)) { 41 if (PhysicalDocumentManager::move($sOldDocumentFileSystemPath, $sNewDocumentFileSystemPath)) {
  42 +
  43 + // fire subscription alerts for the moved document (and the folder its in)
  44 + $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("MovedDocument"),
  45 + SubscriptionConstants::subscriptionType("DocumentSubscription"),
  46 + array( "folderID" => $iOldFolderID,
  47 + "modifiedDocumentName" => $oDocument->getName(),
  48 + "oldFolderName" => Folder::getFolderName($iOldFolderID),
  49 + "newFolderName" => Folder::getFolderName($fFolderID) ));
  50 + $default->log->info("moveDocumentBL.php fired $count subscription alerts for moved document " . $oDocument->getName());
  51 +
  52 + // fire folder subscriptions for the destination folder
  53 + $count = SubscriptionEngine::fireSubscription($oDocument->getFolderID(), SubscriptionConstants::subscriptionAlertType("MovedDocument"),
  54 + SubscriptionConstants::subscriptionType("FolderSubscription"),
  55 + array( "modifiedDocumentName" => $oDocument->getName(),
  56 + "oldFolderName" => Folder::getFolderName($iOldFolderID),
  57 + "newFolderName" => Folder::getFolderName($fFolderID) ));
  58 + $default->log->info("moveDocumentBL.php fired $count (folderID=$fFolderID) folder subscription alerts for moved document " . $oDocument->getName());
  59 +
  60 +
40 //redirect to the view path 61 //redirect to the view path
41 redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); 62 redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID");
42 } else { 63 } else {