You are here

function brightcove_update_7007 in Brightcove Video Connect 7.3

Same name and namespace in other branches
  1. 7.5 brightcove.install \brightcove_update_7007()

Fix default players for Brightcove field instances.

File

./brightcove.install, line 250
Installation file for Brightcove module.

Code

function brightcove_update_7007() {
  $players = brightcove_player_load_all();

  // Get all of the brightcove fields.
  $fields = field_read_fields(array(
    'type' => 'brightcove_field',
  ));
  foreach ($fields as $field) {

    // Update the value of the default player for brightcove field instances.
    $instances = field_read_instances(array(
      'field_name' => $field['field_name'],
    ));
    foreach ($instances as $instance) {
      if (!empty($players)) {
        foreach ($players as $player) {
          if ($instance['settings']['brightcove_player'] == $player->pid) {
            $instance['settings']['brightcove_player'] = $player->name;
            field_update_instance($instance);
          }
        }
      }
    }
  }
}