Commit 186e943b0cf6e940dbb2a2c6bf2d02a1d9c20523

Authored by rob
1 parent 84bed718

*** empty log message ***


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1997 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/DocumentCollaboration.inc
... ... @@ -164,6 +164,7 @@ class DocumentCollaboration {
164 164 $oEmail = & new Email();
165 165 $oEmail->send($oUser->getEmail(), "Document collaboration role active", $sBody);
166 166 }
  167 + DocumentCollaboration::createDependantDocuments(& $oFolderUserRole);
167 168 }
168 169 return true;
169 170 }
... ... @@ -175,9 +176,52 @@ class DocumentCollaboration {
175 176 }
176 177  
177 178 /**
  179 + * Creates any new documents that must be created for the
  180 + * folder collaboration step with primary key $iGroupFolderApprovalID. Users
  181 + * responsible for their creation are notified via email
  182 + */
  183 + function createDependantDocuments($oFolderUserRole) {
  184 + global $default;
  185 + //only create the documents if they haven't been created
  186 + if ($oFolderUserRole->getDependantDocumentsCreated() == false) {
  187 + $sQuery = "SELECT * FROM $default->owl_dependant_document_template_table WHERE group_folder_approval_link_id = " . $oFolderUserRole->getGroupFolderApprovalID();
  188 + $sql = $default->db;
  189 + $sql->query($sQuery);
  190 + while ($sql->next_record()) {
  191 + $oDependantDocumentInstance = & new DependantDocumentInstance($sql->f("document_title"), $sql->f("default_user_id"), $sql->f("template_document_id"), $oFolderUserRole->getDocumentID());
  192 + if ($oDependantDocumentInstance->create()) {
  193 + //get the user who is responsible for creating the new document
  194 + $oUser = User::get($oDependantDocumentInstance->getUserID());
  195 + //get the document that can be used as a template, if there is one
  196 + $oDocument = Document::get($oDependantDocumentInstance->getTemplateDocumentID());
  197 + //send the user notification via email
  198 + $sBody = $oUser->getName() . ", a step in the document collaboration process requires you to create a new document. Click here or log onto " .
  199 + "KnowledgeTree and select the relevant link under the 'Dependant Documents' heading on your dashboard to upload it.";
  200 + //if we have a template document
  201 + if (!($oDocument === false)) {
  202 + $sBody .= "The document entitled " . generateLink("/control.php", "action=viewDocument&fDocumentID=" . $oDocument->getID(), $oDocument->getName()) . " " .
  203 + "can be used as a template";
  204 + }
  205 + $oEmail = & new Email();
  206 + $oEmail->send($oUser->getEmail(), "Dependant document creation required", $sBody);
  207 + } else {
  208 + $_SESSION["errorMessage"] = "Error creating dependant documents when moving to next collaboration step. FolderUserRoleID: " + $oFolderUserRole->getID();
  209 + return false;
  210 + }
  211 + }
  212 + $oFolderUserRole->setDependantDocumentsCreated(true);
  213 + $oFolderUserRole->update();
  214 + }
  215 + }
  216 +
  217 + /**
178 218 * Rolls back a collaboration step if it is
179 219 * rejected by the user. This is a problem function as
180 220 * it really should have transactions, but doesn't
  221 + *
  222 + * Note that new documents created for a folder collaboration step
  223 + * are NOT rolled back - they are simply allowed to continue. When
  224 + * this step is next reached, these documents won't be created again
181 225 *
182 226 */
183 227 function rollbackCollaborationStep($iDocumentID, $sComment = "") {
... ... @@ -221,13 +265,16 @@ class DocumentCollaboration {
221 265  
222 266  
223 267 $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);
  268 + //send an email only if the user is to be notified via email
  269 + if ($oUserToNotify->getEmailNotification()) {
  270 + $oCurrentUser = User::get($_SESSION["userID"]);
  271 + $sBody = $oUserToNotify->getUserName() . ", the document, '" . generateLink("/presentation/lookAndFeel/knowledgeTree/documentmanagement/viewBL.php", "fDocumentID=" . $this->iId, $oDocument->getName()) . "' " .
  272 + "has been rejected by " . $oUserToNotify->getName() . " in the document collaboration process. The collaboration process has been rolled back to the previous step. " .
  273 + "Your role is no longer active and and any acceptances you may have made have been voided. " .
  274 + "The comment entered by " . $oUserToNotify->getName() . " was: $sComment";
  275 + $oEmail = & new Email();
  276 + $oEmail->send($oUserToNotify->getEmail(), "Document rejected in collaboration process", $sBody);
  277 + }
231 278 }
232 279  
233 280 //get the previous sequence number
... ...