/**
     * Processes contact us form and sends email to merchant
     *
     * @service contact_us write
     * @param $fields
     */
    public function save(Gpf_Rpc_Params $params) {
        $form = new Gpf_Rpc_Form($params);

        $subject = $this->getFieldValue($form, "subject");
        $text = $this->getFieldValue($form, "text");
        Gpf_Session::getAuthUser()->getPapUserId();

        $user = new Pap_Common_User();
        $user->setPrimaryKeyValue(Gpf_Session::getAuthUser()->getPapUserId());
        try {
        	$user->load();
        } catch (Gpf_DbEngine_NoRowException $e) {
        	$form->setErrorMessage($this->_("User cannot be found"));
        	return $form;
        }

        $mailTemplate = new Pap_Mail_MerchantOnContactUs();
        $mailTemplate->setUser($user);
        $mailTemplate->setEmail($subject, $text);
        $mailTemplate->addRecipient(Pap_Common_User::getMerchantEmail());
        $mailTemplate->setFromEmail($user->getEmail());
        $mailTemplate->setFromName($user->getFirstName()." ".$user->getLastName());
        $mailTemplate->send();

        $form->setInfoMessage($this->_("Email was successfully sent to merchant"));
        return $form;
    }
示例#2
0
 public function getGeneralAffiliateLinkNoRpc($affiliateId = null) {
     if ($affiliateId == null) {
         $affiliateId = Gpf_Session::getAuthUser()->getUserId();
     }
     $affiliate = new Pap_Common_User();
     $affiliate->setId($affiliateId);
     $affiliate->load();
     $mainSiteUrl = Gpf_Settings::get(Pap_Settings::MAIN_SITE_URL);
     return Pap_Tracking_ClickTracker::getInstance()->getClickUrl(null, $affiliate, $mainSiteUrl);
 }
示例#3
0
 /**
  * @service banner read
  */
 public function showPreview(Gpf_Rpc_Params $params) {
     $banner = Pap_Features_RebrandPdfBanner_Banner::create($params);
     $banner->load();
     $form = new Gpf_Rpc_Form($params);
     $user = new Pap_Common_User();
     $user->setId($form->getFieldValue('affiliateId'));
     $user->load();
     $processor = new Pap_Features_RebrandPdfBanner_Pdf_Processor();
     $processor->showBannerByUser($user, $banner);
 }
    private function sendMail(Gpf_Db_MailTemplate $dbTemplate, Gpf_Rpc_Form $form) {
        $user = new Pap_Common_User();
        $user->setId($form->getFieldValue('userid'));
        $user->load();

        $template = new Pap_Mail_MassMailTemplate();
        $template->setTemplateId($dbTemplate->getId());
        $template->setUser($user);
        $template->addRecipient($user->getEmail());
        $template->send();
    }
	/**	 
	 * @param Gpf_Rpc_Form $form
	 * @return Pap_Common_User
	 */
	private function getUser(Gpf_Rpc_Form $form) {
		$user = new Pap_Common_User();
		try {
			$user->setId(Gpf_Session::getAuthUser()->getPapUserId());
			$user->load();
		} catch (Gpf_Exception $e) {
			$form->setErrorMessage($e->getMessage());
			return null;
		}
		return $user;
	}
示例#6
0
 public function getAttributes() {
     $ret = parent::getAttributes();
     if ($this->isLogged()) {
         $user = new Pap_Common_User();
         $user->setId($this->getPapUserId());
         $user->load();
         for ($i=1; $i<=25; $i++) {
             $ret['data'.$i] = $user->get('data'.$i);
         }
         $ret[Pap_Db_Table_Users::PARENTUSERID] = $user->getParentUserId();
     }
     return $ret;
 }
	private function loginFromSession($session){
		Gpf_Session::create(null, $session);
		$papAlertData = new Pap_Alert_Data();
		$papAlertData->computeTimeOffset();

		$this->user = new Pap_Common_User();
		try {
			$this->user->setId(Gpf_Session::getAuthUser()->getPapUserId());
		} catch (Exception $e) {
			throw new Gpf_Rpc_SessionExpiredException();
		}
		$this->user->load();
		$this->initializeApplication();
	}
示例#8
0
	public function authenticate($username, $password) {
		try {
			$userId = $this->findUserId($username, $password);
			$this->user = new Pap_Common_User();
			$this->user->setId($userId);
			$this->user->load();

			Gpf_Session::create(new Pap_Tracking_ModuleBase());
			$this->computeTimeOffset();

		} catch (Gpf_Exception $e) {
			Gpf_Log::warning($e->getMessage());
			$this->user = null;
		}
	}
示例#9
0
 /**
  * @throws Gpf_DbEngine_NoRowException
  * @param $userId
  * @return Pap_Common_User
  */
 public static function getUserById($userId)
 {
     $user = new Pap_Common_User();
     $user->setId($userId);
     $user->load();
     return $user;
 }
 /**
  *
  * @param $affId
  * @return Pap_Common_User
  */
 private function loadAffiliate($affId) {
     $affUser = new Pap_Common_User();
     $affUser->setId($affId);
     $affUser->load();
     return $affUser;
 }
    private function getCommissionTypeAndValue($campaignId, $userId, $commissionTypeId, $tier = null) {
        if (is_null($tier) || $tier == '') {
            $tier = 1;
        }

        // getting user
        if($userId == '') {
            $this->errorMsg = $this->_("User is not valid!");
            return false;
        }
        $user = new Pap_Common_User();
        $user->setPrimaryKeyValue($userId);
        try {
            $user->load();
        } catch (Gpf_DbEngine_NoRowException $e) {
            $this->errorMsg = $this->_("User is not valid!");
            return false;
        }

        // getting campaign
        $campaign = new Pap_Common_Campaign();
        $campaign->setId($campaignId);
        try {
            $campaign->load();
        } catch (Gpf_DbEngine_NoRowException $e) {
            $this->errorMsg = $this->_("Campaign is not valid!");
            return false;
        }
        // getting commission type
        try {
            $commissionType = new Pap_Db_CommissionType();
            $commissionType->setId($commissionTypeId);
            $commissionType->setStatus(Pap_Db_CommissionType::STATUS_ENABLED);
            $commissionType->loadFromData();
        } catch (Gpf_DbEngine_NoRowException $e) {
            $this->errorMsg = $this->_("Transaction type is not valid or doesn't exist in this campaign!");
            return false;
        }
        $fixedcostType = $commissionType->getFixedcostType();
        $fixedcostValue = $commissionType->getFixedcostValue();
        // getting commission group
        $commGroupId = $campaign->getCommissionGroupForUser($userId);
        if($commGroupId == false) {
            $this->errorMsg = $this->_("Cannot recognize commission group for this user in campaign!");
            return false;
        }

        $rsCommissions = $campaign->getCommissionsCollection($commGroupId, $commissionType->getId());
        $commType = null;
        $commValue = null;
        foreach($rsCommissions as $record) {
            if($record->get('tier') == $tier && $record->get('subtype') == 'N') {
                $commType = $record->get('commissiontype');
                $commValue = $record->get('commissionvalue');
                break;
            }
        }

        if($commType == null) {
            $this->errorMsg = $this->_("Error getting commission settings!");
            return false;
        }

        return array('type' => $commType, 'value' => $commValue, 'fixedcostValue' => $fixedcostValue, 'fixedcostType' => $fixedcostType);
    }
 protected function getUserById($userId) {
     $user = new Pap_Common_User();
     $user->setId($userId);
     $user->load();
     return $user;
 }
 private function isExistsUser($userId) {
     $user = new Pap_Common_User();
     $user->setId($userId);
     try {
         $user->load();
         return true;
     } catch (Gpf_DbEngine_NoRowException $e) {
         return false;
     }
 }
示例#14
0
 /**
  * @throws Gpf_DbEngine_NoRowException
  */
 private function getUser() {
     $user = new Pap_Common_User();
     $user->setId(Gpf_Session::getAuthUser()->getPapUserId());
     $user->load();
     return $user;
 }
示例#15
0
	/**
	 * gets user by user id
	 * @param $userId
	 * @return Pap_Common_User
	 */
	protected function getUserById($context, $id) {
		if($id == '') {
			return null;
		}

		// try to get user by userid
		$user = new Pap_Common_User();
		$user->setPrimaryKeyValue($id);
		try {
			$user->load();
			if($user->getStatus() == Pap_Common_Constants::STATUS_DECLINED) {
				$context->debug("    User with UserId: $id found, but he is declined. We'll not use him.");
				return null;
			}

			$context->debug("    User with UserId: $id found and valid (approved or pending)");
			return $user;
		} catch (Gpf_DbEngine_NoRowException $e) {
			$context->debug("    User with UserId: $id doesn't exist");
			return null;
		}
	}
示例#16
0
 protected function processAccountIdAndVisitorId(Pap_Tracking_ActionTracker $saleTracker, $cookie) {
     parent::processAccountIdAndVisitorId($saleTracker, $cookie);
     if (Gpf_Settings::get(PayPal_Config::APPROVE_AFFILIATE) == Gpf::YES) {
         $this->debug('Automatic approval of affiliates with sale is enabled');
         $userId = $this->computeAffiliateId($saleTracker->getVisitorId(), $saleTracker->getAccountId());
         try {
             $affiliate = new Pap_Common_User();
             $affiliate->setId($userId);
             $affiliate->load();
             if ($affiliate->getStatus() == Pap_Common_Constants::STATUS_PENDING) {
                 $affiliate->setStatus(Pap_Common_Constants::STATUS_APPROVED);
                 $affiliate->update();
             }
         } catch (Gpf_Exception $e) {
             $this->debug('Error occured during approving affiliate with id=' . $userId);
         }
     }
 }
示例#17
0
 public function loadUser($userId) {
     $this->user = new Pap_Common_User();
     $this->user->setId(Gpf_Session::getAuthUser()->getPapUserId());
     $this->user->load();
     return $this->user;
 }
	/**
	 * @param Gpf_Data_Row $row
	 */
	private function addVATData(Gpf_Data_Row $row) {
	    try {
            $user = new Pap_Common_User();
            $user->setId($row->get('userid'));
            $user->load();
	    } catch (Gpf_Exception $e) {
            $row->add('vat', $this->_('N/A'));
            $row->add('amounttopay', $this->_('N/A'));
            return;
        }

        $currency = Pap_Common_Utils_CurrencyUtils::getDefaultCurrency();

        $payout = new Pap_Common_Payout($user, $currency, $row->get(Pap_Db_Table_Transactions::COMMISSION), null);

        if (!$payout->getApplyVat()) {
            $row->add('vat', $this->_('N/A'));
            $row->add('amounttopay', $row->get(Pap_Db_Table_Transactions::COMMISSION));
            return;
        }
        $row->add('vat', $payout->getVatPercentage() . ' %');
        $row->add('amounttopay', $payout->getAmountWithVat());
	}
示例#19
0
	/**
	 * @return Pap_Common_User or null
	 */
	public function getChosenUser($chosenUserId) {
		$user = new Pap_Common_User();
		$user->setId($chosenUserId);
		try {
			$user->load();
			return $user;
		} catch (Gpf_Exception $e) {
			return null;
		}
	}
示例#20
0
 private function getParentWhoReachedCondition($userId, array $reachedConditionUserIds) {
     $user = new Pap_Common_User();
     $user->setId($userId);
     $user->load();
     if (is_null($user->getParentUserId()) || $user->getParentUserId() == '') {
         return null;
     }
     if (in_array($user->getParentUserId(), $reachedConditionUserIds)) {
         return $user->getParentUserId();
     }
     return $this->getParentWhoReachedCondition($user->getParentUserId(), $reachedConditionUserIds);
 }