function media_upgrade_file_types_confirm_submit

cis7 media.pages.inc media_upgrade_file_types_confirm_submit($form, &$form_state)
cle7 media.pages.inc media_upgrade_file_types_confirm_submit($form, &$form_state)
elmsmedia7 media.pages.inc media_upgrade_file_types_confirm_submit($form, &$form_state)
icor7 media.pages.inc media_upgrade_file_types_confirm_submit($form, &$form_state)
meedjum_blog7 media.pages.inc media_upgrade_file_types_confirm_submit($form, &$form_state)
mooc7 media.pages.inc media_upgrade_file_types_confirm_submit($form, &$form_state)

File types migration confirmation page sumit. Executes actual migration.

File

sites/all/modules/ulmus/media/includes/media.pages.inc, line 221
Common pages for the Media module.

Code

function media_upgrade_file_types_confirm_submit($form, &$form_state) {
  $migratable_types = _media_get_migratable_file_types();
  foreach ($migratable_types as $type) {
    if ($_GET[$type] && $bundle_new = file_type_load($_GET[$type])) {
      // Old bundle might be deleted so let's fake some values.
      $bundle_old = file_type_load($type);
      if (empty($bundle_old)) {
        $bundle_old = new stdClass;
        $bundle_old->type = $type;
        $bundle_old->mimetypes = array();
        $bundle_old->export_type = 2;
      }

      // Migrate fields to new bundle.
      if ($_GET['migrate_fields']) {
        $old_fields = db_select('field_config_instance', 'fc')->fields('fc', array('field_name'))->condition('entity_type', 'file')->condition('bundle', $bundle_old->type)->execute()->fetchCol();
        $new_fields = db_select('field_config_instance', 'fc')->fields('fc', array('field_name'))->condition('entity_type', 'file')->condition('bundle', $bundle_new->type)->execute()->fetchCol();
        $fields_to_move = array_diff($old_fields, $new_fields);
        $fields_to_drop = array_diff($old_fields, $fields_to_move);

        db_update('field_config_instance')->fields(array('bundle' => $bundle_new->type))->condition('entity_type', 'file')->condition('bundle', $bundle_old->type)->condition('field_name', $fields_to_move, 'IN')->execute();

        db_delete('field_config_instance')->condition('entity_type', 'file')->condition('bundle', $bundle_old->type)->condition('field_name', $fields_to_drop, 'IN')->execute();

        field_cache_clear();
        module_invoke_all('field_attach_rename_bundle', 'file', $bundle_old->type, $bundle_new->type);
      }

      // Migrate mimetypes to new bundle.
      if ($_GET['migrate_mimes']) {
        $changed = FALSE;
        foreach ($bundle_old->mimetypes as $mime) {
          if (!file_entity_match_mimetypes($bundle_new->mimetypes, $mime)) {
            $bundle_new->mimetypes[] = $mime;
            $changed = TRUE;
          }
        }

        if ($changed) {
          file_type_save($bundle_new);
        }
      }

      // Delete old bundle.
      if ($_GET['delete_old_type'] && $bundle_old->export_type == 1) {
        file_type_delete($bundle_old);
      }

      // Migrate files.
      db_update('file_managed')->fields(array('type' => $bundle_new->type))->condition('type', $bundle_old->type)->execute();
    }
  }

  $form_state['redirect'] = 'admin/structure/file-types';
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.