Skip to content

Commit

Permalink
Dev Added support for mail handling override (a plugin can now tell
Browse files Browse the repository at this point in the history
limesurvey it will take care of mail delivery).
  • Loading branch information
SamMousa committed Mar 29, 2014
1 parent efa7334 commit e0e7642
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions application/controllers/admin/tokens.php
Expand Up @@ -1463,20 +1463,42 @@ function email($iSurveyId, $tokenids = null)
}
}

/**
* Event for email handling.
* Parameter type description:
* subject rw Body of the email
* to rw Recipient(s)
* from rw Sender(s)
* type r "invitation" or "reminder"
* send w If true limesurvey will send the email. Setting this to false will cause limesurvey to assume the mail has been sent by the plugin.
* error w If set and "send" is true, log the error as failed email attempt.
* token r Raw token data.
*/
$event = new PluginEvent('beforeTokenEmail');
$event->set('type', $sTemplate);
$event->set('subject', $modsubject);
$event->set('to', $to);
$event->set('body', $modmessage);
$event->set('from', $from);
$event->set('bounce', getBounceEmail($iSurveyId));
$event->set('token', $emrow);
App()->getPluginManager()->dispatchEvent($event);
$modsubject = $event->get('subject');
$modmessage = $event->get('body');
$to = $event->get('to');
$from = $event->get('from');
// This is some ancient global used for error reporting instead of a return value from the actual mail function..
$maildebug = $event->get('error', $maildebug);
if (!$event->isStopped() && SendEmailMessage($modmessage, $modsubject, $to, $from, Yii::app()->getConfig("sitename"), $bHtml, getBounceEmail($iSurveyId), $aRelevantAttachments, $customheaders))
if ($event->get('send', true) == false)
{
// This is some ancient global used for error reporting instead of a return value from the actual mail function..
$maildebug = $event->get('error', $maildebug);
$success = $event->get('error') == null;
}
else
{
$success = SendEmailMessage($modmessage, $modsubject, $to, $from, Yii::app()->getConfig("sitename"), $bHtml, getBounceEmail($iSurveyId), $aRelevantAttachments, $customheaders);
}

if ($success)
{
// Put date into sent
$token = Token::model($iSurveyId)->findByPk($emrow['tid']);
Expand Down

2 comments on commit e0e7642

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we have to add this event in regsiter too .

And then have a $event->set('source', 'register'); ? (have source in array : admin toke, register, remote control etc ... : not sure)

I can add it in the 2.06 regsitering system

@Shnoulle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.