/** * takes an associative array and creates a contribution page object * * @param array $params (reference ) an assoc array of name/value pairs * * @return object CRM_Contribute_DAO_ContributionPage object * @access public * @static */ public static function &create(&$params) { $financialTypeId = NULL; if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) { $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id'); } $dao = new CRM_Contribute_DAO_ContributionPage(); $dao->copyValues($params); $dao->save(); if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) { CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_contribution_page', $params['financial_type_id']); } return $dao; }
/** * Takes an associative array and creates a contribution page object. * * @param array $params * (reference ) an assoc array of name/value pairs. * * @return CRM_Contribute_DAO_ContributionPage */ public static function &create(&$params) { $financialTypeId = NULL; if (!empty($params['id']) && !CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $params['id'], NULL, 1)) { $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $params['id'], 'financial_type_id'); } $hook = empty($params['id']) ? 'create' : 'edit'; CRM_Utils_Hook::pre($hook, 'ContributionPage', CRM_Utils_Array::value('id', $params), $params); $dao = new CRM_Contribute_DAO_ContributionPage(); $dao->copyValues($params); $dao->save(); if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) { CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_contribution_page', $params['financial_type_id']); } CRM_Utils_Hook::post($hook, 'ContributionPage', $dao->id, $dao); return $dao; }
/** * function to add the event * * @param array $params reference array contains the values submitted by the form * * @access public * @static * * @return object */ static function add(&$params) { CRM_Utils_System::flushCache(); $financialTypeId = NULL; if (!empty($params['id'])) { CRM_Utils_Hook::pre('edit', 'Event', $params['id'], $params); if (empty($params['skipFinancialType'])) { $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['id'], 'financial_type_id'); } } else { CRM_Utils_Hook::pre('create', 'Event', NULL, $params); } $event = new CRM_Event_DAO_Event(); $event->copyValues($params); $result = $event->save(); if (!empty($params['id'])) { CRM_Utils_Hook::post('edit', 'Event', $event->id, $event); } else { CRM_Utils_Hook::post('create', 'Event', $event->id, $event); } if ($financialTypeId && !empty($params['financial_type_id']) && $financialTypeId != $params['financial_type_id']) { CRM_Price_BAO_PriceFieldValue::updateFinancialType($params['id'], 'civicrm_event', $params['financial_type_id']); } return $result; }