X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FImport%2FForm%2FMapField.php;h=e6f03f3f203c22758f255a305a01dc56318d4eb2;hb=51ccfbbea3adab11200800e01f1233cddc7e5272;hp=03ef69cc9352b683f3a35d141d9f10fb23850ca9;hpb=8906b92a00b4907e620e80624fb6ac6baa368bed;p=civicrm-core.git diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 03ef69cc93..a6e0823133 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -1,7 +1,7 @@ get('dataSource'); @@ -151,9 +150,16 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { } } } - + // 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. @@ -190,10 +196,9 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { } /** - * Function to actually build the form + * Build the form object * * @return void - * @access public */ public function buildQuickForm() { //to save the current mappings @@ -613,15 +618,15 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { } /** - * global validation rules for the form + * Global validation rules for the form * - * @param array $fields posted values of the form + * @param array $fields + * Posted values of the form. * * @return array list of errors to be posted back to the form * @static - * @access public */ - static function formRule($fields) { + public static function formRule($fields) { $errors = array(); if (!empty($fields['saveMapping'])) { $nameField = CRM_Utils_Array::value('saveMappingName', $fields); @@ -656,7 +661,6 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { * preview the file and extract some summary statistics * * @return void - * @access public */ public function postProcess() { $params = $this->controller->exportValues('MapField'); @@ -695,11 +699,15 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { ); //set respective mapper params to array. - foreach (array_keys($mapperParams) as $mapperParam)$$mapperParam = array(); + foreach (array_keys($mapperParams) as $mapperParam) { + $$mapperParam = array(); + } for ($i = 0; $i < $this->_columnCount; $i++) { //set respective mapper value to null - foreach (array_values($mapperParams) as $mapperParam)$$mapperParam = NULL; + foreach (array_values($mapperParams) as $mapperParam) { + $$mapperParam = NULL; + } $fldName = CRM_Utils_Array::value(0, $mapperKeys[$i]); $selOne = CRM_Utils_Array::value(1, $mapperKeys[$i]); @@ -809,7 +817,7 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { for ($i = 0; $i < $this->_columnCount; $i++) { $updateMappingFields = new CRM_Core_DAO_MappingField(); - $updateMappingFields->id = CRM_Utils_Array::value($i,$mappingFieldsId); + $updateMappingFields->id = CRM_Utils_Array::value($i, $mappingFieldsId); $updateMappingFields->mapping_id = $params['mappingId']; $updateMappingFields->column_number = $i; @@ -968,13 +976,14 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { } /** - * format custom field name. + * Format custom field name. * combine group and field name to avoid conflict. * + * @param $fields + * * @return void - * @access public */ - function formatCustomFieldName(&$fields) { + public function formatCustomFieldName(&$fields) { //CRM-2676, replacing the conflict for same custom field name from different custom group. $fieldIds = $formattedFieldNames = array(); foreach ($fields as $key => $value) { @@ -998,4 +1007,3 @@ class CRM_Contact_Import_Form_MapField extends CRM_Import_Form_MapField { return $formattedFieldNames; } } -