/**
	 * @param String_type $attributeName
	 * @param String $defaultValue
	 * @return String
	 */
	private function getSettingWithDefaultValue($attributeName, $defaultValue) {
		try {
			return Gpf_Db_Table_UserAttributes::getSetting($attributeName, $this->user->getAccountUserId());
		} catch (Gpf_DbEngine_NoRowException $e) {
		}
		return $defaultValue;
	}
 /**
  * @service banner read
  * @param $bannerId
  * @return Gpf_Rpc_Action
  */
 public function check(Gpf_Rpc_Params $params) {
     $response = new Gpf_Rpc_Action($params);
     $bannerFactory = new Pap_Common_Banner_Factory();
     $site = $bannerFactory->getBanner($params->get('id'));
     $site->setDestinationUrl(rtrim($params->get('url'), "/\\").'/');
     
     $response->setInfoMessage('Site replication .htaccess is working at this location');
     $response->setErrorMessage('Site replication .htaccess is not set up at this location or it is not working correctly. Please make sure that you have mod_rewrite and mod_proxy enabled in your Apache configuration');
     
     $testUser = new Pap_Common_User();
     $testUser->setRefId(Pap_Features_SiteReplication_Replicator::TEST_STRING);
     $request = new Gpf_Net_Http_Request();
     $request->setUrl($site->getUrl($testUser).Pap_Features_SiteReplication_Replicator::TEST_STRING);
     $httpClient = new Gpf_Net_Http_Client();
     try {
         $testResponse = $httpClient->execute($request);
         if ($testResponse->getBody() == Pap_Features_SiteReplication_Replicator::TEST_RESPONSE) {
             $response->addOk();
         } else {
             $response->addError();                
         }
     } catch (Gpf_Exception $e) {
         $response->addError();
     }
     
     return $response;
 }
示例#3
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;
		}
	}
示例#4
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);
 }
示例#5
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();
    }
	protected function addFillBonus(Pap_Common_User $user, $fillCount, $commission) {
		$transaction = new Pap_Common_Transaction();
		$transaction->setCommission($commission);
		$transaction->setType(Pap_Db_Transaction::TYPE_EXTRA_BONUS);
		$transaction->setDateInserted(Gpf_Common_DateUtils::now());
		$transaction->setStatus(Pap_Common_Constants::STATUS_APPROVED);
		$transaction->setPayoutStatus(Pap_Common_Constants::PSTATUS_UNPAID);
		$transaction->setUserId($user->getId());
		$transaction->setSystemNote($this->_('Matrix %sx fill bonus', $fillCount));
		$transaction->insert();
	}
 private function sendMail($templateId, Gpf_Data_Record $userRecord)
 {
     $user = new Pap_Common_User();
     $user->fillFromRecord($userRecord);
     $user->setPassword($userRecord->get('password'));
     $template = new Pap_Mail_MassMailTemplate();
     $template->setTemplateId($templateId);
     $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;
	}
示例#10
0
 private function getBaseCode(Pap_Common_User $user, $fileName = 'hover.php', $flags = '') {
     $url = Gpf_Paths::getInstance()->getFullBaseServerUrl() . "include/Pap/Features/HoverBanner/LyteBox/";
     $code = '<script type="text/javascript" src="'.
     $url . 'lytebox.js"></script>
             <link rel="stylesheet" href="'.
     $url . 'lytebox.css" type="text/css" media="screen" />
             <div id="' . $this->getId() . '" rel="lyteframe" rev="width: {$width}px; height: {$height}px; scrolling: no;" href="'.
     Gpf_Paths::getInstance()->getFullScriptsUrl() . $fileName .
             '?'.Gpf_Settings::get(Pap_Settings::PARAM_NAME_USER_ID).'='.$user->getId().
             '&amp;'.Gpf_Settings::get(Pap_Settings::PARAM_NAME_BANNER_ID).'='.$this->getId() . '"></div>';
     return $this->replaceWidthHeightConstants($code, $flags);
 }
示例#11
0
	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);
		}
	}
示例#12
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;
 }
示例#13
0
 protected function setVariableValues() {
     $this->setVariable(self::AFF_NAME, trim($this->user->getFirstName()) . ' ' . trim($this->user->getLastName()));
     $this->setVariable(self::AFF_REFID, trim($this->user->getRefId()));
     $this->setVariable(self::AFF_EMAIL, trim($this->user->getEmail()));
     $this->setVariable(self::AFF_IP, Gpf_Http::getRemoteIp());
     
     $this->setVariable(AutoResponsePlus_Config::NAME, $this->getSettingForSubject(AutoResponsePlus_Config::NAME));
     $this->setVariable(AutoResponsePlus_Config::PASSWORD, $this->getSettingForSubject(AutoResponsePlus_Config::PASSWORD));
     $this->setVariable(AutoResponsePlus_Config::AUTORESPONDER_ADDRESS, $this->getSettingForSubject(AutoResponsePlus_Config::AUTORESPONDER_ADDRESS));
     $this->setVariable(AutoResponsePlus_Config::HTML, (Gpf_Settings::get(AutoResponsePlus_Config::HTML) == Gpf::YES ? 'html' : 'plain'));
     $this->setVariable(AutoResponsePlus_Config::TRACKING_TAB, $this->getSettingForSubject(AutoResponsePlus_Config::TRACKING_TAB));
     $this->setVariable(AutoResponsePlus_Config::DROP_RULES, (Gpf_Settings::get(AutoResponsePlus_Config::DROP_RULES) == Gpf::YES ? 'yes' : 'no'));
 }
    /**
     * 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;
    }
 /**
  * @return Pap_Common_User
  */
 protected function getUserById($userId) {
     try {
         return Pap_Common_User::getUserById($userId);
     } catch (Gpf_Exception $e) {
         return null;
     }
 }
    private function sendNotificationToMerchant(Pap_Contexts_Signup $context) {
        $context->debug('Sending notification email to merchant started');
        $context->debug('Notification on new affiliate signup email is enabled, sending to address: '.Pap_Common_User::getMerchantEmail());

        $this->sendMerchantNewUserSignupMail($context->getUserObject(), Pap_Common_User::getMerchantEmail());

        $context->debug('Sending notification email to merchant ended');
    }
	private function isAffiliate(){
		$role = $this->user->getRoleId();
		if($role=='pap_merc'){
			return false;
		}else if($role=='pap_aff'){
			return true;
		}
		throw new Exception('Unknown RoleTypeId '.Gpf_Session::getAuthUser()->getUserId());
	}
 public function getSrcCode(Pap_Common_Banner $banner, Pap_Common_User $user, Pap_Db_Channel $channel = null, $data1 = '', $data2 = ''){
     $code = $this->getScriptUrl("imp.php");
     $code .= "?".Pap_Tracking_Request::getAffiliateClickParamName()."=".$user->getRefId();
     $code .= "&amp;".Pap_Tracking_Request::getBannerClickParamName()."=".$banner->getId();
     if ($banner->getParentBannerId() != null) {
         $code .= "&amp;".Pap_Tracking_Request::getRotatorBannerParamName()."=".$banner->getParentBannerId();
     }
     if($channel != null && is_object($channel)) {
         $code .= "&amp;".Pap_Tracking_Request::getChannelParamName()."=".$channel->getValue();
     }
     if($data1 != '') {
         $code .= "&amp;".Pap_Tracking_Request::getExtraDataParamName(1)."=".$data1;
     }
     if($data2 != '') {
         $code .= "&amp;".Pap_Tracking_Request::getExtraDataParamName(2)."=".$data2;
     }
     
     return $code;
 }
 private function sendNotificationToMerchant(Pap_Db_DirectLinkUrl $directLink) {
     $mail = new Pap_Mail_MerchantNewDirectLinkNotification($directLink);
     $mail->loadUser(Gpf_Session::getAuthUser()->getPapUserId());
     $mail->addRecipient(Pap_Common_User::getMerchantEmail());
     try {
         $mail->send();
     } catch (Exception $e) {
     	Gpf_Log::error($this->_('Error sending new direct link notification email to merchant: %s', $e->getMessage()));
     }
 }
示例#20
0
 /**
  * @param boolean $toMerchant
  */
 private function createInvoiceMail($toMerchant) {
     if ($toMerchant) {
         $mailTemplate = new Pap_Mail_MerchantInvoice();
         $mailTemplate->addRecipient(Pap_Common_User::getMerchantEmail());
         $mailTemplate->setFromEmail($this->user->getEmail());
         return $mailTemplate;
     }
     $mailTemplate = new Pap_Mail_AffiliateInvoice();
     $mailTemplate->addRecipient($this->user->getEmail());
     return $mailTemplate;
 }
示例#21
0
 public function getHtaccessCode(Pap_Common_User $user = null) {
     $code  = '# Start Post Affiliate Site Replication Code'."\n";
     $code .= 'RewriteEngine on'."\n\n";
     if ($user == null) {
         $code .= 'RewriteCond %{REQUEST_FILENAME} !-d'."\n";
         $code .= 'RewriteCond %{REQUEST_FILENAME} !-f'."\n";
         $code .= 'RewriteRule ^([^/]+)/(.*) '.Gpf_Paths::getInstance()->getFullScriptsUrl().'page.php?a_aid=$1&a_bid='.$this->getId().'&a_file=$2 [L,P,QSA]'."\n";
         $code .= "\n";
         $code .= 'RewriteCond %{REQUEST_FILENAME} !-d'."\n";
         $code .= 'RewriteCond %{REQUEST_FILENAME} !-f'."\n";
         $code .= 'RewriteRule ^([^/]+) '.Gpf_Paths::getInstance()->getFullScriptsUrl().'page.php?a_aid=$1&a_bid='.$this->getId().'&a_redir=Y [L,P,QSA]'."\n";
     } else {
         $code .= 'RewriteCond %{REQUEST_FILENAME} !-d'."\n";
         $code .= 'RewriteCond %{REQUEST_FILENAME} !-f'."\n";
         $code .= 'RewriteRule ^(.*) '.Gpf_Paths::getInstance()->getFullScriptsUrl().'page.php?a_aid='.$user->getRefId().'&a_bid='.$this->getId().'&a_file=$1 [P,QSA]'."\n";
     }
     $code .= "\n";
     $code .= '# End of Post Affiliate Site Replication Code'."\n";
     return $code;
 }
示例#22
0
    protected function checkUsernameIsUnique(Gpf_Rpc_Form $form, $operationType) {
        $id = null;
        if($operationType == self::EDIT) {
           $id = $this->getId($form);
        }

        if (Pap_Common_User::isUsernameUnique($form->getFieldValue('username'), $id)) {
            return true;
        }

        $form->setErrorMessage($this->_("Username is already used by another user."));
        return false;
    }
示例#23
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;
		}
	}
示例#24
0
 /**
  * @param Pap_Common_User $user
  * @return string
  */
 public function getDescription(Pap_Common_User $user) {
     if ($user->getType() == Pap_Application::ROLETYPE_MERCHANT) {
         $description = $this->get(Pap_Db_Table_Banners::DATA1);
     } else {
         $description = $this->get(Pap_Db_Table_Banners::DATA2);
     }
     
     $description = str_replace('$Affiliate_id', $user->getId(), $description);
     $description = str_replace('$Affiliate_refid', $user->getRefId(), $description);
     $description = str_replace('$Affiliate_name', $user->getName(), $description);
     $description = str_replace('$Affiliate_username', $user->getUserName(), $description);
     
     return $description;
 }
示例#25
0
    public function getUserFieldValue($code) {
        if($this->user == null) {
            throw new Gpf_Exception("You have to set User before getting user fields value!");
        }

        if($code == 'refid') {
            return $this->user->getRefId();
        } else if($code == 'firstname') {
            return $this->user->getFirstName();
        } else if($code == 'lastname') {
            return $this->user->getLastName();
        } else if($code == 'password') {
            return $this->user->getPassword();
        } else if($code == 'username') {
            return $this->user->getUserName();
        } else if($this->isCountryCode($code)){
            return $this->getCountryName($this->user->get($code));
        }
        try {
            return $this->user->get($code);
        } catch (Gpf_Exception $e) {
        }
        return '';
    }
示例#26
0
 	public function setUsernameRefid(Pap_Common_User $user) {
 	    $user->setRefId($user->getUserName());
 	}
   public function saveCommission(Pap_Contexts_Tracking $context, Pap_Common_User $user, Pap_Tracking_Common_Commission $commission) {
        $context->debug('Saving '.$context->getActionType().' commission started');

        $transaction = $context->getTransaction($commission->getTier());
        if ($transaction == null) {
            $transaction = clone $context->getTransaction(1);
            $transaction->setPersistent(false);
            $transaction->generateNewTransactionId();
        }
        if (($parentTransaction = $context->getTransaction($commission->getTier() - 1)) != null) {
            $transaction->setParentTransactionId($parentTransaction->getId());
        }
        if (($channel = $context->getChannelObject()) != null) {
            $transaction->setChannel($channel->getId());
        }

        $transaction->setTier($commission->getTier());
        $transaction->setUserId($user->getId());
        $transaction->setCampaignId($context->getCampaignObject()->getId());
        $transaction->setAccountId($context->getAccountId());

        $banner = $context->getBannerObject();
        if (!is_null($banner)) {
            $transaction->setBannerId($banner->getId());
        }

        if ($user->getStatus() == 'P') {
        	$transaction->setStatus('P');
        	$context->debug('Commission is saved as pending because user state is in pending');
        } else {
            $transaction->setStatus($commission->getStatus());
        }
        $transaction->setPayoutStatus(Pap_Common_Transaction::PAYOUT_UNPAID);
        $transaction->setCommissionTypeId($context->getCommissionTypeObject()->getId());
        $transaction->setCountryCode(($context->getVisit()!=null)?$context->getVisit()->getCountryCode():'');
        $transaction->setType($context->getCommissionTypeObject()->getType());
        $transaction->setCommission($commission->getCommission($context->getRealTotalCost()-$context->getFixedCost()));
        $context->debug('  Computed commission is: '.$transaction->getCommission());
        $transaction->setClickCount(1);
        $transaction->setLogGroupId($context->getLoggerGroupId());

        if ($transaction->getTier() == 1) {
            $transaction->setSaleId($transaction->getId());
        } else {
            $transaction->setSaleId($context->getTransaction(1)->getSaleId());
        }

        //check if we can save zero commission
        if ($transaction->getCommission() == 0 &&
        $context->getCommissionTypeObject()->getSaveZeroCommissions() != Gpf::YES) {
            $context->debug('  Saving of commission transaction was STOPPED. Saving of zero commissions is disabled. Trans id: '.$transaction->getId());
            return Gpf_Plugins_Engine::PROCESS_CONTINUE;
        }


        $transactionCompoundContext = new Pap_Common_TransactionCompoundContext($transaction, $context);
        Gpf_Plugins_Engine::extensionPoint('Tracker.saveCommissions.beforeSaveTransaction', $transactionCompoundContext);
        if (!$transactionCompoundContext->getSaveTransaction()) {
            $context->debug('  Saving of commission transaction was STOPPED by plugin. Trans id: '.$transaction->getId());
            return Gpf_Plugins_Engine::PROCESS_CONTINUE;
        }

        $this->saveTransaction($transaction, $context->getVisitDateTime());
        $context->setTransactionObject($transaction, $commission->getTier());

        $context->debug('    Commission transaction was successfully saved with ID: '.$transaction->getId());
        $context->debug('Saving '.$context->getActionType().' commission ended');
        $context->debug('');

        return Gpf_Plugins_Engine::PROCESS_CONTINUE;
    }
示例#28
0
 function getAffiliateID(){
     return $this->user->getId();
 }
    private function sendMail($templateId, Gpf_Data_Record $userRecord, $filterId, $affiliateId) {
        $user = new Pap_Common_User();
        $user->fillFromRecord($userRecord);

        if ($userRecord->contains(Pap_Mail_MassMailAffiliatesGrid::COLUMN_PASSWORD)) {
            $user->setPassword($userRecord->get(Pap_Mail_MassMailAffiliatesGrid::COLUMN_PASSWORD));
        } else if ($userRecord->contains(Gpf_Db_Table_AuthUsers::PASSWORD)) {
            $user->setPassword($userRecord->get(Gpf_Db_Table_AuthUsers::PASSWORD));
        }

        $template = new Pap_Mail_MassMailTemplate();        

        if ($affiliateId != null && $affiliateId != '') {
            $this->setFromEmailAndName($template, $affiliateId);        
        }
        $template->setTemplateId($templateId);
        $template->setUser($user);
        $template->addRecipient($user->getEmail());
        $template->send();
    }
示例#30
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);
         }
     }
 }