oxreview.php

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