protected $_dedupeFields;
+ protected static $customFields;
+
/**
* Attempt to match header labels with our mapper fields
* FIXME: This is essentially the same function as parent::defaultFromHeader
}
}
}
-
+ // retrieve and highlight required custom fields
+ $formattedFieldNames = $this->formatCustomFieldName($this->_mapperFields);
+ self::$customFields = CRM_Core_BAO_CustomField::getFields($this->_contactType);
+ foreach(self::$customFields as $key => $attr) {
+ if (!empty($attr['is_required'])) {
+ $highlightedFields[] = "custom_$key";
+ }
+ }
$this->assign('highlightedFields', $highlightedFields);
- $this->_formattedFieldNames[$contactType] = $this->_mapperFields = array_merge($this->_mapperFields, $this->formatCustomFieldName($this->_mapperFields));
+ $this->_formattedFieldNames[$contactType] = $this->_mapperFields = array_merge($this->_mapperFields, $formattedFieldNames);
$columnNames = array();
//get original col headers from csv if present.
if (!array_key_exists($customFieldID, $customFields)) {
self::addToErrorMsg(ts('field ID'), $errorMessage);
}
+ // validate null values for required custom fields of type boolean
+ if (!empty($customFields[$customFieldID]['is_required']) && (empty($params['custom_'.$customFieldID]) && !is_numeric($params['custom_'.$customFieldID])) && $customFields[$customFieldID]['data_type'] == 'Boolean') {
+ self::addToErrorMsg($customFields[$customFieldID]['label'].'::'.$customFields[$customFieldID]['groupTitle'], $errorMessage);
+ }
+
//For address custom fields, we do get actual custom field value as an inner array of
//values so need to modify
if (array_key_exists($customFieldID, $addressCustomFields)) {
}
elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
if (CRM_Utils_String::strtoboolstr($value) === FALSE) {
- self::addToErrorMsg($customFields[$customFieldID]['label'], $errorMessage);
+ self::addToErrorMsg($customFields[$customFieldID]['label'].'::'.$customFields[$customFieldID]['groupTitle'], $errorMessage);
}
}
// need not check for label filed import
}
}
else {
- if ($getValue[$cnt]['location_type_id'] == $params[$locKeys][$key]['location_type_id']) {
+ if ((!empty($getValue[$cnt]['location_type_id']) && !empty($params[$locKeys][$key]['location_type_id'])) && $getValue[$cnt]['location_type_id'] == $params[$locKeys][$key]['location_type_id']) {
unset($params[$locKeys][$key]);
}
}
self::formatCustomDate($params, $formatted, $dateType, $key);
}
elseif ($customFields[$customFieldID]['data_type'] == 'Boolean') {
- $params[$key] = CRM_Utils_String::strtoboolstr($val);
+ if (empty($val) && !is_numeric($val) && $this->_onDuplicate == CRM_Import_Parser::DUPLICATE_FILL) {
+ //retain earlier value when Import mode is `Fill`
+ unset($params[$key]);
+ }
+ else {
+ $params[$key] = CRM_Utils_String::strtoboolstr($val);
}
}
$params[$key] = $this->checkGender($val);
}
}
+ }
//now format custom data.
foreach ($params as $key => $field) {
- if (!isset($field) || empty($field)){
- unset($params[$key]);
- continue;
- }
-
if (is_array($field)) {
$isAddressCustomField = FALSE;
foreach ($field as $value) {
// to check if not update mode and unset the fields with empty value.
if (!$this->_updateWithId && array_key_exists('custom', $formatted)) {
foreach ($formatted['custom'] as $customKey => $customvalue) {
+ if (empty($formatted['custom'][$customKey][- 1]['is_required'])) {
+ $formatted['custom'][$customKey][-1]['is_required'] = $customFields[$customKey]['is_required'];
+ }
$emptyValue = CRM_Utils_Array::value('value', $customvalue[ - 1]);
if (!isset($emptyValue)) {
unset($formatted['custom'][$customKey]);
}
$locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE);
$form->assign('locDataURL', $locDataURL);
+
+ if (!empty($form->_submitValues['onbehalf'])) {
+ $form->assign('submittedOnBehalf', $form->_submitValues['onbehalfof_id']);
+ $form->assign('submittedOnBehalfInfo', json_encode($form->_submitValues['onbehalf']));
+ }
}
if ($form->_values['is_for_organization'] != 2) {
$form->addElement('hidden', 'hidden_onbehalf_profile', 1);
}
}
-
$cfTable.default_value,
$cfTable.options_per_line, $cfTable.text_length,
$cfTable.custom_group_id,
+ $cfTable.is_required,
$cgTable.extends, $cfTable.is_search_range,
$cgTable.extends_entity_column_value,
$cgTable.extends_entity_column_id,
$fields[$dao->id]['option_group_id'] = $dao->option_group_id;
$fields[$dao->id]['date_format'] = $dao->date_format;
$fields[$dao->id]['time_format'] = $dao->time_format;
+ $fields[$dao->id]['is_required'] = $dao->is_required;
}
CRM_Core_BAO_Cache::setItem($fields,
}
$fieldId = $field['id'];
- $elementName = $field['element_name'];
+ if (!empty($field['element_name'])) {
+ $elementName = $field['element_name'];
+ }
switch ($field['html_type']) {
case 'Multi-Select':
case 'AdvMulti-Select':
// Verify user id
$user = CRM_Utils_Request::retrieve('uid', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, CRM_Core_Session::singleton()->get('userID'));
- if (!$user || !CRM_Contact_BAO_Contact_Permission::validateChecksumContact($user, CRM_Core_DAO::$_nullObject, FALSE)) {
+ if (empty($user) || (CRM_Utils_Request::retrieve('cs', 'String', $form, FALSE) && !CRM_Contact_BAO_Contact_Permission::validateChecksumContact($user, CRM_Core_DAO::$_nullObject, FALSE))
+ ) {
CRM_Utils_System::civiExit();
}
CRM_Utils_System::civiExit();
}
}
-
--- /dev/null
+{* file to handle db changes in 4.4.7 during upgrade *}
$valid = CRM_Core_BAO_CustomValue::typecheck(CRM_Utils_Array::value('type', $value),
CRM_Utils_Array::value('value', $value)
);
- if (!$valid) {
+ if (!$valid && $value['is_required']) {
return civicrm_api3_create_error('Invalid value for custom field \'' .
CRM_Utils_Array::value('name', $custom) . '\''
);
}
-function setLocationDetails(contactID) {
+function setLocationDetails(contactID , reset) {
+ var submittedCID = {/literal}"{$submittedOnBehalf}"{literal};
+ var submittedOnBehalfInfo = {/literal}'{$submittedOnBehalfInfo}'{literal};
+ submittedOnBehalfInfo = cj.parseJSON(submittedOnBehalfInfo);
+ if (submittedCID == contactID) {
+ cj.each(submittedOnBehalfInfo, function(key, value) {
+ cj('#onbehalf_' + key ).val(value);
+ });
+ return;
+ }
+
resetValues();
var locationUrl = {/literal}"{$locDataURL}"{literal} + contactID + "&ufId=" + {/literal}"{$profileId}"{literal};
cj.ajax({