oxnewslist.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxNewslist extends oxList
00008 {
00014     protected $_sObjectsInListName = 'oxnews';
00015 
00019     protected $_oUser = null;
00020 
00029     public function loadNews( $iLimit = 0 )
00030     {
00031         if ( $iLimit ) {
00032             $this->setSqlLimit( 0, $iLimit );
00033         }
00034 
00035         $sNewsViewName = getViewName( 'oxnews' );
00036         $oBaseObject   = $this->getBaseObject();
00037         $sSelectFields = $oBaseObject->getSelectFields();
00038 
00039         if ( $oUser = $this->getUser() ) {
00040             // performance - only join if user is logged in
00041             $sSelect  = "select $sSelectFields from $sNewsViewName ";
00042             $sSelect .= "left join oxobject2group on oxobject2group.oxobjectid=$sNewsViewName.oxid where ";
00043             $sSelect .= "oxobject2group.oxgroupsid in ( select oxgroupsid from oxobject2group where oxobjectid='".$oUser->getId()."' ) or ";
00044             $sSelect .= "( oxobject2group.oxgroupsid is null ) ";
00045         } else {
00046             $sSelect  = "select $sSelectFields, oxobject2group.oxgroupsid from $sNewsViewName ";
00047             $sSelect .= "left join oxobject2group on oxobject2group.oxobjectid=$sNewsViewName.oxid where oxobject2group.oxgroupsid is null ";
00048         }
00049 
00050         $sSelect .= " and ".$oBaseObject->getSqlActiveSnippet();
00051         $sSelect .= " group by $sNewsViewName.oxid order by $sNewsViewName.oxdate desc ";
00052 
00053         $this->selectString( $sSelect );
00054     }
00055 
00063     public function setUser( $oUser )
00064     {
00065         $this->_oUser = $oUser;
00066     }
00067 
00073     public function getUser()
00074     {
00075         if ( $this->_oUser == null ) {
00076             $this->_oUser = parent::getUser();
00077         }
00078 
00079         return $this->_oUser;
00080     }
00081 }

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