function soundcloudfield_update_7000 in SoundCloud field 7
Update field instances to be in sync with the new instance settings.
File
- ./
soundcloudfield.install, line 29 - Install, update and uninstall functions for the SoundCloud field module.
Code
function soundcloudfield_update_7000() {
$instances = field_info_instances();
foreach ($instances as $entity_type => $entities) {
foreach ($entities as $bundle => $fields) {
foreach ($fields as $field_name => $instance) {
if (in_array($instance['widget']['type'], array(
'soundcloud_url',
))) {
$changed = FALSE;
if (!empty($instance['settings']['soundcloudplayer'])) {
if (empty($instance['settings']['soundcloudplayer']['flash_player']) || !isset($instance['settings']['soundcloudplayer']['flash_player']['height']) || !isset($instance['settings']['soundcloudplayer']['flash_player']['height_sets']) || !isset($instance['settings']['soundcloudplayer']['flash_player']['showcomments'])) {
$instance['settings']['soundcloudplayer']['flash_player'] = array(
'height' => 81,
'height_sets' => 305,
'showcomments' => 0,
);
$changed = TRUE;
}
if (empty($instance['settings']['soundcloudplayer']['html5_player']) || !isset($instance['settings']['soundcloudplayer']['html5_player']['html5_player_height']) || !isset($instance['settings']['soundcloudplayer']['html5_player']['html5_player_height_sets'])) {
$instance['settings']['soundcloudplayer']['html5_player'] = array(
'html5_player_height' => SOUNDCLOUDFIELD_DEFAULT_HTML5_PLAYER_HEIGHT,
'html5_player_height_sets' => SOUNDCLOUDFIELD_DEFAULT_HTML5_PLAYER_HEIGHT_SETS,
);
$changed = TRUE;
}
if (empty($instance['settings']['soundcloudplayer']['visual_player']) || !isset($instance['settings']['soundcloudplayer']['visual_player']['visual_player_height'])) {
$instance['settings']['soundcloudplayer']['visual_player'] = array(
'visual_player_height' => SOUNDCLOUDFIELD_DEFAULT_VISUAL_PLAYER_HEIGHT,
);
$changed = TRUE;
}
}
if ($changed) {
field_update_instance($instance);
}
}
}
}
}
field_cache_clear();
drupal_set_message(t('Field instances of type SoundCloud have been updated.'));
}