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 /index.php | |
| parent | c07dc79add21f2677680fcc9736b82276d2f8a72 (diff) | |
| download | newsletters-522af529d05393e3e369fc6e4d498ca5f172a8a9.tar.gz newsletters-522af529d05393e3e369fc6e4d498ca5f172a8a9.tar.bz2 newsletters-522af529d05393e3e369fc6e4d498ca5f172a8a9.zip | |
subscription changing appears to be working
Diffstat (limited to 'index.php')
| -rw-r--r-- | index.php | 49 |
1 files changed, 24 insertions, 25 deletions
@@ -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 ); |
