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