account_newsletter.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Account_Newsletter extends Account
00010 {
00015     protected $_sThisTemplate = 'page/account/newsletter.tpl';
00016 
00022     protected $_blNewsletter = null;
00023 
00029     protected $_iSubscriptionStatus = 0;
00030 
00038     public function render()
00039     {
00040 
00041         parent::render();
00042 
00043         // is logged in ?
00044         $oUser = $this->getUser();
00045         if ( !$oUser ) {
00046             return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00047         }
00048 
00049         return $this->_sThisTemplate;
00050     }
00051 
00052 
00058     public function isNewsletter()
00059     {
00060         if ( $this->_blNewsletter === null ) {
00061 
00062             // initiating status
00063             $this->_blNewsletter = false;
00064 
00065             // now checking real subscription status
00066             $oUser = $this->getUser();
00067             if ( $oUser &&  $oUser->inGroup( 'oxidnewsletter' ) && ( $oUser->getNewsSubscription()->getOptInStatus() == 1 ) ) {
00068                 $this->_blNewsletter = true;
00069             }
00070         }
00071 
00072         return $this->_blNewsletter;
00073     }
00074 
00081     public function subscribe()
00082     {
00083         // is logged in ?
00084         $oUser = $this->getUser();
00085         if ( !$oUser ) {
00086             return false;
00087         }
00088 
00089         $oSubscription = $oUser->getNewsSubscription();
00090         if ( ! ( $iStatus = oxConfig::getParameter( 'status' ) ) ) {
00091             $oUser->removeFromGroup( 'oxidnewsletter' );
00092             $oSubscription->setOptInStatus( 0 );
00093             $this->_iSubscriptionStatus = -1;
00094         } else {
00095             // assign user to newsletter group
00096             $oUser->addToGroup( 'oxidnewsletter' );
00097             $oSubscription->setOptInEmailStatus( 0 );
00098             $oSubscription->setOptInStatus( 1 );
00099             $this->_iSubscriptionStatus = 1;
00100         }
00101     }
00102 
00109     public function getSubscriptionStatus()
00110     {
00111         return $this->_iSubscriptionStatus;
00112     }
00113 
00119     public function getBreadCrumb()
00120     {
00121         $aPaths = array();
00122         $aPath = array();
00123 
00124         $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_MY_ACCOUNT', oxLang::getInstance()->getBaseLanguage(), false );
00125         $aPath['link']  = oxSeoEncoder::getInstance()->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=account' );
00126         $aPaths[] = $aPath;
00127 
00128         $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_NEWSLETTER_SETTINGS', oxLang::getInstance()->getBaseLanguage(), false );
00129         $aPath['link']  = $this->getLink();
00130         $aPaths[] = $aPath;
00131 
00132         return $aPaths;
00133     }
00134 }