Commit e1ba4d8e48b4706bc106fae3e009a0662db120a3

Authored by Michael Joseph
1 parent fbf2fa25

corrected collaboration emails and added methods to retrieve the last collaborator of a document


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1532 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/Document.inc
@@ -767,13 +767,45 @@ class Document { @@ -767,13 +767,45 @@ class Document {
767 function isLastStepInCollaborationProcess($iDocumentID) { 767 function isLastStepInCollaborationProcess($iDocumentID) {
768 global $default; 768 global $default;
769 $sql = $default->db; 769 $sql = $default->db;
770 - $sql->query("SELECT * FROM $default->owl_folders_user_roles_table WHERE document_id = $iDocumentID AND active = 0 AND done = 0");  
771 - if ($sql->next_record()) {  
772 - return false;  
773 - }  
774 - return true; 770 + $sQuery = "SELECT * FROM $default->owl_folders_user_roles_table WHERE document_id = $iDocumentID AND done = 0";
  771 + $sql->query($sQuery);
  772 + $default->log->info("lastCollabStep:$sQuery");
  773 + if ($sql->num_rows() > 1) {
  774 + return false;
  775 + } else {
  776 + return true;
  777 + }
775 } 778 }
776 779
  780 + /**
  781 + * Returns the userID of the last user in the collaboration process
  782 + */
  783 + function getLastCollaboratorID($iDocumentID) {
  784 +
  785 + global $default;
  786 + $sql = $default->db;
  787 + // returns all users, the sequence of their collaboration and the time of completion
  788 + $sQuery = "SELECT FURL.user_id, FURL.datetime, GFAL.precedence FROM $default->owl_folders_user_roles_table FURL " .
  789 + "INNER JOIN $default->owl_groups_folders_approval_table GFAL ON FURL.group_folder_approval_id = GFAL.id " .
  790 + "WHERE FURL.document_id = $iDocumentID " .
  791 + "ORDER BY GFAL.precedence";
  792 + $sql->query($sQuery);
  793 + $iPrecedence = -1;
  794 + $iDateTime = 0;
  795 + $iUserID = -1;
  796 + while ($sql->next_record()) {
  797 + if ($sql->f("precedence") >= $iPrecedence) {
  798 + $iPrecedence = $sql->f("precedence");
  799 + $iDateCompleted = strtotime($sql->f("datetime"));
  800 + if ($iDateCompleted > $iDateTime) {
  801 + $iDateTime = $iDateCompleted;
  802 + $iUserID = $sql->f("user_id");
  803 + }
  804 + }
  805 + }
  806 + return ($iUserID == -1) ? false : $iUserID;
  807 + }
  808 +
777 /** 809 /**
778 * Begins the next step(s) in the document 810 * Begins the next step(s) in the document
779 * collaboration process 811 * collaboration process
@@ -818,9 +850,9 @@ class Document { @@ -818,9 +850,9 @@ class Document {
818 //get the user to email 850 //get the user to email
819 $oUser = User::get($oFolderUserRole->getUserID()); 851 $oUser = User::get($oFolderUserRole->getUserID());
820 if ($oUser->getEmailNotification()) { 852 if ($oUser->getEmailNotification()) {
821 -  
822 - $sBody = $oUser->getUserName() . ", your role of '" . $oRole->getName() . "' in the document, '" . $this->sName . "' collaboration process is now active. " .  
823 - "Click " . generateControllerLink("viewDocument", "fDocumentID=" . $this->iId, "here") . " to access " . 853 + $oDocument = & Document::get($iDocumentID);
  854 + $sBody = $oUser->getName() . ", your role of '" . $oRole->getName() . "' in the document, '" . $oDocument->getName() . "' collaboration process is now active. " .
  855 + "Click " . generateControllerLink("viewDocument", "fDocumentID=$iDocumentID", "here") . " to access " .
824 "the document"; 856 "the document";
825 857
826 $oEmail = & new Email(); 858 $oEmail = & new Email();