Go to the documentation of this file.00001 <?php
00002
00008 class Invite extends oxUBase
00009 {
00014 protected $_sThisTemplate = 'page/privatesales/invite.tpl';
00015
00020 protected $_sThisLoginTemplate = 'page/account/login.tpl';
00021
00026 protected $_aReqFields = array( 'rec_email', 'send_name', 'send_email', 'send_message', 'send_subject' );
00027
00032 protected $_oCrossSelling = null;
00033
00038 protected $_oSimilarProducts = null;
00039
00044 protected $_oRecommList = null;
00045
00050 protected $_aInviteData = null;
00051
00056 protected $_oCaptcha = null;
00057
00062 protected $_iMailStatus = null;
00063
00069 public function render()
00070 {
00071 $oConfig = $this->getConfig();
00072
00073 if ( !$oConfig->getConfigParam( "blInvitationsEnabled" ) ) {
00074 oxRegistry::getUtils()->redirect( $oConfig->getShopHomeURL() );
00075 return;
00076 }
00077
00078 parent::render();
00079
00080 return $this->getUser() ? $this->_sThisTemplate : $this->_sThisLoginTemplate;
00081 }
00082
00089 public function send()
00090 {
00091 $oConfig = $this->getConfig();
00092
00093 if ( !$oConfig->getConfigParam( "blInvitationsEnabled" ) ) {
00094 oxRegistry::getUtils()->redirect( $oConfig->getShopHomeURL() );
00095 }
00096
00097 $aParams = oxConfig::getParameter( 'editval', true );
00098 $oUser = $this->getUser();
00099 if ( !is_array( $aParams ) || !$oUser ) {
00100 return;
00101 }
00102
00103
00104 $oParams = (object) $aParams;
00105 $this->setInviteData( (object) oxConfig::getParameter( 'editval' ) );
00106
00107
00108 $sMac = oxConfig::getParameter( 'c_mac' );
00109 $sMacHash = oxConfig::getParameter( 'c_mach' );
00110 $oCaptcha = $this->getCaptcha();
00111
00112 if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
00113
00114 oxRegistry::get("oxUtilsView")->addErrorToDisplay( 'MESSAGE_WRONG_VERIFICATION_CODE' );
00115 return;
00116 }
00117
00118 $oUtilsView = oxRegistry::get("oxUtilsView");
00119
00120
00121 foreach ( $this->_aReqFields as $sFieldName ) {
00122
00123 if ( $sFieldName == "rec_email" ) {
00124 foreach ( $aParams[$sFieldName] as $sKey => $sEmail ) {
00125
00126 if ( empty( $sEmail ) ) {
00127 unset( $aParams[$sFieldName][$sKey] );
00128 }
00129 }
00130
00131
00132 if ( count( $aParams[$sFieldName] ) < 1 ) {
00133 $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY');
00134 return;
00135 }
00136
00137
00138 $oParams->rec_email = $aParams[$sFieldName];
00139 }
00140
00141 if ( !isset( $aParams[$sFieldName] ) || !$aParams[$sFieldName] ) {
00142 $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY');
00143 return;
00144 }
00145 }
00146
00147 $oUtils = oxRegistry::getUtils();
00148
00149
00150 foreach ( $aParams["rec_email"] as $sRecipientEmail ) {
00151 if ( !$oUtils->isValidEmail( $sRecipientEmail ) ) {
00152 $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_INVITE_INCORRECTEMAILADDRESS');
00153 return;
00154 }
00155 }
00156
00157 if ( !$oUtils->isValidEmail( $aParams["send_email"] ) ) {
00158 $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_INVITE_INCORRECTEMAILADDRESS');
00159 return;
00160 }
00161
00162
00163 $oEmail = oxNew( 'oxemail' );
00164
00165 if ( $oEmail->sendInviteMail( $oParams ) ) {
00166 $this->_iMailStatus = 1;
00167
00168
00169 $oUser = $this->getUser();
00170
00171
00172 $oUser->updateInvitationStatistics( $aParams["rec_email"] );
00173 } else {
00174 oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL');
00175 }
00176 }
00177
00183 public function getInviteSendStatus()
00184 {
00185
00186 if ( $this->_iMailStatus == 1 ) {
00187 return true;
00188 }
00189 return false;
00190 }
00191
00199 public function setInviteData( $oData )
00200 {
00201 $this->_aInviteData = $oData;
00202 }
00203
00209 public function getInviteData()
00210 {
00211 return $this->_aInviteData;
00212 }
00213
00219 public function getCaptcha()
00220 {
00221 if ( $this->_oCaptcha === null ) {
00222 $this->_oCaptcha = oxNew('oxCaptcha');
00223 }
00224 return $this->_oCaptcha;
00225 }
00226
00232 public function getBreadCrumb()
00233 {
00234 $aPaths = array();
00235 $aPath = array();
00236
00237 $aPath['title'] = oxRegistry::getLang()->translateString( 'INVITE_YOUR_FRIENDS', oxRegistry::getLang()->getBaseLanguage(), false );
00238 $aPath['link'] = $this->getLink();
00239 $aPaths[] = $aPath;
00240
00241 return $aPaths;
00242 }
00243
00244
00245 }