本文整理汇总了PHP中CRM_Core_BAO_CustomField::getFields方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_CustomField::getFields方法的具体用法?PHP CRM_Core_BAO_CustomField::getFields怎么用?PHP CRM_Core_BAO_CustomField::getFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_CustomField
的用法示例。
在下文中一共展示了CRM_Core_BAO_CustomField::getFields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDateFields
/**
* Get all fields of the type Date
*/
static function getDateFields()
{
$allFields = CRM_Core_BAO_CustomField::getFields('');
$dateFields = array('birth_date' => ts('Birth Date'));
foreach ($allFields as $fieldID => $field) {
if ($field['data_type'] == 'Date') {
$dateFields["custom_{$fieldID}"] = $field['label'];
}
}
return $dateFields;
}
示例2: testGetFields
public function testGetFields()
{
$customGroup = Custom::createGroup(array(), 'Individual');
$fields = array('label' => 'testFld1', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroup->id);
$customField1 = CRM_Core_BAO_CustomField::create($fields);
$customFieldID1 = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', 'Database check for created CustomField.');
$fields = array('label' => 'testFld2', 'data_type' => 'String', 'html_type' => 'Text', 'is_active' => 1, 'custom_group_id' => $customGroup->id);
$customField2 = CRM_Core_BAO_CustomField::create($fields);
$customFieldID2 = $this->assertDBNotNull('CRM_Core_DAO_CustomField', $customGroup->id, 'id', 'custom_group_id', 'Database check for created CustomField.');
$getCustomFields = array();
$getCustomFields = CRM_Core_BAO_CustomField::getFields('Individual', TRUE, TRUE);
//$this->assertEquals( 'testFld1', $getCustomFields[$customFieldID1][0], 'Confirm First Custom field label' );
//$this->assertEquals( 'testFld2', $getCustomFields[$customFieldID2][0], 'Confirm Second Custom field label' );
Custom::deleteGroup($customGroup);
}
示例3: civicrm_api3_pcpteams_create
/**
* File for the CiviCRM APIv3 group functions
*
* @package CiviCRM_APIv3
* @subpackage API_pcpteams
* @copyright CiviCRM LLC (c) 2004-2014
*/
function civicrm_api3_pcpteams_create($params)
{
// since we are allowing html input from the user
// we also need to purify it, so lets clean it up
// $params['pcp_title'] = $pcp['title'];
// $params['pcp_contact_id'] = $pcp['contact_id'];
$htmlFields = array('intro_text', 'page_text', 'title');
foreach ($htmlFields as $field) {
if (!empty($params[$field])) {
$params[$field] = CRM_Utils_String::purifyHTML($params[$field]);
}
}
$entity_table = CRM_PCP_BAO_PCP::getPcpEntityTable($params['page_type']);
$pcpBlock = new CRM_PCP_DAO_PCPBlock();
$pcpBlock->entity_table = $entity_table;
$pcpBlock->entity_id = $params['page_id'];
$pcpBlock->find(TRUE);
$params['pcp_block_id'] = $pcpBlock->id;
$params['goal_amount'] = CRM_Utils_Rule::cleanMoney($params['goal_amount']);
// 1 -> waiting review
// 2 -> active / approved (default for now)
$params['status_id'] = CRM_Utils_Array::value('status_id', $params, 2);
// active by default for now
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 1);
$pcp = CRM_Pcpteams_BAO_PCP::create($params, FALSE);
//Custom Set
$customFields = CRM_Core_BAO_CustomField::getFields('PCP', FALSE, FALSE, NULL, NULL, TRUE);
$isCustomValueSet = FALSE;
foreach ($customFields as $fieldID => $fieldValue) {
list($tableName, $columnName, $cgId) = CRM_Core_BAO_CustomField::getTableColumnGroup($fieldID);
if (!empty($params[$columnName]) || !empty($params["custom_{$fieldID}"])) {
$isCustomValueSet = TRUE;
//FIXME: to find out the custom value exists, set -1 as default now
$params["custom_{$fieldID}_-1"] = !empty($params[$columnName]) ? $params[$columnName] : $params["custom_{$fieldID}"];
}
}
if ($isCustomValueSet) {
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $pcp->id, 'PCP');
CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_pcp', $pcp->id);
}
//end custom set
$values = array();
@_civicrm_api3_object_to_array_unique_fields($pcp, $values[$pcp->id]);
return civicrm_api3_create_success($values, $params, 'Pcpteams', 'create');
}
示例4: postProcess
/**
* Form submission of new/edit contact is processed.
*/
public function postProcess()
{
// check if dedupe button, if so return.
$buttonName = $this->controller->getButtonName();
if ($buttonName == $this->_dedupeButtonName) {
return;
}
//get the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$group = CRM_Utils_Array::value('group', $params);
if (!empty($group) && is_array($group)) {
unset($params['group']);
foreach ($group as $key => $value) {
$params['group'][$value] = 1;
}
}
CRM_Contact_BAO_Contact_Optimizer::edit($params, $this->_preEditValues);
if (!empty($params['image_URL'])) {
CRM_Contact_BAO_Contact::processImageParams($params);
}
if (is_numeric(CRM_Utils_Array::value('current_employer_id', $params)) && !empty($params['current_employer'])) {
$params['current_employer'] = $params['current_employer_id'];
}
// don't carry current_employer_id field,
// since we don't want to directly update DAO object without
// handling related business logic ( eg related membership )
if (isset($params['current_employer_id'])) {
unset($params['current_employer_id']);
}
$params['contact_type'] = $this->_contactType;
if (empty($params['contact_sub_type']) && $this->_isContactSubType) {
$params['contact_sub_type'] = array($this->_contactSubType);
}
if ($this->_contactId) {
$params['contact_id'] = $this->_contactId;
}
//make deceased date null when is_deceased = false
if ($this->_contactType == 'Individual' && !empty($this->_editOptions['Demographics']) && empty($params['is_deceased'])) {
$params['is_deceased'] = FALSE;
$params['deceased_date'] = NULL;
}
if (isset($params['contact_id'])) {
// process membership status for deceased contact
$deceasedParams = array('contact_id' => CRM_Utils_Array::value('contact_id', $params), 'is_deceased' => CRM_Utils_Array::value('is_deceased', $params, FALSE), 'deceased_date' => CRM_Utils_Array::value('deceased_date', $params, NULL));
$updateMembershipMsg = $this->updateMembershipStatus($deceasedParams);
}
// action is taken depending upon the mode
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_Hook::pre('edit', $params['contact_type'], $params['contact_id'], $params);
} else {
CRM_Utils_Hook::pre('create', $params['contact_type'], NULL, $params);
}
$customFields = CRM_Core_BAO_CustomField::getFields($params['contact_type'], FALSE, TRUE);
//CRM-5143
//if subtype is set, send subtype as extend to validate subtype customfield
$customFieldExtends = CRM_Utils_Array::value('contact_sub_type', $params) ? $params['contact_sub_type'] : $params['contact_type'];
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $this->_contactId, $customFieldExtends, TRUE);
if ($this->_contactId && !empty($this->_oldSubtypes)) {
CRM_Contact_BAO_ContactType::deleteCustomSetForSubtypeMigration($this->_contactId, $params['contact_type'], $this->_oldSubtypes, $params['contact_sub_type']);
}
if (array_key_exists('CommunicationPreferences', $this->_editOptions)) {
// this is a chekbox, so mark false if we dont get a POST value
$params['is_opt_out'] = CRM_Utils_Array::value('is_opt_out', $params, FALSE);
}
// process shared contact address.
CRM_Contact_BAO_Contact_Utils::processSharedAddress($params['address']);
if (!array_key_exists('TagsAndGroups', $this->_editOptions) && !empty($params['group'])) {
unset($params['group']);
}
if (!empty($params['contact_id']) && $this->_action & CRM_Core_Action::UPDATE && !empty($params['group'])) {
// figure out which all groups are intended to be removed
$contactGroupList = CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], 'Added');
if (is_array($contactGroupList)) {
foreach ($contactGroupList as $key) {
if ((!array_key_exists($key['group_id'], $params['group']) || $params['group'][$key['group_id']] != 1) && empty($key['is_hidden'])) {
$params['group'][$key['group_id']] = -1;
}
}
}
}
// parse street address, CRM-5450
$parseStatusMsg = NULL;
if ($this->_parseStreetAddress) {
$parseResult = self::parseAddress($params);
$parseStatusMsg = self::parseAddressStatusMsg($parseResult);
}
// Allow un-setting of location info, CRM-5969
$params['updateBlankLocInfo'] = TRUE;
$contact = CRM_Contact_BAO_Contact::create($params, TRUE, FALSE, TRUE);
// status message
if ($this->_contactId) {
$message = ts('%1 has been updated.', array(1 => $contact->display_name));
} else {
$message = ts('%1 has been created.', array(1 => $contact->display_name));
}
// set the contact ID
$this->_contactId = $contact->id;
//.........这里部分代码省略.........
示例5: buildQuickForm
/**
* Build the form
*
* @access public
*
* @return void
*/
function buildQuickForm()
{
$ufGroupId = $this->get('ufGroupId');
if (!$ufGroupId) {
CRM_Core_Error::fatal('ufGroupId is missing');
}
$this->_title = ts('Batch Update for Activities') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
CRM_Utils_System::setTitle($this->_title);
$this->addDefaultButtons(ts('Save'));
$this->_fields = array();
$this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW);
// remove file type field and then limit fields
$suppressFields = FALSE;
$removehtmlTypes = array('File', 'Autocomplete-Select');
foreach ($this->_fields as $name => $field) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) {
$suppressFields = TRUE;
unset($this->_fields[$name]);
}
//fix to reduce size as we are using this field in grid
if (is_array($field['attributes']) && $this->_fields[$name]['attributes']['size'] > 19) {
//shrink class to "form-text-medium"
$this->_fields[$name]['attributes']['size'] = 19;
}
}
$this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
$this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Activities'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->assign('profileTitle', $this->_title);
$this->assign('componentIds', $this->_activityHolderIds);
$fileFieldExists = FALSE;
//load all campaigns.
if (array_key_exists('activity_campaign_id', $this->_fields)) {
$this->_componentCampaigns = array();
CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Activity_DAO_Activity', TRUE, 'campaign_id', 'id', ' id IN (' . implode(' , ', array_values($this->_activityHolderIds)) . ' ) ');
}
$customFields = CRM_Core_BAO_CustomField::getFields('Activity');
foreach ($this->_activityHolderIds as $activityId) {
$typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$customValue = CRM_Utils_Array::value($customFieldID, $customFields);
if (!empty($customValue['extends_entity_column_value'])) {
$entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value']);
}
if (!empty($entityColumnValue[$typeId]) || CRM_Utils_System::isNull($entityColumnValue[$typeId])) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
}
} else {
// handle non custom fields
CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
}
}
}
$this->assign('fields', $this->_fields);
// don't set the status message when form is submitted.
// $buttonName = $this->controller->getButtonName('submit');
if ($suppressFields) {
CRM_Core_Session::setStatus(ts("FILE or Autocomplete Select type field(s) in the selected profile are not supported for Batch Update."), ts("Some fields have been excluded"), "info");
}
$this->addDefaultButtons(ts('Update Activities'));
}
示例6: validate
/**
* @return bool
*/
public function validate()
{
if (CRM_Utils_System::isNull($this->_value)) {
return TRUE;
}
switch ($this->_name) {
case 'contact_id':
// note: we validate extistence of the contact in API, upon
// insert (it would be too costlty to do a db call here)
return CRM_Utils_Rule::integer($this->_value);
case 'register_date':
return CRM_Utils_Rule::date($this->_value);
/* @codingStandardsIgnoreStart
case 'event_id':
static $events = null;
if (!$events) {
$events = CRM_Event_PseudoConstant::event();
}
if (in_array($this->_value, $events)) {
return true;
}
else {
return false;
}
break;
@codingStandardsIgnoreEnd */
/* @codingStandardsIgnoreStart
case 'event_id':
static $events = null;
if (!$events) {
$events = CRM_Event_PseudoConstant::event();
}
if (in_array($this->_value, $events)) {
return true;
}
else {
return false;
}
break;
@codingStandardsIgnoreEnd */
default:
break;
}
// check whether that's a valid custom field id
// and if so, check the contents' validity
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($this->_name)) {
static $customFields = NULL;
if (!$customFields) {
$customFields = CRM_Core_BAO_CustomField::getFields('Participant');
}
if (!array_key_exists($customFieldID, $customFields)) {
return FALSE;
}
return CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $this->_value);
}
return TRUE;
}
示例7: membership_format_params
/**
* @deprecated - this function formats params according to v2 standards but
* need to be sure about the impact of not calling it so retaining on the import class
* take the input parameter list as specified in the data model and
* convert it into the same format that we use in QF and BAO object
*
* @param array $params Associative array of property name/value
* pairs to insert in new contact.
* @param array $values The reformatted properties that we can use internally
*
* @param array $create Is the formatted Values array going to
* be used for CRM_Member_BAO_Membership:create()
*
* @return array|error
* @access public
*/
function membership_format_params($params, &$values, $create = FALSE)
{
require_once 'api/v3/utils.php';
$fields = CRM_Member_DAO_Membership::fields();
_civicrm_api3_store_values($fields, $params, $values);
$customFields = CRM_Core_BAO_CustomField::getFields('Membership');
foreach ($params as $key => $value) {
// ignore empty values or empty arrays etc
if (CRM_Utils_System::isNull($value)) {
continue;
}
//Handling Custom Data
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
$values[$key] = $value;
$type = $customFields[$customFieldID]['html_type'];
if ($type == 'CheckBox' || $type == 'Multi-Select' || $type == 'AdvMulti-Select') {
$mulValues = explode(',', $value);
$customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, true);
$values[$key] = array();
foreach ($mulValues as $v1) {
foreach ($customOption as $customValueID => $customLabel) {
$customValue = $customLabel['value'];
if (strtolower($customLabel['label']) == strtolower(trim($v1)) || strtolower($customValue) == strtolower(trim($v1))) {
if ($type == 'CheckBox') {
$values[$key][$customValue] = 1;
} else {
$values[$key][] = $customValue;
}
}
}
}
}
}
switch ($key) {
case 'membership_contact_id':
if (!CRM_Utils_Rule::integer($value)) {
throw new Exception("contact_id not valid: {$value}");
}
$dao = new CRM_Core_DAO();
$qParams = array();
$svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = {$value}", $qParams);
if (!$svq) {
throw new Exception("Invalid Contact ID: There is no contact record with contact_id = {$value}.");
}
$values['contact_id'] = $values['membership_contact_id'];
unset($values['membership_contact_id']);
break;
case 'membership_type_id':
if (!CRM_Utils_Array::value($value, CRM_Member_PseudoConstant::membershipType())) {
throw new Exception('Invalid Membership Type Id');
}
$values[$key] = $value;
break;
case 'membership_type':
$membershipTypeId = CRM_Utils_Array::key(ucfirst($value), CRM_Member_PseudoConstant::membershipType());
if ($membershipTypeId) {
if (CRM_Utils_Array::value('membership_type_id', $values) && $membershipTypeId != $values['membership_type_id']) {
throw new Exception('Mismatched membership Type and Membership Type Id');
}
} else {
throw new Exception('Invalid Membership Type');
}
$values['membership_type_id'] = $membershipTypeId;
break;
case 'status_id':
if (!CRM_Utils_Array::value($value, CRM_Member_PseudoConstant::membershipStatus())) {
throw new Exception('Invalid Membership Status Id');
}
$values[$key] = $value;
break;
case 'membership_status':
$membershipStatusId = CRM_Utils_Array::key(ucfirst($value), CRM_Member_PseudoConstant::membershipStatus());
if ($membershipStatusId) {
if (CRM_Utils_Array::value('status_id', $values) && $membershipStatusId != $values['status_id']) {
throw new Exception('Mismatched membership Status and Membership Status Id');
}
} else {
throw new Exception('Invalid Membership Status');
}
$values['status_id'] = $membershipStatusId;
break;
default:
break;
}
//.........这里部分代码省略.........
示例8: buildQuickForm
/**
* Build the form
*
* @access public
* @return void
*/
function buildQuickForm()
{
$ufGroupId = $this->get('ufGroupId');
if (!$ufGroupId) {
CRM_Core_Error::fatal('ufGroupId is missing');
}
require_once "CRM/Core/BAO/UFGroup.php";
require_once "CRM/Core/BAO/CustomGroup.php";
$this->_title = ts('Batch Update for Contributions') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
CRM_Utils_System::setTitle($this->_title);
$this->addDefaultButtons(ts('Save'));
$this->_fields = array();
$this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, false, CRM_Core_Action::VIEW);
// remove file type field and then limit fields
$suppressFields = false;
$removehtmlTypes = array('File', 'Autocomplete-Select');
foreach ($this->_fields as $name => $field) {
if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes)) {
$suppressFields = true;
unset($this->_fields[$name]);
}
//fix to reduce size as we are using this field in grid
if (is_array($field['attributes']) && $this->_fields[$name]['attributes']['size'] > 19) {
//shrink class to "form-text-medium"
$this->_fields[$name]['attributes']['size'] = 19;
}
}
$this->_fields = array_slice($this->_fields, 0, $this->_maxFields);
$this->addButtons(array(array('type' => 'submit', 'name' => ts('Update Contribution(s)'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->assign('profileTitle', $this->_title);
$this->assign('componentIds', $this->_contributionIds);
$fileFieldExists = false;
//fix for CRM-2752
require_once "CRM/Core/BAO/CustomField.php";
$customFields = CRM_Core_BAO_CustomField::getFields('Contribution');
foreach ($this->_contributionIds as $contributionId) {
$typeId = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $contributionId, 'contribution_type_id');
foreach ($this->_fields as $name => $field) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) {
$customValue = CRM_Utils_Array::value($customFieldID, $customFields);
if ($typeId == $customValue['extends_entity_column_value'] || CRM_Utils_System::isNull($customValue['extends_entity_column_value'])) {
CRM_Core_BAO_UFGroup::buildProfile($this, $field, null, $contributionId);
}
} else {
// handle non custom fields
CRM_Core_BAO_UFGroup::buildProfile($this, $field, null, $contributionId);
}
}
}
$this->assign('fields', $this->_fields);
// don't set the status message when form is submitted.
$buttonName = $this->controller->getButtonName('submit');
if ($suppressFields && $buttonName != '_qf_Batch_next') {
CRM_Core_Session::setStatus("FILE or Autocomplete Select type field(s) in the selected profile are not supported for Batch Update and have been excluded.");
}
$this->addDefaultButtons(ts('Update Contributions'));
}
示例9: formatCommonData
/**
* format common params data to proper format to store.
*
* @param array $params contain record values.
* @param array $formatted array of formatted data.
* @param array $contactFields contact DAO fields.
* @static
*/
function formatCommonData($params, &$formatted, &$contactFields)
{
$csType = array(CRM_Utils_Array::value('contact_type', $formatted));
//CRM-5125
//add custom fields for contact sub type
if (!empty($this->_contactSubType)) {
$csType = $this->_contactSubType;
}
if ($relCsType = CRM_Utils_Array::value('contact_sub_type', $formatted)) {
$csType = $relCsType;
}
$customFields = CRM_Core_BAO_CustomField::getFields($formatted['contact_type'], false, false, $csType);
//if a Custom Email Greeting, Custom Postal Greeting or Custom Addressee is mapped, and no "Greeting / Addressee Type ID" is provided, then automatically set the type = Customized, CRM-4575
$elements = array('email_greeting_custom' => 'email_greeting', 'postal_greeting_custom' => 'postal_greeting', 'addressee_custom' => 'addressee');
foreach ($elements as $k => $v) {
if (array_key_exists($k, $params) && !array_key_exists($v, $params)) {
$label = key(CRM_Core_OptionGroup::values($v, true, null, null, 'AND v.name = "Customized"'));
$params[$v] = $label;
}
}
//format date first
$session =& CRM_Core_Session::singleton();
$dateType = $session->get("dateTypes");
foreach ($params as $key => $val) {
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
//we should not update Date to null, CRM-4062
if ($val && $customFields[$customFieldID]['data_type'] == 'Date') {
self::formatCustomDate($params, $formatted, $dateType, $key);
unset($params[$key]);
} else {
if ($customFields[$customFieldID]['data_type'] == 'Boolean') {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
}
if ($key == 'birth_date' && $val) {
CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
} else {
if ($key == 'deceased_date' && $val) {
CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key);
} else {
if ($key == 'is_deceased' && $val) {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
} else {
if ($key == 'gender') {
//CRM-4360
$params[$key] = $this->checkGender($val);
}
}
}
}
}
//now format custom data.
foreach ($params as $key => $field) {
if ($field == null || $field === '') {
continue;
}
if (is_array($field)) {
foreach ($field as $value) {
$break = false;
if (is_array($value)) {
foreach ($value as $name => $testForEmpty) {
// check if $value does not contain IM provider or phoneType
if (($name !== 'phone_type_id' || $name !== 'provider_id') && ($testForEmpty === '' || $testForEmpty == null)) {
$break = true;
break;
}
}
} else {
$break = true;
}
if (!$break) {
_civicrm_add_formatted_param($value, $formatted);
}
}
continue;
}
$formatValues = array($key => $field);
if ($key !== 'preferred_communication_method' && array_key_exists($key, $contactFields)) {
// due to merging of individual table and
// contact table, we need to avoid
// preferred_communication_method forcefully
$formatValues['contact_type'] = $formatted['contact_type'];
}
if ($key == 'id' && isset($field)) {
$formatted[$key] = $field;
}
_civicrm_add_formatted_param($formatValues, $formatted);
//Handling Custom Data
if (($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) && array_key_exists($customFieldID, $customFields)) {
//get the html type.
$type = $customFields[$customFieldID]['html_type'];
//.........这里部分代码省略.........
示例10: postProcess
/**
* This function is called when the form is submitted
*
* @access public
* @return None
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$quickSave = false;
if (CRM_Utils_Array::value('_qf_Relationship_refresh_save', $_POST) || CRM_Utils_Array::value('_qf_Relationship_refresh_savedetails', $_POST)) {
$quickSave = true;
}
$this->set('searchDone', 0);
$this->set('callAjax', false);
if (CRM_Utils_Array::value('_qf_Relationship_refresh', $_POST) || $quickSave) {
if (is_numeric($params['rel_contact_id'])) {
if ($quickSave) {
$params['contact_check'] = array($params['rel_contact_id'] => 1);
} else {
$this->search($params);
$quickSave = false;
}
} else {
$this->set('callAjax', true);
$this->set('relType', $params['relationship_type_id']);
$this->set('relContact', $params['rel_contact']);
$quickSave = false;
}
$this->set('searchDone', 1);
if (!$quickSave) {
return;
}
}
// action is taken depending upon the mode
$ids = array();
$ids['contact'] = $this->_contactId;
// modify params for ajax call
$this->modifyParams($params);
if ($this->_action & CRM_Core_Action::DELETE) {
CRM_Contact_BAO_Relationship::del($this->_relationshipId);
return;
}
$relationshipTypeId = str_replace(array('_a_b', '_b_a'), array('', ''), $params['relationship_type_id']);
if ($this->_action & CRM_Core_Action::UPDATE) {
$ids['relationship'] = $this->_relationshipId;
$relation = CRM_Contact_BAO_Relationship::getContactIds($this->_relationshipId);
$ids['contactTarget'] = $relation->contact_id_a == $this->_contactId ? $relation->contact_id_b : $relation->contact_id_a;
//if relationship type change and previously it was
//employer / emplyee relationship with current employer
//than clear the current employer. CRM-3235.
//make sure we has to have employer id before firing queries, CRM-7306
$employerId = CRM_Utils_Array::value('current_employee_id', $this->_values);
$isDisabled = true;
if (CRM_Utils_Array::value('is_active', $params)) {
$isDisabled = false;
}
$relChanged = true;
if ($relationshipTypeId == $this->_values['relationship_type_id']) {
$relChanged = false;
}
if ($employerId && ($isDisabled || $relChanged)) {
require_once 'CRM/Contact/BAO/Contact/Utils.php';
CRM_Contact_BAO_Contact_Utils::clearCurrentEmployer($this->_values['current_employee_id']);
}
} elseif ($quickSave) {
if ($params['add_current_employee'] && $this->_allRelationshipNames[$relationshipTypeId]["name_a_b"] == 'Employee of') {
$params['employee_of'] = $params['rel_contact_id'];
} elseif ($params['add_current_employer'] && $this->_allRelationshipNames[$relationshipTypeId]["name_b_a"] == 'Employer of') {
$params['employer_of'] = array($params['rel_contact_id'] => 1);
}
if (!$this->_rtype) {
$this->_rtype = str_replace($relationshipTypeId . '_', '', $params['relationship_type_id']);
}
}
$params['start_date'] = CRM_Utils_Date::processDate($params['start_date'], null, true);
$params['end_date'] = CRM_Utils_Date::processDate($params['end_date'], null, true);
//special case to handle if all checkboxes are unchecked
$customFields = CRM_Core_BAO_CustomField::getFields('Relationship', false, false, $relationshipTypeId);
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_relationshipId, 'Relationship');
list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::create($params, $ids);
// if this is called from case view,
//create an activity for case role removal.CRM-4480
if ($this->_caseId) {
require_once "CRM/Case/BAO/Case.php";
CRM_Case_BAO_Case::createCaseRoleActivity($this->_caseId, $relationshipIds, $params['contact_check'], $this->_contactId);
}
$status = '';
if ($valid) {
$status .= ' ' . ts('%count new relationship record created.', array('count' => $valid, 'plural' => '%count new relationship records created.'));
}
if ($invalid) {
$status .= ' ' . ts('%count relationship record not created due to invalid target contact type.', array('count' => $invalid, 'plural' => '%count relationship records not created due to invalid target contact type.'));
}
if ($duplicate) {
$status .= ' ' . ts('%count relationship record not created - duplicate of existing relationship.', array('count' => $duplicate, 'plural' => '%count relationship records not created - duplicate of existing relationship.'));
}
if ($saved) {
$status .= ts('Relationship record has been updated.');
//.........这里部分代码省略.........
示例11: formatCustomField
/**
* Format custom fields before inserting
*
* @param int $customFieldId custom field id
* @param array $customFormatted formatted array
* @param mix $value value of custom field
* @param string $customFieldExtend custom field extends
* @param int $customValueId custom option value id
* @param int $entityId entity id (contribution, membership...)
*
* @return array $customFormatted formatted custom field array
* @static
*/
static function formatCustomField($customFieldId, &$customFormatted, $value, $customFieldExtend, $customValueId = null, $entityId = null, $inline = false)
{
//get the custom fields for the entity
//subtype and basic type
$customDataSubType = null;
if (in_array($customFieldExtend, CRM_Contact_BAO_ContactType::subTypes())) {
// This is the case when getFieldsForImport() requires fields
// of subtype and its parent.CRM-5143
$customDataSubType = $customFieldExtend;
$customFieldExtend = CRM_Contact_BAO_ContactType::getBasicType($customDataSubType);
}
$customFields = CRM_Core_BAO_CustomField::getFields($customFieldExtend, false, $inline, $customDataSubType);
if (!array_key_exists($customFieldId, $customFields)) {
return;
}
// return if field is a 'code' field
if (CRM_Utils_Array::value('is_view', $customFields[$customFieldId])) {
return;
}
list($tableName, $columnName, $groupID) = self::getTableColumnGroup($customFieldId);
if (is_array($customFieldExtend)) {
$customFieldExtend = $customFieldExtend[0];
}
if (!$customValueId && !$customFields[$customFieldId]['is_multiple'] && $entityId) {
//get the entity table for the custom field
require_once "CRM/Core/BAO/CustomQuery.php";
$entityTable = CRM_Core_BAO_CustomQuery::$extendsMap[$customFieldExtend];
$query = "\nSELECT id \n FROM {$tableName}\n WHERE entity_id={$entityId}";
$customValueId = CRM_Core_DAO::singleValueQuery($query);
}
//fix checkbox, now check box always submits values
if ($customFields[$customFieldId]['html_type'] == 'CheckBox') {
if ($value) {
// Note that only during merge this is not an array, and you can directly use value
if (is_array($value)) {
$selectedValues = null;
foreach ($value as $selId => $val) {
if ($val) {
$selectedValues .= $selId . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
}
}
if ($selectedValues) {
$value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . $selectedValues;
} else {
$value = '';
}
}
}
}
if ($customFields[$customFieldId]['html_type'] == 'Multi-Select' || $customFields[$customFieldId]['html_type'] == 'AdvMulti-Select') {
if ($value) {
// Note that only during merge this is not an array,
// and you can directly use value, CRM-4385
if (is_array($value)) {
$value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, array_values($value)) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
}
} else {
$value = '';
}
}
$date = null;
if ($customFields[$customFieldId]['data_type'] == 'Date') {
if (!CRM_Utils_System::isNull($value)) {
$format = $customFields[$customFieldId]['date_format'];
if (in_array($format, array('dd-mm', 'mm/dd'))) {
$dateTimeArray = explode(' ', $value);
$separator = '/';
if ($format == 'dd-mm') {
$separator = '-';
}
$value = $dateTimeArray[0] . $separator . '1902';
if (array_key_exists(1, $dateTimeArray)) {
$value .= ' ' . $dateTimeArray[1];
}
}
$date = CRM_Utils_Date::processDate($value);
}
$value = $date;
}
if ($customFields[$customFieldId]['data_type'] == 'Float' || $customFields[$customFieldId]['data_type'] == 'Money') {
if (!$value) {
$value = 0;
}
if ($customFields[$customFieldId]['data_type'] == 'Money') {
require_once 'CRM/Utils/Rule.php';
$value = CRM_Utils_Rule::cleanMoney($value);
}
//.........这里部分代码省略.........
示例12: postProcess
/**
* Function to process the form
*
* @access public
*
* @return None
*/
public function postProcess()
{
$tx = new CRM_Core_Transaction();
// check if dedupe button, if so return.
$buttonName = $this->controller->getButtonName();
if (isset($this->_dedupeButtonName) && $buttonName == $this->_dedupeButtonName) {
return;
}
if ($this->_action & CRM_Core_Action::DELETE) {
$statusMsg = NULL;
$caseDelete = CRM_Case_BAO_Case::deleteCase($this->_caseId, TRUE);
if ($caseDelete) {
$statusMsg = ts('The selected case has been moved to the Trash. You can view and / or restore deleted cases by checking the "Deleted Cases" option under Find Cases.<br />');
}
CRM_Core_Session::setStatus($statusMsg);
return;
}
if ($this->_action & CRM_Core_Action::RENEW) {
$statusMsg = NULL;
$caseRestore = CRM_Case_BAO_Case::restoreCase($this->_caseId);
if ($caseRestore) {
$statusMsg = ts('The selected case has been restored.<br />');
}
CRM_Core_Session::setStatus($statusMsg);
return;
}
// store the submitted values in an array
$params = $this->controller->exportValues($this->_name);
$params['now'] = date("Ymd");
// 1. call begin post process
if ($this->_activityTypeFile) {
eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}" . "::beginPostProcess( \$this, \$params );");
}
if (CRM_Utils_Array::value('hidden_custom', $params) && !isset($params['custom'])) {
$customFields = array();
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, NULL, 'Case');
}
// 2. create/edit case
if (CRM_Utils_Array::value('case_type_id', $params)) {
$caseType = CRM_Case_PseudoConstant::caseType('name');
$params['case_type'] = $caseType[$params['case_type_id']];
$params['subject'] = $params['activity_subject'];
$params['case_type_id'] = CRM_Core_DAO::VALUE_SEPARATOR . $params['case_type_id'] . CRM_Core_DAO::VALUE_SEPARATOR;
}
$caseObj = CRM_Case_BAO_Case::create($params);
$params['case_id'] = $caseObj->id;
// unset any ids, custom data
unset($params['id'], $params['custom']);
// add tags if exists
$tagParams = array();
if (!empty($params['tag'])) {
$tagParams = array();
foreach ($params['tag'] as $tag) {
$tagParams[$tag] = 1;
}
}
CRM_Core_BAO_EntityTag::create($tagParams, 'civicrm_case', $caseObj->id);
//save free tags
if (isset($params['case_taglist']) && !empty($params['case_taglist'])) {
CRM_Core_Form_Tag::postProcess($params['case_taglist'], $caseObj->id, 'civicrm_case', $this);
}
// user context
$url = CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&action=view&cid={$this->_currentlyViewedContactId}&id={$caseObj->id}");
$session = CRM_Core_Session::singleton();
$session->pushUserContext($url);
// 3. format activity custom data
if (CRM_Utils_Array::value('hidden_custom', $params)) {
$customFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $this->_activityTypeId);
$customFields = CRM_Utils_Array::crmArrayMerge($customFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, $customFields, $this->_activityId, 'Activity');
}
// 4. call end post process
if ($this->_activityTypeFile) {
eval("CRM_Case_Form_Activity_{$this->_activityTypeFile}" . "::endPostProcess( \$this, \$params );");
}
// 5. auto populate activites
// 6. set status
CRM_Core_Session::setStatus("{$params['statusMsg']}");
}
示例13: import
/**
* Handle the values in import mode.
*
* @param int $onDuplicate
* The code for what action to take on duplicates.
* @param array $values
* The array of values belonging to this line.
*
* @return bool
* the result of this processing
*/
public function import($onDuplicate, &$values)
{
// first make sure this is a valid line
$response = $this->summary($values);
if ($response != CRM_Import_Parser::VALID) {
return $response;
}
$params =& $this->getActiveFieldParams();
$formatted = array('version' => 3);
// don't add to recent items, CRM-4399
$formatted['skipRecentView'] = TRUE;
//for date-Formats
$session = CRM_Core_Session::singleton();
$dateType = $session->get('dateTypes');
$customDataType = !empty($params['contact_type']) ? $params['contact_type'] : 'Contribution';
$customFields = CRM_Core_BAO_CustomField::getFields($customDataType);
//CRM-10994
if (isset($params['total_amount']) && $params['total_amount'] == 0) {
$params['total_amount'] = '0.00';
}
foreach ($params as $key => $val) {
if ($val) {
switch ($key) {
case 'receive_date':
case 'cancel_date':
case 'receipt_date':
case 'thankyou_date':
$params[$key] = CRM_Utils_Date::formatDate($params[$key], $dateType);
break;
case 'pledge_payment':
$params[$key] = CRM_Utils_String::strtobool($val);
break;
}
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
if ($customFields[$customFieldID]['data_type'] == 'Date') {
CRM_Contact_Import_Parser_Contact::formatCustomDate($params, $formatted, $dateType, $key);
unset($params[$key]);
} elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
}
}
//date-Format part ends
static $indieFields = NULL;
if ($indieFields == NULL) {
$tempIndieFields = CRM_Contribute_DAO_Contribution::import();
$indieFields = $tempIndieFields;
}
$paramValues = array();
foreach ($params as $key => $field) {
if ($field == NULL || $field === '') {
continue;
}
$paramValues[$key] = $field;
}
//import contribution record according to select contact type
if ($onDuplicate == CRM_Import_Parser::DUPLICATE_SKIP && (!empty($paramValues['contribution_contact_id']) || !empty($paramValues['external_identifier']))) {
$paramValues['contact_type'] = $this->_contactType;
} elseif ($onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE && (!empty($paramValues['contribution_id']) || !empty($values['trxn_id']) || !empty($paramValues['invoice_id']))) {
$paramValues['contact_type'] = $this->_contactType;
} elseif (!empty($params['soft_credit'])) {
$paramValues['contact_type'] = $this->_contactType;
} elseif (!empty($paramValues['pledge_payment'])) {
$paramValues['contact_type'] = $this->_contactType;
}
//need to pass $onDuplicate to check import mode.
if (!empty($paramValues['pledge_payment'])) {
$paramValues['onDuplicate'] = $onDuplicate;
}
require_once 'CRM/Utils/DeprecatedUtils.php';
$formatError = _civicrm_api3_deprecated_formatted_param($paramValues, $formatted, TRUE, $onDuplicate);
if ($formatError) {
array_unshift($values, $formatError['error_message']);
if (CRM_Utils_Array::value('error_data', $formatError) == 'soft_credit') {
return CRM_Contribute_Import_Parser::SOFT_CREDIT_ERROR;
} elseif (CRM_Utils_Array::value('error_data', $formatError) == 'pledge_payment') {
return CRM_Contribute_Import_Parser::PLEDGE_PAYMENT_ERROR;
}
return CRM_Import_Parser::ERROR;
}
if ($onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, NULL, 'Contribution');
} else {
//fix for CRM-2219 - Update Contribution
// onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE
if (!empty($paramValues['invoice_id']) || !empty($paramValues['trxn_id']) || !empty($paramValues['contribution_id'])) {
$dupeIds = array('id' => CRM_Utils_Array::value('contribution_id', $paramValues), 'trxn_id' => CRM_Utils_Array::value('trxn_id', $paramValues), 'invoice_id' => CRM_Utils_Array::value('invoice_id', $paramValues));
$ids['contribution'] = CRM_Contribute_BAO_Contribution::checkDuplicateIds($dupeIds);
//.........这里部分代码省略.........
示例14: postProcess
//.........这里部分代码省略.........
$tag = new CRM_Core_DAO_EntityTag();
$tag->entity_id = $this->_contactId;
$tag->tag_id = $this->_tagId;
if (!$tag->find()) {
// send thank you email directly, the user is known and validated
$this->_sendEmailMode = self::EMAIL_THANK;
// Set status for signature activity to completed
$params['statusId'] = 2;
} else {
// send email verification email
$this->_sendEmailMode = self::EMAIL_CONFIRM;
// Set status for signature activity to scheduled until email is verified
$params['statusId'] = 1;
}
}
break;
default:
// more than 1 matching contact
// for time being, take the first matching contact (not sure that's the best strategy, but better than creating another duplicate)
$this->_contactId = $params['contactId'] = $ids[0];
// check if user has already signed this petition - redirects to Thank You if true
$this->redirectIfSigned($params);
if ($this->petition['bypass_confirm']) {
// send thank you email directly, bypassing confirmation
$this->_sendEmailMode = self::EMAIL_THANK;
// Set status for signature activity to completed
$params['statusId'] = 2;
break;
}
if ($tag_name) {
$tag = new CRM_Core_DAO_EntityTag();
$tag->entity_id = $this->_contactId;
$tag->tag_id = $this->_tagId;
if (!$tag->find()) {
// send thank you email
$this->_sendEmailMode = self::EMAIL_THANK;
// Set status for signature activity to completed
$params['statusId'] = 2;
} else {
// send email verification email
$this->_sendEmailMode = self::EMAIL_CONFIRM;
// Set status for signature activity to scheduled until email is verified
$params['statusId'] = 1;
}
}
break;
}
$transaction = new CRM_Core_Transaction();
// CRM-17029 - get the add_to_group_id from the _contactProfileFields array.
// There's a much more elegant solution with
// array_values($this->_contactProfileFields)[0] but it's PHP 5.4+ only.
$slice = array_slice($this->_contactProfileFields, 0, 1);
$firstField = array_shift($slice);
$addToGroupID = isset($firstField['add_to_group_id']) ? $firstField['add_to_group_id'] : NULL;
$this->_contactId = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_contactProfileFields, $this->_contactId, $addToGroupID, $this->_contactProfileId, $this->_ctype, TRUE);
// get additional custom activity profile field data
// to save with new signature activity record
$surveyInfo = $this->bao->getSurveyInfo($this->_surveyId);
$customActivityFields = CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, $surveyInfo['activity_type_id']);
$customActivityFields = CRM_Utils_Array::crmArrayMerge($customActivityFields, CRM_Core_BAO_CustomField::getFields('Activity', FALSE, FALSE, NULL, NULL, TRUE));
$params['custom'] = CRM_Core_BAO_CustomField::postProcess($params, NULL, 'Activity');
// create the signature activity record
$params['contactId'] = $this->_contactId;
$params['activity_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->petition);
$result = $this->bao->createSignature($params);
// send thank you or email verification emails
// if logged in using Facebook connect and email on form matches Fb email,
// no need for email confirmation, send thank you email
if ($this->forceEmailConfirmed['flag'] && $this->forceEmailConfirmed['email'] == $params['email-Primary']) {
$this->_sendEmailMode = self::EMAIL_THANK;
}
switch ($this->_sendEmailMode) {
case self::EMAIL_THANK:
// mark the signature activity as completed and set confirmed cookie
$this->bao->confirmSignature($result->id, $this->_contactId, $this->_surveyId);
break;
case self::EMAIL_CONFIRM:
// set 'Unconfirmed' tag for this new contact
if ($tag_name) {
unset($tag_params);
$tag_params['contact_id'] = $this->_contactId;
$tag_params['tag_id'] = $this->_tagId;
$tag_params['version'] = 3;
$tag_value = civicrm_api('entity_tag', 'create', $tag_params);
}
break;
}
//send email
$params['activityId'] = $result->id;
$params['tagId'] = $this->_tagId;
$transaction->commit();
$this->bao->sendEmail($params, $this->_sendEmailMode);
if ($result) {
// call the hook before we redirect
$this->postProcessHook();
// set the template to thank you
$url = CRM_Utils_System::url('civicrm/petition/thankyou', 'pid=' . $this->_surveyId . '&id=' . $this->_sendEmailMode . '&reset=1');
CRM_Utils_System::redirect($url);
}
}
示例15: import
/**
* handle the values in import mode
*
* @param int $onDuplicate the code for what action to take on duplicates
* @param array $values the array of values belonging to this line
*
* @return boolean the result of this processing
* @access public
*/
function import($onDuplicate, &$values)
{
// first make sure this is a valid line
$response = $this->summary($values);
if ($response != CRM_Member_Import_Parser::VALID) {
return $response;
}
$params =& $this->getActiveFieldParams();
//assign join date equal to start date if join date is not provided
if (!$params['join_date'] && $params['membership_start_date']) {
$params['join_date'] = $params['membership_start_date'];
}
$session =& CRM_Core_Session::singleton();
$dateType = $session->get("dateTypes");
$formatted = array();
$customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $params));
// don't add to recent items, CRM-4399
$formatted['skipRecentView'] = true;
foreach ($params as $key => $val) {
if ($val) {
switch ($key) {
case 'join_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Import_Parser_Contact::addToErrorMsg('Join Date', $errorMessage);
}
} else {
CRM_Import_Parser_Contact::addToErrorMsg('Join Date', $errorMessage);
}
break;
case 'membership_start_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
}
} else {
CRM_Import_Parser_Contact::addToErrorMsg('Start Date', $errorMessage);
}
break;
case 'membership_end_date':
if (CRM_Utils_Date::convertToDefaultDate($params, $dateType, $key)) {
if (!CRM_Utils_Rule::date($params[$key])) {
CRM_Import_Parser_Contact::addToErrorMsg('End Date', $errorMessage);
}
} else {
CRM_Import_Parser_Contact::addToErrorMsg('End Date', $errorMessage);
}
break;
case 'is_override':
$params[$key] = CRM_Utils_String::strtobool($val);
break;
}
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
if ($customFields[$customFieldID][2] == 'Date') {
CRM_Import_Parser_Contact::formatCustomDate($params, $formatted, $dateType, $key);
unset($params[$key]);
} else {
if ($customFields[$customFieldID][2] == 'Boolean') {
$params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
}
}
}
//date-Format part ends
static $indieFields = null;
if ($indieFields == null) {
require_once 'CRM/Member/DAO/Membership.php';
$tempIndieFields =& CRM_Member_DAO_Membership::import();
$indieFields = $tempIndieFields;
}
$formatValues = array();
foreach ($params as $key => $field) {
if ($field == null || $field === '') {
continue;
}
$formatValues[$key] = $field;
}
$formatError = _civicrm_membership_formatted_param($formatValues, $formatted, true);
if ($formatError) {
array_unshift($values, $formatError['error_message']);
return CRM_Member_Import_Parser::ERROR;
}
if ($onDuplicate != CRM_Member_Import_Parser::DUPLICATE_UPDATE) {
$formatted['custom'] = CRM_Core_BAO_CustomField::postProcess($formatted, CRM_Core_DAO::$_nullObject, null, 'Membership');
} else {
//fix for CRM-2219 Update Membership
// onDuplicate == CRM_Member_Import_Parser::DUPLICATE_UPDATE
if (CRM_Utils_Array::value('is_override', $formatted) && !CRM_Utils_Array::value('status_id', $formatted)) {
array_unshift($values, "Required parameter missing: Status");
return CRM_Member_Import_Parser::ERROR;
//.........这里部分代码省略.........