Commit bc7f6615b924d90ce4e0a0a92b6a68af004431ea

Authored by nbm
1 parent 0a29c847

Show errors in sending email on the next page.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3331 c91229c3-7414-0410-bfa2-8a42b809f60b
presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php
@@ -107,6 +107,7 @@ function sendUserEmails($aUserIDs, $oDocument, $sComment = "") { @@ -107,6 +107,7 @@ function sendUserEmails($aUserIDs, $oDocument, $sComment = "") {
107 */ 107 */
108 function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentName, $sComment) { 108 function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentName, $sComment) {
109 global $default; 109 global $default;
  110 + global $emailerrors;
110 $oSendingUser = User::get($_SESSION["userID"]); 111 $oSendingUser = User::get($_SESSION["userID"]);
111 112
112 $sMessage = "<font face=\"arial\" size=\"2\">"; 113 $sMessage = "<font face=\"arial\" size=\"2\">";
@@ -123,10 +124,17 @@ function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentN @@ -123,10 +124,17 @@ function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentN
123 $sTitle = "Link: " . $sDocumentName . " from " . $oSendingUser->getName(); 124 $sTitle = "Link: " . $sDocumentName . " from " . $oSendingUser->getName();
124 //email the hyperlink 125 //email the hyperlink
125 $oEmail = new Email(); 126 $oEmail = new Email();
126 - if ($oEmail->send($sDestEmailAddress, $sTitle, $sMessage)) {  
127 - $default->log->info("Send email ($sTitle) to $sDestEmailAddress");  
128 - } else { 127 + $res = $oEmail->send($sDestEmailAddress, $sTitle, $sMessage);
  128 + if (PEAR::isError($res)) {
  129 + $default->log->error($res->getMessage());
  130 + $emailerrors[] = $res->getMessage();
  131 + return $res;
  132 + } else if ($res === false) {
129 $default->log->error("Error sending email ($sTitle) to $sDestEmailAddress"); 133 $default->log->error("Error sending email ($sTitle) to $sDestEmailAddress");
  134 + $emailerrors[] = "Error sending email ($sTitle) to $sDestEmailAddress");
  135 + return PEAR::raiseError("Error sending email ($sTitle) to $sDestEmailAddress");
  136 + } else {
  137 + $default->log->info("Send email ($sTitle) to $sDestEmailAddress");
130 } 138 }
131 139
132 // emailed link transaction 140 // emailed link transaction
@@ -138,6 +146,8 @@ function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentN @@ -138,6 +146,8 @@ function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentN
138 } 146 }
139 } 147 }
140 148
  149 +$emailerrors = array();
  150 +
141 if (checkSession()) { 151 if (checkSession()) {
142 if (isset($fDocumentID)) { 152 if (isset($fDocumentID)) {
143 //get the document to send 153 //get the document to send
@@ -157,6 +167,10 @@ if (checkSession()) { @@ -157,6 +167,10 @@ if (checkSession()) {
157 sendGroupEmails($aGroupIDs, $oDocument, $fComment); 167 sendGroupEmails($aGroupIDs, $oDocument, $fComment);
158 // send user emails 168 // send user emails
159 sendUserEmails($aUserIDs, $oDocument, $fComment); 169 sendUserEmails($aUserIDs, $oDocument, $fComment);
  170 +
  171 + if (count($emailerrors)) {
  172 + $_SESSION['errorMessage'] = join("<br />\n", $emailerrors);
  173 + }
160 174
161 //go back to the document view page 175 //go back to the document view page
162 redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); 176 redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID");