public function recognize(Pap_Contexts_Action $context) { if ($context->isVisitorAffiliateRecognized()) { return; } if(Gpf_Settings::get(Pap_Settings::TRACK_BY_IP_SETTING_NAME) != Gpf::YES) { return; } $ip = $context->getIp(); $context->debug('Trying to get visitor affiliate from IP address '. $ip); $visitorAffiliate = $this->visitorAffiliateCache->getLatestVisitorAffiliateFromIp($ip, $context->getAccountId()); if ($visitorAffiliate == null) { $context->debug("No visitor affiliate from IP '$ip'"); return; } try { $periodInSeconds = $this->getValidityInSeconds(); } catch (Gpf_Exception $e) { $context->debug($e->getMessage()); return; } $dateFrom = new Gpf_DateTime($context->getVisitDateTime()); $dateFrom->addSecond(-1*$periodInSeconds); $dateVisit = new Gpf_DateTime($visitorAffiliate->getDateVisit()); if ($dateFrom->compare($dateVisit) > 0) { $context->debug(" No click from IP '$ip' found within ip validity period"); return null; } if (!$context->isTrackingMethodSet()) { $context->setTrackingMethod(Pap_Common_Transaction::TRACKING_METHOD_IP_ADDRESS); } $context->debug('Visitor affiliate recognized from IP, id: '.$visitorAffiliate->getId(). ', accountId: '. $visitorAffiliate->getAccountId()); $context->setVisitorAffiliate($visitorAffiliate); }
public function isValid() { $validTo = new Gpf_DateTime($this->get(Gpf_Db_Table_QuickTasks::VALIDTO)); return $validTo->compare(new Gpf_DateTime()) > 0; }