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:
Ingo Schommer 2007-09-16 01:02:32 +00:00
parent 03423e67be
commit 24ed3ff68b
3 changed files with 17 additions and 5 deletions

View File

@ -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() );
}
}

View File

@ -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();
}

View File

@ -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>