Permalink
Browse files

Dev Added email attachment support for admin notifications, detailed …

…admin notifications and conformations.
  • Loading branch information...
SamMousa committed Dec 10, 2012
1 parent 97d1246 commit f4f501133447ba6190ba4a78a3118d8d03c90026
Showing with 41 additions and 3 deletions.
  1. +41 −3 application/helpers/frontend_helper.php
@@ -974,7 +974,25 @@ function submittokens($quotaexit = false) {
//Only send confirmation email if there is a valid email address
if (validateEmailAddress($cnfrow['email'])) {
- SendEmailMessage($message, $subject, $to, $from, $sitename, $ishtml);
+ $aAttachments = unserialize($thissurvey['attachments']);
+
+ $aRelevantAttachments = array();
+ /*
+ * Iterate through attachments and check them for relevance.
+ */
+ if (isset($aAttachments['admin_notification']))
+ {
+ foreach ($aAttachments['admin_notification'] as $aAttachment)
+ {
+ $relevance = $aAttachment['relevance'];
+ // If the attachment is relevant it will be added to the mail.
+ if (LimeExpressionManager::ProcessRelevance($relevance) && file_exists($aAttachment['url']))
+ {
+ $aRelevantAttachments[] = $aAttachment['url'];
+ }
+ }
+ }
+ SendEmailMessage($message, $subject, $to, $from, $sitename, $ishtml, null, $aRelevantAttachments);
}
} else {
//There is nothing in the message or "Send confirmation emails" is set to "No" , so don't send a confirmation email
@@ -1118,14 +1136,34 @@ function sendSubmitNotifications($surveyid)
}
$sFrom = $thissurvey['adminname'].' <'.$thissurvey['adminemail'].'>';
+
+ $aAttachments = unserialize($thissurvey['attachments']);
+
+ $aRelevantAttachments = array();
+ /*
+ * Iterate through attachments and check them for relevance.
+ */
+ if (isset($aAttachments['admin_notification']))
+ {
+ foreach ($aAttachments['admin_notification'] as $aAttachment)
+ {
+ $relevance = $aAttachment['relevance'];
+ // If the attachment is relevant it will be added to the mail.
+ if (LimeExpressionManager::ProcessRelevance($relevance) && file_exists($aAttachment['url']))
+ {
+ $aRelevantAttachments[] = $aAttachment['url'];
+ }
+ }
+ }
+
$redata=compact(array_keys(get_defined_vars()));
if (count($aEmailNotificationTo)>0)
{
$sMessage=templatereplace($thissurvey['email_admin_notification'],$aReplacementVars,$redata,'frontend_helper[1398]',($thissurvey['anonymized'] == "Y"));
$sSubject=templatereplace($thissurvey['email_admin_notification_subj'],$aReplacementVars,$redata,'frontend_helper[1399]',($thissurvey['anonymized'] == "Y"));
foreach ($aEmailNotificationTo as $sRecipient)
{
- if (!SendEmailMessage($sMessage, $sSubject, $sRecipient, $sFrom, $sitename, true, getBounceEmail($surveyid)))
+ if (!SendEmailMessage($sMessage, $sSubject, $sRecipient, $sFrom, $sitename, true, getBounceEmail($surveyid), $aRelevantAttachments))
{
if ($debug>0)
{
@@ -1141,7 +1179,7 @@ function sendSubmitNotifications($surveyid)
$sSubject=templatereplace($thissurvey['email_admin_responses_subj'],$aReplacementVars,$redata,'frontend_helper[1415]',($thissurvey['anonymized'] == "Y"));
foreach ($aEmailResponseTo as $sRecipient)
{
- if (!SendEmailMessage($sMessage, $sSubject, $sRecipient, $sFrom, $sitename, true, getBounceEmail($surveyid)))
+ if (!SendEmailMessage($sMessage, $sSubject, $sRecipient, $sFrom, $sitename, true, getBounceEmail($surveyid), $aRelevantAttachments))
{
if ($debug>0)
{

0 comments on commit f4f5011

Please sign in to comment.