From 23026641de4ecfaa978485b1a6d808bd12f0e791 Mon Sep 17 00:00:00 2001 From: Christian Fowler Date: Tue, 20 Dec 2005 22:05:07 +0000 Subject: clean up sending so it acutally works now --- BitMailer.php | 14 ++++++-------- admin/send.php | 22 +++++++++++++++------- templates/send_newsletters.tpl | 6 ++++++ 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/BitMailer.php b/BitMailer.php index 3578fb3..41cdfab 100644 --- a/BitMailer.php +++ b/BitMailer.php @@ -1,12 +1,12 @@ * - * @version $Revision: 1.1 $ $Date: 2005/12/16 06:34:54 $ $Author: spiderr $ + * @version $Revision: 1.2 $ $Date: 2005/12/20 22:05:07 $ $Author: spiderr $ */ /** @@ -51,22 +51,20 @@ class BitMailer extends phpmailer { exit; } - function queueRecipients( $pRecipients ) { + function queueRecipients( $pContentId, $pRecipients ) { $ret = 0; - if( $this->isValid() ) { -vd( $this->mContentId ); + if( !empty( $pRecipients ) && BitBase::verifyId( $pContentId ) ) { $queueTime = time(); foreach( array_keys( $pRecipients ) AS $email ) { $insertHash['email'] = $email; if( !empty( $pRecipients[$email]['user_id'] ) ) { $insertHash['user_id'] = $pRecipients[$email]['user_id']; } - $insertHash['content_id'] = $this->mContentId; + $insertHash['content_id'] = $pContentId; $insertHash['queue_date'] = $queueTime; $this->mDb->associateInsert( BIT_DB_PREFIX.'tiki_mail_queue', $insertHash ); $ret++; } -die; } return $ret; } diff --git a/admin/send.php b/admin/send.php index d455a55..58dedcd 100644 --- a/admin/send.php +++ b/admin/send.php @@ -1,6 +1,6 @@ verifyPackage( 'newsletters' ); require_once( NEWSLETTERS_PKG_PATH.'lookup_newsletter_edition_inc.php' ); -if (isset($_REQUEST["template_id"]) && $_REQUEST["template_id"] > 0) { +$feedback = array(); + +if( @BitBase::verifyId( $_REQUEST["template_id"] ) ) { $template_data = $tikilib->get_template($_REQUEST["template_id"]); $_REQUEST['edit'] = $template_data["content"]; @@ -30,9 +31,15 @@ if( $gContent->isValid() && isset( $_REQUEST['preview'] ) ) { $recipients = $gContent->getRecipients( $_REQUEST['send_group'] ); $gBitSmarty->assign_by_ref( 'recipientList', $recipients ); } elseif( $gContent->isValid() && isset( $_REQUEST["send"] ) ) { - $emails = $gContent->getRecipients( $_REQUEST['send_group'] ); - $gContent->queueRecipients( $emails ); -die; + if( $emails = $gContent->getRecipients( $_REQUEST['send_group'] ) ) { + global $gBitMailer; + $gBitMailer = new BitMailer(); + $gBitMailer->queueRecipients( $gContent->mContentId, $emails ); + $feedback['success'] = count( $emails ).' '.tra( 'emails were queued to be sent:' ).' '.$gContent->getTitle(); + $gContent->mEditionId = NULL; + } else { + $feedback['error'] = tra( 'No emails were queued.' ); + } } if( $gContent->isValid() ) { @@ -51,6 +58,7 @@ if( $gContent->isValid() ) { } } +$gBitSmarty->assign_by_ref( 'feedback', $feedback ); // Display the template $gBitSystem->display( 'bitpackage:newsletters/send_newsletters.tpl'); diff --git a/templates/send_newsletters.tpl b/templates/send_newsletters.tpl index 44e803c..4fb40b5 100644 --- a/templates/send_newsletters.tpl +++ b/templates/send_newsletters.tpl @@ -7,6 +7,12 @@
+ {if $feedback} +
+ {formfeedback hash=$feedback} +
+ {/if} + {if $gContent->isValid()} {form} -- cgit v1.3