You are here

function feeds_unlock_tab_form in Feeds 7.2

Same name and namespace in other branches
  1. 8.2 feeds.pages.inc \feeds_unlock_tab_form()

Render a feeds unlock form.

Used on both node pages and configuration pages. Therefore $node may be missing.

1 string reference to 'feeds_unlock_tab_form'
feeds_menu in ./feeds.module
Implements hook_menu().

File

./feeds.pages.inc, line 295
Menu callbacks, form callbacks and helpers.

Code

function feeds_unlock_tab_form($form, &$form_state, FeedsImporter $importer = NULL, $node = NULL) {
  if (empty($node)) {
    $source = feeds_source($importer->id);
    $form['#redirect'] = 'import/' . $source->id;
  }
  else {
    $importer_id = feeds_get_importer_id($node->type);
    $source = feeds_source($importer_id, $node->nid);
    $form['#redirect'] = 'node/' . $source->feed_nid;
  }

  // Form cannot pass on source object.
  $form['#importer_id'] = $source->id;
  $form['#feed_nid'] = $source->feed_nid;
  $form['source_status'] = array(
    '#type' => 'fieldset',
    '#title' => t('Status'),
    '#tree' => TRUE,
    '#value' => feeds_source_status($source),
  );
  $form = confirm_form($form, t('Unlock this importer?'), $form['#redirect'], '', t('Delete'), t('Cancel'), 'confirm feeds update');
  if ($source
    ->progressImporting() == FEEDS_BATCH_COMPLETE && $source
    ->progressClearing() == FEEDS_BATCH_COMPLETE) {
    $form['source_locked'] = array(
      '#type' => 'markup',
      '#title' => t('Not Locked'),
      '#tree' => TRUE,
      '#markup' => t('This importer is not locked, therefore it cannot be unlocked.'),
    );
    $form['actions']['submit']['#disabled'] = TRUE;
    $form['actions']['submit']['#value'] = t('Unlock (disabled)');
  }
  else {
    $form['actions']['submit']['#value'] = t('Unlock');
  }
  return $form;
}