private function updateValidityFor(Pap_Common_Campaign $campaign) { $context = new Pap_Contexts_BackwardCompatibility(); $context->setCampaignObject($campaign); $lifetime = ceil(Pap_Tracking_Cookie::getCookieLifeTimeInDays($context)); $this->updateValidToDate($lifetime, $campaign->getId()); }
/** * @param Pap_Contexts_Tracking $context * @return boolean */ private function isInCookieLifetimeLimit(Pap_Contexts_Tracking $context) { $select = new Gpf_SqlBuilder_SelectBuilder(); $select->select->add(Pap_Db_Table_Transactions::DATE_INSERTED); $select->from->add(Pap_Db_Table_Transactions::getName()); $select->where->add(Pap_Db_Table_Transactions::DATA1, '=', $this->getIdentifier($context)); $select->where->add(Pap_Db_Table_Transactions::R_TYPE, '=', Pap_Db_Transaction::TYPE_SALE); $select->orderBy->add(Pap_Db_Table_Transactions::DATE_INSERTED); $select->limit->set(0, 1); try { $firstSale = $select->getOneRow()->get(Pap_Db_Table_Transactions::DATE_INSERTED); $cookieLifeTime = Pap_Tracking_Cookie::getCookieLifeTimeInDays($context); if (Gpf_Common_DateUtils::getDifference($firstSale, Gpf_Common_DateUtils::getDateTime(time()), 'day') > $cookieLifeTime) { $context->debug(' Transaction is not in cookie limit. Date of first transaction: ' . $firstSale . ' is not in cookie limit: ' . $cookieLifeTime . ' days.'); return false; } } catch (Gpf_DbEngine_NoRowException $e) { } return true; }
public static function getVisitorAffiliateValidity(Pap_Contexts_Tracking $context, Pap_Db_VisitorAffiliate $visitorAffiliate) { return Gpf_Common_DateUtils::addDateUnit($visitorAffiliate->getDateVisit(), Pap_Tracking_Cookie::getCookieLifeTimeInDays($context), Gpf_Common_DateUtils::DAY); }