示例#1
0
 /**
  * Update the is_active flag in the db.
  *
  * @param int $id
  *   Id of the database record.
  * @param bool $is_active
  *   Value we want to set the is_active field.
  *
  * @return Object
  *   DAO object on sucess, null otherwise
  */
 public static function setIsActive($id, $is_active)
 {
     if (!$is_active) {
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->product_id = $id;
         $dao->delete();
     }
     return CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Product', $id, 'is_active', $is_active);
 }
示例#2
0
 /**
  * Process the form.
  *
  * @return void
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     $urlParams = 'civicrm/admin/contribute/premium';
     if ($this->_action & CRM_Core_Action::PREVIEW) {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         $single = $session->get('singleForm');
         CRM_Utils_System::redirect($url);
         return;
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->id = $this->_pid;
         $dao->delete();
         CRM_Core_Session::setStatus(ts('Selected Premium Product has been removed from this Contribution Page.'), ts('Saved'), 'success');
         CRM_Utils_System::redirect($url);
     } else {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         if ($this->_pid) {
             $params['id'] = $this->_pid;
         }
         $dao = new CRM_Contribute_DAO_Premium();
         $dao->entity_table = 'civicrm_contribution_page';
         $dao->entity_id = $this->_id;
         $dao->find(TRUE);
         $premiumID = $dao->id;
         $params['premiums_id'] = $premiumID;
         $oldWeight = NULL;
         if ($this->_pid) {
             $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PremiumsProduct', $this->_pid, 'weight', 'id');
         }
         // updateOtherWeights needs to filter on premiums_id
         $filter = array('premiums_id' => $params['premiums_id']);
         $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Contribute_DAO_PremiumsProduct', $oldWeight, $params['weight'], $filter);
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->copyValues($params);
         $dao->save();
         CRM_Utils_System::redirect($url);
     }
 }
 /**
  * Process the form
  *
  * @return void
  * @access public
  */
 public function postProcess()
 {
     // get the submitted form values.
     $params = $this->controller->exportValues($this->_name);
     $urlParams = 'civicrm/admin/contribute/premium';
     if ($this->_action & CRM_Core_Action::PREVIEW) {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         $single = $session->get('singleForm');
         CRM_Utils_System::redirect($url);
         return;
     }
     if ($this->_action & CRM_Core_Action::DELETE) {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->id = $this->_pid;
         $dao->delete();
         CRM_Core_Session::setStatus(ts('Selected Premium Product has been removed from this Contribution Page.'));
         CRM_Utils_System::redirect($url);
     } else {
         $session = CRM_Core_Session::singleton();
         $url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
         if ($this->_pid) {
             $params['id'] = $this->_pid;
         }
         $dao = new CRM_Contribute_DAO_Premium();
         $dao->entity_table = 'civicrm_contribution_page';
         $dao->entity_id = $this->_id;
         $dao->find(TRUE);
         $premiumID = $dao->id;
         $params['premiums_id'] = $premiumID;
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->copyValues($params);
         $dao->save();
         CRM_Utils_System::redirect($url);
     }
 }
示例#4
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();
     }
 }
 /**
  * update the is_active flag in the db
  *
  * @param int      $id        id of the database record
  * @param boolean  $is_active value we want to set the is_active field
  *
  * @return Object             DAO object on sucess, null otherwise
  * @static
  */
 static function setIsActive($id, $is_active)
 {
     if (!$is_active) {
         require_once 'CRM/Contribute/DAO/PremiumsProduct.php';
         $dao = new CRM_Contribute_DAO_PremiumsProduct();
         $dao->product_id = $id;
         $dao->delete();
     }
     return CRM_Core_DAO::setFieldValue('CRM_Contribute_DAO_Product', $id, 'is_active', $is_active);
 }