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 $_iSubscriptionStatus = 0;
00030
00041 public function render()
00042 {
00043 parent::render();
00044
00045
00046 $oUser = $this->getUser();
00047 if ( !$oUser ) {
00048 return $this->_sThisTemplate = $this->_sThisLoginTemplate;
00049 }
00050
00051
00052 $this->_aViewData['blnewsletter'] = $this->isNewsletter();
00053
00054
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
00071 $this->_blNewsletter = false;
00072
00073
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
00092 $oUser = $this->getUser();
00093 if ( !$oUser ) {
00094 return false;
00095 }
00096
00097 $oSubscription = $oUser->getNewsSubscription();
00098 if ( ! ( $iStatus = oxConfig::getParameter( 'status' ) ) ) {
00099 $oUser->removeFromGroup( 'oxidnewsletter' );
00100 $oSubscription->setOptInStatus( 0 );
00101 $this->_iSubscriptionStatus = -1;
00102 } else {
00103
00104 $oUser->addToGroup( 'oxidnewsletter' );
00105 $oSubscription->setOptInEmailStatus( 0 );
00106 $oSubscription->setOptInStatus( 1 );
00107 $this->_iSubscriptionStatus = 1;
00108 }
00109
00110
00111 if ( $this->getSubscriptionStatus() == 1) {
00112 $this->_aViewData['blsubscribed'] = true;
00113 }
00114 if ( $this->getSubscriptionStatus() == -1) {
00115 $this->_aViewData['blsubscribed'] = false;
00116 }
00117 }
00118
00125 public function getSubscriptionStatus()
00126 {
00127 return $this->_iSubscriptionStatus;
00128 }
00129 }