コード例 #1
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
 protected function signUserToCampaign($userId, $campaignId, Gpf_Rpc_Form $form) {
     $campaign = new Pap_Common_Campaign();
     $campaign->setId($campaignId);
     try {
         $campaign->load();
     } catch (Gpf_Exception $e) {
         Gpf_Log::debug('SignupToCampaignPlugin: Invalid campaign '.$campaignId);
         return false;
     }
     if ($campaign->getCampaignType() == Pap_Common_Campaign::CAMPAIGN_TYPE_PUBLIC) {
         return false;
     }
     $userInCommGroup = new Pap_Db_UserInCommissionGroup();
     
     $user = new pap_common_user();
     $user->setId($userId);
     $user->load();
     if($user->getStatus() == Pap_Common_Constants::STATUS_PENDING){
         $userInCommGroup->addUserToGroup($campaign->getId(), $userId,
         $campaign->getDefaultCommissionGroup(), Pap_Common_Constants::STATUS_APPROVED);
         return true;
     }
     $userInCommGroup->addUserToGroupAndSendNotification($campaign->getId(), $userId,
     $campaign->getDefaultCommissionGroup(), Pap_Common_Constants::STATUS_APPROVED);
     return true;
 }
コード例 #2
0
	private function getUserCommissionGroupFromCache(Pap_Common_Campaign $campaign, $userId) {
		if (isset($this->userCommissionGroup[$campaign->getId()][$userId])) {
			return $this->userCommissionGroup[$campaign->getId()][$userId];
		}
		$userCommissionGroup = $campaign->getCommissionGroupForUser($userId);
		$this->userCommissionGroup[$campaign->getId()][$userId] = $userCommissionGroup;
		return $userCommissionGroup;
	}
コード例 #3
0
    private function updateNullValidTo() {
        $select = new Gpf_SqlBuilder_SelectBuilder();
        $select->select->add('campaignid');
        $select->select->add('cookielifetime');
        $select->from->add(Pap_Db_Table_Campaigns::getName());
        $recordSet = $select->getAllRows();

        foreach ($recordSet as $record) {
            $campaign = new Pap_Common_Campaign();
            $campaign->setId($record->get('campaignid'));
            $campaign->setCookieLifetime($record->get('cookielifetime'));
            $this->updateValidityFor($campaign);
        }
    }
コード例 #4
0
 private function checkCampaign(Pap_Contexts_Tracking $context, Pap_Common_Campaign $campaign) {
     if ($this->isAccountRecognizedNotFromDefault($context) && $campaign->getAccountId() != $context->getAccountId()) {
         $context->debug("Campaign with Id: ".$campaign->getId()." and name '".$campaign->getName()."' cannot be used with accountId: '". $context->getAccountId() ."'!");
         throw new Gpf_Exception("Campaign is from differen account");
     }
     $status = $campaign->getCampaignStatus();
     if($status == Pap_Db_Campaign::CAMPAIGN_STATUS_STOPPED
         || $status == Pap_Db_Campaign::CAMPAIGN_STATUS_STOPPED_INVISIBLE) {
         $context->debug("Campaign with Id: ".$campaign->getId()." and name '".$campaign->getName()."' is stopped, cannot be used!");
         throw new Gpf_Exception("Campaign stopped");
     }
     if($status == Pap_Db_Campaign::CAMPAIGN_STATUS_DELETED) {
         $context->debug("Campaign with Id: ".$campaign->getId()." and name '".$campaign->getName()."' is deleted, cannot be used!");
         throw new Gpf_Exception("Campaign deleted");
     }
 }
コード例 #5
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
    public function firstTimeApproved(Pap_Affiliates_User $user){
        $userInCommision = new Pap_Db_UserInCommissionGroup();

        $selectBuilder = new Gpf_SqlBuilder_SelectBuilder();
        $selectBuilder->select->addAll(Pap_Db_Table_Campaigns::getInstance(), 'ca');
        
        $selectBuilder->from->add('qu_pap_commissiongroups', 'c');
        $selectBuilder->from->addInnerJoin('qu_pap_userincommissiongroup', 'u', 'u.commissiongroupid=c.commissiongroupid');
        $selectBuilder->from->addInnerJoin(Pap_Db_Table_Campaigns::getName(), 'ca', 'ca.'.Pap_Db_Table_Campaigns::ID.'=c.campaignid');
        $selectBuilder->where->add('u.userid','=',$user->getId());
        foreach ($selectBuilder->getAllRowsIterator() as $row){
            $campaign = new Pap_Common_Campaign();
            $campaign->fillFromRecord($row);
            $userInCommision->sendInviteMail($campaign,$user->getId());
        }
    }
コード例 #6
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
 private function setRecognizedParams(Pap_Contexts_Action $context) {
     $context->setUserObject($this->affiliate);
     $context->setBannerObject($this->banner);
     $context->setCampaignObject($this->campaign);
     $context->setAccountId($this->campaign->getAccountId(), Pap_Contexts_Tracking::ACCOUNT_RECOGNIZED_FROM_CAMPAIGN);
     $context->setTrackingMethod(Pap_Common_Transaction::TRACKING_METHOD_COUPON);
     $context->getTransaction()->setCouponId($this->coupon->getId());
     $context->getTransaction()->set(Pap_Db_Table_Transactions::BANNER_ID, $this->banner->getId());
 }
コード例 #7
0
 protected function setVariableValues() {
     parent::setVariableValues();
     $this->setVariable('campaignid', $this->campaign->getId());
     $this->setVariable('campaignname', Gpf_Lang::_localizeRuntime($this->campaign->getName(), $this->getRecipientLanguage()));
     $this->setVariable('campaignstatus', Pap_Common_Constants::getStatusAsText($this->campaign->getCampaignStatus()));
     $this->setVariable('campaigntype', $this->getTypeAsText($this->campaign->getCampaignType()));
     $this->setVariable('campaigndescription', Gpf_Lang::_localizeRuntime($this->campaign->getDescription(), $this->getRecipientLanguage()));
     $this->setVariable('campaignlongdescription', Gpf_Lang::_localizeRuntime($this->campaign->getLongDescription(), $this->getRecipientLanguage()));
 }
コード例 #8
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
	private function saveCpmTransaction(Pap_Contexts_Impression $context) {
	    $campaign = new Pap_Common_Campaign();
	    $campaign->setId($context->getBannerObject()->getCampaignId());
	    $campaign->load();
	    $context->setCampaignObject($campaign);
	    $transaction = new Pap_Common_Transaction();
	    $transaction->setType(Pap_Common_Constants::TYPE_CPM);
	    $context->setTransactionObject($transaction);

	    $commissionType = new Pap_Tracking_Common_RecognizeCommType();
	    $commissionType->process($context);

	    $commissionGroup = new Pap_Tracking_Common_RecognizeCommGroup();
        $commissionGroup->recognize($context);

        $commissionSettings = new Pap_Tracking_Common_RecognizeCommSettings();
        $commissionSettings->recognize($context);

        $saveCommissions = new Pap_Tracking_Common_UpdateAllCommissions();
        $saveCommissions->process($context);
        $saveCommissions->saveChanges();
	}
コード例 #9
0
 public function getLinkingMethod(Pap_Common_Banner $banner = null) {
     if ($banner != null && $banner->getCampaignId() != '') {
         $campaign = new Pap_Common_Campaign();
         $campaign->setId($banner->getCampaignId());
         $campaign->load();
         if ($campaign->getLinkingMethod() != self::LINKMETHOD_DEFAULT_VALUE && 
             $campaign->getLinkingMethod() != null &&
             $campaign->getLinkingMethod() != '') {
             return $campaign->getLinkingMethod();
         }
     }
     return Gpf_Settings::get(Pap_Settings::SETTING_LINKING_METHOD);
 }
コード例 #10
0
 /**
  * @throws Gpf_Exception
  * @return Pap_Db_CommissionType
  */
 protected function getCommissionType($campaignId, $transactionType) {
     $campaign = new Pap_Common_Campaign();
     $campaign->setId($campaignId);
     try {
         $campaign->load();
     } catch (Gpf_Exception $e) {
         throw new Gpf_Exception($this->_('Campaign with Campaign ID: '.$campaignId.' does not exist'));
     }
     return $campaign->getCommissionTypeObject($transactionType);
 }
コード例 #11
0
 private function addUserNoRpc(Gpf_Rpc_Action $action, $campaignId, $userId, $commissionGroupId, $status, $sendNotification = false) {
     try {
         if ($sendNotification) {
             $this->addUserToGroupAndSendNotification($campaignId, $userId, $commissionGroupId, $status);
         } else {
             $this->addUserToGroup($campaignId, $userId, $commissionGroupId, $status);
         }
         Gpf_Plugins_Engine::extensionPoint('PostAffiliate.UserInCommissionGroup.addUser', Pap_Common_Campaign::getCampaignById($campaignId));
         $action->addOk();
     } catch (Exception $e) {
         $action->setErrorMessage($this->_('User is also in this or other commission group for this campaign'));
         $action->addError();
     }
 }
コード例 #12
0
	/**
	 * Returns default commission group in campaign.
	 * If it doesn't exist, function will create & return
	 * new default commission group record.
	 * @param $campaignId
	 */
	public function getDefaultCommissionGroupId($campaignId) {
		if ($campaignId == "") {
			throw new Exception($this->_("Campaign ID cannot be empty!"));
		}
		$campaign = new Pap_Common_Campaign();
		$campaign->setId($campaignId);
		return $campaign->getDefaultCommissionGroup();
	}
コード例 #13
0
    protected function insertCampaignObject($id, $accountId, $name, $description, $dateIns, $status, $productid, $campaignId) {
        $obj = new Pap_Common_Campaign();
        $obj->setId($id);
        $obj->setAccountId($accountId);
        $obj->setName($name);
        $obj->set('description', $description);
        $obj->set('dateinserted', $dateIns);
        $obj->setCampaignStatus($status);

        $publicStatus = $this->getPap3Setting($campaignId, 'Aff_camp_status');

        $obj->setCampaignType(($publicStatus == 1 ? Pap_Db_Campaign::CAMPAIGN_TYPE_PUBLIC : Pap_Db_Campaign::CAMPAIGN_TYPE_ON_INVITATION));
        $obj->set('productid', $productid);
        $obj->resetOverwriteCookieToDefault();
        $obj->save();

        $commGrp = new Pap_Db_CommissionGroup();
        $commGrp->setId($obj->getDefaultCommissionGroup());
        $commGrp->load();
        $commGrp->delete();
    }
コード例 #14
0
ファイル: Impression.php プロジェクト: AmineCherrai/rostanvo
 /**
  * @throws Gpf_Exception
  * @return Pap_Common_Campaign
  */
 protected function getCampaign($campaignId)
 {
     if (!isset($this->campaignCache[$campaignId])) {
         $campaign = new Pap_Common_Campaign();
         $campaign->setId($campaignId);
         $campaign->load();
         $this->campaignCache[$campaignId] = $campaign;
     }
     return $this->campaignCache[$campaignId];
 }
コード例 #15
0
 protected function getCommissionGroupForUser(Pap_Common_Campaign $campaign, $userId) {        
     $groupId = $campaign->getCommissionGroupForUser($userId);        
     return $groupId;
 }
コード例 #16
0
 /**
  * @param $campaignId
  * @return String
  */
 private function getAccountIdFromCampaignId($campaignId) {
     $campaign = Pap_Common_Campaign::getCampaignById($campaignId);
     if ($campaign == null) {
         throw new Gpf_Exception($this->_('Campaign with id %s does not exist.', $campaignId));
     }
     return $campaign->getAccountId();
 }
コード例 #17
0
 /**
  * @return Gpf_Settings_AccountSettings
  */
 protected function createAccountSettings() {
 	$campaign = new Pap_Common_Campaign();
 	$campaign->setId($this->transaction->getCampaignId());
 	try {
 		$campaign->load();
 		return Gpf_Settings::getAccountSettings($campaign->getAccountId());
 	} catch (Gpf_Exception $e) {
 	}
 	return Gpf_Settings::getAccountSettings(Gpf_Db_Account::DEFAULT_ACCOUNT_ID);
 }
コード例 #18
0
ファイル: Main.class.php プロジェクト: AmineCherrai/rostanvo
 private function getMerchantNotificationEmail(Pap_Common_Campaign $campaign) {
     $setting = new Gpf_Db_Setting();
     $setting->setAccountId($campaign->getAccountId());
     $setting->setName(Pap_Settings::MERCHANT_NOTIFICATION_EMAIL);
     try{
         $setting->loadFromData(array(Gpf_Db_Table_Settings::ACCOUNTID, Gpf_Db_Table_Settings::NAME));
         if($setting->getValue() != '') {
             return $setting->getValue();
         }
     } catch (Gpf_Exception $e) {
     }
     return Pap_Common_User::getMerchantEmail();
 }
コード例 #19
0
 public function insertDefaultCommissionType($type) {
     $this->campaign->insertCommissionType($type);
 }
コード例 #20
0
 /**
  * @return Pap_Common_Campaign
  */
 protected function getCampaignById($campaignId) {
     try {
         return Pap_Common_Campaign::getCampaignById($campaignId);
     } catch (Gpf_Exception $e) {
         return null;
     }
 }
コード例 #21
0
 public function isOverwriteEnabled(Pap_Common_Campaign $campaignObject = null, Pap_Common_User $userObject = null) {
     if ($userObject != null) {
         try {
             switch (Gpf_Db_Table_UserAttributes::getSetting(Pap_Settings::OVERWRITE_COOKIE, $userObject->getAccountUserId())) {
                 case GPF::YES: return true;
                 case GPF::NO:  return false;
                 default: break;
             }
         } catch (Gpf_Exception $e) {
         }
     }
     $campaignOverwrite = 'D';
     if($campaignObject != null) {
         $campaignOverwrite = $campaignObject->getOverwriteCookie();
     }
     switch ($campaignOverwrite) {
         case GPF::YES: return true;
         case GPF::NO: return false;
         default: return $this->isGeneralOverwriteAllowed();
     }
 }
コード例 #22
0
 /**
  * @return Pap_Common_Campaign
  */
 protected function createCampaign($campaignId) {
     return Pap_Common_Campaign::getCampaignById($campaignId);
 }
コード例 #23
0
    /**
     * @param String $campaignId
     * @return NULL|Pap_Common_Campaign
     */
    public static function getCampaignById($campaignId) {
        if($campaignId == '') {
            return null;
        }

        $campaign = new Pap_Common_Campaign();
        $campaign->setPrimaryKeyValue($campaignId);
        try {
            $campaign->load();
        } catch (Gpf_DbEngine_NoRowException $e) {
            return null;
        }
        return $campaign;
    }
コード例 #24
0
    /**
     * @return Pap_Common_Campaign
     */
    private function createFirstCampaign() {
        $campaign = new Pap_Common_Campaign();
        $campaign->setId('11111111');
        $campaign->setName('First campaign');
        $campaign->setCampaignStatus(Pap_Common_Campaign::CAMPAIGN_STATUS_ACTIVE);
        $campaign->setCampaignType(Pap_Common_Campaign::CAMPAIGN_TYPE_PUBLIC);
        $campaign->setCookieLifetime(0);
        $campaign->resetOverwriteCookieToDefault();
        $campaign->setAccountId($this->account->getId());
        $campaign->save();

        return $campaign;
    }
コード例 #25
0
 /**
  * @throws Gpf_DbEngine_NoRowException
  * @param $userInCommGroup
  */
 private function sendMail(Pap_Db_UserInCommissionGroup $userInCommGroup) {
 	$mailContext = new Pap_Features_PrivateCampaigns_MailContext();
     $mailContext->setCampaign(Pap_Common_Campaign::getCampaignById(Pap_Db_CommissionGroup::getCommissionGroupById($userInCommGroup->getCommissionGroupId())->getCampaignId()));
     $mailContext->setUser(Pap_Common_User::getUserById($userInCommGroup->getUserId()));
     $mailContext->setUserInCommissionGroup($userInCommGroup);
     Gpf_Plugins_Engine::extensionPoint('PostAffiliate.UserInCommissionGroup.changeStatus', $mailContext);
 }
コード例 #26
0
 protected function getCampaignName($campaignId) {
     $campaign = new Pap_Common_Campaign();
     $campaign->setId($campaignId);
     try {
         $campaign->load();
         return $campaign->getName();
     } catch (Gpf_Exception $e) {
         return '';
     }
 }
コード例 #27
0
    private function createDefaultCommissionSettings(Pap_Common_Campaign $campaign) {
        $commissionGroupId = $campaign->getDefaultCommissionGroup();

        $clickCommTypeId = $campaign->insertCommissionType(Pap_Common_Constants::TYPE_CLICK);
        self::createCommission($commissionGroupId, $clickCommTypeId, 1, '$', 0.5);

        $saleCommTypeId = $campaign->insertCommissionType(Pap_Common_Constants::TYPE_SALE);
        self::createCommission($commissionGroupId, $saleCommTypeId, 1, '%', 30);
        self::createCommission($commissionGroupId, $saleCommTypeId, 2, '%', 10);
    }
 protected function getCampaignById($campaignId) {
     $campaign = new Pap_Common_Campaign();
     $campaign->setId($campaignId);
     $campaign->load();
     return $campaign;
 }