function mvf_update_7102 in Measured Value Field 7
Update settings of MVF instances.
File
- ./
mvf.install, line 52 - Install, update, and uninstall functions for the Measured Value Field module.
Code
function mvf_update_7102() {
$mvf_field_types = array_keys(module_invoke('mvf', 'field_info'));
foreach (field_info_field_map() as $field_name => $field_info) {
if (in_array($field_info['type'], $mvf_field_types)) {
$field_info = field_info_field($field_name);
foreach ($field_info['bundles'] as $entity_type => $bundles) {
foreach ($bundles as $bundle) {
$instance = field_info_instance($entity_type, $field_name, $bundle);
$map = array(
'MVFUnitSuggesterHardCoded' => 'hardcoded',
'MVFUnitSuggesterLocale' => 'locale',
'MVFUnitSuggesterOriginal' => 'original',
'MVFPerUserUnitSuggesterUser' => 'per_user',
);
$instance['settings']['mvf']['unit_suggesters_settings'] = isset($instance['display']['default']['settings']['mvf']['unit_suggester_settings']) ? $instance['display']['default']['settings']['mvf']['unit_suggester_settings'] : array();
foreach ($instance['settings']['mvf']['unit_suggesters_settings'] as $k => $v) {
unset($instance['settings']['mvf']['unit_suggesters_settings'][$k]);
if (isset($map[$k])) {
$instance['settings']['mvf']['unit_suggesters_settings'][$map[$k]] = $v;
}
}
foreach ($instance['display'] as $view_mode => $display) {
$display['settings']['mvf']['override'] = FALSE;
unset($display['settings']['mvf']['unit_suggester_settings']);
$instance['display'][$view_mode] = $display;
}
field_update_instance($instance);
}
}
}
}
}