function _emvideo_upgrade_from_video_cck in Embedded Media Field 6
Same name and namespace in other branches
- 6.3 contrib/emvideo/emvideo.install \_emvideo_upgrade_from_video_cck()
- 6.2 contrib/emvideo/emvideo.install \_emvideo_upgrade_from_video_cck()
Clean up our messes when migrating from video_cck.
1 call to _emvideo_upgrade_from_video_cck()
- emvideo_install in contrib/
emvideo/ emvideo.install - Implementation of hook_install().
File
- contrib/
emvideo/ emvideo.install, line 69 - Installation, configuration, and removal of the emvideo module.
Code
function _emvideo_upgrade_from_video_cck() {
$ret = array();
// Do nothing if this is a new install. We know that if there are no existing fields with video_cck type.
// if ($__TODO_REPLACE_WITH_PROPER_CHECK) {
// return $ret;
// }
// Change any fields from 'video_cck' to 'emvideo' type.
db_query("UPDATE {content_node_field} SET type='emvideo' WHERE type='video_cck'");
db_query("UPDATE {content_node_field_instance} SET widget_type='emvideo_textfields' WHERE widget_type='video_cck_textfields'");
// Rebuild our content types.
content_clear_type_cache();
// Make sure the previous updates have been run. Some people may have been holding onto a really old version.
// On the one hand, we could tell them on the project page not to do that. But then we get to hear them complain
// in the issue queue. We're already half way there; I'd rather just take care of it.
// Load our existing fields.
$fields = content_fields();
// Some lazy folks may be upgrading from a pre-video_cck_update_2 site. Bad developer, bad!
// @TODO: decide if we want to figure this out or force people to update entirely in d5 first...
// foreach ($fields as $field) {
// switch ($field['type']) {
// case 'emvideo':
// $columns = array(
// 'data' => array('type' => 'longtext', 'not null' => TRUE, 'default' => "''", 'sortable' => FALSE),
// );
// // The following line will actually trigger (negligible) warnings if we did things right.
// // Thus we suppress the warnings. Good developer, good!
// @content_alter_db_field(array(), array(), $field, $columns);
// break;
// }
// }
// Fix any provider variables. Note that we may be updating from a pre video_cck_update_3 site,
// so we fix those sites too. Shame on them for not updating d5 first...
drupal_load('module', 'emfield');
foreach (emfield_system_list('emvideo') as $provider) {
$test = variable_get('emfield_video_cck_allow_' . $provider->name, NULL);
$test = isset($test) ? $test : variable_get('video_cck_allow_' . $provider->name, NULL);
if (isset($test)) {
variable_set('emfield_emvideo_allow_' . $provider->name, $test);
variable_del('emfield_video_cck_allow_' . $provider->name);
variable_del('video_cck_allow_' . $provider->name);
}
}
// </Fancy Hand-Waving>
return TRUE;
}