Commit 73df1c157ceb66c231a119bf3703cc6119e232af
1 parent
d2d7a4d0
Allow email addresses to be added free-form to the list of people to
send the document link/attachment to. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3335 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
24 additions
and
5 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/emailBL.php
| @@ -27,7 +27,7 @@ | @@ -27,7 +27,7 @@ | ||
| 27 | 27 | ||
| 28 | require_once("../../../../config/dmsDefaults.php"); | 28 | require_once("../../../../config/dmsDefaults.php"); |
| 29 | 29 | ||
| 30 | -KTUtil::extractGPC('fAttachDocument', 'fComment', 'fDocumentID', 'fSendEmail', 'groupNewRight', 'userNewRight'); | 30 | +KTUtil::extractGPC('fAttachDocument', 'fComment', 'fDocumentID', 'fEmailAddresses', 'fSendEmail', 'groupNewRight', 'userNewRight'); |
| 31 | 31 | ||
| 32 | require_once("$default->fileSystemRoot/lib/security/Permission.inc"); | 32 | require_once("$default->fileSystemRoot/lib/security/Permission.inc"); |
| 33 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | 33 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); |
| @@ -103,6 +103,21 @@ function sendUserEmails($aUserIDs, $oDocument, $sComment = "", $bAttachDocument) | @@ -103,6 +103,21 @@ function sendUserEmails($aUserIDs, $oDocument, $sComment = "", $bAttachDocument) | ||
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | /** | 105 | /** |
| 106 | + * Sends emails to the manually entered email addresses | ||
| 107 | + */ | ||
| 108 | +function sendManualEmails($aEmailAddresses, $oDocument, $sComment = "", $bAttachDocument) { | ||
| 109 | + global $default; | ||
| 110 | + | ||
| 111 | + // loop through users | ||
| 112 | + foreach ($aEmailAddresses as $sEmailAddress) { | ||
| 113 | + $default->log->info("sendingEmail to address " . $sEmailAddress); | ||
| 114 | + if (validateEmailAddress($sEmailAddress)) { | ||
| 115 | + sendEmail($sEmailAddress, $sEmailAddress, $oDocument->getID(), $oDocument->getName(), $sComment, $bAttachDocument); | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | +} | ||
| 119 | + | ||
| 120 | +/** | ||
| 106 | * Constructs the email message text and sends the message | 121 | * Constructs the email message text and sends the message |
| 107 | */ | 122 | */ |
| 108 | function sendEmail($sDestEmailAddress, $sDestUserName, $iDocumentID, $sDocumentName, $sComment, $bAttachDocument = false) { | 123 | function sendEmail($sDestEmailAddress, $sDestUserName, $iDocumentID, $sDocumentName, $sComment, $bAttachDocument = false) { |
| @@ -206,14 +221,17 @@ if (checkSession()) { | @@ -206,14 +221,17 @@ if (checkSession()) { | ||
| 206 | // explode group and user ids | 221 | // explode group and user ids |
| 207 | $aGroupIDs = explode(",", $groupNewRight); | 222 | $aGroupIDs = explode(",", $groupNewRight); |
| 208 | $aUserIDs = explode(",", $userNewRight); | 223 | $aUserIDs = explode(",", $userNewRight); |
| 209 | - $default->log->info("Sending email to groups=$groupNewRight; users=$userNewRight"); | 224 | + $aEmailAddresses = explode(" ", $fEmailAddresses); |
| 225 | + $default->log->info("Sending email to groups=$groupNewRight; users=$userNewRight; manual=$fEmailAddresses"); | ||
| 210 | 226 | ||
| 211 | //if we're going to send a mail, first make there is someone to send it to | 227 | //if we're going to send a mail, first make there is someone to send it to |
| 212 | - if ((count($aGroupIDs) > 1) || (count($aUserIDs) > 1)) { | 228 | + if ((count($aGroupIDs) > 1) || (count($aUserIDs) > 1) || (count($aEmailAddresses) != 0)) { |
| 213 | // send group emails | 229 | // send group emails |
| 214 | sendGroupEmails($aGroupIDs, $oDocument, $fComment, (boolean)$fAttachDocument); | 230 | sendGroupEmails($aGroupIDs, $oDocument, $fComment, (boolean)$fAttachDocument); |
| 215 | // send user emails | 231 | // send user emails |
| 216 | sendUserEmails($aUserIDs, $oDocument, $fComment, (boolean)$fAttachDocument); | 232 | sendUserEmails($aUserIDs, $oDocument, $fComment, (boolean)$fAttachDocument); |
| 233 | + // send manual email addresses | ||
| 234 | + sendManualEmails($aEmailAddresses, $oDocument, $fComment, (boolean)$fAttachDocument); | ||
| 217 | 235 | ||
| 218 | if (count($emailerrors)) { | 236 | if (count($emailerrors)) { |
| 219 | $_SESSION['errorMessage'] = join("<br />\n", $emailerrors); | 237 | $_SESSION['errorMessage'] = join("<br />\n", $emailerrors); |
presentation/lookAndFeel/knowledgeTree/documentmanagement/emailUI.inc
| @@ -92,6 +92,7 @@ function getDocumentEmailPage($oDocument) { | @@ -92,6 +92,7 @@ function getDocumentEmailPage($oDocument) { | ||
| 92 | $sToRender .= "</table></td></tr>"; | 92 | $sToRender .= "</table></td></tr>"; |
| 93 | $sToRender .= "<tr><td><table>\n"; | 93 | $sToRender .= "<tr><td><table>\n"; |
| 94 | $sToRender .= "<tr><td valign=\"top\">" . _("Attach Document") . "</td><td><input type=\"checkbox\" name=\"fAttachDocument\" /></td></tr>";//</tr>\n"; | 94 | $sToRender .= "<tr><td valign=\"top\">" . _("Attach Document") . "</td><td><input type=\"checkbox\" name=\"fAttachDocument\" /></td></tr>";//</tr>\n"; |
| 95 | + $sToRender .= "<tr><td valign=\"top\">" . _("Email Addresses") . "</td><td><textarea rows=\"5\" cols=\"30\" name=\"fEmailAddresses\"></textarea></td>";//</tr>\n"; | ||
| 95 | $sToRender .= "<tr><td valign=\"top\">" . _("Comment") . "</td><td><textarea rows=\"5\" cols=\"30\" name=\"fComment\"></textarea></td>";//</tr>\n"; | 96 | $sToRender .= "<tr><td valign=\"top\">" . _("Comment") . "</td><td><textarea rows=\"5\" cols=\"30\" name=\"fComment\"></textarea></td>";//</tr>\n"; |
| 96 | $sToRender .= "<td valign=\"bottom\"><table><tr><td><input type=\"image\" src=\"" . KTHtml::getEmailButton() . "\" border=\"0\" /></td><td><a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\"><img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\"/></a></td></tr></table></td></tr>\n"; | 97 | $sToRender .= "<td valign=\"bottom\"><table><tr><td><input type=\"image\" src=\"" . KTHtml::getEmailButton() . "\" border=\"0\" /></td><td><a href=\"$default->rootUrl/control.php?action=viewDocument&fDocumentID=" . $oDocument->getID() . "\"><img src=\"" . KTHtml::getCancelButton() . "\" border=\"0\"/></a></td></tr></table></td></tr>\n"; |
| 97 | $sToRender .= "</table></td></tr>\n"; | 98 | $sToRender .= "</table></td></tr>\n"; |
| @@ -111,8 +112,8 @@ function getDocumentEmailPage($oDocument) { | @@ -111,8 +112,8 @@ function getDocumentEmailPage($oDocument) { | ||
| 111 | 112 | ||
| 112 | $sToRender .= "<script language='javascript'>\n"; | 113 | $sToRender .= "<script language='javascript'>\n"; |
| 113 | $sToRender .= "function validateForm(theForm) {\n"; | 114 | $sToRender .= "function validateForm(theForm) {\n"; |
| 114 | - $sToRender .= "\tif (isBlank(theForm.groupNewRight) && isBlank(theForm.userNewRight)) {\n"; | ||
| 115 | - $sToRender .= "\t\talert(\"" . _("Please choose either at least one Group or User to email a link to this document.") . "\");return false;\n\t}\n"; | 115 | + $sToRender .= "\tif (isBlank(theForm.groupNewRight) && isBlank(theForm.userNewRight) && isBlank(theForm.fEmailAddresses)) {\n"; |
| 116 | + $sToRender .= "\t\talert(\"" . _("Please choose either at least one Group, User, or Email address to email this document.") . "\");return false;\n\t}\n"; | ||
| 116 | $sToRender .= "return true;\n}\n"; | 117 | $sToRender .= "return true;\n}\n"; |
| 117 | $sToRender .= "</script >\n"; | 118 | $sToRender .= "</script >\n"; |
| 118 | return $sToRender; | 119 | return $sToRender; |