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
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
00063 $this->_blNewsletter = false;
00064
00065
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
00084 $oUser = $this->getUser();
00085 if ( !$oUser ) {
00086 return false;
00087 }
00088
00089 $oSubscription = $oUser->getNewsSubscription();
00090 $iStatus = oxConfig::getParameter( 'status' );
00091
00092 if ( $iStatus == 0 && $iStatus !== null ) {
00093 $oUser->removeFromGroup( 'oxidnewsletter' );
00094 $oSubscription->setOptInStatus( 0 );
00095 $this->_iSubscriptionStatus = -1;
00096 } if ( $iStatus == 1 ) {
00097
00098 $oUser->addToGroup( 'oxidnewsletter' );
00099 $oSubscription->setOptInEmailStatus( 0 );
00100 $oSubscription->setOptInStatus( 1 );
00101 $this->_iSubscriptionStatus = 1;
00102 }
00103 }
00104
00111 public function getSubscriptionStatus()
00112 {
00113 return $this->_iSubscriptionStatus;
00114 }
00115
00121 public function getBreadCrumb()
00122 {
00123 $aPaths = array();
00124 $aPath = array();
00125 $oUtils = oxRegistry::get("oxUtilsUrl");
00126 $aPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_ACCOUNT_MY_ACCOUNT', oxRegistry::getLang()->getBaseLanguage(), false );
00127 $aPath['link'] = oxRegistry::get("oxSeoEncoder")->getStaticUrl( $this->getViewConfig()->getSelfLink() . 'cl=account' );
00128 $aPaths[] = $aPath;
00129
00130 $aPath['title'] = oxRegistry::getLang()->translateString( 'PAGE_ACCOUNT_NEWSLETTER_SETTINGS', oxRegistry::getLang()->getBaseLanguage(), false );
00131 $aPath['link'] = $oUtils->cleanUrl( $this->getLink(), array( 'fnc' ));
00132 $aPaths[] = $aPath;
00133
00134 return $aPaths;
00135 }
00136 }