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
00030 public function loadNews( $iFrom = 0, $iLimit = 10 )
00031 {
00032 if ( $iLimit ) {
00033 $this->setSqlLimit( $iFrom, $iLimit );
00034 }
00035
00036 $sNewsViewName = getViewName( 'oxnews' );
00037 $oBaseObject = $this->getBaseObject();
00038 $sSelectFields = $oBaseObject->getSelectFields();
00039
00040 if ( $oUser = $this->getUser() ) {
00041
00042 $sSelect = "select $sSelectFields from $sNewsViewName ";
00043 $sSelect .= "left join oxobject2group on oxobject2group.oxobjectid=$sNewsViewName.oxid where ";
00044 $sSelect .= "oxobject2group.oxgroupsid in ( select oxgroupsid from oxobject2group where oxobjectid='".$oUser->getId()."' ) or ";
00045 $sSelect .= "( oxobject2group.oxgroupsid is null ) ";
00046 } else {
00047 $sSelect = "select $sSelectFields, oxobject2group.oxgroupsid from $sNewsViewName ";
00048 $sSelect .= "left join oxobject2group on oxobject2group.oxobjectid=$sNewsViewName.oxid where oxobject2group.oxgroupsid is null ";
00049 }
00050
00051 $sSelect .= " and ".$oBaseObject->getSqlActiveSnippet();
00052 $sSelect .= " and $sNewsViewName.oxshortdesc <> '' ";
00053 $sSelect .= " group by $sNewsViewName.oxid order by $sNewsViewName.oxdate desc ";
00054
00055
00056 $this->selectString( $sSelect );
00057 }
00058
00064 public function getCount()
00065 {
00066 $myConfig = $this->getConfig();
00067 $oDb = oxDb::getDb();
00068
00069 $sNewsViewName = getViewName( 'oxnews' );
00070 $oBaseObject = $this->getBaseObject();
00071
00072
00073 if ( $oUser = $this->getUser() ) {
00074
00075 $sSelect = "select COUNT($sNewsViewName.`oxid`) from $sNewsViewName ";
00076 $sSelect .= "left join oxobject2group on oxobject2group.oxobjectid=$sNewsViewName.oxid where ";
00077 $sSelect .= "oxobject2group.oxgroupsid in ( select oxgroupsid from oxobject2group where oxobjectid='".$oUser->getId()."' ) or ";
00078 $sSelect .= "( oxobject2group.oxgroupsid is null ) ";
00079 } else {
00080 $sSelect = "select COUNT($sNewsViewName.`oxid`) from $sNewsViewName ";
00081 $sSelect .= "left join oxobject2group on oxobject2group.oxobjectid=$sNewsViewName.oxid where oxobject2group.oxgroupsid is null ";
00082 }
00083
00084 $sSelect .= " and ".$oBaseObject->getSqlActiveSnippet();
00085
00086
00087 $iRecCnt = (int) $oDb->getOne( $sSelect );
00088
00089 return $iRecCnt;
00090 }
00091
00099 public function setUser( $oUser )
00100 {
00101 $this->_oUser = $oUser;
00102 }
00103
00109 public function getUser()
00110 {
00111 if ( $this->_oUser == null ) {
00112 $this->_oUser = parent::getUser();
00113 }
00114
00115 return $this->_oUser;
00116 }
00117 }