Give an error if the custom field we're supposed to be matching against can't be found

This commit is contained in:
Nathan Gray 2012-01-20 19:51:03 +00:00
parent 03671abeb8
commit ca1c9e681a

View File

@ -515,18 +515,26 @@ class infolog_import_infologs_csv implements importexport_iface_import_plugin {
if($app && $custom_field && $value) if($app && $custom_field && $value)
{ {
$cfs = config::get_customfields($app); $cfs = config::get_customfields($app);
// Error if no custom fields, probably something wrong in definition
if(!$cfs[$custom_field]) if(!$cfs[$custom_field])
{ {
// Check for users specifing label instead of name // Check for users specifing label instead of name
foreach($cfs as $name => $settings) foreach($cfs as $name => $settings)
{ {
if($settings['label'] == $custom_field) if(strtolower($settings['label']) == strtolower($custom_field))
{ {
$custom_field = $name; $custom_field = $name;
break; break;
} }
} }
} }
// Couldn't find field, give an error - something's wrong
if(!$cfs[$custom_field] && !$cfs[substr($custom_field,1)]) {
$this->errors[$record_num] .= lang('No custom field "%1" for %2.',
$custom_field, lang($app));
return false;
}
if($custom_field[0] != '#') $custom_field = '#' . $custom_field; if($custom_field[0] != '#') $custom_field = '#' . $custom_field;
// Search // Search