Go to the documentation of this file.00001 <?php
00002
00007 class oxActionList extends oxList
00008 {
00009
00015 protected $_sObjectsInListName = 'oxactions';
00016
00022 public function loadFinishedByCount($iCount)
00023 {
00024 $sViewName = $this->getBaseObject()->getViewName();
00025 $sDate = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime());
00026
00027 $oDb = oxDb::getDb();
00028 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='" . $this->getConfig()->getShopId() . "' and oxactiveto>0 and oxactiveto < " . $oDb->quote($sDate) . "
00029 " . $this->_getUserGroupFilter() . "
00030 order by oxactiveto desc, oxactivefrom desc limit " . (int) $iCount;
00031 $this->selectString($sQ);
00032 $this->_aArray = array_reverse($this->_aArray, true);
00033 }
00034
00040 public function loadFinishedByTimespan($iTimespan)
00041 {
00042 $sViewName = $this->getBaseObject()->getViewName();
00043 $sDateTo = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime());
00044 $sDateFrom = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime() - $iTimespan);
00045 $oDb = oxDb::getDb();
00046 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='" . $this->getConfig()->getShopId() . "' and oxactiveto < " . $oDb->quote($sDateTo) . " and oxactiveto > " . $oDb->quote($sDateFrom) . "
00047 " . $this->_getUserGroupFilter() . "
00048 order by oxactiveto, oxactivefrom";
00049 $this->selectString($sQ);
00050 }
00051
00055 public function loadCurrent()
00056 {
00057 $sViewName = $this->getBaseObject()->getViewName();
00058 $sDate = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime());
00059 $oDb = oxDb::getDb();
00060 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='" . $this->getConfig()->getShopId() . "' and (oxactiveto > " . $oDb->quote($sDate) . " or oxactiveto=0) and oxactivefrom != 0 and oxactivefrom < " . $oDb->quote($sDate) . "
00061 " . $this->_getUserGroupFilter() . "
00062 order by oxactiveto, oxactivefrom";
00063 $this->selectString($sQ);
00064 }
00065
00071 public function loadFutureByCount($iCount)
00072 {
00073 $sViewName = $this->getBaseObject()->getViewName();
00074 $sDate = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime());
00075 $oDb = oxDb::getDb();
00076 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='" . $this->getConfig()->getShopId() . "' and (oxactiveto > " . $oDb->quote($sDate) . " or oxactiveto=0) and oxactivefrom > " . $oDb->quote($sDate) . "
00077 " . $this->_getUserGroupFilter() . "
00078 order by oxactiveto, oxactivefrom limit " . (int) $iCount;
00079 $this->selectString($sQ);
00080 }
00081
00087 public function loadFutureByTimespan($iTimespan)
00088 {
00089 $sViewName = $this->getBaseObject()->getViewName();
00090 $sDate = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime());
00091 $sDateTo = date('Y-m-d H:i:s', oxRegistry::get("oxUtilsDate")->getTime() + $iTimespan);
00092 $oDb = oxDb::getDb();
00093 $sQ = "select * from {$sViewName} where oxtype=2 and oxactive=1 and oxshopid='" . $this->getConfig()->getShopId() . "' and (oxactiveto > " . $oDb->quote($sDate) . " or oxactiveto=0) and oxactivefrom > " . $oDb->quote($sDate) . " and oxactivefrom < " . $oDb->quote($sDateTo) . "
00094 " . $this->_getUserGroupFilter() . "
00095 order by oxactiveto, oxactivefrom";
00096 $this->selectString($sQ);
00097 }
00098
00106 protected function _getUserGroupFilter($oUser = null)
00107 {
00108 $oUser = ($oUser == null) ? $this->getUser() : $oUser;
00109 $sTable = getViewName('oxactions');
00110 $sGroupTable = getViewName('oxgroups');
00111
00112 $aIds = array();
00113
00114 if ($oUser && count($aGroupIds = $oUser->getUserGroups())) {
00115 foreach ($aGroupIds as $oGroup) {
00116 $aIds[] = $oGroup->getId();
00117 }
00118 }
00119
00120 $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';
00121 $sQ = " and (
00122 select
00123 if(EXISTS(select 1 from oxobject2action, $sGroupTable where $sGroupTable.oxid=oxobject2action.oxobjectid and oxobject2action.oxactionid=$sTable.OXID and oxobject2action.oxclass='oxgroups' LIMIT 1),
00124 $sGroupSql,
00125 1)
00126 ) ";
00127
00128 return $sQ;
00129 }
00130
00136 public function areAnyActivePromotions()
00137 {
00138 return (bool) oxDb::getDb()->getOne("select 1 from " . getViewName('oxactions') . " where oxtype=2 and oxactive=1 and oxshopid='" . $this->getConfig()->getShopId() . "' limit 1");
00139 }
00140
00141
00145 public function loadBanners()
00146 {
00147 $oBaseObject = $this->getBaseObject();
00148 $oViewName = $oBaseObject->getViewName();
00149 $sQ = "select * from {$oViewName} where oxtype=3 and " . $oBaseObject->getSqlActiveSnippet()
00150 . " and oxshopid='" . $this->getConfig()->getShopId() . "' " . $this->_getUserGroupFilter()
00151 . " order by oxsort";
00152 $this->selectString($sQ);
00153 }
00154 }