コード例 #1
0
    public static function prepareVisitorAffiliate(Pap_Db_VisitorAffiliate $visitorAffiliate, Pap_Contexts_Tracking $context) {
        $visitorAffiliate->setUserId($context->getUserObject()->getId());

        if ($context->getBannerObject() != null) {
            $visitorAffiliate->setBannerId($context->getBannerObject()->getId());
        } else {
            $visitorAffiliate->setBannerId(null);
        }
        
        if ($context->getChannelObject() != null) {
            $visitorAffiliate->setChannelId($context->getChannelObject()->getId());
        }

        $visitorAffiliate->setCampaignId($context->getCampaignObject()->getId());
        $visitorAffiliate->setIp($context->getIp());
        $visitorAffiliate->setDateVisit($context->getDateCreated());
        $visitorAffiliate->setReferrerUrl($context->getReferrerUrl());
        $visitorAffiliate->setData1($context->getExtraDataFromRequest(1));
        $visitorAffiliate->setData2($context->getExtraDataFromRequest(2));
        $visitorAffiliate->setValidTo(self::getVisitorAffiliateValidity($context, $visitorAffiliate));
    }
コード例 #2
0
    private function getVisitorAffiliate(Pap_Db_VisitorAffiliate $firstClickVisitorAffiliate,
    Pap_Db_VisitorAffiliate $oldVisitorAffiliate = null, Pap_Tracking_Visit_VisitorAffiliateCache $cache,
    Pap_Contexts_Tracking $context) {

        if ($firstClickVisitorAffiliate->getDateVisit() > $context->getDateCreated()) {
            return $firstClickVisitorAffiliate;
        }

        if ($oldVisitorAffiliate == null) {
            $visitorAffiliate = $cache->createVisitorAffiliate($context->getVisitorId());
            $visitorAffiliate->setDateVisit($context->getDateCreated());
            return $visitorAffiliate;
        }

        if ($oldVisitorAffiliate->getDateVisit() < $context->getDateCreated()) {
            return $oldVisitorAffiliate;
        }

        return null;
    }