/** * function to add or update either a Personal Campaign Page OR a PCP Block * * @param array $params reference array contains the values submitted by the form * @param bool $pcpBlock if true, create or update PCPBlock, else PCP * @access public * @static * @return object */ static function add(&$params, $pcpBlock = true) { if ($pcpBlock) { // action is taken depending upon the mode require_once 'CRM/Contribute/DAO/PCPBlock.php'; $dao = new CRM_Contribute_DAO_PCPBlock(); $dao->copyValues($params); $dao->save(); return $dao; } else { require_once 'CRM/Contribute/DAO/PCP.php'; $dao = new CRM_Contribute_DAO_PCP(); $dao->copyValues($params); // ensure we set status_id since it is a not null field // we should change the schema and allow this to be null if (!$dao->id && !isset($dao->status_id)) { $dao->status_id = 0; } // set currency for CRM-1496 if (!isset($dao->currency)) { $config =& CRM_Core_Config::singleton(); $dao->currency = $config->defaultCurrency; } $dao->save(); return $dao; } }
/** * Helper function to delete a PCP related stuff viz. Profile, PCP Block Entry * * @param array key value pair * pcpBlockId - id of the PCP Block Id, profileID - id of Supporter Profile * to be deleted * @return boolean true if success, false otherwise * */ function delete($params) { $delete_params = array('id' => $params['profileId']); $resulProfile = civicrm_api('uf_group', 'delete', $delete_params); require_once 'CRM/Contribute/DAO/PCPBlock.php'; $dao = new CRM_Contribute_DAO_PCPBlock(); $dao->id = $params['blockId']; if ($dao->find(TRUE)) { $resultBlock = $dao->delete(); } if ($id = CRM_Utils_Array::value('pcpId', $params)) { require_once 'CRM/Contribute/BAO/PCP.php'; CRM_Contribute_BAO_PCP::delete($id); } if ($resulProfile && $resultBlock) { return TRUE; } return FALSE; }
/** * Process the form when submitted * * @return void * @access public */ public function postProcess() { require_once 'CRM/Core/Transaction.php'; $transaction = new CRM_Core_Transaction(); // first delete the join entries associated with this contribution page require_once 'CRM/Core/DAO/UFJoin.php'; $dao = new CRM_Core_DAO_UFJoin(); $params = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id); $dao->copyValues($params); $dao->delete(); require_once 'CRM/Core/OptionGroup.php'; $groupName = "civicrm_contribution_page.amount.{$this->_id}"; CRM_Core_OptionGroup::deleteAssoc($groupName); //next delete the membership block fields require_once 'CRM/Member/DAO/MembershipBlock.php'; $dao = new CRM_Member_DAO_MembershipBlock(); $dao->entity_table = 'civicrm_contribution_page'; $dao->entity_id = $this->_id; $dao->delete(); //next delete the pcp block fields require_once 'CRM/Contribute/DAO/PCPBlock.php'; $dao = new CRM_Contribute_DAO_PCPBlock(); $dao->entity_table = 'civicrm_contribution_page'; $dao->entity_id = $this->_id; $dao->delete(); // need to delete premiums. CRM-4586 require_once 'CRM/Contribute/BAO/Premium.php'; CRM_Contribute_BAO_Premium::deletePremium($this->_id); // price set cleanup, CRM-5527 require_once 'CRM/Price/BAO/Set.php'; CRM_Price_BAO_Set::removeFrom('civicrm_contribution_page', $this->_id); // finally delete the contribution page require_once 'CRM/Contribute/DAO/ContributionPage.php'; $dao = new CRM_Contribute_DAO_ContributionPage(); $dao->id = $this->_id; $dao->delete(); $transaction->commit(); CRM_Core_Session::setStatus(ts('The contribution page \'%1\' has been deleted.', array(1 => $this->_title))); }
/** * returns the list of fields that can be exported * * @access public * return array */ function &export($prefix = false) { if (!self::$_export) { self::$_export = array(); $fields =& self::fields(); foreach ($fields as $name => $field) { if (CRM_Utils_Array::value('export', $field)) { if ($prefix) { self::$_export['pcp_block'] =& $fields[$name]; } else { self::$_export[$name] =& $fields[$name]; } } } } return self::$_export; }
/** * Process the form * * @return void * @access public */ function postProcess() { // get the submitted form values. $params = $this->controller->exportValues($this->_name); $params['entity_id'] = $this->_id; $params['entity_table'] = 'civicrm_contribution_page'; $dao = new CRM_Contribute_DAO_PCPBlock(); $dao->entity_table = 'civicrm_contribution_page'; $dao->entity_id = $this->_id; $dao->find(true); $params['id'] = $dao->id; $params['is_active'] = CRM_Utils_Array::value('is_active', $params, false); $params['is_approval_needed'] = CRM_Utils_Array::value('is_approval_needed', $params, false); $params['is_tellfriend_enabled'] = CRM_Utils_Array::value('is_tellfriend_enabled', $params, false); require_once 'CRM/Contribute/BAO/PCP.php'; $dao = CRM_Contribute_BAO_PCP::add($params); }