private function isExistsCampaign($campaignId) { $campaign = new Pap_Db_Campaign(); $campaign->setId($campaignId); try { $campaign->load(); } catch (Gpf_DbEngine_NoRowException $e) { return false; } return true; }
private function disableActionCommissionInCampaigns() { $campaign = new Pap_Db_Campaign(); $campaigns = $campaign->loadCollection(); foreach ($campaigns as $campaign) { $commissionType = new Pap_Db_CommissionType(); $commissionType->setCampaignId($campaign->getId()); $commissionType->setType(Pap_Common_Constants::TYPE_ACTION); $commTypeCollection = $commissionType->loadCollection(); foreach ($commTypeCollection as $commTypeRow) { $commTypeRow->setStatus(Pap_Db_CommissionType::STATUS_DISABLED); $commTypeRow->save(); } } }
private function addCpmCommissionToCampaigns() { $campaign = new Pap_Db_Campaign(); $campaigns = $campaign->loadCollection(); foreach ($campaigns as $campaign) { $commissionType = new Pap_Db_CommissionType(); $commissionType->setCampaignId($campaign->getId()); $commissionType->setType(Pap_Common_Constants::TYPE_CPM); try { $commissionType->loadFromData(); } catch (Gpf_DbEngine_NoRowException $e) { $commissionType->setStatus(Pap_Db_CommissionType::STATUS_DISABLED); $commissionType->setRecurrencePresetId(Pap_Db_CommissionType::RECURRENCE_NONE); $commissionType->setApproval(Pap_Db_CommissionType::APPROVAL_AUTOMATIC); $commissionType->setZeroOrdersCommission(Gpf::NO); $commissionType->setSaveZeroCommission(Gpf::NO); $commissionType->insert(); } } }
public static function getDefaultCampaignId($accountId = null) { if ($accountId == null) { $accountId = Gpf_Db_Account::DEFAULT_ACCOUNT_ID; } $campaign = new Pap_Db_Campaign(); $campaign->setAccountId($accountId); $campaign->setIsDefault(); try { $campaign->loadFromData(array(self::ACCOUNTID, self::IS_DEFAULT)); return $campaign->getId(); } catch (Gpf_Exception $e) { } return null; }
function __construct() { parent::__construct(); }
/** * @throws Gpf_Exception */ protected function resolveAccountId($campaignId) { $campaign = new Pap_Db_Campaign(); $campaign->setId($campaignId); try { $campaign->load(); return $campaign->getAccountId(); } catch (Gpf_DbEngine_NoRowException $e) { throw new Gpf_Exception("Can not resolve accountId for campaign '{$campaignId}' in Pap_Db_Banner::resolveAccountId()"); } }
protected function addRow(Gpf_Rpc_Form $form, Gpf_DbEngine_RowBase $row) { $newCampaign = new Pap_Db_Campaign(); $newCampaign->setAccountId($row->get(Pap_Db_Table_Campaigns::ACCOUNTID)); $newCampaign->setIsDefault(); try { $newCampaign->loadFromData(array(Pap_Db_Table_Campaigns::ACCOUNTID,Pap_Db_Table_Campaigns::IS_DEFAULT)); } catch (Gpf_DbEngine_NoRowException $e){ $row->set(Pap_Db_Table_Campaigns::IS_DEFAULT,Gpf::YES); } $row->insert(); }
private function setSplitCommissionsBonus(Pap_Db_Campaign $campaign) { $commissionType = new Pap_Db_CommissionType(); $commissionType->setCampaignId($campaign->getId()); $commissionType->setType(Pap_Common_Constants::TYPE_SALE); $commissionType->loadFromData(array(Pap_Db_Table_CommissionTypes::CAMPAIGNID, Pap_Db_Table_CommissionTypes::TYPE)); $overwriteCookie = $campaign->getOverwriteCookie(); if ($overwriteCookie != Gpf::YES && $overwriteCookie != Gpf::NO) { $overwriteCookie = $this->isGeneralOverwriteAllowed(); } if ($overwriteCookie == Gpf::YES) { $firstClickBonus = 0; $lastClickBonus = 100; } else { $firstClickBonus = 100; $lastClickBonus = 0; } Pap_Db_Table_CommissionTypeAttributes::getInstance()->setCommissionTypeAttributeValue($commissionType->getId(), Pap_Features_SplitCommissions_SplitCommissionsForm::FIRST_AFF_BONUS, $firstClickBonus); Pap_Db_Table_CommissionTypeAttributes::getInstance()->setCommissionTypeAttributeValue($commissionType->getId(), Pap_Features_SplitCommissions_SplitCommissionsForm::LAST_AFF_BONUS, $lastClickBonus); }
private function getAffiliateCount() { $banner = new Pap_Db_Banner(); $banner->setId($this->form->getFieldValue(Pap_Features_Coupon_CreateCoupons::BANNER_ID)); try { $banner->load(); $campaignId = $banner->getCampaignId(); } catch (Gpf_DbEngine_NoRowException $e) { $campaignId = null; } $campaign = new Pap_Db_Campaign(); $campaign->setId($campaignId); try { $campaign->load(); $campaignType = $campaign->getCampaignType(); } catch (Gpf_DbEngine_NoRowException $e) { $campaignType = null; } if ($campaignType != Pap_Db_Campaign::CAMPAIGN_TYPE_PUBLIC) { return Pap_Db_Table_UserInCommissionGroup::getUsersInCommissionGroupCount($campaignId); } return Pap_Db_Table_Users::getInstance()->getAffiliateCount(); }
protected function getCampaign($campaignId) { $campaignObject = new Pap_Db_Campaign(); $campaignObject->setId($campaignId); $campaignObject->load(); return $campaignObject; }
protected function getCommissionGroupId(Gpf_Data_Record $campaignRecord) { $campaign = new Pap_Db_Campaign(); $campaign->fillFromRecord($campaignRecord); $commissionGroupId = $campaign->checkUserIsInCampaign(Gpf_Session::getAuthUser()->getPapUserId()); if ($commissionGroupId != false) { return $commissionGroupId; } return null; }
protected function getAccountIdFromCampaign($campaignId) { $campaign = new Pap_Db_Campaign(); $campaign->setId($campaignId); $campaign->load(); return $campaign->getAccountId(); }
private function addCampaignDetails(Gpf_Data_RecordSet $inputResult) { $inputResult->addColumn('campaigndetails'); $commissionsTable = Pap_Db_Table_Commissions::getInstance(); $allCommissions = $commissionsTable->getAllCommissionsInCampaign(); $campaignCommissions = array(); foreach ($inputResult as $record) { $campaignId = $record->get('campaignid'); if (!array_key_exists($campaignId, $campaignCommissions)) { $campaign = new Pap_Db_Campaign(); $campaign->setId($campaignId); $commissionGroupId = $campaign->checkUserIsInCampaign(Gpf_Session::getAuthUser()->getPapUserId()); if ($commissionGroupId == false) { $commissionGroupId = null; } $campaignCommissions[$campaignId] = $commissionsTable->getCommissionsDescription($campaignId,$allCommissions,$commissionGroupId); } $record->set('campaigndetails', $campaignCommissions[$campaignId]); } return $inputResult; }
protected function init() { $banner = new Pap_Db_Banner(); $banner->setId($this->form->getFieldValue(Pap_Features_Coupon_CreateCoupons::BANNER_ID)); try { $banner->load(); $this->campaignId = $banner->getCampaignId(); } catch (Gpf_DbEngine_NoRowException $e) { $this->campaignId = null; } $campaign = new Pap_Db_Campaign(); $campaign->setId($this->campaignId); try { $campaign->load(); $this->campaignType = $campaign->getCampaignType(); } catch (Gpf_DbEngine_NoRowException $e) { $this->campaignType = null; } }
private function getAffiliateCommissionGroupId($campaignID) { $campaign = new Pap_Db_Campaign(); $campaign->setId($campaignID); $commissionGroupId = $campaign->checkUserIsInCampaign(Gpf_Session::getAuthUser()->getPapUserId()); if ($commissionGroupId != false) { return $commissionGroupId; } return Pap_Db_Table_Commissions::getInstance()->getDefaultCommissionGroup($campaignID); }