private function saveAndIncrementImpressionCount(Pap_Contexts_Impression $context, Pap_Db_Impression $impression) { $impression = $this->getImpression($impression); if ($context->isUnique()) { $context->debug(' Impression is unique'); $impression->addUniqueCount($context->getCount()); } else { $context->debug(' Impression is not unique'); } $impression->addRawCount($context->getCount()); $impression->save(); Gpf_Plugins_Engine::extensionPoint('Tracker.impression.afterSave', $context); }
public function saveRotatorImpression(Pap_Contexts_Impression $context) { $context->debug('FEATURE BannerRotator: saveRotatorImpression started'); $banner = $context->getBannerObject(); if($banner != null && $context->getParentBannerId() != null){ $banner->setParentBannerId($context->getParentBannerId()); $context->debug(' FEATURE BannerRotator: Saving rotator impression'); $this->saveChildImpression($banner, $context); } else { $context->debug(' FEATURE BannerRotator: Banner is not in rotator, skipping'); } $context->debug('FEATURE BannerRotator: saveRotatorImpression ended'); $context->debug(''); return Gpf_Plugins_Engine::PROCESS_CONTINUE; }
public function saveCommission(Pap_Contexts_Impression $context) { $context->debug(' Impression: CPM commission starting'); $cpmCommission = new Pap_Db_CpmCommission(); $cpmCommission->setUserId($context->getUserObject()->getId()); $cpmCommission->setBannerId($context->getBannerObject()->getId()); try { $context->debug(' Impression: load CPM impression count for user: '******' banner: ' . $context->getBannerObject()->getId()); $cpmCommission->load(); $cpmCommission->setCount($cpmCommission->getCount()+$context->getCount()); $context->debug(' Impression: CPM actual impression count: ' . $cpmCommission->getCount()); if ($cpmCommission->getCount() < self::IMPRESSION_COUNT_PER_COMMISSION) { $cpmCommission->save(); $context->debug(' Impression: CPM actual impression count saved.'); } else { try { while ($cpmCommission->getCount() >= self::IMPRESSION_COUNT_PER_COMMISSION) { $cpmCommission->setCount($cpmCommission->getCount()-self::IMPRESSION_COUNT_PER_COMMISSION); $this->saveCpmTransaction($context); $context->debug(' Impression: CPM commission created'); } } catch (Pap_Tracking_Exception $e) { $context->debug($this->_sys("CPM commissions not defined in campaign %s", $context->getCampaignObject()->getName())); $cpmCommission->setCount($cpmCommission->getCount() % self::IMPRESSION_COUNT_PER_COMMISSION); $context->debug(' Impression: CPM commission not defined, CPM impression count set ' . $cpmCommission->getCount() % self::IMPRESSION_COUNT_PER_COMMISSION); } $cpmCommission->save(); } } catch (Gpf_DbEngine_NoRowException $e) { $cpmCommission->setCount($context->getCount()); $cpmCommission->save(); $context->debug(' Impression: CPM commission not impression count, count set: ' . $context->getCount()); } $context->debug(' Impression: CPM commission ending'); }
/** * @return Pap_Db_Channel * @throws Gpf_Exception */ private function getChannelFromParameter(Pap_Contexts_Impression $context) { $context->debug('Trying to get channel from parameter'); return $this->getChannelById($context, $context->getRequestObject()->getChannelId()); }