You are here

function emvideo_update_6016 in Embedded Media Field 6

Same name and namespace in other branches
  1. 6.3 contrib/emvideo/emvideo.install \emvideo_update_6016()
  2. 6.2 contrib/emvideo/emvideo.install \emvideo_update_6016()

Add a duration column to existing fields.

File

contrib/emvideo/emvideo.install, line 388
Installation, configuration, and removal of the emvideo module.

Code

function emvideo_update_6016() {
  $ret = array();

  // 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 ($field['type'] == 'emvideo') {

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

  // Build a batch that grabs the duration for each video field.
  $batch = array(
    'title' => t('Importing duration.'),
    'operations' => array(),
    'file' => drupal_get_path('module', 'emvideo') . '/emvideo.install',
  );
  foreach ($fields as $field_name => $field) {
    $batch['operations'][] = array(
      '_emvideo_update_get_duration',
      array(
        $field,
      ),
    );
    $ret[] = array(
      'query' => t('Saved available video durations for the %field field.', array(
        '%field' => $field['field_name'],
      )),
      'success' => TRUE,
    );
  }
  batch_set($batch);

  // Clear caches.
  cache_clear_all('*', content_cache_tablename(), TRUE);
  cache_clear_all('*', 'cache', TRUE);
  return $ret;
}