You are here

function eck_revision_batch_operation_delete_entity_revisions in ECK Revision 7

1 string reference to 'eck_revision_batch_operation_delete_entity_revisions'
eck_revision_form_eck__properties__form_submit in ./eck_revision.module

File

./eck_revision.module, line 360
ECK Revision module.

Code

function eck_revision_batch_operation_delete_entity_revisions($entity_type, $entity, $field_tables, $operation_details, &$context) {

  // Get the entity label.
  $title = $entity->title;

  // Delete every revision ID of every fields of this entity.
  $revisions = eck_revision_entity_revision_list($entity_type, $entity);
  foreach ($revisions as $revision) {
    $result = entity_revision_delete($entity_type, $revision->revision_id);
  }

  // Set new revision ID every fields of this entity.
  foreach ($field_tables[$entity->type] as $table) {
    $num_update = db_update($table)
      ->fields(array(
      'revision_id' => $entity->id,
    ))
      ->condition('entity_type', $entity_type, '=')
      ->condition('bundle', $entity->type, '=')
      ->condition('entity_id', $entity->id, '=')
      ->execute();
  }

  // Set batch data.
  $context['results'][] = $entity->id . ' : ' . check_plain($title);
  $context['message'] = t('Deleting revisions data for "@title"', array(
    '@title' => $title,
  )) . ' ' . $operation_details;
}