diff options
| author | Christian Fowler <spider@viovio.com> | 2005-12-28 23:43:24 +0000 |
|---|---|---|
| committer | Christian Fowler <spider@viovio.com> | 2005-12-28 23:43:24 +0000 |
| commit | 522af529d05393e3e369fc6e4d498ca5f172a8a9 (patch) | |
| tree | 26c32b6436eb588d84267aee6eefa83c5981c3ff | |
| parent | c07dc79add21f2677680fcc9736b82276d2f8a72 (diff) | |
| download | newsletters-522af529d05393e3e369fc6e4d498ca5f172a8a9.tar.gz newsletters-522af529d05393e3e369fc6e4d498ca5f172a8a9.tar.bz2 newsletters-522af529d05393e3e369fc6e4d498ca5f172a8a9.zip | |
subscription changing appears to be working
| -rw-r--r-- | BitMailer.php | 10 | ||||
| -rw-r--r-- | index.php | 49 | ||||
| -rw-r--r-- | templates/user_subscriptions.tpl | 2 |
3 files changed, 31 insertions, 30 deletions
diff --git a/BitMailer.php b/BitMailer.php index 10ac4c5..d672058 100644 --- a/BitMailer.php +++ b/BitMailer.php @@ -1,12 +1,12 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.8 2005/12/28 23:21:24 spiderr Exp $ + * $Header: /cvsroot/bitweaver/_bit_newsletters/Attic/BitMailer.php,v 1.9 2005/12/28 23:43:24 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.8 2005/12/28 23:21:24 spiderr Exp $ + * $Id: BitMailer.php,v 1.9 2005/12/28 23:43:24 spiderr Exp $ * * Class that handles editions of newsletters * @package newsletters @@ -15,7 +15,7 @@ * * @author spiderr <spider@steelsun.com> * - * @version $Revision: 1.8 $ $Date: 2005/12/28 23:21:24 $ $Author: spiderr $ + * @version $Revision: 1.9 $ $Date: 2005/12/28 23:43:24 $ $Author: spiderr $ */ /** @@ -182,10 +182,11 @@ class BitMailer extends phpmailer { } function storeSubscriptions( $pSubHash ) { + $ret = FALSE; global $gBitSystem, $gBitDb; $query = "delete from `".BIT_DB_PREFIX."tiki_mail_subscriptions` where `".key( $pSubHash['sub_lookup'] )."`=?"; $result = $gBitDb->query($query, array( current( $pSubHash['sub_lookup'] ) ) ); - + $ret = TRUE; if( !empty( $pSubHash['unsub_content'] ) ) { foreach( $pSubHash['unsub_content'] as $conId ) { $storeHash = array(); @@ -199,6 +200,7 @@ class BitMailer extends phpmailer { $gBitDb->associateInsert( BIT_DB_PREFIX."tiki_mail_subscriptions", $storeHash ); } } + return $ret; } @@ -1,6 +1,6 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_newsletters/index.php,v 1.12 2005/12/28 23:21:24 spiderr Exp $ +// $Header: /cvsroot/bitweaver/_bit_newsletters/index.php,v 1.13 2005/12/28 23:43:24 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. @@ -33,35 +33,33 @@ $listHash = array(); $newsletters = $gContent->getList( $listHash ); $gBitSmarty->assign_by_ref('newsletters', $newsletters ); -if( isset( $_REQUEST["sub"] ) ) { - if( strlen( $_REQUEST["sub"] ) == 32 && ($subInfo = BitMailer::lookupSubscription( array( 'url_code' => $_REQUEST["sub"] ) )) ) { - $gBitSmarty->assign( 'subInfo', $subInfo ); +if( isset( $_REQUEST["sub"] ) || $gBitUser->isRegistered() ) { + if( isset( $_REQUEST["sub"] ) && strlen( $_REQUEST["sub"] ) == 32 && ($subInfo = BitMailer::lookupSubscription( array( 'url_code' => $_REQUEST["sub"] ) )) ) { $lookup['email'] = $subInfo['email']; $unsubs = BitMailer::getUnsubscriptions( $lookup ); - $gBitSmarty->assign( 'unsubs', $unsubs ); - if( isset( $_REQUEST["update"] ) ) { - $subHash['response_content_id'] = $_REQUEST['response_content_id']; - $subHash['sub_lookup'] = !empty( $subInfo['user_id'] ) ? array( 'user_id' => $subInfo['user_id'] ) : array( 'email' => $subInfo['email'] ); - foreach( array_keys( $newsletters ) as $nlContentId ) { - if( empty( $_REQUEST['nl_content_id'][$nlContentId] ) ) { - $subHash['unsub_content'][] = $nlContentId; - } - } - if( BitMailer::storeSubscriptions( $subHash ) ) { - $feedback['success'] = tra( "Your subscriptions were updated." ); - } else { - $feedback['error'] = tra( "Subscriptions were not updated." ); - } + } else { + if( !$subInfo = BitMailer::lookupSubscription( array( 'user_id' => $gBitUser->mUserId ) ) ) { + $subInfo = $gBitUser->mInfo; } + $lookup['user_id'] = $gBitUser->mUserId; + $unsubs = BitMailer::getUnsubscriptions( $lookup ); } - $mid = 'bitpackage:newsletters/user_subscriptions.tpl'; -} elseif( $gBitUser->isRegistered() ) { - if( !$subInfo = BitMailer::lookupSubscription( array( 'user_id' => $gBitUser->mUserId ) ) ) { - $subInfo = $gBitUser->mInfo; + if( isset( $_REQUEST["update"] ) ) { + $subHash['response_content_id'] = $_REQUEST['response_content_id']; + $subHash['sub_lookup'] = !empty( $subInfo['user_id'] ) ? array( 'user_id' => $subInfo['user_id'] ) : array( 'email' => $subInfo['email'] ); + foreach( array_keys( $newsletters ) as $nlContentId ) { + if( !in_array( $nlContentId, $_REQUEST['nl_content_id'] ) ) { + $subHash['unsub_content'][] = $nlContentId; + } + } + if( BitMailer::storeSubscriptions( $subHash ) ) { + $feedback['success'] = tra( "Your subscriptions were updated." ); + } else { + $feedback['error'] = tra( "Subscriptions were not updated." ); + } + $unsubs = BitMailer::getUnsubscriptions( $lookup ); } $gBitSmarty->assign( 'subInfo', $subInfo ); - $lookup['user_id'] = $gBitUser->mUserId; - $unsubs = BitMailer::getUnsubscriptions( $lookup ); $gBitSmarty->assign( 'unsubs', $unsubs ); $mid = 'bitpackage:newsletters/user_subscriptions.tpl'; } @@ -111,10 +109,11 @@ if( $gContent->isValid() ) { } } */ - $gBitSmarty->assign( 'feedback', $feedback ); $mid = 'bitpackage:newsletters/newsletters.tpl'; } +$gBitSmarty->assign( 'feedback', $feedback ); + // Display the template $gBitSystem->display( $mid ); diff --git a/templates/user_subscriptions.tpl b/templates/user_subscriptions.tpl index 457c5f7..93afaed 100644 --- a/templates/user_subscriptions.tpl +++ b/templates/user_subscriptions.tpl @@ -6,7 +6,7 @@ </div> <div class="body"> - {formfeedback success=$success error=$gContent->mErrors} + {formfeedback hash=$feedback} {form enctype="multipart/form-data" id="editpageform"} <input type="hidden" name="response_content_id" value="{$subInfo.content_id}" /> {if $smarty.request.sub} |
