oxnewslist.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxNewslist extends oxList
00009 {
00015     protected $_sObjectsInListName = 'oxnews';
00016 
00020     protected $_oUser = null;
00021 
00030     public function loadNews( $iLimit = 0 )
00031     {
00032         if ( $iLimit ) {
00033             $this->setSqlLimit( 0, $iLimit );
00034         }
00035 
00036         $sNewsViewName = getViewName( 'oxnews' );
00037         $sSelectFields = $this->getBaseObject()->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 ".$this->getBaseObject()->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 Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5