00001 <?php
00002
00008 class oxRating extends oxBase
00009 {
00015 protected $_blDisableShopCheck = true;
00016
00022 protected $_sClassName = 'oxrating';
00023
00027 public function __construct()
00028 {
00029 parent::__construct();
00030 $this->init( 'oxratings' );
00031 }
00032
00038 protected function _insert()
00039 {
00040
00041 $this->oxratings__oxtimestamp= new oxField(date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime() ));
00042
00043 return parent::_insert();
00044 }
00045
00055 public function allowRating( $sUserId, $sType, $sObjectId)
00056 {
00057 $oDB = oxDb::getDb();
00058 $myConfig = oxConfig::getInstance();
00059 if ( $iRatingLogsTimeout = $myConfig->getConfigParam( 'iRatingLogsTimeout' ) ) {
00060 $sExpDate = date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime() - $iRatingLogsTimeout*24*60*60);
00061 $oDB->execute( "delete from oxratings where oxtimestamp < '$sExpDate'" );
00062 }
00063 $sSelect = "select oxid from oxratings where oxuserid = '$sUserId' and oxtype='$sType' and oxobjectid = '$sObjectId'";
00064 if ( $oDB->getOne( $sSelect ) ) {
00065 return false;
00066 }
00067
00068 return true;
00069 }
00070
00071 }