diff options
| -rw-r--r-- | BitMailer.php | 17 | ||||
| -rw-r--r-- | BitNewsletterEdition.php | 17 | ||||
| -rw-r--r-- | admin/send.php | 10 | ||||
| -rw-r--r-- | admin/tend_mail_queue.php | 12 | ||||
| -rw-r--r-- | templates/mail_edition_header.tpl | 2 | ||||
| -rw-r--r-- | templates/send_newsletters.tpl | 15 | ||||
| -rw-r--r-- | templates/view_edition.tpl | 2 |
7 files changed, 39 insertions, 36 deletions
diff --git a/BitMailer.php b/BitMailer.php index 5d8d821..fef9088 100644 --- a/BitMailer.php +++ b/BitMailer.php @@ -1,12 +1,12 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.32 2007/05/04 14:54:37 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.33 2007/05/04 16:40:18 spiderr Exp $ * * Copyright (c) 2004 bitweaver.org * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: BitMailer.php,v 1.32 2007/05/04 14:54:37 spiderr Exp $ + * $Id: BitMailer.php,v 1.33 2007/05/04 16:40:18 spiderr Exp $ * * Class that handles editions of newsletters * @package newsletters @@ -15,7 +15,7 @@ * * @author spiderr <spider@steelsun.com> * - * @version $Revision: 1.32 $ $Date: 2007/05/04 14:54:37 $ $Author: spiderr $ + * @version $Revision: 1.33 $ $Date: 2007/05/04 16:40:18 $ $Author: spiderr $ */ /** @@ -92,7 +92,7 @@ class BitMailer extends phpmailer { $lookupCol = 'email'; $bindVars[] = $email; } - $rs = $this->mDb->query( "UPDATE `".BIT_DB_PREFIX."mail_queue` SET `queue_time`=?, `begin_date`=NULL, `sent_date`=NULL, `last_read_date`=NULL, `reads`=0 WHERE `content_id`=? AND `$lookupCol`=?", array( $bindVars ) ); + $rs = $this->mDb->query( "UPDATE `".BIT_DB_PREFIX."mail_queue` SET `queue_date`=?, `begin_date`=NULL, `sent_date`=NULL, `last_read_date`=NULL, `reads`=0 WHERE `content_id`=? AND `$lookupCol`=?", array( $bindVars ) ); $ret++; } } @@ -105,7 +105,8 @@ class BitMailer extends phpmailer { $this->mDb->StartTrans(); $query = "SELECT * FROM `".BIT_DB_PREFIX."mail_queue` mq - WHERE `sent_date` IS NULL ".$this->mDb->SQLForUpdate(); + WHERE `sent_date` IS NULL + ORDER BY `queue_date` ".$this->mDb->SQLForUpdate(); if( $rs = $this->mDb->query( $query, NULL ) ) { while( $pick = $rs->fetchRow() ) { $this->sendQueue( $pick ); @@ -118,6 +119,7 @@ class BitMailer extends phpmailer { function sendQueue( $pQueueMixed ) { global $gBitSmarty, $gBitSystem; + static $body = array(); if( is_array( $pQueueMixed ) ) { $pick = $pQueueMixed; } elseif( is_numeric( $pQueueMixed ) ) { @@ -125,7 +127,6 @@ class BitMailer extends phpmailer { } if( !empty( $pick ) ) { - $body = array(); $this->mDb->query( "UPDATE `".BIT_DB_PREFIX."mail_queue` SET `begin_date`=? WHERE `mail_queue_id` = ? ", array( time(), $pick['mail_queue_id'] ) ); if( !empty( $pick['user_id'] ) ) { $userHash = $this->mDb->getRow( "SELECT * FROM `".BIT_DB_PREFIX."users_users` WHERE `user_id`=?", array( $pick['user_id'] ) ); @@ -150,9 +151,9 @@ class BitMailer extends phpmailer { $unsub = ''; if( $body[$pick['content_id']]['object']->mNewsletter->getField('unsub_msg') ) { $gBitSmarty->assign( 'url_code', $pick['url_code'] ); - $gBitSmarty->assign( 'sending', TRUE ); } $gBitSystem->preDisplay(''); + $gBitSmarty->assign( 'sending', TRUE ); $gBitSmarty->assign( 'unsubMessage', $unsub ); $gBitSmarty->assign( 'trackCode', $pick['url_code'] ); $gBitSmarty->assign( 'mid', 'bitpackage:newsletters/view_edition.tpl' ); @@ -162,7 +163,7 @@ class BitMailer extends phpmailer { $this->AddReplyTo( $body[$pick['content_id']]['reply_to'], $gBitSystem->getConfig( 'bitmailer_from' ) ); print "TO: $pick[email]\t"; if( $this->sendMail( $pick, $body[$pick['content_id']]['subject'], $htmlBody ) ) { - print "SENT\n"; + print "SENT <br/>\n"; flush(); $updateQuery = "UPDATE `".BIT_DB_PREFIX."mail_queue` SET `sent_date`=?,`url_code`=? WHERE `content_id`=? AND `email`=?"; $this->mDb->query( $updateQuery, array( time(), $pick['url_code'], $pick['content_id'], $pick['email'] ) ); } else { diff --git a/BitNewsletterEdition.php b/BitNewsletterEdition.php index 4fcf795..e0a7ca9 100644 --- a/BitNewsletterEdition.php +++ b/BitNewsletterEdition.php @@ -1,12 +1,12 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletterEdition.php,v 1.24 2007/01/06 09:46:19 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_newsletters/BitNewsletterEdition.php,v 1.25 2007/05/04 16:40:18 spiderr Exp $ * * Copyright (c) 2004 bitweaver.org * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: BitNewsletterEdition.php,v 1.24 2007/01/06 09:46:19 squareing Exp $ + * $Id: BitNewsletterEdition.php,v 1.25 2007/05/04 16:40:18 spiderr Exp $ * * Class that handles editions of newsletters * @package newsletters @@ -15,7 +15,7 @@ * * @author spiderr <spider@steelsun.com> * - * @version $Revision: 1.24 $ $Date: 2007/01/06 09:46:19 $ $Author: squareing $ + * @version $Revision: 1.25 $ $Date: 2007/05/04 16:40:18 $ $Author: spiderr $ */ /** @@ -198,7 +198,7 @@ class BitNewsletterEdition extends LibertyAttachable { return( $this->getField( 'is_draft' ) ); } - function getRecipients( $pGroupArray, $validated = TRUE ) { + function getRecipients( $pGroupArray, $validated = TRUE, $pRequeue = FALSE ) { global $gBitUser; $ret = array(); if( is_array( $pGroupArray ) ) { @@ -221,10 +221,11 @@ class BitNewsletterEdition extends LibertyAttachable { $ret[$sub['email']] = $sub; } } - - $query = "SELECT `email`, `user_id` FROM `".BIT_DB_PREFIX."mail_queue` WHERE `content_id`=?"; - if( $dupes = $this->mDb->getAssoc( $query, array( $this->mContentId ) ) ) { - $ret = array_diff_keys( $ret, $dupes ); + if( !$pRequeue ) { + $query = "SELECT `email`, `user_id` FROM `".BIT_DB_PREFIX."mail_queue` WHERE `content_id`=?"; + if( $dupes = $this->mDb->getAssoc( $query, array( $this->mContentId ) ) ) { + $ret = array_diff_keys( $ret, $dupes ); + } } } return $ret; diff --git a/admin/send.php b/admin/send.php index f1a1232..8156b0f 100644 --- a/admin/send.php +++ b/admin/send.php @@ -1,6 +1,6 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.15 2007/04/25 20:59:12 spiderr Exp $ +// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.16 2007/05/04 16:40:20 spiderr Exp $ // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // All Rights Reserved. See copyright.txt for details and a complete list of authors. @@ -29,18 +29,18 @@ if( @BitBase::verifyId( $_REQUEST["edition_id"] ) ) { $gBitSmarty->assign('preview', 'n'); $gBitSmarty->assign('presend', 'n'); $gBitSmarty->assign('emited', 'n'); -$validated = (isset($_REQUEST["validated"]) && !empty($_REQUEST["validated"])) ? TRUE : FALSE; +$validated = !empty( $_REQUEST["validated"] ) ? TRUE : FALSE; if( $gContent->isValid() && isset( $_REQUEST['preview'] ) && isset( $_REQUEST['send_group'] ) ) { - $recipients = $gContent->getRecipients( $_REQUEST['send_group'], $validated ); + $recipients = $gContent->getRecipients( $_REQUEST['send_group'], $validated, !empty( $_REQUEST['test_mode'] ) ); $gBitSmarty->assign_by_ref( 'recipientList', $recipients ); $gBitSmarty->assign( 'validated', $validated ); $gBitSmarty->assign( 'sending', TRUE ); } elseif( $gContent->isValid() && isset( $_REQUEST["send"] ) ) { - if( $emails = $gContent->getRecipients( $_REQUEST['send_group'], $validated ) ) { + if( $emails = $gContent->getRecipients( $_REQUEST['send_group'], $validated, !empty( $_REQUEST['test_mode'] ) ) ) { global $gBitMailer; $gBitMailer = new BitMailer(); - $gBitMailer->queueRecipients( $gContent->mContentId, $gContent->mNewsletter->mContentId, $emails ); + $gBitMailer->queueRecipients( $gContent->mContentId, $gContent->mNewsletter->mContentId, $emails, !empty( $_REQUEST['test_mode'] ) ); $feedback['success'] = count( $emails ).' '.tra( 'emails were queued to be sent:' ).' '.$gContent->getTitle(); $gContent->mEditionId = NULL; } else { diff --git a/admin/tend_mail_queue.php b/admin/tend_mail_queue.php index 14f815b..61c7a0a 100644 --- a/admin/tend_mail_queue.php +++ b/admin/tend_mail_queue.php @@ -1,13 +1,6 @@ <?php - - global $gBitSystem, $_SERVER; - - $_SERVER['SCRIPT_URL'] = ''; - $_SERVER['HTTP_HOST'] = ''; - $_SERVER['HTTP_USER_AGENT'] = ''; - $_SERVER['SERVER_NAME'] = ''; - $_SERVER['SERVER_ADMIN'] = ''; - $_SERVER['SERVER_SOFTWARE'] = 'command line'; + global $gShellScript; + $gShellScript = TRUE; $_REQUEST['uri_mode'] = TRUE; /** @@ -24,7 +17,6 @@ require_once( NEWSLETTERS_PKG_PATH.'BitMailer.php' ); global $gBitMailer; $gBitMailer = new BitMailer(); - $gBitMailer->tendQueue(); } diff --git a/templates/mail_edition_header.tpl b/templates/mail_edition_header.tpl index 1765d77..da9cf8d 100644 --- a/templates/mail_edition_header.tpl +++ b/templates/mail_edition_header.tpl @@ -8,3 +8,5 @@ {/if} </div> + <div><small>{tr}If you have trouble reading this email,{/tr} <a href="{$gContent->getDisplayUrl()}">{tr}read it on the web{/tr}</a></small></div> + diff --git a/templates/send_newsletters.tpl b/templates/send_newsletters.tpl index 456c263..06c3217 100644 --- a/templates/send_newsletters.tpl +++ b/templates/send_newsletters.tpl @@ -20,7 +20,8 @@ {if $smarty.request.emited eq 'y'} {tr}The newsletter was sent to {$sent} email addresses{/tr} {elseif $smarty.request.preview} - <input type="hidden" name="validated" value="{$validated}" /> + <input type="hidden" name="validated" value="{$smarty.request.validated}" /> + <input type="hidden" name="test_mode" value="{$smarty.request.test_mode}" /> {jstabs} {jstab title="Preview Newsletter"} {legend legend="Preview Newsletter"} @@ -65,12 +66,20 @@ </div> <div class="row"> + {formlabel label="Send Test"} + {forminput} + <input type="checkbox" name="test_mode" /> + {formhelp note="This will enable you to send the newsletter to the same recipients again."} + {/forminput} + </div> +{* + <div class="row"> {formlabel label="Only send to validated emails"} {forminput} - <input type="checkbox" name="validated" "checked" /> + <input type="checkbox" name="validated" checked="checked" /> {/forminput} </div> - +*} <div class="row submit"> <input type="submit" name="preview" value="{tr}Preview{/tr}" /> </div> diff --git a/templates/view_edition.tpl b/templates/view_edition.tpl index 50a023a..24ce74c 100644 --- a/templates/view_edition.tpl +++ b/templates/view_edition.tpl @@ -11,8 +11,6 @@ <a href="{$smarty.const.NEWSLETTERS_PKG_URL}edition.php?edition_id={$gContent->mEditionId}&remove=1">{biticon ipackage="icons" iname="edit-delete" iexplain="delete"}</a> {/if} </div> - {else} - <div><small>{tr}This newsletter can be viewed on the web at{/tr} <a href="{$gContent->getDisplayUrl()}">{$gContent->getDisplayUrl()}</a></small></div> {/if} <div class="header"> |
