mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
elofgren: NEW FEATURE: Add 'Send to only people not previously sent to' option for sending Newsletters. Please test. :)
(merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@42001 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
03423e67be
commit
24ed3ff68b
@ -8,7 +8,7 @@ class NewsletterEmailProcess extends BatchProcess {
|
||||
protected $nlType;
|
||||
protected $messageID;
|
||||
|
||||
function __construct( $subject, $body, $from, $newsletter, $nlType, $messageID = null ) {
|
||||
function __construct( $subject, $body, $from, $newsletter, $nlType, $messageID = null, $only_to_unsent = 0) {
|
||||
|
||||
$this->subject = $subject;
|
||||
$this->body = $body;
|
||||
@ -17,7 +17,13 @@ class NewsletterEmailProcess extends BatchProcess {
|
||||
$this->nlType = $nlType;
|
||||
$this->messageID = $messageID;
|
||||
|
||||
parent::__construct( $nlType->Recipients() );
|
||||
$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() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -441,6 +441,11 @@ class NewsletterAdmin extends LeftAndMain {
|
||||
break;
|
||||
case "List":
|
||||
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID );
|
||||
break;
|
||||
case "Unsent":
|
||||
$only_to_unsent = 1;
|
||||
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID, $only_to_unsent);
|
||||
break;
|
||||
}
|
||||
|
||||
return FormResponse::respond();
|
||||
@ -452,8 +457,8 @@ class NewsletterAdmin extends LeftAndMain {
|
||||
$email->send();
|
||||
}
|
||||
|
||||
static function sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID = null ) {
|
||||
$emailProcess = new NewsletterEmailProcess( $subject, $body, $from, $newsletter, $nlType, $messageID );
|
||||
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);
|
||||
return $emailProcess->start();
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,8 @@
|
||||
<input type="hidden" name="NewsletterID" />
|
||||
<ul class="optionset">
|
||||
<li><input name="SendType" id="SendTypeTest" value="Test" checked="checked" type="radio" /> <label for="SendTypeTest">Send test to</label> <input name="TestEmail" type="text" /></li>
|
||||
<li><input name="SendType" id="SendTypeList" value="List" type="radio" /> <label for="SendTypeList">Send to the mailing list</label></li>
|
||||
<li><input name="SendType" id="SendTypeList" value="List" type="radio" /> <label for="SendTypeList">Send to the entire mailing list</label></li>
|
||||
<li><input name="SendType" id="SendTypeUnsent" value="Unsent" type="radio" /> <label for="SendTypeUnsent">Send to only people not previously sent to</label></li>
|
||||
</ul>
|
||||
$SendProgressBar
|
||||
</fieldset>
|
||||
|
Loading…
Reference in New Issue
Block a user