account_newsletter.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Account_Newsletter extends Account
00010 {
00015     protected $_sThisTemplate = 'account_newsletter.tpl';
00016 
00022     protected $_blNewsletter = null;
00023 
00029     protected $_iSubsriptionStatus = 0;
00030 
00041     public function render()
00042     {
00043         parent::render();
00044 
00045         // is logged in ?
00046         $oUser = $this->getUser();
00047         if ( !$oUser ) {
00048             return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00049         }
00050 
00051         //to maintain compatibility we still set the old template variable using new getter in render
00052         $this->_aViewData['blnewsletter'] = $this->isNewsletter();
00053 
00054         //loading shop info
00055         $this->_aViewData['actshop'] = $this->getConfig()->getActiveShop();
00056 
00057         return $this->_sThisTemplate;
00058     }
00059 
00060 
00066     public function isNewsletter()
00067     {
00068         if ( $this->_blNewsletter === null ) {
00069 
00070             // initiating status
00071             $this->_blNewsletter = false;
00072 
00073             // now checking real subscription status
00074             $oUser = $this->getUser();
00075             if ( $oUser &&  $oUser->inGroup( 'oxidnewsletter' ) && ( $oUser->getNewsSubscription()->getOptInStatus() == 1 ) ) {
00076                 $this->_blNewsletter = true;
00077             }
00078         }
00079 
00080         return $this->_blNewsletter;
00081     }
00082 
00089     public function subscribe()
00090     {
00091         // is logged in ?
00092         $oUser = $this->getUser();
00093         if ( !$oUser ) {
00094             return false;
00095         }
00096 
00097         if ( ! ( $iStatus = oxConfig::getParameter( 'status' ) ) ) {
00098             $oUser->removeFromGroup( 'oxidnewsletter' );
00099             $oUser->getNewsSubscription()->setOptInStatus( 0 );
00100             $this->_iSubsriptionStatus = -1;
00101         } else {
00102             // assign user to newsletter group
00103             $oUser->addToGroup( 'oxidnewsletter' );
00104             $oUser->getNewsSubscription()->setOptInEmailStatus( 0 );
00105             $oUser->getNewsSubscription()->setOptInStatus( 1 );
00106             $this->_iSubsriptionStatus = 1;
00107         }
00108 
00109         //to maintain compatibility we still set the old template variable using new getter
00110         if ( $this->getSubscriptionStatus() == 1) {
00111             $this->_aViewData['blsubscribed'] = true;
00112         }
00113         if ( $this->getSubscriptionStatus() == -1) {
00114             $this->_aViewData['blsubscribed'] = false;
00115         }
00116     }
00117 
00124     public function getSubscriptionStatus()
00125     {
00126         return $this->_iSubsriptionStatus;
00127     }
00128 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5