private function getNewNumberRefid() { $codeGenerator = new Gpf_Common_CodeUtils_CodeGenerator('{99999999}'); for ($i = 1; $i <= 5; $i++) { $refid = $codeGenerator->generate(); try { Pap_Affiliates_User::loadFromId($refid); } catch (Gpf_Exception $e) { return $refid; } } }
private function getNewRefid() { $codeGenerator = new Gpf_Common_CodeUtils_CodeGenerator(Gpf_Settings::get(CustomRefid_Config::CUSTOM_REFID_FORMAT)); for ($i = 1; $i <= 5; $i++) { $refid = $codeGenerator->generate(); try { Pap_Affiliates_User::loadFromId($refid); } catch (Gpf_Exception $e) { return $refid; } } }
/** * gets user by user id * @param $userId * @return Pap_Affiliates_User */ protected function getUserById($context, $id) { if($id == '') { return null; } try { return Pap_Affiliates_User::loadFromId($id); } catch (Gpf_Exception $e) { $this->debug($context, "User with RefId/UserId: $id doesn't exist"); return null; } }
public function afterSaveTransactionSendAffiliateNotification(Pap_Common_Transaction $transaction) { if ($transaction->getTier() != '1' || $transaction->getStatus() != Pap_Common_Constants::STATUS_APPROVED || ($transaction->getType() != Pap_Common_Constants::TYPE_SALE && $transaction->getType() != Pap_Common_Constants::TYPE_ACTION)) { return; } $user = Pap_Affiliates_User::loadFromId($transaction->getUserId()); if ($user->getStatus() != Pap_Common_Constants::STATUS_APPROVED || !$this->isUserAutomaticallyRegistered($user)) { return; } if (!$this->isRegistrationEmailSent($user) || (!$this->wasUserLoggedIn($user) && Gpf::YES == Gpf_Settings::get(Pap_Features_AutoRegisteringAffiliates_Config::REGISTRATION_NOTIFICATION_EVERY_SALE))) { Gpf_Log::info('AutoRegisteringAffiliates - afterSaveFirstApprovedTransaction - sendApprovedAffiliateFirstSaleEmail to userid: ' . $user->getId() . ' (' . $user->getUserName() .')' ); $this->sendApprovedAffiliateFirstSaleEmail($user); } }
public function processFillBonus(Pap_Common_User $child) { try { $originalParent = Pap_Affiliates_User::loadFromId($child->getOriginalParentUserId()); } catch (Gpf_Exception $e) { Gpf_Log::debug('Forced Matrix: Cannot load parent: ' . $e->getMessage()); return; } $matrix = $this->createMatrix(); if ($matrix->isFilled($originalParent)) { $matrixFillBonus = new Pap_Features_ForcedMatrix_MatrixFillBonus(); $matrixFillBonus->process($originalParent); } }
/** * @return Pap_Common_User */ public function getUser() { try { return Pap_Affiliates_User::loadFromId($this->getRequestParameter($this->getAffiliateClickParamName())); } catch (Gpf_Exception $e) { return null; } }
protected function loadUserFromId($id) { return Pap_Affiliates_User::loadFromId($id); }
/** * 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); } }
/** * @throws Gpf_Exception * @return Pap_Affiliates_User */ protected function getAffiliate($userID) { return Pap_Affiliates_User::loadFromId($userID); }
private function checkParentUserIsValid($row, Gpf_Rpc_Form $form, $operationType) { if (Gpf_Settings::get(Pap_Settings::NOT_SET_PARENT_AFFILIATE) == Gpf::YES) { $this->setParentUserId($row, ''); return true; } if (!$form->existsField("parentuserid") || $form->getFieldValue("parentuserid") == "") { if (!$form->existsField('cookieParentUserId') || $form->getFieldValue('cookieParentUserId') == '') { return true; } $parentUserId = $form->getFieldValue('cookieParentUserId'); $parentUserIdDoNotValidate = true; } else { $parentUserId = $form->getFieldValue("parentuserid"); $parentUserIdDoNotValidate = $form->existsField("parentUserIdValidate") && $form->getFieldValue("parentUserIdValidate") == "N"; } try { $affiliate = Pap_Affiliates_User::loadFromId($parentUserId); $this->setParentUserId($row, $affiliate->getId()); $this->setOriginalParentUserId($row, $affiliate->getId()); } catch (Gpf_Exception $e) { if ($parentUserIdDoNotValidate) { $this->setParentUserId($row, ''); return true; } else { $form->setErrorMessage($this->_("Selected parent user does not exist")); return false; } } if ($operationType == self::ADD) { return true; } $result = $this->checkForCycle($affiliate, $this->getId($form)); if ($result==false){ $form->setErrorMessage($this->_("Selected parent can not be used!")); } return $result; }
private function loadUser($id) { try { return Pap_Affiliates_User::loadFromId($id); } catch (Gpf_Exception $e) { throw new Gpf_Exception($this->_sys('Error loading user \'%s\'', $id)); } }
/** * @return Pap_Affiliates_User * @throws Gpf_Exception */ protected function getUser($affiliateId) { if (!isset($this->affiliateCache[$affiliateId])) { $this->affiliateCache[$affiliateId] = Pap_Affiliates_User::loadFromId($affiliateId); } return $this->affiliateCache[$affiliateId]; }
public static function fillCachedBanner(Pap_Common_Banner $banner, Pap_Db_CachedBanner $cachedBanner){ if ($cachedBanner->getParentBannerId() != '') { $banner->setParentBannerId($cachedBanner->getParentBannerId()); } $banner->fillCachedBanner($cachedBanner, Pap_Affiliates_User::loadFromId($cachedBanner->getUserId())); if($cachedBanner->getWrapper() == self::URL_VALUE_INNERPAGE){ $cachedBanner->setCode(self::INNERPAGE_BEGIN . $cachedBanner->getCode() . self::INNERPAGE_END); } }
public function beforeSave(Pap_Common_TransactionCompoundContext $transactionCompoundContext){ $user = Pap_Affiliates_User::loadFromId($transactionCompoundContext->getTransaction()->getUserId()); if ($user->getParentUserId() != '') { $transactionCompoundContext->setSaveTransaction(false); } }
/** * returns user object from user ID stored in default affiliate * * @return string */ private function getDefaultAffiliate(Pap_Contexts_Tracking $context) { $context->debug(" Trying to get default affiliate"); if (Gpf_Settings::get(Pap_Settings::SAVE_UNREFERED_SALE_LEAD_SETTING_NAME) != Gpf::YES) { $context->debug(" Save unreferred sale is not enabled"); return null; } $userId = Gpf_Settings::get(Pap_Settings::DEFAULT_AFFILIATE_SETTING_NAME); if($userId == '') { $context->debug(" No default affiliate defined"); return null; } $userObj = Pap_Affiliates_User::loadFromId($userId); if($userObj == null) { return null; } return $userObj; }