Go to the documentation of this file.00001 <?php
00002
00007 class oxReview extends oxBase
00008 {
00014 protected $_blDisableShopCheck = true;
00015
00021 protected $_sClassName = 'oxreview';
00022
00026 public function __construct()
00027 {
00028 parent::__construct();
00029 $this->init( 'oxreviews' );
00030 }
00031
00039 public function assign( $dbRecord )
00040 {
00041 $blRet = parent::assign( $dbRecord );
00042
00043 if ( isset( $this->oxreviews__oxuserid ) && $this->oxreviews__oxuserid->value ) {
00044 $oDb = oxDb::getDb();
00045 $this->oxuser__oxfname = new oxField( $oDb->getOne( "select oxfname from oxuser where oxid=".$oDb->quote( $this->oxreviews__oxuserid->value ) ));
00046 }
00047
00048 return $blRet;
00049 }
00050
00058 public function load( $oxId )
00059 {
00060 if ( $blRet = parent::load( $oxId ) ) {
00061
00062 $this->oxreviews__oxcreate->setValue(oxUtilsDate::getInstance()->formatDBDate( $this->oxreviews__oxcreate->value ));
00063 }
00064
00065 return $blRet;
00066 }
00067
00073 protected function _insert()
00074 {
00075
00076 $this->oxreviews__oxcreate = new oxField(date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime() ));
00077 return parent::_insert();
00078 }
00079
00080
00091 public function loadList($sType, $aIds, $blLoadEmpty = false, $iLoadInLang = null)
00092 {
00093 $oDb = oxDb::getDb();
00094
00095 $oRevs = oxNew( 'oxlist' );
00096 $oRevs->init( 'oxreview' );
00097
00098 $sObjectIdWhere = '';
00099 if ( is_array( $aIds ) && count( $aIds ) ) {
00100 $sObjectIdWhere = "oxreviews.oxobjectid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aIds ))." )";
00101 } elseif ( is_string( $aIds ) && $aIds ) {
00102 $sObjectIdWhere = "oxreviews.oxobjectid = ".$oDb->quote( $aIds );
00103 } else {
00104 return $oRevs;
00105 }
00106
00107 $iLoadInLang = is_null( $iLoadInLang ) ? (int) oxLang::getInstance()->getBaseLanguage() : (int) $iLoadInLang;
00108
00109 $sSelect = "select oxreviews.* from oxreviews where oxreviews.oxtype = ".$oDb->quote( $sType )." and $sObjectIdWhere and oxreviews.oxlang = '$iLoadInLang'";
00110
00111 if ( !$blLoadEmpty ) {
00112 $sSelect .= ' and oxreviews.oxtext != "" ';
00113 }
00114
00115 if ( $this->getConfig()->getConfigParam( 'blGBModerate' ) ) {
00116 $sSelect .= ' and ( oxreviews.oxactive = "1" ';
00117 $sSelect .= ( $oUser = $this->getUser() ) ? 'or oxreviews.oxuserid = ' . $oDb->quote( $oUser->getId() ) . ' )' : ')';
00118 }
00119
00120 $sSelect .= ' order by oxreviews.oxcreate desc ';
00121
00122 $oRevs->selectString( $sSelect );
00123
00124
00125 foreach ( $oRevs as $oItem ) {
00126 $oItem->oxreviews__oxcreate->convertToFormattedDbDate();
00127 $oItem->oxreviews__oxtext->convertToPseudoHtml();
00128 }
00129
00130 return $oRevs;
00131 }
00132 }