You are here

function emfield_update_6202 in Embedded Media Field 6.2

Same name and namespace in other branches
  1. 6.3 emfield.install \emfield_update_6202()

Add a new column to fields for media status.

File

./emfield.install, line 243
This is the emfield.module's install, configuration, and removal file.

Code

function emfield_update_6202() {
  $ret = array();
  include_once drupal_get_path('module', 'content') . '/includes/content.admin.inc';

  // Build a list of fields that need data updating.
  $fields = array();
  foreach (content_types_install() as $type_name => $type_fields) {
    foreach ($type_fields as $field) {
      if (in_array($field['module'], array(
        'emvideo',
        'emimage',
        'emaudio',
      ))) {

        // We only process a given field once.
        $fields[$field['field_name']] = $field;
      }
    }
  }

  // Update database storage.
  foreach ($fields as $field) {
    $new_field = $field;
    unset($field['version']);
    content_alter_db($field, $new_field);
    $ret[] = array(
      'query' => t('Added media availability status to the %field field.', array(
        '%field' => $field['field_name'],
      )),
      'success' => TRUE,
    );
  }
  content_clear_type_cache(TRUE);
  content_associate_fields('emvideo');
  content_associate_fields('emaudio');
  content_associate_fields('emimage');
  return $ret;
}