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 107 */
108 108 function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentName, $sComment) {
109 109 global $default;
  110 + global $emailerrors;
110 111 $oSendingUser = User::get($_SESSION["userID"]);
111 112  
112 113 $sMessage = "<font face=\"arial\" size=\"2\">";
... ... @@ -123,10 +124,17 @@ function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentN
123 124 $sTitle = "Link: " . $sDocumentName . " from " . $oSendingUser->getName();
124 125 //email the hyperlink
125 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 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 140 // emailed link transaction
... ... @@ -138,6 +146,8 @@ function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentN
138 146 }
139 147 }
140 148  
  149 +$emailerrors = array();
  150 +
141 151 if (checkSession()) {
142 152 if (isset($fDocumentID)) {
143 153 //get the document to send
... ... @@ -157,6 +167,10 @@ if (checkSession()) {
157 167 sendGroupEmails($aGroupIDs, $oDocument, $fComment);
158 168 // send user emails
159 169 sendUserEmails($aUserIDs, $oDocument, $fComment);
  170 +
  171 + if (count($emailerrors)) {
  172 + $_SESSION['errorMessage'] = join("<br />\n", $emailerrors);
  173 + }
160 174  
161 175 //go back to the document view page
162 176 redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID");
... ...