Go to the documentation of this file.00001 <?php
00002
00007 class oxActionList extends oxList
00008 {
00014 protected $_sObjectsInListName = 'oxactions';
00015
00023 public function loadFinishedByCount($iCount)
00024 {
00025 $sViewName = $this->getBaseObject()->getViewName();
00026 $sDate = date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime() );
00027 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='".$this->getConfig()->getShopId()."' and oxactiveto>0 and oxactiveto < ".oxDb::getDb()->quote($sDate)."
00028 ".$this->_getUserGroupFilter()."
00029 order by oxactiveto desc, oxactivefrom desc limit ".(int)$iCount;
00030 $this->selectString( $sQ );
00031 $this->_aArray = array_reverse( $this->_aArray, true );
00032 }
00033
00041 public function loadFinishedByTimespan($iTimespan)
00042 {
00043 $sViewName = $this->getBaseObject()->getViewName();
00044 $sDateTo = date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime() );
00045 $sDateFrom = date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime()-$iTimespan );
00046 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='".$this->getConfig()->getShopId()."' and oxactiveto < ".oxDb::getDb()->quote($sDateTo)." and oxactiveto > ".oxDb::getDb()->quote($sDateFrom)."
00047 ".$this->_getUserGroupFilter()."
00048 order by oxactiveto, oxactivefrom";
00049 $this->selectString( $sQ );
00050 }
00051
00057 public function loadCurrent()
00058 {
00059 $sViewName = $this->getBaseObject()->getViewName();
00060 $sDate = date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime() );
00061 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='".$this->getConfig()->getShopId()."' and (oxactiveto > ".oxDb::getDb()->quote($sDate)." or oxactiveto=0) and oxactivefrom != 0 and oxactivefrom < ".oxDb::getDb()->quote($sDate)."
00062 ".$this->_getUserGroupFilter()."
00063 order by oxactiveto, oxactivefrom";
00064 $this->selectString( $sQ );
00065 }
00066
00074 public function loadFutureByCount($iCount)
00075 {
00076 $sViewName = $this->getBaseObject()->getViewName();
00077 $sDate = date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime() );
00078 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='".$this->getConfig()->getShopId()."' and (oxactiveto > ".oxDb::getDb()->quote($sDate)." or oxactiveto=0) and oxactivefrom > ".oxDb::getDb()->quote($sDate)."
00079 ".$this->_getUserGroupFilter()."
00080 order by oxactiveto, oxactivefrom limit ".(int)$iCount;
00081 $this->selectString( $sQ );
00082 }
00083
00091 public function loadFutureByTimespan($iTimespan)
00092 {
00093 $sViewName = $this->getBaseObject()->getViewName();
00094 $sDate = date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime() );
00095 $sDateTo = date( 'Y-m-d H:i:s', oxUtilsDate::getInstance()->getTime()+$iTimespan );
00096 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='".$this->getConfig()->getShopId()."' and (oxactiveto > ".oxDb::getDb()->quote($sDate)." or oxactiveto=0) and oxactivefrom > ".oxDb::getDb()->quote($sDate)." and oxactivefrom < ".oxDb::getDb()->quote($sDateTo)."
00097 ".$this->_getUserGroupFilter()."
00098 order by oxactiveto, oxactivefrom";
00099 $this->selectString( $sQ );
00100 }
00101
00109 protected function _getUserGroupFilter( $oUser = null )
00110 {
00111 $oUser = ( $oUser == null ) ? $this->getUser() : $oUser;
00112 $sTable = getViewName( 'oxactions' );
00113 $sGroupTable = getViewName( 'oxgroups' );
00114
00115 $aIds = array();
00116
00117 if ( $oUser && count( $aGroupIds = $oUser->getUserGroups() ) ) {
00118 foreach ( $aGroupIds as $oGroup ) {
00119 $aIds[] = $oGroup->getId();
00120 }
00121 }
00122
00123 $sGroupSql = count( $aIds ) ?"EXISTS(select oxobject2action.oxid from oxobject2action where oxobject2action.oxactionid=$sTable.OXID and oxobject2action.oxclass='oxgroups' and oxobject2action.OXOBJECTID in (".implode(', ', oxDb::getInstance()->quoteArray($aIds) ).") )":'0';
00124 $sQ = " and (
00125 select
00126 if(EXISTS(select 1 from oxobject2action, $sGroupTable where $sGroupTable.oxid=oxobject2action.oxobjectid and oxobject2action.oxactionid=$sTable.OXID and oxobject2action.oxclass='oxgroups' LIMIT 1),
00127 $sGroupSql,
00128 1)
00129 ) ";
00130
00131 return $sQ;
00132 }
00133
00139 public function areAnyActivePromotions()
00140 {
00141 return (bool) oxDb::getDb()->getOne("select 1 from ".getViewName( 'oxactions' )." where oxtype=2 and oxactive=1 and oxshopid='".$this->getConfig()->getShopId()."' limit 1");
00142 }
00143
00144
00145
00146
00152 public function loadBanners()
00153 {
00154 $oBaseObject = $this->getBaseObject();
00155 $oViewName = $oBaseObject->getViewName();
00156 $sQ = "select * from {$oViewName} where oxtype=3 and " . $oBaseObject->getSqlActiveSnippet()
00157 . " and oxshopid='" . $this->getConfig()->getShopId() . "' " . $this->_getUserGroupFilter()
00158 . " order by oxsort";
00159 $this->selectString( $sQ );
00160 }
00161 }