OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
oxreview.php
Go to the documentation of this file.
1 <?php
2 
8 class oxReview extends oxBase
9 {
15  protected $_blDisableShopCheck = true;
16 
22  protected $_sClassName = 'oxreview';
23 
27  public function __construct()
28  {
30  $this->init( 'oxreviews' );
31  }
32 
40  public function assign( $dbRecord )
41  {
42  $blRet = parent::assign( $dbRecord );
43 
44  if ( isset( $this->oxreviews__oxuserid ) && $this->oxreviews__oxuserid->value ) {
45  $oDb = oxDb::getDb();
46  $this->oxuser__oxfname = new oxField( $oDb->getOne( "select oxfname from oxuser where oxid=".$oDb->quote( $this->oxreviews__oxuserid->value ) ));
47  }
48 
49  return $blRet;
50  }
51 
59  public function load( $oxId )
60  {
61  if ( $blRet = parent::load( $oxId ) ) {
62  // convert date's to international format
63  $this->oxreviews__oxcreate->setValue(oxRegistry::get("oxUtilsDate")->formatDBDate( $this->oxreviews__oxcreate->value ));
64  }
65 
66  return $blRet;
67  }
68 
74  protected function _insert()
75  {
76  // set oxcreate
77  $this->oxreviews__oxcreate = new oxField(date( 'Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime() ));
78  return parent::_insert();
79  }
80 
81 
92  public function loadList($sType, $aIds, $blLoadEmpty = false, $iLoadInLang = null)
93  {
94  $oDb = oxDb::getDb();
95 
96  $oRevs = oxNew( 'oxlist' );
97  $oRevs->init( 'oxreview' );
98 
99  $sObjectIdWhere = '';
100  if ( is_array( $aIds ) && count( $aIds ) ) {
101  $sObjectIdWhere = "oxreviews.oxobjectid in ( ".implode(", ", oxDb::getInstance()->quoteArray( $aIds ))." )";
102  } elseif ( is_string( $aIds ) && $aIds ) {
103  $sObjectIdWhere = "oxreviews.oxobjectid = ".$oDb->quote( $aIds );
104  } else {
105  return $oRevs;
106  }
107 
108  $iLoadInLang = is_null( $iLoadInLang ) ? (int) oxRegistry::getLang()->getBaseLanguage() : (int) $iLoadInLang;
109 
110  $sSelect = "select oxreviews.* from oxreviews where oxreviews.oxtype = ".$oDb->quote( $sType )." and $sObjectIdWhere and oxreviews.oxlang = '$iLoadInLang'";
111 
112  if ( !$blLoadEmpty ) {
113  $sSelect .= ' and oxreviews.oxtext != "" ';
114  }
115 
116  if ( $this->getConfig()->getConfigParam( 'blGBModerate' ) ) {
117  $sSelect .= ' and ( oxreviews.oxactive = "1" ';
118  $sSelect .= ( $oUser = $this->getUser() ) ? 'or oxreviews.oxuserid = ' . $oDb->quote( $oUser->getId() ) . ' )' : ')';
119  }
120 
121  $sSelect .= ' order by oxreviews.oxcreate desc ';
122 
123  $oRevs->selectString( $sSelect );
124 
125  // change date
126  foreach ( $oRevs as $oItem ) {
127  $oItem->oxreviews__oxcreate->convertToFormattedDbDate();
128  $oItem->oxreviews__oxtext->convertToPseudoHtml();
129  }
130 
131  return $oRevs;
132  }
133 
139  public function getObjectType()
140  {
141  return $this->oxreviews__oxtype->value;
142  }
143 
149  public function getObjectId()
150  {
151  return $this->oxreviews__oxobjectid->value;
152  }
153 
154 
155 
156 }