You are here

function fc_rebuild_submit in Field Complete 7

File

./fc.admin.inc, line 78
Field Complete - Provides field-based completeness for any entity - admin.

Code

function fc_rebuild_submit($form, &$form_state) {

  // Build the batch data
  $batch = array(
    'operations' => array(),
    'finished' => 'fc_rebuild_finished',
    'title' => t('Rebuilding Field Complete table'),
    'init_message' => t('Rebuild of Field Complete table is starting.'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('Rebuild of Field Complete table has encountered an error.'),
    'file' => drupal_get_path('module', 'fc') . '/fc.admin.inc',
  );
  $entity_info = fc_entity_types();
  foreach (array_filter($form_state['values']['entity_types']) as $entity_type) {
    $batch['operations'][] = array(
      'fc_rebuild_process',
      array(
        $entity_type,
        $entity_info[$entity_type],
      ),
    );

    // Remove any current entries in the table for this entity_type
    db_delete('fc')
      ->condition('entity_type', $entity_type)
      ->execute();
  }
  batch_set($batch);
}