From bc7f6615b924d90ce4e0a0a92b6a68af004431ea Mon Sep 17 00:00:00 2001 From: nbm Date: Mon, 6 Jun 2005 19:02:18 +0000 Subject: [PATCH] Show errors in sending email on the next page. --- presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php index 0310001..fea18f1 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php @@ -107,6 +107,7 @@ function sendUserEmails($aUserIDs, $oDocument, $sComment = "") { */ function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentName, $sComment) { global $default; + global $emailerrors; $oSendingUser = User::get($_SESSION["userID"]); $sMessage = ""; @@ -123,10 +124,17 @@ function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentN $sTitle = "Link: " . $sDocumentName . " from " . $oSendingUser->getName(); //email the hyperlink $oEmail = new Email(); - if ($oEmail->send($sDestEmailAddress, $sTitle, $sMessage)) { - $default->log->info("Send email ($sTitle) to $sDestEmailAddress"); - } else { + $res = $oEmail->send($sDestEmailAddress, $sTitle, $sMessage); + if (PEAR::isError($res)) { + $default->log->error($res->getMessage()); + $emailerrors[] = $res->getMessage(); + return $res; + } else if ($res === false) { $default->log->error("Error sending email ($sTitle) to $sDestEmailAddress"); + $emailerrors[] = "Error sending email ($sTitle) to $sDestEmailAddress"); + return PEAR::raiseError("Error sending email ($sTitle) to $sDestEmailAddress"); + } else { + $default->log->info("Send email ($sTitle) to $sDestEmailAddress"); } // emailed link transaction @@ -138,6 +146,8 @@ function sendEmail($sDestEmailAddress, $sDestUserName, $fDocumentID, $sDocumentN } } +$emailerrors = array(); + if (checkSession()) { if (isset($fDocumentID)) { //get the document to send @@ -157,6 +167,10 @@ if (checkSession()) { sendGroupEmails($aGroupIDs, $oDocument, $fComment); // send user emails sendUserEmails($aUserIDs, $oDocument, $fComment); + + if (count($emailerrors)) { + $_SESSION['errorMessage'] = join("
\n", $emailerrors); + } //go back to the document view page redirect("$default->rootUrl/control.php?action=viewDocument&fDocumentID=$fDocumentID"); -- libgit2 0.21.4