/** * @return Pap_Common_Campaign */ public static function createDefaultCampaign($accountId, $campaignName, $campaignId = null, $type = Pap_Common_Campaign::CAMPAIGN_TYPE_PUBLIC) { $campaign = new Pap_Common_Campaign(); if ($campaignId != null) { $campaign->setId($campaignId); } $campaign->setName($campaignName); $campaign->setDateInserted(Gpf_Common_DateUtils::now()); $campaign->setCampaignStatus(Pap_Common_Campaign::CAMPAIGN_STATUS_ACTIVE); $campaign->setCampaignType($type); $campaign->setCookieLifetime(0); $campaign->resetOverwriteCookieToDefault(); $campaign->setAccountId($accountId); $campaign->setIsDefault(); $campaign->save(); self::createDefaultCommissionSettings($campaign); return $campaign; }
protected function checkBeforeSave(Pap_Common_Campaign $row, Gpf_Rpc_Form $form, $operationType) { /** $this->checkCampaignValidity($row, $form, $operationType); */ if($row->getIsDefault() && $row->get('rstatus') <> Pap_Db_Campaign::CAMPAIGN_STATUS_ACTIVE) { throw new Gpf_Exception($this->_("Error, you cannot deactivate Default campaign")); } if($row->get('rstatus') == "") { throw new Gpf_Exception($this->_("You have to specify status of campaign (rstatus field)")); } /* if ($row->getIsDefault() || $row->getCampaignType() == null) { if ($form->existsField('rtype') && $form->getFieldValue('rtype') != Pap_Db_Campaign::CAMPAIGN_TYPE_PUBLIC) { throw new Gpf_Exception($this->_("Type of default campaign must be public")); } } */ if ($row->getDateInserted() == null || $row->getDateInserted() == '') { $row->setDateInserted(Gpf_Common_DateUtils::now()); } if (!$form->existsField('accountid') || $form->getFieldValue('accountid') == '') { $row->set("accountid", Gpf_Session::getAuthUser()->getAccountId()); } return true; }