Commit 6b0c6bfaf47faa99932e88ccda4e98aef719b3d4
1 parent
90e903ca
Implement document move subscription notices using the triggers
framework. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4093 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
42 additions
and
1 deletions
plugins/ktstandard/KTSubscriptions.php
| @@ -160,5 +160,46 @@ class KTDeleteSubscriptionTrigger { | @@ -160,5 +160,46 @@ class KTDeleteSubscriptionTrigger { | ||
| 160 | } | 160 | } |
| 161 | } | 161 | } |
| 162 | } | 162 | } |
| 163 | -$oTRegistry->registerTrigger('checkout', 'postValidate', 'KTDeleteSubscriptionTrigger', 'ktstandard.triggers.subscription.delete'); | 163 | +$oTRegistry->registerTrigger('delete', 'postValidate', 'KTDeleteSubscriptionTrigger', 'ktstandard.triggers.subscription.delete'); |
| 164 | +// }}} | ||
| 165 | + | ||
| 166 | +// {{{ KTDocumentMoveSubscriptionTrigger | ||
| 167 | +class KTDocumentMoveSubscriptionTrigger { | ||
| 168 | + var $aInfo = null; | ||
| 169 | + function setInfo(&$aInfo) { | ||
| 170 | + $this->aInfo =& $aInfo; | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + function postValidate() { | ||
| 174 | + global $default; | ||
| 175 | + $oDocument =& $this->aInfo["document"]; | ||
| 176 | + $oOldFolder =& $this->aInfo["old_folder"]; | ||
| 177 | + $oNewFolder =& $this->aInfo["new_folder"]; | ||
| 178 | + | ||
| 179 | + // fire subscription alerts for the moved document (and the folder its in) | ||
| 180 | + $count = SubscriptionEngine::fireSubscription($oDocument->getId(), SubscriptionConstants::subscriptionAlertType("MovedDocument"), | ||
| 181 | + SubscriptionConstants::subscriptionType("DocumentSubscription"), | ||
| 182 | + array( | ||
| 183 | + "folderID" => $oOldFolder->getId(), | ||
| 184 | + "modifiedDocumentName" => $oDocument->getName(), | ||
| 185 | + "oldFolderName" => Folder::getFolderName($oOldFolder->getId()), | ||
| 186 | + "newFolderName" => Folder::getFolderName($oNewFolder->getID()), | ||
| 187 | + ) | ||
| 188 | + ); | ||
| 189 | + $default->log->info("moveDocumentBL.php fired $count (folderID=$fFolderID) folder subscription alerts for moved document " . $oDocument->getName()); | ||
| 190 | + | ||
| 191 | + // fire folder subscriptions for the destination folder | ||
| 192 | + $count = SubscriptionEngine::fireSubscription($oNewFolder->getId(), SubscriptionConstants::subscriptionAlertType("MovedDocument"), | ||
| 193 | + SubscriptionConstants::subscriptionType("FolderSubscription"), | ||
| 194 | + array( | ||
| 195 | + "folderID" => $oOldFolder->getId(), | ||
| 196 | + "modifiedDocumentName" => $oDocument->getName(), | ||
| 197 | + "oldFolderName" => Folder::getFolderName($oOldFolder->getId()), | ||
| 198 | + "newFolderName" => Folder::getFolderName($oNewFolder->getId()), | ||
| 199 | + ) | ||
| 200 | + ); | ||
| 201 | + $default->log->info("moveDocumentBL.php fired $count (folderID=$fFolderID) folder subscription alerts for moved document " . $oDocument->getName()); | ||
| 202 | + } | ||
| 203 | +} | ||
| 204 | +$oTRegistry->registerTrigger('moveDocument', 'postValidate', 'KTDocumentMoveSubscriptionTrigger', 'ktstandard.triggers.subscription.moveDocument'); | ||
| 164 | // }}} | 205 | // }}} |