protected function clearRotatorsWithBanner($banner){ $bannerInRotator = new Pap_Db_BannerInRotator(); $bannerInRotator->setRotatedBannerId($banner->getId()); Pap_Db_Table_CachedBanners::deleteCachedBannersForBanner($banner->getId()); foreach($bannerInRotator->loadCollection() as $bannerInRotatorDelete){ Pap_Db_Table_CachedBanners::deleteCachedBannersForBanner($bannerInRotatorDelete->getParentBannerId()); } }
function parseRotatorBannerDescription() { $row = new Pap_Db_BannerInRotator(); $row->setParentBannerId($this->getId()); $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->addAll(Pap_Db_Table_BannersInRotators::getInstance()); $select->from->add(Pap_Db_Table_BannersInRotators::getName()); $select->where->add(Pap_Db_Table_BannersInRotators::PARENT_BANNER_ID,'=',$this->getId()); $dateCondition = new Gpf_SqlBuilder_CompoundWhereCondition(); $dateCondition->add(Pap_Db_Table_BannersInRotators::VALID_UNTIL,'=',null,'OR',false); $dateCondition->add(Pap_Db_Table_BannersInRotators::VALID_UNTIL,'>',date(self::DATETIME_FORMAT),'OR'); $select->where->addCondition($dateCondition,'AND'); foreach ($select->getAllRows() as $row){ $this->rotatedBanners[] = $row; $this->maxRank+=$row->get(Pap_Db_Table_BannersInRotators::RANK); } }
protected function checkDates(Pap_Db_BannerInRotator $banner){ $from = $this->form->getFieldValue(Pap_Db_Table_BannersInRotators::VALID_FROM); $to = $this->form->getFieldValue(Pap_Db_Table_BannersInRotators::VALID_UNTIL); if ($from == null && $to == null) { throw(new Gpf_Exception($this->_("Rotator banner can not contain same banner twice"))); } $fromDb = $banner->getValidFrom(); $toDb = $banner->getValidUntil(); if ($fromDb == null && $toDb == null) { throw(new Gpf_Exception($this->_("Rotator banner can not contain same banner twice"))); } $dateFrom = new Gpf_DateTime($fromDb); $dateFrom->getClientTime()->toDateTime(); $dateUntil = new Gpf_DateTime($toDb); $dateUntil->getClientTime()->toDateTime(); $errorMsg = "Date is coliding with other date: ".$dateFrom->getClientTime()->toDateTime()." -> ".$dateUntil->getClientTime()->toDateTime(); if ($from == null && $to != null){ if ($to < $fromDb) { return; } throw(new Gpf_Exception($this->_($errorMsg))); } if ($from != null && $to == null){ if ($from > $toDb) { return; } throw(new Gpf_Exception($this->_($errorMsg))); } if ($fromDb == null && $toDb != null){ if ($from > $toDb) { return; } throw(new Gpf_Exception($this->_($errorMsg))); } if ($fromDb != null && $toDb == null){ if ($to < $fromDb) { return; } throw(new Gpf_Exception($this->_($errorMsg))); } if (($from < $fromDb && $to < $fromDb) || ($from > $toDb && $to > $toDb)) { return; } throw(new Gpf_Exception($this->_($errorMsg))); }