Commit a576545e411b113de6d046b5cd71bd61e1168583

Authored by rob
1 parent 45b382cb

Added functionality to email web master


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1310 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/documentmanagement/Document.inc
@@ -772,13 +772,15 @@ class Document { @@ -772,13 +772,15 @@ class Document {
772 $oRole = Role::get($oFolderCollaboration->getRoleID()); 772 $oRole = Role::get($oFolderCollaboration->getRoleID());
773 //get the user to email 773 //get the user to email
774 $oUser = User::get($oFolderUserRole->getUserID()); 774 $oUser = User::get($oFolderUserRole->getUserID());
775 -  
776 - $sBody = $oUser->getUserName() . ", your role of '" . $oRole->getName() . "' in the document, '" . $this->sName . "' collaboration process is now active. " .  
777 - "Click <a href=\"https://" . $_SERVER["SERVER_NAME"] . "$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $this->iId . "\">here</a> to access " .  
778 - "the document";  
779 -  
780 - $oEmail = & new Email($default->owl_email_from, $default->owl_email_fromname);  
781 - $oEmail->send($oUser->getEmail(), "Document collaboration role active", $sBody, $default->owl_email_from, $default->owl_email_fromname); 775 + if ($oUser->getEmailNotification()) {
  776 +
  777 + $sBody = $oUser->getUserName() . ", your role of '" . $oRole->getName() . "' in the document, '" . $this->sName . "' collaboration process is now active. " .
  778 + "Click <a href=\"https://" . $_SERVER["SERVER_NAME"] . "$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $this->iId . "\">here</a> to access " .
  779 + "the document";
  780 +
  781 + $oEmail = & new Email($default->owl_email_from, $default->owl_email_fromname);
  782 + $oEmail->send($oUser->getEmail(), "Document collaboration role active", $sBody, $default->owl_email_from, $default->owl_email_fromname);
  783 + }
782 } 784 }
783 return true; 785 return true;
784 } 786 }
@@ -823,15 +825,17 @@ class Document { @@ -823,15 +825,17 @@ class Document {
823 //reset all steps and email the creator 825 //reset all steps and email the creator
824 Document::resetDocumentCollaborationSteps($iDocumentID); 826 Document::resetDocumentCollaborationSteps($iDocumentID);
825 $oDocument = Document::get($iDocumentID); 827 $oDocument = Document::get($iDocumentID);
826 - $oUser = User::get($oDocument->getCreatorID());  
827 - $oCurrentUser = User::get($_SESSION["userID"]);  
828 -  
829 - $sBody = $oUser->getUserName() . ", the document, '<a href=\"https://" . $_SERVER["SERVER_NAME"] . "$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $this->iId . "\">" . $oDocument->getName() . "</a>' " .  
830 - "has been rejected by " . $oCurrentUser->getName() . " in the document collaboration process. The collaboration process has been stopped. " .  
831 - "The comment entered by " . $oCurrentUser->getName() . " was: $sComment";  
832 -  
833 - $oEmail = & new Email($default->owl_email_from, $default->owl_email_fromname);  
834 - $oEmail->send($oUser->getEmail(), "Document rejected in collaboration process", $sBody, $default->owl_email_from, $default->owl_email_fromname); 828 + if ($oUser->getEmailNotification()) {
  829 + $oUser = User::get($oDocument->getCreatorID());
  830 + $oCurrentUser = User::get($_SESSION["userID"]);
  831 +
  832 + $sBody = $oUser->getUserName() . ", the document, '<a href=\"https://" . $_SERVER["SERVER_NAME"] . "$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $this->iId . "\">" . $oDocument->getName() . "</a>' " .
  833 + "has been rejected by " . $oCurrentUser->getName() . " in the document collaboration process. The collaboration process has been stopped. " .
  834 + "The comment entered by " . $oCurrentUser->getName() . " was: $sComment";
  835 +
  836 + $oEmail = & new Email($default->owl_email_from, $default->owl_email_fromname);
  837 + $oEmail->send($oUser->getEmail(), "Document rejected in collaboration process", $sBody, $default->owl_email_from, $default->owl_email_fromname);
  838 + }
835 } else { 839 } else {
836 //there are steps prior to this step 840 //there are steps prior to this step
837 $sQuery = "SELECT FURL.id AS furl_id " . 841 $sQuery = "SELECT FURL.id AS furl_id " .
@@ -850,15 +854,17 @@ class Document { @@ -850,15 +854,17 @@ class Document {
850 $oFolderUserRole->update(); 854 $oFolderUserRole->update();
851 855
852 $oDocument = Document::get($iDocumentID); 856 $oDocument = Document::get($iDocumentID);
853 - $oUser = User::get($oFolderUserRole->getUserID());  
854 - $oCurrentUser = User::get($_SESSION["userID"]);  
855 -  
856 - $sBody = $oUser->getUserName() . ", the document, '<a href=\"https://" . $_SERVER["SERVER_NAME"] . "$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $this->iId . "\">" . $oDocument->getName() . "</a>' " .  
857 - "has been rejected by " . $oCurrentUser->getName() . " in the document collaboration process. Please re-perform you step in the collaboration process." .  
858 - "The comment entered by " . $oCurrentUser->getName() . " was: $sComment";  
859 -  
860 - $oEmail = & new Email($default->owl_email_from, $default->owl_email_fromname);  
861 - $oEmail->send($oUser->getEmail(), "Document rejected in collaboration process", $sBody, $default->owl_email_from, $default->owl_email_fromname); 857 + if ($oUser->getEmailNotification()) {
  858 + $oUser = User::get($oFolderUserRole->getUserID());
  859 + $oCurrentUser = User::get($_SESSION["userID"]);
  860 +
  861 + $sBody = $oUser->getUserName() . ", the document, '<a href=\"https://" . $_SERVER["SERVER_NAME"] . "$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $this->iId . "\">" . $oDocument->getName() . "</a>' " .
  862 + "has been rejected by " . $oCurrentUser->getName() . " in the document collaboration process. Please re-perform you step in the collaboration process." .
  863 + "The comment entered by " . $oCurrentUser->getName() . " was: $sComment";
  864 +
  865 + $oEmail = & new Email($default->owl_email_from, $default->owl_email_fromname);
  866 + $oEmail->send($oUser->getEmail(), "Document rejected in collaboration process", $sBody, $default->owl_email_from, $default->owl_email_fromname);
  867 + }
862 868
863 } 869 }
864 $oFolderUserRole = FolderUserRole::get($iCurrentFolderUserRoleID); 870 $oFolderUserRole = FolderUserRole::get($iCurrentFolderUserRoleID);
@@ -869,6 +875,50 @@ class Document { @@ -869,6 +875,50 @@ class Document {
869 875
870 } 876 }
871 } 877 }
  878 +
  879 + /**
  880 + * Checks if a document is pending web publishing
  881 + *
  882 + *
  883 + */
  884 + function documentIsPendingWebPublishing($iDocumentID) {
  885 + global $default;
  886 + $sQuery = "SELECT * FROM $default->owl_web_documents_table WHERE document_id = $iDocumentID AND status_id = 1";
  887 + $sql = $default->db;
  888 + $sql->query($sQuery);
  889 + if ($sql->next_record()) {
  890 + return true;;
  891 + }
  892 + return false;
  893 + }
  894 +
  895 + /**
  896 + * Notify the web master when a document is awaiting publishing
  897 + *
  898 + */
  899 + function notifyWebMaster($iDocumentID) {
  900 + global $default;
  901 + $sQuery = "SELECT WS.web_master_id " .
  902 + "FROM $default->owl_web_sites_table AS WS INNER JOIN $default->owl_web_documents_table AS WD ON WS.id = WD.web_site_id " .
  903 + "WHERE WD.document_id = $iDocumentID";
  904 + $sql->$default->db;
  905 + $sql->query($sQuery);
  906 + if ($sql->next_record()) {
  907 + $oUser = User::get($sql->f("web_master_id"));
  908 + if (!($oUser === false)) {
  909 + if ($oUser->getEmailNotification()) {
  910 + $oDocument = Document::get($iDocumentID);
  911 + $sBody = $oUser->getUserName() . ", the document <a href=\"https://" . $_SERVER["SERVER_NAME"] . "$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $this->iId . "\">" . $oDocument->getName() . "</a> to access " .
  912 + "is pending web publishing";
  913 +
  914 + $oEmail = & new Email($default->owl_email_from, $default->owl_email_fromname);
  915 + $oEmail->send($oUser->getEmail(), "Document collaboration role active", $sBody, $default->owl_email_from, $default->owl_email_fromname);
  916 + }
  917 + }
  918 +
  919 + }
  920 +
  921 + }
872 } 922 }
873 923
874 ?> 924 ?>