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 $_aReqFields = array( 'rec_email', 'send_name', 'send_email', 'send_message', 'send_subject' );
00021
00026 protected $_oCrossSelling = null;
00027
00032 protected $_oSimilarProducts = null;
00033
00038 protected $_oRecommList = null;
00039
00044 protected $_aInviteData = null;
00045
00050 protected $_oCaptcha = null;
00051
00056 protected $_iMailStatus = null;
00057
00063 public function render()
00064 {
00065 $oConfig = $this->getConfig();
00066
00067 if ( !$oConfig->getConfigParam( "blInvitationsEnabled" ) ) {
00068 oxUtils::getInstance()->redirect( $oConfig->getShopHomeURL() );
00069 return;
00070 }
00071
00072 parent::render();
00073
00074 return $this->_sThisTemplate;
00075 }
00076
00083 public function send()
00084 {
00085 $oConfig = $this->getConfig();
00086
00087 if ( !$oConfig->getConfigParam( "blInvitationsEnabled" ) ) {
00088 oxUtils::getInstance()->redirect( $oConfig->getShopHomeURL() );
00089 }
00090
00091 $aParams = oxConfig::getParameter( 'editval', true );
00092 if ( !is_array( $aParams ) ) {
00093 return;
00094 }
00095
00096
00097 $oParams = (object) $aParams;
00098 $this->setInviteData( (object) oxConfig::getParameter( 'editval' ) );
00099
00100
00101 $sMac = oxConfig::getParameter( 'c_mac' );
00102 $sMacHash = oxConfig::getParameter( 'c_mach' );
00103 $oCaptcha = $this->getCaptcha();
00104
00105 if ( !$oCaptcha->pass( $sMac, $sMacHash ) ) {
00106
00107 oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_WRONGCAPTCHA' );
00108 return;
00109 }
00110
00111 $oUtilsView = oxUtilsView::getInstance();
00112
00113
00114 foreach ( $this->_aReqFields as $sFieldName ) {
00115
00116 if ( $sFieldName == "rec_email" ) {
00117 foreach ( $aParams[$sFieldName] as $sKey => $sEmail ) {
00118
00119 if ( empty( $sEmail ) ) {
00120 unset( $aParams[$sFieldName][$sKey] );
00121 }
00122 }
00123
00124
00125 if ( count( $aParams[$sFieldName] ) < 1 ) {
00126 $oUtilsView->addErrorToDisplay('EXCEPTION_INVITE_COMLETECORRECTLYFIELDS');
00127 return;
00128 }
00129
00130
00131 $oParams->rec_email = $aParams[$sFieldName];
00132 }
00133
00134 if ( !isset( $aParams[$sFieldName] ) || !$aParams[$sFieldName] ) {
00135 $oUtilsView->addErrorToDisplay('EXCEPTION_INVITE_COMLETECORRECTLYFIELDS');
00136 return;
00137 }
00138 }
00139
00140 $oUtils = oxUtils::getInstance();
00141
00142
00143 foreach ( $aParams["rec_email"] as $sRecipientEmail ) {
00144 if ( !$oUtils->isValidEmail( $sRecipientEmail ) ) {
00145 $oUtilsView->addErrorToDisplay('EXCEPTION_INVITE_INCORRECTEMAILADDRESS');
00146 return;
00147 }
00148 }
00149
00150 if ( !$oUtils->isValidEmail( $aParams["send_email"] ) ) {
00151 $oUtilsView->addErrorToDisplay('EXCEPTION_INVITE_INCORRECTEMAILADDRESS');
00152 return;
00153 }
00154
00155
00156 $oEmail = oxNew( 'oxemail' );
00157
00158 if ( $oEmail->sendInviteMail( $oParams ) ) {
00159 $this->_iMailStatus = 1;
00160
00161
00162 $oUser = $this->getUser();
00163
00164
00165 if ( $oUser ) {
00166 $oUser->updateInvitationStatistics( $aParams["rec_email"] );
00167 }
00168
00169 } else {
00170 oxUtilsView::getInstance()->addErrorToDisplay('EXCEPTION_INVITE_ERRORWHILESENDINGMAIL');
00171 }
00172 }
00173
00179 public function getInviteSendStatus()
00180 {
00181
00182 if ( $this->_iMailStatus == 1 ) {
00183 return true;
00184 }
00185 return false;
00186 }
00187
00195 public function setInviteData( $oData )
00196 {
00197 $this->_aInviteData = $oData;
00198 }
00199
00205 public function getInviteData()
00206 {
00207 return $this->_aInviteData;
00208 }
00209
00215 public function getCaptcha()
00216 {
00217 if ( $this->_oCaptcha === null ) {
00218 $this->_oCaptcha = oxNew('oxCaptcha');
00219 }
00220 return $this->_oCaptcha;
00221 }
00222
00228 public function getBreadCrumb()
00229 {
00230 $aPaths = array();
00231 $aPath = array();
00232
00233 $aPath['title'] = oxLang::getInstance()->translateString( 'PAGE_PRIVATESALES_INVITE_TITLE', oxLang::getInstance()->getBaseLanguage(), false );
00234 $aPath['link'] = $this->getLink();
00235 $aPaths[] = $aPath;
00236
00237 return $aPaths;
00238 }
00239
00240
00241 }