suggest.php
Go to the documentation of this file.00001 <?php
00002
00008 class Suggest extends oxUBase
00009 {
00014 protected $_sThisTemplate = 'suggest.tpl';
00015
00020 protected $_aReqFields = array( 'rec_name', '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 $_aSuggestData = null;
00045
00050 protected $_oCaptcha = null;
00051
00064 public function render()
00065 {
00066 parent::render();
00067
00068 $this->_aViewData['product'] = $this->getProduct();
00069 $this->_aViewData['crossselllist'] = $this->getCrossSelling();
00070 $this->_aViewData['similarlist'] = $this->getSimilarProducts();
00071 $this->_aViewData['similarrecommlist'] = $this->getRecommList();
00072
00073 $this->_aViewData['oCaptcha'] = $this->getCaptcha();
00074
00075 $this->_aViewData['editval'] = $this->getSuggestData();
00076
00077 return $this->_sThisTemplate;
00078 }
00079
00089 public function send()
00090 {
00091 $aParams = oxConfig::getParameter( 'editval', true );
00092 if ( !is_array( $aParams ) ) {
00093 return;
00094 }
00095
00096
00097 $oParams = (object) $aParams;
00098 $this->setSuggestData( (object) oxConfig::getParameter( 'editval' ) );
00099
00100
00101 $sMac = oxConfig::getParameter( 'c_mac' );
00102 $sMacHash = oxConfig::getParameter( 'c_mach' );
00103 $oCaptcha = oxNew('oxCaptcha');
00104
00105 if ( !$oCaptcha->pass($sMac, $sMacHash ) ) {
00106
00107 oxUtilsView::getInstance()->addErrorToDisplay( 'EXCEPTION_INPUT_NOTALLFIELDS' );
00108 return false;
00109 }
00110
00111 $oUtilsView = oxUtilsView::getInstance();
00112
00113 foreach ( $this->_aReqFields as $sFieldName ) {
00114 if ( !isset( $aParams[$sFieldName] ) || !$aParams[$sFieldName] ) {
00115 $oUtilsView->addErrorToDisplay('SUGGEST_COMLETECORRECTLYFIELDS');
00116 return;
00117 }
00118 }
00119
00120 $sReturn = "";
00121
00122 $sSearchParamForLink = rawurlencode( oxConfig::getParameter( 'searchparam', true ) );
00123 if ( $sSearchParamForLink ) {
00124 $sReturn .= "&searchparam=$sSearchParamForLink";
00125 }
00126
00127 $sSearchCatId = oxConfig::getParameter( 'searchcnid' );
00128 if ( $sSearchCatId ) {
00129 $sReturn .= "&searchcnid=$sSearchCatId";
00130 }
00131
00132 $sSearchVendor = oxConfig::getParameter( 'searchvendor' );
00133 if ( $sSearchVendor ) {
00134 $sReturn .= "&searchvendor=$sSearchVendor";
00135 }
00136
00137 if ( ( $sSearchManufacturer = oxConfig::getParameter( 'searchmanufacturer' ) ) ) {
00138 $sReturn .= "&searchmanufacturer=$sSearchManufacturer";
00139 }
00140
00141 $sListType = oxConfig::getParameter( 'listtype' );
00142 if ( $sListType ) {
00143 $sReturn .= "&listtype=$sListType";
00144 }
00145
00146
00147 $oEmail = oxNew( 'oxemail' );
00148 $oProduct = $this->getProduct();
00149 if ( $oProduct && $oEmail->sendSuggestMail( $oParams, $oProduct ) ) {
00150 return 'details?anid='.$oProduct->getId().$sReturn;
00151 } else {
00152 oxUtilsView::getInstance()->addErrorToDisplay('SUGGEST_INVALIDMAIL');
00153 }
00154 }
00155
00161 public function getProduct()
00162 {
00163 if ( $this->_oProduct === null ) {
00164 $this->_oProduct = false;
00165
00166 if ( $sAnid = oxConfig::getParameter( 'anid' ) ) {
00167 $this->_oProduct = oxNewArticle( $sAnid );
00168 }
00169 }
00170 return $this->_oProduct;
00171 }
00172
00178 public function getCrossSelling()
00179 {
00180 if ( $this->_oCrossSelling === null ) {
00181 $this->_oCrossSelling = false;
00182 if ( $oProduct = $this->getProduct() ) {
00183 $this->_oCrossSelling = $oProduct->getCrossSelling();
00184 }
00185 }
00186 return $this->_oCrossSelling;
00187 }
00188
00194 public function getSimilarProducts()
00195 {
00196 if ( $this->_oSimilarProducts === null ) {
00197 $this->_oSimilarProducts = false;
00198 if ( $oProduct = $this->getProduct() ) {
00199 $this->_oSimilarProducts = $oProduct->getSimilarProducts();
00200 }
00201 }
00202 return $this->_oSimilarProducts;
00203 }
00204
00210 public function getRecommList()
00211 {
00212 if (!$this->getViewConfig()->getShowListmania()) {
00213 return false;
00214 }
00215
00216 if ( $this->_oRecommList === null ) {
00217 $this->_oRecommList = false;
00218 if ( $oProduct = $this->getProduct() ) {
00219 $oRecommList = oxNew('oxrecommlist');
00220 $this->_oRecommList = $oRecommList->getRecommListsByIds( array( $oProduct->getId() ) );
00221 }
00222 }
00223 return $this->_oRecommList;
00224 }
00225
00233 public function setSuggestData( $oData )
00234 {
00235 $this->_aSuggestData = $oData;
00236 }
00237
00243 public function getSuggestData()
00244 {
00245 return $this->_aSuggestData;
00246 }
00247
00255 public function getLink( $iLang = null )
00256 {
00257 $sLink = parent::getLink( $iLang );
00258
00259
00260 if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
00261 $sLink .= ( ( strpos( $sLink, '?' ) === false ) ? '?' : '&' ) . "cnid={$sVal}";
00262 }
00263
00264
00265 if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
00266 $sLink .= ( ( strpos( $sLink, '?' ) === false ) ? '?' : '&' ) . "anid={$sVal}";
00267 }
00268
00269 return $sLink;
00270 }
00271
00277 public function getCaptcha()
00278 {
00279 if ( $this->_oCaptcha === null ) {
00280 $this->_oCaptcha = oxNew('oxCaptcha');
00281 }
00282 return $this->_oCaptcha;
00283 }
00284
00285 }