oxreview.php

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             // convert date's to international format
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         // set oxcreate
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             foreach ( $aIds as $sId ) {
00101                 if ( $sObjectIdWhere ) {
00102                     $sObjectIdWhere .= ', ';
00103                 }
00104                 $sObjectIdWhere .= $oDb->quote( $sId );
00105             }
00106             $sObjectIdWhere = "oxreviews.oxobjectid in ( $sObjectIdWhere )";
00107         } elseif ( is_string( $aIds ) && $aIds ) {
00108             $sObjectIdWhere = "oxreviews.oxobjectid = ".$oDb->quote( $aIds );
00109         } else {
00110             return $oRevs;
00111         }
00112 
00113         $iLoadInLang = is_null( $iLoadInLang ) ? (int) oxLang::getInstance()->getBaseLanguage() : (int) $iLoadInLang;
00114 
00115         $sType = $oDb->quote( $sType );
00116         $sSelect = "select oxreviews.* from oxreviews where oxreviews.oxtype = $sType and $sObjectIdWhere and oxreviews.oxlang = '$iLoadInLang'";
00117 
00118         if ( !$blLoadEmpty ) {
00119             $sSelect .= ' and oxreviews.oxtext != "" ';
00120         }
00121 
00122         if ( $this->getConfig()->getConfigParam( 'blGBModerate' ) ) {
00123             $sSelect .= ' and ( oxreviews.oxactive = "1" ';
00124             $sSelect .= ( $oUser = $this->getUser() ) ? 'or  oxreviews.oxuserid = "' . $oUser->getId() . '" )' :  ')';
00125         }
00126 
00127         $sSelect .= ' order by oxreviews.oxcreate desc ';
00128 
00129         $oRevs->selectString( $sSelect );
00130 
00131         // change date
00132         foreach ( $oRevs as $oItem ) {
00133             $oItem->oxreviews__oxcreate->convertToFormattedDbDate();
00134             $oItem->oxreviews__oxtext->convertToPseudoHtml();
00135         }
00136 
00137         return $oRevs;
00138     }
00139 }

Generated on Tue Apr 21 15:45:45 2009 for OXID eShop CE by  doxygen 1.5.5