You are here

function relation_add_update_7003 in Relation add 7

Move relation global settings to the instance setting.

File

./relation_add.install, line 59
Relation Add install file.

Code

function relation_add_update_7003() {
  $fields = field_info_fields();
  $relation_fields = array();
  foreach ($fields as $name => $field) {
    if ('relation_add' == $field['type']) {
      $relation_fields[$name] = $field;
    }
  }
  $bundle_display = variable_get('relation_add_bundle_display', FALSE);
  $iso_language_codes = variable_get('relation_add_iso_language_codes', array(
    'iso_choice' => 0,
  ));
  foreach ($relation_fields as $field_name => $field) {
    foreach ($field['bundles'] as $entity_type => $bundles) {
      foreach ($bundles as $bundle) {
        $instance = field_info_instance($entity_type, $field_name, $bundle);
        $instance['widget']['settings']['relation_endpoint_bundle_display'] = $bundle_display;
        $instance['widget']['settings']['relation_endpoint_iso_language_codes'] = $iso_language_codes['iso_choice'];
        field_update_instance($instance);
      }
    }
  }
  variable_del('relation_add_bundle_display');
  variable_del('relation_add_iso_language_codes');
  return t('Move relation global settings to the instance setting.');
}