/** * processes match and sets userid, campaign, banner, channel */ protected function fillParametersFromMatch(Pap_Contexts_Click $context, $match) { if($match == null || $match == false || !is_array($match) || count($match) != 5) { $context->debug(" Matching data are in incorrect format"); } $userId = $match['userid']; $url = $match['url']; $channelid = $match['channelid']; $campaignid = $match['campaignid']; $bannerid = $match['bannerid']; $context->debug(" Referrer matched '$url' pattern"); // user if ($userId == '') { $context->debug(" DirectLink affiliate Id is empty stopping"); $context->setDoTrackerSave(false); return; } try { $user = Pap_Affiliates_User::loadFromId($userId); } catch (Gpf_Exception $e) { $context->debug(" DirectLink affiliate with id '$userId' doesn't exist"); $context->setDoTrackerSave(false); return; } $context->debug(" Setting affiliate from referrer URL. Affiliate Id: ".$userId.""); $context->setUserObject($user); // banner $banner = null; try { $bannerFactory = new Pap_Common_Banner_Factory(); $banner = $bannerFactory->getBanner($bannerid); $context->debug("Setting banner from referrer URL. Banner Id: ".$bannerid.""); $context->setBannerObject($banner); } catch (Gpf_Exception $e) { $context->debug("Banner parameter in DirectLink is empty"); } // campaign $campaign = $this->getCampaignById($context, $campaignid); if($campaignid != '' && $campaign != null) { $context->debug(" Setting campaign from DirectLink. Campaign Id: ".$campaignid.""); $context->setCampaignObject($campaign); } else { $context->debug(" Campaign parameter in DirectLink is empty"); } if($banner != null) { $context->debug(" Trying to get campaign from banner"); $campaign = $this->getCampaignFromBanner($context, $banner); } if($campaign == null) { $campaign = $this->getDefaultCampaign($context); } if($campaign != null) { $context->setCampaignObject($campaign); } else { $context->setDoTrackerSave(false); $context->debug(" No default campaign defined"); } // channel $channel = $this->getChannelById($context, $channelid); if($channelid != '' && $channel != null) { $context->debug(" Setting channel from referrer URL. Channel Id: ".$channelid.""); $context->setChannelObject($channel); } else { $context->debug(" Channel parameter in DirectLink is empty"); } // account if ($campaign != null) { $context->setAccountId($campaign->getAccountId(), Pap_Contexts_Tracking::ACCOUNT_RECOGNIZED_FROM_CAMPAIGN); } }