/** * constructs context instance * It creates debug logger if there are parameters for it * */ protected function __construct() { Gpf_Session::getAuthUser()->setAccountId(Gpf_Db_Account::DEFAULT_ACCOUNT_ID); $this->initDebugLogger(); $cookieObj = new Pap_Tracking_Cookie(); $cookieObj->setLogger($this->getLogger()); }
/** * constructs context instance * It creates debug logger if there are parameters for it * */ protected function __construct() { $this->setActionType($this->getActionTypeConstant()); $this->initDebugLogger(); $this->setRequestObject( new Pap_Tracking_Request() ); $this->setResponseObject( new Pap_Tracking_Response() ); $cookieObj = new Pap_Tracking_Cookie(); $cookieObj->setLogger($this->getLogger()); $this->setCookieObject( $cookieObj ); }
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; }
/** * @return int cookie lifetime in seconds */ public function getCookieLifetime() { return Pap_Tracking_Cookie::computeLifeTimeDaysToSeconds($this->get(Pap_Db_Table_Campaigns::COOKIELIFETIME)); }
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); }
protected function loadCookies(Pap_Db_Visit $visit) { $cookiesArray = array(); $args = explode('||', ltrim($visit->getCookies(), '|'));; foreach ($args as $arg) { $parsedParams = explode('=', $arg); if (count($parsedParams)>=2) { list($argName, $argValue) = $parsedParams; if ($argValue != '') { $cookiesArray[$argName] = urldecode($argValue); } } } $cookies = new Pap_Tracking_Cookie($cookiesArray); try { $this->firstClickCookie = $this->getClickCookie($cookies->getFirstClickCookie()); } catch (Pap_Tracking_Exception $e) { $this->logMessage($e->getMessage()); } try { $this->lastClickCookie = $this->getClickCookie($cookies->getLastClickCookie()); } catch (Pap_Tracking_Exception $e) { $this->logMessage($e->getMessage()); } try { $this->saleCookie = $this->getSaleCookie($cookies->getSaleCookie()); } catch (Pap_Tracking_Exception $e) { $this->logMessage($e->getMessage()); } }
/** * @return int cookie lifetime in seconds OR -1 if is not defined */ public function getCookieLifetime() { if ($this->get(Pap_Db_Table_CommissionGroups::COOKIE_LIFE_TIME) > self::COOKIE_LIFETIME_VALUE_SAME_AS_CAMPAIGN) { return Pap_Tracking_Cookie::computeLifeTimeDaysToSeconds($this->get(Pap_Db_Table_CommissionGroups::COOKIE_LIFE_TIME)); } return self::COOKIE_LIFETIME_VALUE_SAME_AS_CAMPAIGN; }