register.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class Register extends User
00008 {
00014     protected $_sThisTemplate = 'page/account/register.tpl';
00015 
00021     protected $_sSuccessTemplate = 'page/account/register_success.tpl';
00022 
00028     protected $_sConfirmTemplate = 'page/account/register_confirm.tpl';
00029 
00034     protected $_blIsOrderStep = false;
00035 
00041     protected $_iViewIndexState = VIEW_INDEXSTATE_NOINDEXNOFOLLOW;
00042 
00049     public function render()
00050     {
00051         parent::render();
00052 
00053         // checking registration status
00054         if ( $this->isEnabledPrivateSales() && $this->isConfirmed() ) {
00055             $sTemplate = $this->_sConfirmTemplate;
00056         } elseif ( $this->getRegistrationStatus() ) {
00057             $sTemplate = $this->_sSuccessTemplate;
00058         } else {
00059             $sTemplate = $this->_sThisTemplate;
00060         }
00061 
00062         return $sTemplate;
00063     }
00064 
00070     public function getRegistrationError()
00071     {
00072         return oxConfig::getParameter( 'newslettererror' );
00073     }
00074 
00080     public function getRegistrationStatus()
00081     {
00082         return oxConfig::getParameter( 'success' );
00083     }
00084 
00092     public function getDelAddress()
00093     {
00094         // is logged in ?
00095         if ( $this->_oDelAddress === null ) {
00096             $this->_oDelAddress = false;
00097 
00098             if ( $oUser = $this->getUser() ) {
00099                 $sAddressId = $oUser->getSelectedAddress();
00100                 if ( $sAddressId && $sAddressId != '-1' ) {
00101                     $this->_oDelAddress = oxNew( 'oxaddress' );
00102                     $this->_oDelAddress->load( $sAddressId );
00103                 }
00104             }
00105         }
00106 
00107         return $this->_oDelAddress;
00108     }
00109 
00117     public function isFieldRequired( $sField )
00118     {
00119         if ( $aMustFillFields = $this->getMustFillFields() ) {
00120             if ( isset( $aMustFillFields[$sField] ) ) {
00121                 return true;
00122             }
00123         }
00124 
00125         return false;
00126     }
00127 
00135     public function confirmRegistration()
00136     {
00137         $oUser = oxNew( 'oxuser' );
00138         if ( $oUser->loadUserByUpdateId( $this->getUpdateId() ) ) {
00139 
00140             // resetting update key parameter
00141             $oUser->setUpdateKey( true );
00142 
00143             // saving ..
00144             $oUser->oxuser__oxactive = new oxField( 1 );
00145             $oUser->save();
00146 
00147             // forcing user login
00148             oxSession::setVar( 'usr', $oUser->getId() );
00149 
00150             // redirecting to confirmation page
00151             return 'register?confirmstate=1';
00152         } else {
00153             // confirmation failed
00154             oxUtilsView::getInstance()->addErrorToDisplay( 'REGISTER_ERRLINKEXPIRED', false, true );
00155 
00156             // redirecting to confirmation page
00157             return 'account';
00158         }
00159     }
00160 
00166     public function getUpdateId()
00167     {
00168         return oxConfig::getParameter( 'uid' );
00169     }
00170 
00176     public function isConfirmed()
00177     {
00178          return (bool) oxConfig::getParameter( "confirmstate" );
00179     }
00180 
00186     public function getBreadCrumb()
00187     {
00188         $aPaths = array();
00189         $aPath = array();
00190 
00191         $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_ACCOUNT_REGISTER_REGISTER', oxLang::getInstance()->getBaseLanguage(), false );
00192         $aPath['link']  = $this->getLink();
00193         $aPaths[] = $aPath;
00194 
00195         return $aPaths;
00196     }
00197 
00198 
00199 }