public function setSaleCookie(Pap_Contexts_Click $context) { $userObject = $context->getUserObject(); $campaignObject = $context->getCampaignObject(); $channelValue = null; if($context->getChannelObject() != null) { $channelValue = $context->getChannelObject()->getId(); } $campaignId = 0; $lifetime = 0; if($campaignObject != null) { $campaignId = $campaignObject->getId(); } else { $this->debug("No campaign recognized"); } $lifetime = time() + self::getCookieLifetime($context); $cookie = new Pap_Tracking_Cookie_Sale(); $cookie->setAffiliateId($userObject->getId()); $cookie->setCampaignId($campaignId); $cookie->setChannelId($channelValue); $this->setCookie(self::SALE_COOKIE_NAME, $cookie, $lifetime, $this->isOverwriteEnabled($campaignObject, $userObject)); }
/** * * @param $saleCookie * @return Pap_Tracking_Cookie_Sale */ protected function getSaleCookie(Pap_Tracking_Cookie_Sale $saleCookie = null) { if ($saleCookie === null) { return null; } $this->logMessage('Sale cookie not null, affiliateid=' . $saleCookie->getAffiliateId() . ', campaignid=' . $saleCookie->getCampaignId()); if ($this->isClickDataValid($saleCookie->getAffiliateId(), $saleCookie->getCampaignId())) { $this->logMessage('Sale cookie valid, user and campaign exists.'); return $saleCookie; } $this->logMessage('Sale cookie not valid, user or campaign probably does not exists.'); return null; }
/** * @return Pap_Tracking_Cookie_Sale */ public function getClientSaleCookie() { $cookie = new Pap_Tracking_Cookie_Sale(); $cookie->decode($this->getRequestParameter(self::PARAM_ACTION_CLIENT_SALE_COOKIE)); return $cookie; }
protected function setVisitorAndAccount(Pap_Tracking_ActionTracker $saleTracker, $affiliateID, $campaignID, $cookie) { if($affiliateID != '' && $campaignID != '') { try { $saleTracker->setAccountId($this->getAccountIdFromCampaign($campaignID)); } catch (Gpf_Exception $e) { throw new Gpf_Exception('Can not get accountId from campaign, error message:' . $e->getMessage()); } } else { if ($this->isOldCookies($cookie)) { $saleTracker->setCookieValue($cookie); $newVisitorId = $this->generateNewVisitorId(); try { $cookieObj = new Pap_Tracking_Cookie_Sale(); $cookieObj->decode($cookie); $this->fillAccountIdAndVisitorId($saleTracker, $this->getAccountIdFromCampaign($cookieObj->getCampaignId()), $newVisitorId); } catch (Gpf_Exception $e) { $this->debug('Can not get accountId from campaign in old cookie format, error message:' . $e->getMessage() . '. Setting default one.'); $this->fillAccountIdAndVisitorId($saleTracker, Gpf_Db_Account::DEFAULT_ACCOUNT_ID, $newVisitorId); } } else { $this->processAccountIdAndVisitorId($saleTracker, $cookie); } } $this->debug("End registering sale"); }