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:
Ingo Schommer 2007-09-16 01:03:04 +00:00
parent 24ed3ff68b
commit b784ccc5e7
2 changed files with 19 additions and 15 deletions

View File

@ -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;
@ -17,13 +22,7 @@ class NewsletterEmailProcess extends BatchProcess {
$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 );
}

View File

@ -440,11 +440,16 @@ class NewsletterAdmin extends LeftAndMain {
}
break;
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;
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);
echo self::sendToList( $subject, $body, $from, $newsletter, $nlType, $messageID, $newsletter->UnsentSubscribers());
break;
}
@ -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();
}