mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
elofgren: Clean up the code which enabled the 'Send to only people not previously sent to' feature committed in r38895
(merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@42002 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
24ed3ff68b
commit
b784ccc5e7
@ -8,7 +8,12 @@ class NewsletterEmailProcess extends BatchProcess {
|
||||
protected $nlType;
|
||||
protected $messageID;
|
||||
|
||||
function __construct( $subject, $body, $from, $newsletter, $nlType, $messageID = null, $only_to_unsent = 0) {
|
||||
/**
|
||||
* Set up a Newsletter Email Process
|
||||
*
|
||||
* @recipients A DataObject containing the addresses of the recipients of this newsletter
|
||||
*/
|
||||
function __construct( $subject, $body, $from, $newsletter, $nlType, $messageID = null, $recipients) {
|
||||
|
||||
$this->subject = $subject;
|
||||
$this->body = $body;
|
||||
@ -16,14 +21,8 @@ class NewsletterEmailProcess extends BatchProcess {
|
||||
$this->newsletter = $newsletter;
|
||||
$this->nlType = $nlType;
|
||||
$this->messageID = $messageID;
|
||||
|
||||
$groupID = $nlType->GroupID;
|
||||
// Allow sending to only those who have not already received it.
|
||||
if (0 == $only_to_unsent) {
|
||||
parent::__construct( DataObject::get( 'Member', "`GroupID`='$groupID'", null, "INNER JOIN `Group_Members` ON `MemberID`=`Member`.`ID`" ) );
|
||||
} else {
|
||||
parent::__construct( $newsletter->UnsentSubscribers() );
|
||||
}
|
||||
|
||||
parent::__construct( $recipients );
|
||||
|
||||
}
|
||||
|
||||
|
@ -440,12 +440,17 @@ class NewsletterAdmin extends LeftAndMain {
|
||||
}
|
||||
break;
|
||||
case "List":
|
||||
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID );
|
||||
break;
|
||||
// Send to the entire mailing list.
|
||||
$groupID = $nlType->GroupID;
|
||||
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID,
|
||||
DataObject::get( 'Member', "`GroupID`='$groupID'", null, "INNER JOIN `Group_Members` ON `MemberID`=`Member`.`ID`" )
|
||||
);
|
||||
break;
|
||||
case "Unsent":
|
||||
// Send to only those who have not already been sent this newsletter.
|
||||
$only_to_unsent = 1;
|
||||
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID, $only_to_unsent);
|
||||
break;
|
||||
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID, $newsletter->UnsentSubscribers());
|
||||
break;
|
||||
}
|
||||
|
||||
return FormResponse::respond();
|
||||
@ -457,8 +462,8 @@ class NewsletterAdmin extends LeftAndMain {
|
||||
$email->send();
|
||||
}
|
||||
|
||||
static function sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID = null, $only_to_unsent = 0) {
|
||||
$emailProcess = new NewsletterEmailProcess( $subject, $body, $from, $newsletter, $nlType, $messageID, $only_to_unsent);
|
||||
static function sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID = null, $recipients) {
|
||||
$emailProcess = new NewsletterEmailProcess( $subject, $body, $from, $newsletter, $nlType, $messageID, $recipients);
|
||||
return $emailProcess->start();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user