You are here

function drush_feeds_disable in Feeds 7.2

Disables a set of Feeds importers.

File

./feeds.drush.inc, line 680
Drush commands for Feeds module.

Code

function drush_feeds_disable() {
  $all = array_keys(feeds_importer_load_all(TRUE));
  $enabled = array_keys(feeds_importer_load_all());
  $to_disable = array_intersect(func_get_args(), $enabled);
  $missing = array_diff(func_get_args(), $all);
  $already_disabled = array_diff(func_get_args(), $enabled, $missing);
  if ($missing) {
    drush_print(dt('The following importers are missing: !importers', array(
      '!importers' => implode(', ', $missing),
    )));
  }
  if ($already_disabled) {
    drush_print(dt('The following importers are already disabled: !importers', array(
      '!importers' => implode(', ', $already_disabled),
    )));
  }
  if ($to_disable) {
    drush_print(dt('The following importers will be disabled: !importers', array(
      '!importers' => implode(', ', $to_disable),
    )));
  }
  elseif (count(func_get_args()) == 0) {
    return drush_set_error(dt('Please specify a space delimited list of importers to disable.'));
  }
  else {
    return drush_print(dt('There are no importers to disable.'));
  }
  if (!drush_confirm(dt('Do you really want to continue?'))) {
    return drush_log(dt('Aborting.'), 'ok');
  }
  $disabled = variable_get('default_feeds_importer', array());
  foreach ($to_disable as $importer_id) {
    $disabled[$importer_id] = TRUE;
    drush_log(dt("The importer '!importer' has been disabled.", array(
      '!importer' => $importer_id,
    )), 'ok');
  }
  variable_set('default_feeds_importer', $disabled);
  feeds_cache_clear();
}