Commit 276239575cef8f1a8b18c03ca7c0450dd006cb39

Authored by nbm
1 parent 19320684

Add a transaction for the move


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3646 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/moveDocumentBL.php
@@ -119,10 +119,9 @@ for ($i = 0; $i < count($fDocumentIDs); $i++) { @@ -119,10 +119,9 @@ for ($i = 0; $i < count($fDocumentIDs); $i++) {
119 119
120 //we're trying to move a document 120 //we're trying to move a document
121 $oDocument = & Document::get($fDocumentIDs[$i]); 121 $oDocument = & Document::get($fDocumentIDs[$i]);
122 - $oNewFolder = & Folder::get($fFolderID);  
123 $iOldFolderID = $oDocument->getFolderID(); 122 $iOldFolderID = $oDocument->getFolderID();
124 -  
125 $oOldFolder =& Folder::get($iOldFolderID); 123 $oOldFolder =& Folder::get($iOldFolderID);
  124 + $oNewFolder = & Folder::get($fFolderID);
126 125
127 // check that there is no filename collision in the destination directory 126 // check that there is no filename collision in the destination directory
128 $sNewDocumentFileSystemPath = Folder::getFolderPath($fFolderID) . $oDocument->getFileName(); 127 $sNewDocumentFileSystemPath = Folder::getFolderPath($fFolderID) . $oDocument->getFileName();
@@ -138,9 +137,6 @@ for ($i = 0; $i < count($fDocumentIDs); $i++) { @@ -138,9 +137,6 @@ for ($i = 0; $i < count($fDocumentIDs); $i++) {
138 continue; 137 continue;
139 } 138 }
140 139
141 - //get the old document path  
142 - $sOldDocumentFileSystemPath = Folder::getFolderPath($iOldFolderID) . $oDocument->getFileName();  
143 -  
144 //put the document in the new folder 140 //put the document in the new folder
145 $oDocument->setFolderID($fFolderID); 141 $oDocument->setFolderID($fFolderID);
146 if (!$oDocument->update(true)) { 142 if (!$oDocument->update(true)) {
@@ -149,8 +145,6 @@ for ($i = 0; $i < count($fDocumentIDs); $i++) { @@ -149,8 +145,6 @@ for ($i = 0; $i < count($fDocumentIDs); $i++) {
149 continue; 145 continue;
150 } 146 }
151 147
152 - //get the old document path  
153 - $sOldDocumentFileSystemPath = Folder::getFolderPath($iOldFolderID) . $oDocument->getFileName();  
154 //move the document on the file system 148 //move the document on the file system
155 if (!$oStorage->moveDocument($oDocument, $oOldFolder, $oNewFolder)) { 149 if (!$oStorage->moveDocument($oDocument, $oOldFolder, $oNewFolder)) {
156 $oDocument->setFolderID($iOldFolderID); 150 $oDocument->setFolderID($iOldFolderID);
@@ -162,6 +156,16 @@ for ($i = 0; $i < count($fDocumentIDs); $i++) { @@ -162,6 +156,16 @@ for ($i = 0; $i < count($fDocumentIDs); $i++) {
162 } 156 }
163 $oDocument->update(); 157 $oDocument->update();
164 158
  159 + $sMoveMessage = sprintf("Moved from %s/%s to %s/%s",
  160 + $oOldFolder->getFullPath(),
  161 + $oOldFolder->getName(),
  162 + $oNewFolder->getFullPath(),
  163 + $oNewFolder->getName());
  164 +
  165 + // create the document transaction record
  166 + $oDocumentTransaction = & new DocumentTransaction($oDocument->getID(), $sMoveMessage, MOVE);
  167 + $oDocumentTransaction->create();
  168 +
165 // fire subscription alerts for the moved document (and the folder its in) 169 // fire subscription alerts for the moved document (and the folder its in)
166 $count = SubscriptionEngine::fireSubscription($fDocumentIDs[$i], SubscriptionConstants::subscriptionAlertType("MovedDocument"), 170 $count = SubscriptionEngine::fireSubscription($fDocumentIDs[$i], SubscriptionConstants::subscriptionAlertType("MovedDocument"),
167 SubscriptionConstants::subscriptionType("DocumentSubscription"), 171 SubscriptionConstants::subscriptionType("DocumentSubscription"),