/**
     * gets user by user id
     * @param $userId
     * @return Pap_Affiliates_User
     */
    public function getUserById($context, $id) {
        if($id == '') {
            return null;
        }

        if (isset($this->usersCache[$id])) {
            return $this->usersCache[$id];
        }

        try {
            $this->usersCache[$id] = $this->loadUserFromId($id);
            return $this->usersCache[$id];
        } catch (Gpf_Exception $e) {

            $context->debug("User with RefId/UserId: $id doesn't exist");

            $valueContext = new Gpf_Plugins_ValueContext(null);
            $valueContext->setArray(array($id, $context));

            Gpf_Plugins_Engine::extensionPoint('Tracker.RecognizeAffiliate.getUserById', $valueContext);

            $user = $valueContext->get();

            if (!is_null($user)) {
                $this->usersCache[$id] = $user;
                return $this->usersCache[$id];
            }

            return null;
        }
    }
Пример #2
0
 protected function sendNewUserSignupApprovedMail() {
     $disableApprovalEmailNewUserSignup = new Gpf_Plugins_ValueContext(false);
     $disableApprovalEmailNewUserSignup->setArray(array($this));
     Gpf_Plugins_Engine::extensionPoint('PostAffiliate.affiliate.sendNewUserSignupApprovedMail', $disableApprovalEmailNewUserSignup);
     if ($disableApprovalEmailNewUserSignup->get()) {
         Gpf_Log::debug('Sending NewUserSignupApproved notification to affiliate ended by any feature or plugin. Affiliate '.$this->getId().': '.$this->getName().'.');
         return;
     }
     $signupEmail = new Pap_Signup_SendEmailToUser();
     $signupEmail->sendNewUserSignupApprovedMail($this, $this->getEmail());
 }
Пример #3
0
 public function userStatusChanged(Gpf_Plugins_ValueContext $context) {
     $data = $context->get();
     $user = $data[0];
     $newStatus = $data[1];
     Gpf_Log::info('GetResponse - userStatusChanged started, status:' . $newStatus);
     $this->connect();
     $oldEmail = $this->loadContactEmail($user);
     if($newStatus == Pap_Common_Constants::STATUS_APPROVED && !$this->isSubscribed) {
         $this->signupToGetResponse($user);
         return;
     }
     if($this->isSubscribed) {
         $this->deleteContact($user, $oldEmail);
     }
 }
Пример #4
0
 function getValue($code){
     if($code === self::VAR_AFF_ID){
         return $this->getAffiliateID();
     }else if($code === self::VAR_AFF_SIGN){
         return $this->getAffiliateSignup();
     }else if($code === self::VAR_DEST_URL){
         return $this->getDestURL();
     }else if($code === self::BANNER_ID){
         return $this->banner->getId();
     }
     $valueContext = new Gpf_Plugins_ValueContext($code);
     $valueContext->setArray(array('user' => $this->user));
     Gpf_Plugins_Engine::extensionPoint('PostAffiliate.RebrandPdfBanner_Variables.getValue', $valueContext);
     if ($valueContext->get() != $code) {
         return $valueContext->get();
     }
     return $this->fields->getUserFieldValue($code);
 }
  protected function addFilter(Gpf_SqlBuilder_Filter $filter) {
     switch ($filter->getCode()) {
         case "search":
             $this->addSearch($filter);
             break;
         case "orderId":
             $this->addOrderId($filter);
             break;
         case "channelValue":
         	$this->addChannel($filter);
     }
     
     $context = new Gpf_Plugins_ValueContext('');
     $context->setArray(array(
             'filter' => $filter,
             'whereClause' => $this->_selectBuilder->where
     ));
     Gpf_Plugins_Engine::extensionPoint('PostAffiliate.Pap_Common_Reports_TransactionsGridBase.addFilter', $context);
 }
Пример #6
0
    public function getDefaultCountry(Gpf_Plugins_ValueContext $valueContext) {
        $ip = Gpf_Http::getRemoteIp();
        if (!strlen($ip) || $ip == '127.0.0.1') {
            return;
        }

        try {
            $location = new GeoIp_Location();
            $location->setIpString($ip);
            $location->load();
            $valueContext->set($location->getCountryCode());
        } catch (Exception $e) {
        }
    }
Пример #7
0
 public function replaceBannerConstants($text, Pap_Common_User $user)
 {
     $text = str_replace('{$bannerid}', $this->getId(), $text);
     $valueContext = new Gpf_Plugins_ValueContext($text);
     $valueContext->setArray(array('bannerType' => $this->getBannerType(), 'user' => $user));
     Gpf_Plugins_Engine::extensionPoint('PostAffiliate.Banner.replaceBannerConstants', $valueContext);
     return $valueContext->get();
 }
Пример #8
0
 public function decodeValue(Gpf_Plugins_ValueContext $value) {
     $value->set($this->getEncoder()->decrypt($value->get()));
 }
Пример #9
0
    public function setAffiliateByEmail(Gpf_Plugins_ValueContext $valueContext) {
        $data = $valueContext->getArray();
        $userEmail = $data[0];
        /**
         * @var unknown_type
         */
        $trackingContext = $data[1];

        $valueContext->set($this->createUserFromEmail($userEmail, $trackingContext));
    }
Пример #10
0
 public function getDefaultDataType(Gpf_Plugins_ValueContext $value) {
     $value->set('saleTotalCost');
 }
    public function sendOnChangeStatusNotification() {
        try {
            $user = $this->getUser($this->transaction);
        } catch (Gpf_DbEngine_NoRowException $e) {
            Gpf_Log::error('User with userid=' . $this->transaction->getUserId() . 'can not be loaded and mail can not be send.');
            Gpf_Log::debug('Sending notification to affiliate ended');
            return;
        }
        $isNotify = $this->isNotify($user,
        Pap_Settings::AFF_NOTIFICATION_ON_CHANGE_COMMISSION_STATUS_DEFAULT_SETTING_NAME,
        Pap_Settings::AFF_NOTIFICATION_ON_CHANGE_COMMISSION_STATUS_ENABLED_SETTING_NAME,
            'aff_notification_on_change_comm_status',
        $this->transaction->getStatus(),
        Pap_Settings::AFF_NOTIFICATION_ON_CHANGE_COMMISSION_STATUS_OPTION_STATUS);

        if ($isNotify <> Gpf::YES) {
            Gpf_Log::debug('Sending change status notification to affiliate ended. Affiliate '.$user->getId().': '.$user->getName().' does not have change status notification turned on');
            return;
        }

        if(Gpf_Settings::get(Pap_Settings::NOTIFICATION_ON_COMMISSION_APPROVED) == Gpf::YES && $this->transaction->getStatus() == Pap_Common_Constants::STATUS_APPROVED){
            $this->sendEmail(new Pap_Mail_MerchantOnCommissionApproved(), $user, $this->transaction, $this->getMerchantEmail());
        }

        $disableChangeStatusNotificationEmail = new Gpf_Plugins_ValueContext(false);
        $disableChangeStatusNotificationEmail->setArray(array($user));

        Gpf_Plugins_Engine::extensionPoint('Pap_Tracking_Action_SendTransactionNotificationEmails.sendOnChangeStatusNotificationToAffiliate', $disableChangeStatusNotificationEmail);

        if($disableChangeStatusNotificationEmail->get()) {
            Gpf_Log::debug('Sending change status notification to affiliate ended by any feature or plugin. Affiliate '.$user->getId().': '.$user->getName().'.');
            return;
        }
        $this->sendEmail(new Pap_Mail_AffiliateChangeCommissionStatus(), $user, $this->transaction, $user->getEmail());
        
        Gpf_Log::debug('Sending notification to affiliate ended');
    }
Пример #12
0
 /**
  *
  * @return Gpf_SqlBuilder_WhereClause
  */
 private function getWhereFromContext(Gpf_Plugins_ValueContext $context) {
     $array = $context->getArray();
     return  $array['whereClause'];
 }
Пример #13
0
 /**
  * Schedule mail now to queue and return Outbox object
  *
  */
 public function scheduleNow($sendNow = false, $delayMinutes = 0)
 {
     $outbox = new Gpf_Db_MailOutbox();
     $valueContext = new Gpf_Plugins_ValueContext($delayMinutes);
     $outboxArray = array();
     $outbox->set('mailid', $this->getId());
     $outbox->set('mailaccountid', $this->getMailAccount()->getId());
     $outboxArray[0] = $outbox;
     $valueContext->setArray($outboxArray);
     Gpf_Plugins_Engine::extensionPoint('Gpf_Db_Mail.scheduleNow', $valueContext);
     $outbox->insert();
     if ($sendNow || !$this->isCronRunning()) {
         $outbox->sendNow();
     }
 }
Пример #14
0
 public function getCouponValue(Gpf_Plugins_ValueContext $valueContext) {
     $valueArray = $valueContext->getArray();
     if (substr_count($valueContext->get(), 'couponcode_')) {
         $valueContext->set($this->replaceConstants($valueContext->get() . '}', 'couponcode_', $valueArray['user']->getId()));
     }
 }
Пример #15
0
 public function raiseScheduledTime(Gpf_Plugins_ValueContext $valueContext) {
     $outboxArray = $valueContext->getArray();
     $outbox = $outboxArray[0];
     $outbox->set('scheduled_at', strftime("%Y-%m-%d %H:%M:%S", time() + 60 * $valueContext->get()));
 }