/**
     * 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;
        }
    }
Ejemplo n.º 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());
 }
Ejemplo n.º 3
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);
 }
Ejemplo n.º 5
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();
 }
    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');
    }
Ejemplo n.º 7
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();
     }
 }