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 = oxRegistry::getUtils();
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 $aParams = oxConfig::getParameter( 'pa' );
00061 if ( !isset( $aParams['email'] ) || !$myUtils->isValidEmail( $aParams['email'] ) ) {
00062 $this->_iPriceAlarmStatus = 0;
00063 return;
00064 }
00065
00066 $oCur = $myConfig->getActShopCurrencyObject();
00067
00068 $dPrice = $myUtils->currency2Float( $aParams['price'] );
00069
00070 $oAlarm = oxNew( "oxpricealarm" );
00071 $oAlarm->oxpricealarm__oxuserid = new oxField( oxSession::getVar( 'usr' ));
00072 $oAlarm->oxpricealarm__oxemail = new oxField( $aParams['email']);
00073 $oAlarm->oxpricealarm__oxartid = new oxField( $aParams['aid']);
00074 $oAlarm->oxpricealarm__oxprice = new oxField( $myUtils->fRound( $dPrice, $oCur ));
00075 $oAlarm->oxpricealarm__oxshopid = new oxField( $myConfig->getShopId());
00076 $oAlarm->oxpricealarm__oxcurrency = new oxField( $oCur->name);
00077
00078 $oAlarm->oxpricealarm__oxlang = new oxField(oxRegistry::getLang()->getBaseLanguage());
00079
00080 $oAlarm->save();
00081
00082
00083 $oEmail = oxNew( 'oxemail' );
00084 $this->_iPriceAlarmStatus = (int) $oEmail->sendPricealarmNotification( $aParams, $oAlarm );
00085 }
00086
00092 public function getBidPrice()
00093 {
00094 if ( $this->_sBidPrice === null ) {
00095 $this->_sBidPrice = false;
00096
00097 $aParams = $this->_getParams();
00098 $oCur = $this->getConfig()->getActShopCurrencyObject();
00099 $iPrice = oxRegistry::getUtils()->currency2Float( $aParams['price'] );
00100 $this->_sBidPrice = oxRegistry::getLang()->formatCurrency( $iPrice, $oCur );
00101 }
00102 return $this->_sBidPrice;
00103 }
00104
00110 public function getProduct()
00111 {
00112 if ( $this->_oArticle === null ) {
00113 $this->_oArticle = false;
00114 $aParams = $this->_getParams();
00115 $oArticle = oxNew( 'oxarticle' );
00116 $oArticle->load( $aParams['aid'] );
00117 $this->_oArticle = $oArticle;
00118 }
00119 return $this->_oArticle;
00120 }
00121
00127 private function _getParams()
00128 {
00129 return oxConfig::getParameter( 'pa' );
00130 }
00131
00137 public function getPriceAlarmStatus()
00138 {
00139 return $this->_iPriceAlarmStatus;
00140 }
00141
00142 }