예제 #1
0
 /**
  * Delete premium associated w/ contribution page.
  *
  * @param int $contributionPageID
  */
 public static function deletePremium($contributionPageID)
 {
     if (!$contributionPageID) {
         return;
     }
     //need to delete entries from civicrm_premiums
     //as well as from civicrm_premiums_product, CRM-4586
     $params = array('entity_id' => $contributionPageID, 'entity_table' => 'civicrm_contribution_page');
     $premium = new CRM_Contribute_DAO_Premium();
     $premium->copyValues($params);
     $premium->find();
     while ($premium->fetch()) {
         //lets delete from civicrm_premiums_product
         $premiumsProduct = new CRM_Contribute_DAO_PremiumsProduct();
         $premiumsProduct->premiums_id = $premium->id;
         $premiumsProduct->delete();
         //now delete premium
         $premium->delete();
     }
 }
예제 #2
0
 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     // we do this in case the user has hit the forward/back button
     $dao = new CRM_Contribute_DAO_Premium();
     $dao->entity_table = 'civicrm_contribution_page';
     $dao->entity_id = $this->_id;
     $dao->find(true);
     $premiumID = $dao->id;
     if ($premiumID) {
         $params['id'] = $premiumID;
     }
     $params['premiums_active'] = CRM_Utils_Array::value('premiums_active', $params, false);
     $params['premiums_display_min_contribution'] = CRM_Utils_Array::value('premiums_display_min_contribution', $params, false);
     $params['entity_table'] = 'civicrm_contribution_page';
     $params['entity_id'] = $this->_id;
     $dao = new CRM_Contribute_DAO_Premium();
     $dao->copyValues($params);
     $dao->save();
 }