summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BitMailer.php103
-rw-r--r--admin/mail_queue.php5
-rw-r--r--admin/send.php4
-rw-r--r--templates/view_edition.tpl10
4 files changed, 70 insertions, 52 deletions
diff --git a/BitMailer.php b/BitMailer.php
index 8073470..ed202f1 100644
--- a/BitMailer.php
+++ b/BitMailer.php
@@ -1,12 +1,12 @@
<?php
/**
- * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.25 2006/10/13 09:22:47 lsces Exp $
+ * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.26 2007/04/25 20:59:11 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.25 2006/10/13 09:22:47 lsces Exp $
+ * $Id: BitMailer.php,v 1.26 2007/04/25 20:59:11 spiderr Exp $
*
* Class that handles editions of newsletters
* @package newsletters
@@ -15,7 +15,7 @@
*
* @author spiderr <spider@steelsun.com>
*
- * @version $Revision: 1.25 $ $Date: 2006/10/13 09:22:47 $ $Author: lsces $
+ * @version $Revision: 1.26 $ $Date: 2007/04/25 20:59:11 $ $Author: spiderr $
*/
/**
@@ -78,63 +78,74 @@ class BitMailer extends phpmailer {
}
function tendQueue() {
- global $gBitSmarty, $gBitSystem;
- $body = array();
$this->mDb->StartTrans();
$query = "SELECT *
FROM `".BIT_DB_PREFIX."mail_queue` mq
WHERE `sent_date` IS NULL ".$this->mDb->SQLForUpdate();
if( $rs = $this->mDb->query( $query, NULL ) ) {
while( $pick = $rs->fetchRow() ) {
- if( !empty( $pick['user_id'] ) ) {
- $userHash = $this->mDb->getRow( "SELECT * FROM `".BIT_DB_PREFIX."users_users` WHERE `user_id`=?", array( $pick['user_id'] ) );
- $pick['full_name'] = BitUser::getDisplayName( FALSE, $userHash );
- } else {
- $pick['full_name'] = NULL;
+ $this->sendQueue( $pick );
+ }
+ }
+ $this->mDb->CompleteTrans();
+ }
+
+ function sendQueue( $pQueueMixed ) {
+ global $gBitSmarty, $gBitSystem;
+ if( is_array( $pQueueMixed ) ) {
+ $pick = $pQueueMixed;
+ } elseif( is_numeric( $pQueueMixed ) ) {
+ $pick = $this->mDb->GetRow( "SELECT * FROM `".BIT_DB_PREFIX."mail_queue` mq WHERE `mail_queue_id` = ? ".$this->mDb->SQLForUpdate(), array( $pQueueMixed ) );
+ }
+
+ if( !empty( $pick ) ) {
+ $body = array();
+ if( !empty( $pick['user_id'] ) ) {
+ $userHash = $this->mDb->getRow( "SELECT * FROM `".BIT_DB_PREFIX."users_users` WHERE `user_id`=?", array( $pick['user_id'] ) );
+ $pick['full_name'] = BitUser::getDisplayName( FALSE, $userHash );
+ } else {
+ $pick['full_name'] = NULL;
+ }
+ if( !isset( $body[$pick['content_id']] ) ) {
+ $gBitSmarty->assign( 'sending', TRUE );
+ // We only support sending of newsletters currently
+ $content = new BitNewsletterEdition( NULL, $pick['content_id'] );
+ if( $content->load() ) {
+ $body[$pick['content_id']]['body'] = $content->render();
+ $body[$pick['content_id']]['subject'] = $content->getTitle();
+ $body[$pick['content_id']]['reply_to'] = $content->getField( 'reply_to', $gBitSystem->getConfig( 'site_sender_email', $_SERVER['SERVER_ADMIN'] ) );
+ $body[$pick['content_id']]['object'] = $content;
}
- if( !isset( $body[$pick['content_id']] ) ) {
+// $content[$pick['content_id']] = LibertyBase::getLibertyObject();
+ }
+ if( !empty( $body[$pick['content_id']] ) ) {
+ $pick['url_code'] = md5( $pick['content_id'].$pick['email'].$pick['queue_date'] );
+ $unsub = '';
+ if( $body[$pick['content_id']]['object']->mNewsletter->getField('unsub_msg') ) {
+ $gBitSmarty->assign( 'url_code', $pick['url_code'] );
$gBitSmarty->assign( 'sending', TRUE );
- // We only support sending of newsletters currently
- $content = new BitNewsletterEdition( NULL, $pick['content_id'] );
- if( $content->load() ) {
- $body[$pick['content_id']]['body'] = $content->render();
- $body[$pick['content_id']]['subject'] = $content->getTitle();
- $body[$pick['content_id']]['reply_to'] = $content->getField( 'reply_to', $gBitSystem->getConfig( 'site_sender_email', $_SERVER['SERVER_ADMIN'] ) );
- $body[$pick['content_id']]['object'] = $content;
- }
- // $content[$pick['content_id']] = LibertyBase::getLibertyObject();
}
- if( !empty( $body[$pick['content_id']] ) ) {
- $pick['url_code'] = md5( $pick['content_id'].$pick['email'].$pick['queue_date'] );
- $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( 'mid', 'bitpackage:newsletters/view_edition.tpl' );
- $htmlBody = $gBitSmarty->fetch( 'bitpackage:kernel/bitweaver.tpl' );
- $gBitSmarty->assign( 'unsubMessage', $unsub );
- $gBitSmarty->assign( 'trackCode', $pick['url_code'] );
- $this->ClearReplyTos();
- $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";
- $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 {
- $this->logError( $pick );
- }
- $this->mDb->CompleteTrans();
- $this->mDb->StartTrans();
+ $gBitSystem->preDisplay('');
+ $gBitSmarty->assign( 'mid', 'bitpackage:newsletters/view_edition.tpl' );
+ $htmlBody = $gBitSmarty->fetch( 'bitpackage:kernel/bitweaver.tpl' );
+ $gBitSmarty->assign( 'unsubMessage', $unsub );
+ $gBitSmarty->assign( 'trackCode', $pick['url_code'] );
+ $this->ClearReplyTos();
+ $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";
+ $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 {
+ $this->logError( $pick );
}
+ $this->mDb->CompleteTrans();
+ $this->mDb->StartTrans();
}
}
- $this->mDb->CompleteTrans();
}
-
function sendMail( $pRecipient, $pSubject, $pHtmlBody ) {
$ret = TRUE;
$this->Body = $pHtmlBody;
diff --git a/admin/mail_queue.php b/admin/mail_queue.php
index b16228e..50da2b6 100644
--- a/admin/mail_queue.php
+++ b/admin/mail_queue.php
@@ -14,7 +14,10 @@ if( !empty( $_REQUEST['batch_command'] ) && !empty( $_REQUEST['queue_id'] ) ) {
foreach( $_REQUEST['queue_id'] as $qId ) {
$gBitMailer->expungeQueueRow( $qId );
}
- } elseif( $_REQUEST['batch_command'] == 'send' ) {
+ } elseif( $_REQUEST['batch_command'] == 'send' && !empty( $_REQUEST['queue_id'] ) ) {
+ foreach( $_REQUEST['queue_id'] as $queueId ) {
+ $gBitMailer->sendQueue( $queueId );
+ }
}
}
diff --git a/admin/send.php b/admin/send.php
index 6e07d6f..f1a1232 100644
--- a/admin/send.php
+++ b/admin/send.php
@@ -1,6 +1,6 @@
<?php
-// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.14 2006/06/19 02:35:19 spiderr Exp $
+// $Header: /cvsroot/bitweaver/_bit_newsletters/admin/send.php,v 1.15 2007/04/25 20:59:12 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.
@@ -66,7 +66,7 @@ if( $gContent->isValid() ) {
$gBitSmarty->assign_by_ref( 'feedback', $feedback );
// Display the template
-$gBitSystem->display( 'bitpackage:newsletters/send_newsletters.tpl' , "Send Newsletters");
+$gBitSystem->display( 'bitpackage:newsletters/send_newsletters.tpl' , tra( "Send Newsletter" ).': '.$gContent->getTitle() );
?>
diff --git a/templates/view_edition.tpl b/templates/view_edition.tpl
index 1453ec0..9af45e6 100644
--- a/templates/view_edition.tpl
+++ b/templates/view_edition.tpl
@@ -12,7 +12,7 @@
{/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>
+ <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">
@@ -30,9 +30,13 @@
</div> <!-- end .content -->
</div> <!-- end .body -->
- {if $sending} tcode {$trackCode}
+ {if $sending}
+ <div class="subscriptioninfo">
{include file="bitpackage:newsletters/unsubscribe_inc.tpl"}
- <img src="{$smarty.const.NEWSLETTERS_PKG_URI}track.php?sub={$trackCode}" alt="" />
+ {if $trackCode}
+ <img src="{$smarty.const.NEWSLETTERS_PKG_URI}track.php?sub={$trackCode}" alt="" />
+ {/if}
+ </div>
{/if}
</div><!-- end .newsletters -->