diff --git a/feeds.drush.inc b/feeds.drush.inc index 7d74d34..59adfb1 100644 --- a/feeds.drush.inc +++ b/feeds.drush.inc @@ -353,154 +353,154 @@ function drush_feeds_clear($importer = NULL) { } /** - * Deletes a set of Feeds importers. + * Enables a set of Feeds importers. */ -function drush_feeds_delete() { - $all = feeds_importer_load_all(TRUE); - $to_delete = array_intersect_key($all, array_flip(func_get_args())); - $missing = array_diff(func_get_args(), array_keys($all)); +function drush_feeds_enable() { + $all = array_keys(feeds_importer_load_all(TRUE)); + $enabled = array_keys(feeds_importer_load_all()); + $missing = array_diff(func_get_args(), $all); + $to_enable = array_diff(func_get_args(), $enabled, $missing); + $already_enabled = array_intersect(func_get_args(), $enabled); if ($missing) { drush_print(dt('The following importers are missing: !importers', array('!importers' => implode(', ', $missing)))); } - if ($to_delete) { - drush_print(dt('The following feeds will be deleted: !importers', array('!importers' => implode(', ', array_keys($to_delete))))); + if ($already_enabled) { + drush_print(dt('The following importers are already enabled: !importers', array('!importers' => implode(', ', $already_enabled)))); + } + + if ($to_enable) { + drush_print(dt('The following importers will be enabled: !importers', array('!importers' => implode(', ', $to_enable)))); } else { - return drush_print(dt('There are no importers to delete.')); + return drush_print(dt('There are no importers to enable.')); } if (!drush_confirm(dt('Do you really want to continue?'))) { return drush_log(dt('Aborting.')); } - foreach ($to_delete as $importer) { - $importer->delete(); - drush_log(dt('!importer was deleted successfully.', array('!importer' => $importer->id)), 'ok'); + $disabled = variable_get('default_feeds_importer', array()); + + foreach ($to_enable as $importer) { + unset($disabled[$importer]); + drush_log(dt('!importer has been enabled.', array('!importer' => $importer)), 'ok'); } - feeds_cache_clear(); + variable_set('default_feeds_importer', $disabled); } /** - * Reverts a set of feeds. + * Disables a set of Feeds importers. */ -function drush_feeds_revert() { - $all = feeds_importer_load_all(TRUE); - $missing = array_diff(func_get_args(), array_keys($all)); - $to_revert = array_intersect_key($all, array_flip(func_get_args())); - $cant_revert = array(); - - // Filter out non-overridden importers. - foreach ($to_revert as $delta => $importer) { - if ($importer->export_type !== (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) { - unset($to_revert[$delta]); - $cant_revert[$importer->id] = $importer->id; - } - } +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 ($cant_revert) { - drush_print(dt('The following feeds will be cannot be reverted: !importers', array('!importers' => implode(', ', array_keys($cant_revert))))); + if ($already_disabled) { + drush_print(dt('The following importers are already disabled: !importers', array('!importers' => implode(', ', $already_disabled)))); } - if ($to_revert) { - drush_print(dt('The following feeds will be reverted: !importers', array('!importers' => implode(', ', array_keys($to_revert))))); + if ($to_disable) { + drush_print(dt('The following importers will be disabled: !importers', array('!importers' => implode(', ', $to_disable)))); } else { - return drush_print(dt('There are no importers to revert.')); + 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.')); } - foreach ($to_revert as $importer) { - $importer->delete(); - drush_log(dt('!importer was reverted successfully.', array('!importer' => $importer->id)), 'ok'); + $disabled = variable_get('default_feeds_importer', array()); + foreach ($to_disable as $importer) { + $disabled[$importer] = TRUE; + drush_log(dt('!importer has been disabled.', array('!importer' => $importer)), 'ok'); } - + variable_set('default_feeds_importer', $disabled); feeds_cache_clear(); } /** - * Enables a set of Feeds importers. + * Deletes a set of Feeds importers. */ -function drush_feeds_enable() { - $all = array_keys(feeds_importer_load_all(TRUE)); - $enabled = array_keys(feeds_importer_load_all()); - $missing = array_diff(func_get_args(), $all); - $to_enable = array_diff(func_get_args(), $enabled, $missing); - $already_enabled = array_intersect(func_get_args(), $enabled); +function drush_feeds_delete() { + $all = feeds_importer_load_all(TRUE); + $to_delete = array_intersect_key($all, array_flip(func_get_args())); + $missing = array_diff(func_get_args(), array_keys($all)); if ($missing) { drush_print(dt('The following importers are missing: !importers', array('!importers' => implode(', ', $missing)))); } - if ($already_enabled) { - drush_print(dt('The following importers are already enabled: !importers', array('!importers' => implode(', ', $already_enabled)))); - } - - if ($to_enable) { - drush_print(dt('The following importers will be enabled: !importers', array('!importers' => implode(', ', $to_enable)))); + if ($to_delete) { + drush_print(dt('The following feeds will be deleted: !importers', array('!importers' => implode(', ', array_keys($to_delete))))); } else { - return drush_print(dt('There are no importers to enable.')); + return drush_print(dt('There are no importers to delete.')); } if (!drush_confirm(dt('Do you really want to continue?'))) { return drush_log(dt('Aborting.')); } - $disabled = variable_get('default_feeds_importer', array()); - - foreach ($to_enable as $importer) { - unset($disabled[$importer]); - drush_log(dt('!importer has been enabled.', array('!importer' => $importer)), 'ok'); + foreach ($to_delete as $importer) { + $importer->delete(); + drush_log(dt('!importer was deleted successfully.', array('!importer' => $importer->id)), 'ok'); } - variable_set('default_feeds_importer', $disabled); + feeds_cache_clear(); } /** - * Disables a set of Feeds importers. + * Reverts a set of feeds. */ -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); +function drush_feeds_revert() { + $all = feeds_importer_load_all(TRUE); + $missing = array_diff(func_get_args(), array_keys($all)); + $to_revert = array_intersect_key($all, array_flip(func_get_args())); + $cant_revert = array(); + + // Filter out non-overridden importers. + foreach ($to_revert as $delta => $importer) { + if ($importer->export_type !== (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) { + unset($to_revert[$delta]); + $cant_revert[$importer->id] = $importer->id; + } + } 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 ($cant_revert) { + drush_print(dt('The following feeds will be cannot be reverted: !importers', array('!importers' => implode(', ', array_keys($cant_revert))))); } - if ($to_disable) { - drush_print(dt('The following importers will be disabled: !importers', array('!importers' => implode(', ', $to_disable)))); + if ($to_revert) { + drush_print(dt('The following feeds will be reverted: !importers', array('!importers' => implode(', ', array_keys($to_revert))))); } else { - return drush_print(dt('There are no importers to disable.')); + return drush_print(dt('There are no importers to revert.')); } if (!drush_confirm(dt('Do you really want to continue?'))) { return drush_log(dt('Aborting.')); } - $disabled = variable_get('default_feeds_importer', array()); - foreach ($to_disable as $importer) { - $disabled[$importer] = TRUE; - drush_log(dt('!importer has been disabled.', array('!importer' => $importer)), 'ok'); + foreach ($to_revert as $importer) { + $importer->delete(); + drush_log(dt('!importer was reverted successfully.', array('!importer' => $importer->id)), 'ok'); } - variable_set('default_feeds_importer', $disabled); + feeds_cache_clear(); }