Commit 6721723c11a8f3d67d5b5d9982b42a7a0e71b980
1 parent
74a3635f
Updated collaboration to inform users performing concurrent steps
when their step is rolled back git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1768 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
34 additions
and
5 deletions
lib/documentmanagement/DocumentCollaboration.inc
| @@ -183,16 +183,14 @@ class DocumentCollaboration { | @@ -183,16 +183,14 @@ class DocumentCollaboration { | ||
| 183 | function rollbackCollaborationStep($iDocumentID, $sComment = "") { | 183 | function rollbackCollaborationStep($iDocumentID, $sComment = "") { |
| 184 | global $default; | 184 | global $default; |
| 185 | //get the current sequence number | 185 | //get the current sequence number |
| 186 | - $sQuery = "SELECT GFAT.precedence, GFAT.folder_id, FURL.id AS furl_id " . | 186 | + $sQuery = "SELECT GFAT.precedence, GFAT.folder_id, FURL.id AS furl_id, FURL.document_id AS document_id " . |
| 187 | "FROM $default->owl_folders_user_roles_table AS FURL INNER JOIN $default->owl_groups_folders_approval_table AS GFAT ON FURL.group_folder_approval_id = GFAT.id " . | 187 | "FROM $default->owl_folders_user_roles_table AS FURL INNER JOIN $default->owl_groups_folders_approval_table AS GFAT ON FURL.group_folder_approval_id = GFAT.id " . |
| 188 | "WHERE FURL.document_id = $iDocumentID " . | 188 | "WHERE FURL.document_id = $iDocumentID " . |
| 189 | "AND user_id = " . $_SESSION["userID"] . " " . | 189 | "AND user_id = " . $_SESSION["userID"] . " " . |
| 190 | "AND FURL.active = 1 " . | 190 | "AND FURL.active = 1 " . |
| 191 | "ORDER BY GFAT.precedence ASC"; | 191 | "ORDER BY GFAT.precedence ASC"; |
| 192 | 192 | ||
| 193 | - //echo $sQuery; | ||
| 194 | - | ||
| 195 | - | 193 | + //echo $sQuery; |
| 196 | 194 | ||
| 197 | $sql = $default->db; | 195 | $sql = $default->db; |
| 198 | $sql->query($sQuery); | 196 | $sql->query($sQuery); |
| @@ -200,6 +198,37 @@ class DocumentCollaboration { | @@ -200,6 +198,37 @@ class DocumentCollaboration { | ||
| 200 | $iCurrentSequenceNumber = $sql->f("precedence"); | 198 | $iCurrentSequenceNumber = $sql->f("precedence"); |
| 201 | $iFolderID = $sql->f("folder_id"); | 199 | $iFolderID = $sql->f("folder_id"); |
| 202 | $iCurrentFolderUserRoleID = $sql->f("furl_id"); | 200 | $iCurrentFolderUserRoleID = $sql->f("furl_id"); |
| 201 | + $iDocumentID = $sql->f("document_id"); | ||
| 202 | + | ||
| 203 | + $oDocument = Document::get($iDocumentID); | ||
| 204 | + | ||
| 205 | + //if there are concurrent collaboration steps and one is rejected, then all | ||
| 206 | + //must be rolled back, whether they were accepted or not | ||
| 207 | + $sQuery = "SELECT FURL.id, FURL.user_id " . | ||
| 208 | + "FROM $default->owl_folders_user_roles_table AS FURL INNER JOIN $default->owl_groups_folders_approval_table AS GFAT ON FURL.group_folder_approval_id = GFAT.id " . | ||
| 209 | + "WHERE FURL.document_id = $iDocumentID AND GFAT.precedence = $iCurrentSequenceNumber"; | ||
| 210 | + $sql->query($sQuery); | ||
| 211 | + //echo $sQuery; | ||
| 212 | + //echo $sQuery; | ||
| 213 | + | ||
| 214 | + while ($sql->next_record()) { | ||
| 215 | + //roll back each user's step and then email them to inform them | ||
| 216 | + //of the change | ||
| 217 | + $oFolderUserRole = FolderUserRole::get($sql->f("id")); | ||
| 218 | + $oFolderUserRole->setActive(false); | ||
| 219 | + $oFolderUserRole->setDone(false); | ||
| 220 | + $oFolderUserRole->update(); | ||
| 221 | + | ||
| 222 | + | ||
| 223 | + $oUserToNotify = User::get($sql->f("user_id")); | ||
| 224 | + $oCurrentUser = User::get($_SESSION["userID"]); | ||
| 225 | + $sBody = $oUserToNotify->getUserName() . ", the document, '" . generateLink("/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php", "fDocumentID=" . $this->iId, $oDocument->getName()) . "' " . | ||
| 226 | + "has been rejected by " . $oUserToNotify->getName() . " in the document collaboration process. The collaboration process has been rolled back to the previous step. " . | ||
| 227 | + "Your role is no longer active and and any acceptances you may have made have been voided. " . | ||
| 228 | + "The comment entered by " . $oUserToNotify->getName() . " was: $sComment"; | ||
| 229 | + $oEmail = & new Email(); | ||
| 230 | + $oEmail->send($oUserToNotify->getEmail(), "Document rejected in collaboration process", $sBody); | ||
| 231 | + } | ||
| 203 | 232 | ||
| 204 | //get the previous sequence number | 233 | //get the previous sequence number |
| 205 | $sQuery = "SELECT COALESCE(MAX(precedence), -1) AS precedence " . | 234 | $sQuery = "SELECT COALESCE(MAX(precedence), -1) AS precedence " . |
| @@ -213,7 +242,7 @@ class DocumentCollaboration { | @@ -213,7 +242,7 @@ class DocumentCollaboration { | ||
| 213 | //the current step is the first step | 242 | //the current step is the first step |
| 214 | //reset all steps and email the creator | 243 | //reset all steps and email the creator |
| 215 | DocumentCollaboration::resetDocumentCollaborationSteps($iDocumentID); | 244 | DocumentCollaboration::resetDocumentCollaborationSteps($iDocumentID); |
| 216 | - $oDocument = Document::get($iDocumentID); | 245 | + //$oDocument = Document::get($iDocumentID); |
| 217 | $oUser = User::get($oDocument->getCreatorID()); | 246 | $oUser = User::get($oDocument->getCreatorID()); |
| 218 | if ($oUser->getEmailNotification()) { | 247 | if ($oUser->getEmailNotification()) { |
| 219 | $oCurrentUser = User::get($_SESSION["userID"]); | 248 | $oCurrentUser = User::get($_SESSION["userID"]); |