You are here

function media_gallery_update_7004 in Media Gallery 7

Same name and namespace in other branches
  1. 7.2 media_gallery.install \media_gallery_update_7004()

Configure media license field to have a per-type label and description.

File

./media_gallery.install, line 1103
Install file for media_gallery. Includes field and instance definitions.

Code

function media_gallery_update_7004() {
  drupal_load('module', 'field');
  drupal_load('module', 'media');
  $t = get_t();
  foreach (media_type_get_types() as $bundle => $type) {
    $instance = field_info_instance('media', 'field_license', $bundle);

    // If the instance doesn't exist, we can't update it.
    if ($instance) {
      $label = in_array($bundle, array(
        'image',
        'audio',
        'video',
      )) ? $bundle : 'file';
      $instance['label'] = $t("License settings for this {$label}");
      $instance['description'] = $t('Select a <a href="http://creativecommons.org" target="_new">Creative Commons</a> license for others who use this ' . $label . '.');
      field_update_instance($instance);
    }
  }
}