Go to the documentation of this file.00001 <?php
00002
00008 class Invite extends oxUBase
00009 {
00010
00016 protected $_sThisTemplate = 'page/privatesales/invite.tpl';
00017
00023 protected $_sThisLoginTemplate = 'page/account/login.tpl';
00024
00030 protected $_aReqFields = array('rec_email', 'send_name', 'send_email', 'send_message', 'send_subject');
00031
00037 protected $_oCrossSelling = null;
00038
00044 protected $_oSimilarProducts = null;
00045
00051 protected $_oRecommList = null;
00052
00058 protected $_aInviteData = null;
00059
00065 protected $_oCaptcha = null;
00066
00072 protected $_iMailStatus = null;
00073
00079 public function render()
00080 {
00081 $oConfig = $this->getConfig();
00082
00083 if (!$oConfig->getConfigParam("blInvitationsEnabled")) {
00084 oxRegistry::getUtils()->redirect($oConfig->getShopHomeURL());
00085
00086 return;
00087 }
00088
00089 parent::render();
00090
00091 return $this->getUser() ? $this->_sThisTemplate : $this->_sThisLoginTemplate;
00092 }
00093
00100 public function send()
00101 {
00102 $oConfig = $this->getConfig();
00103
00104 if (!$oConfig->getConfigParam("blInvitationsEnabled")) {
00105 oxRegistry::getUtils()->redirect($oConfig->getShopHomeURL());
00106 }
00107
00108 $aParams = oxRegistry::getConfig()->getRequestParameter('editval', true);
00109 $oUser = $this->getUser();
00110 if (!is_array($aParams) || !$oUser) {
00111 return;
00112 }
00113
00114
00115 $oParams = (object) $aParams;
00116 $this->setInviteData((object) oxRegistry::getConfig()->getRequestParameter('editval'));
00117
00118
00119 $sMac = oxRegistry::getConfig()->getRequestParameter('c_mac');
00120 $sMacHash = oxRegistry::getConfig()->getRequestParameter('c_mach');
00121 $oCaptcha = $this->getCaptcha();
00122
00123 if (!$oCaptcha->pass($sMac, $sMacHash)) {
00124
00125 oxRegistry::get("oxUtilsView")->addErrorToDisplay('MESSAGE_WRONG_VERIFICATION_CODE');
00126
00127 return;
00128 }
00129
00130 $oUtilsView = oxRegistry::get("oxUtilsView");
00131
00132
00133 foreach ($this->_aReqFields as $sFieldName) {
00134
00135 if ($sFieldName == "rec_email") {
00136 foreach ($aParams[$sFieldName] as $sKey => $sEmail) {
00137
00138 if (empty($sEmail)) {
00139 unset($aParams[$sFieldName][$sKey]);
00140 }
00141 }
00142
00143
00144 if (count($aParams[$sFieldName]) < 1) {
00145 $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY');
00146
00147 return;
00148 }
00149
00150
00151 $oParams->rec_email = $aParams[$sFieldName];
00152 }
00153
00154 if (!isset($aParams[$sFieldName]) || !$aParams[$sFieldName]) {
00155 $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_COMPLETE_FIELDS_CORRECTLY');
00156
00157 return;
00158 }
00159 }
00160
00161 $oUtils = oxRegistry::getUtils();
00162
00163
00164 foreach ($aParams["rec_email"] as $sRecipientEmail) {
00165 if (!$oUtils->isValidEmail($sRecipientEmail)) {
00166 $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_INVITE_INCORRECTEMAILADDRESS');
00167
00168 return;
00169 }
00170 }
00171
00172 if (!$oUtils->isValidEmail($aParams["send_email"])) {
00173 $oUtilsView->addErrorToDisplay('ERROR_MESSAGE_INVITE_INCORRECTEMAILADDRESS');
00174
00175 return;
00176 }
00177
00178
00179 $oEmail = oxNew('oxemail');
00180
00181 if ($oEmail->sendInviteMail($oParams)) {
00182 $this->_iMailStatus = 1;
00183
00184
00185 $oUser = $this->getUser();
00186
00187
00188 $oUser->updateInvitationStatistics($aParams["rec_email"]);
00189 } else {
00190 oxRegistry::get("oxUtilsView")->addErrorToDisplay('ERROR_MESSAGE_CHECK_EMAIL');
00191 }
00192 }
00193
00199 public function getInviteSendStatus()
00200 {
00201
00202 if ($this->_iMailStatus == 1) {
00203 return true;
00204 }
00205
00206 return false;
00207 }
00208
00214 public function setInviteData($oData)
00215 {
00216 $this->_aInviteData = $oData;
00217 }
00218
00224 public function getInviteData()
00225 {
00226 return $this->_aInviteData;
00227 }
00228
00234 public function getCaptcha()
00235 {
00236 if ($this->_oCaptcha === null) {
00237 $this->_oCaptcha = oxNew('oxCaptcha');
00238 }
00239
00240 return $this->_oCaptcha;
00241 }
00242
00248 public function getBreadCrumb()
00249 {
00250 $aPaths = array();
00251 $aPath = array();
00252
00253 $iLang = oxRegistry::getLang()->getBaseLanguage();
00254 $aPath['title'] = oxRegistry::getLang()->translateString('INVITE_YOUR_FRIENDS', $iLang, false);
00255 $aPath['link'] = $this->getLink();
00256 $aPaths[] = $aPath;
00257
00258 return $aPaths;
00259 }
00260 }