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