Go to the documentation of this file.00001 <?php
00002
00011 class Pricealarm extends oxUBase
00012 {
00017 protected $_sThisTemplate = 'pricealarm.tpl';
00018
00023 protected $_oArticle = null;
00024
00029 protected $_sBidPrice = null;
00030
00035 protected $_iPriceAlarmStatus = null;
00036
00046 public function addme()
00047 {
00048 $myConfig = $this->getConfig();
00049 $myUtils = oxUtils::getInstance();
00050
00051
00052 $sMac = oxConfig::getParameter( 'c_mac' );
00053 $sMacHash = oxConfig::getParameter( 'c_mach' );
00054 $oCaptcha = oxNew('oxCaptcha');
00055 if (!$oCaptcha->pass($sMac, $sMacHash)) {
00056 $this->_iPriceAlarmStatus = 2;
00057 return;
00058 }
00059
00060
00061
00062 $aParams = oxConfig::getParameter( 'pa' );
00063 if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
00064 $this->_iPriceAlarmStatus = 0;
00065 return;
00066 }
00067
00068 $oCur = $myConfig->getActShopCurrencyObject();
00069
00070 $dPrice = $myUtils->currency2Float( $aParams['price'] );
00071
00072 $oAlarm = oxNew( "oxpricealarm" );
00073 $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
00074 $oAlarm->oxpricealarm__oxemail = new oxField( $aParams['email']);
00075 $oAlarm->oxpricealarm__oxartid = new oxField( $aParams['aid']);
00076 $oAlarm->oxpricealarm__oxprice = new oxField( $myUtils->fRound( $dPrice, $oCur ));
00077 $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
00078 $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
00079
00080 $oAlarm->oxpricealarm__oxlang = new oxField(oxLang::getInstance()->getBaseLanguage());
00081
00082 $oAlarm->save();
00083
00084
00085 $oEmail = oxNew( 'oxemail' );
00086 $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
00087 }
00088
00094 public function getBidPrice()
00095 {
00096 if ( $this->_sBidPrice === null ) {
00097 $this->_sBidPrice = false;
00098
00099 $aParams = $this->_getParams();
00100 $oCur = $this->getConfig()->getActShopCurrencyObject();
00101 $iPrice = oxUtils::getInstance()->currency2Float( $aParams['price'] );
00102 $this->_sBidPrice = oxLang::getInstance()->formatCurrency( $iPrice, $oCur );
00103 }
00104 return $this->_sBidPrice;
00105 }
00106
00112 public function getProduct()
00113 {
00114 if ( $this->_oArticle === null ) {
00115 $this->_oArticle = false;
00116 $aParams = $this->_getParams();
00117 $oArticle = oxNew( 'oxarticle' );
00118 $oArticle->load( $aParams['aid'] );
00119 $this->_oArticle = $oArticle;
00120 }
00121 return $this->_oArticle;
00122 }
00123
00129 private function _getParams()
00130 {
00131 return oxConfig::getParameter( 'pa' );
00132 }
00133
00139 public function getPriceAlarmStatus()
00140 {
00141 return $this->_iPriceAlarmStatus;
00142 }
00143
00144 }