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 $nlType;
|
||||||
protected $messageID;
|
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->subject = $subject;
|
||||||
$this->body = $body;
|
$this->body = $body;
|
||||||
@ -17,13 +22,7 @@ class NewsletterEmailProcess extends BatchProcess {
|
|||||||
$this->nlType = $nlType;
|
$this->nlType = $nlType;
|
||||||
$this->messageID = $messageID;
|
$this->messageID = $messageID;
|
||||||
|
|
||||||
$groupID = $nlType->GroupID;
|
parent::__construct( $recipients );
|
||||||
// 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() );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,11 +440,16 @@ class NewsletterAdmin extends LeftAndMain {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "List":
|
case "List":
|
||||||
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID );
|
// 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;
|
break;
|
||||||
case "Unsent":
|
case "Unsent":
|
||||||
|
// Send to only those who have not already been sent this newsletter.
|
||||||
$only_to_unsent = 1;
|
$only_to_unsent = 1;
|
||||||
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID, $only_to_unsent);
|
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID, $newsletter->UnsentSubscribers());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -457,8 +462,8 @@ class NewsletterAdmin extends LeftAndMain {
|
|||||||
$email->send();
|
$email->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID = null, $only_to_unsent = 0) {
|
static function sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID = null, $recipients) {
|
||||||
$emailProcess = new NewsletterEmailProcess( $subject, $body, $from, $newsletter, $nlType, $messageID, $only_to_unsent);
|
$emailProcess = new NewsletterEmailProcess( $subject, $body, $from, $newsletter, $nlType, $messageID, $recipients);
|
||||||
return $emailProcess->start();
|
return $emailProcess->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user