oxreview.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxReview extends oxBase
00009 {
00010 
00016     protected $_blDisableShopCheck = true;
00017 
00023     protected $_sClassName = 'oxreview';
00024 
00028     public function __construct()
00029     {
00030         parent::__construct();
00031         $this->init('oxreviews');
00032     }
00033 
00041     public function assign($dbRecord)
00042     {
00043         $blRet = parent::assign($dbRecord);
00044 
00045         if (isset($this->oxreviews__oxuserid) && $this->oxreviews__oxuserid->value) {
00046             $oDb = oxDb::getDb();
00047             $this->oxuser__oxfname = new oxField($oDb->getOne("select oxfname from oxuser where oxid=" . $oDb->quote($this->oxreviews__oxuserid->value)));
00048         }
00049 
00050         return $blRet;
00051     }
00052 
00060     public function load($oxId)
00061     {
00062         if ($blRet = parent::load($oxId)) {
00063             // convert date's to international format
00064             $this->oxreviews__oxcreate->setValue(oxRegistry::get("oxUtilsDate")->formatDBDate($this->oxreviews__oxcreate->value));
00065         }
00066 
00067         return $blRet;
00068     }
00069 
00075     protected function _insert()
00076     {
00077         // set oxcreate
00078         $this->oxreviews__oxcreate = new oxField(date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime()));
00079 
00080         return parent::_insert();
00081     }
00082 
00083 
00094     public function loadList($sType, $aIds, $blLoadEmpty = false, $iLoadInLang = null)
00095     {
00096         $oDb = oxDb::getDb();
00097 
00098         $oRevs = oxNew('oxlist');
00099         $oRevs->init('oxreview');
00100 
00101         $sObjectIdWhere = '';
00102         if (is_array($aIds) && count($aIds)) {
00103             $sObjectIdWhere = "oxreviews.oxobjectid in ( " . implode(", ", oxDb::getInstance()->quoteArray($aIds)) . " )";
00104         } elseif (is_string($aIds) && $aIds) {
00105             $sObjectIdWhere = "oxreviews.oxobjectid = " . $oDb->quote($aIds);
00106         } else {
00107             return $oRevs;
00108         }
00109 
00110         $iLoadInLang = is_null($iLoadInLang) ? (int) oxRegistry::getLang()->getBaseLanguage() : (int) $iLoadInLang;
00111 
00112         $sSelect = "select oxreviews.* from oxreviews where oxreviews.oxtype = " . $oDb->quote($sType) . " and $sObjectIdWhere and oxreviews.oxlang = '$iLoadInLang'";
00113 
00114         if (!$blLoadEmpty) {
00115             $sSelect .= ' and oxreviews.oxtext != "" ';
00116         }
00117 
00118         if ($this->getConfig()->getConfigParam('blGBModerate')) {
00119             $sSelect .= ' and ( oxreviews.oxactive = "1" ';
00120             $sSelect .= ($oUser = $this->getUser()) ? 'or  oxreviews.oxuserid = ' . $oDb->quote($oUser->getId()) . ' )' : ')';
00121         }
00122 
00123         $sSelect .= ' order by oxreviews.oxcreate desc ';
00124 
00125         $oRevs->selectString($sSelect);
00126 
00127         // change date
00128         foreach ($oRevs as $oItem) {
00129             $oItem->oxreviews__oxcreate->convertToFormattedDbDate();
00130             $oItem->oxreviews__oxtext->convertToPseudoHtml();
00131         }
00132 
00133         return $oRevs;
00134     }
00135 
00141     public function getObjectType()
00142     {
00143         return $this->oxreviews__oxtype->value;
00144     }
00145 
00151     public function getObjectId()
00152     {
00153         return $this->oxreviews__oxobjectid->value;
00154     }
00155 
00156 
00157 }