You are here

function drush_node_revision_delete_nrd_minimum_age_to_delete_time in Node Revision Delete 7.3

Same name and namespace in other branches
  1. 8 node_revision_delete.drush.inc \drush_node_revision_delete_nrd_minimum_age_to_delete_time()

Callback for the nrd-minimum-age-to-delete-time command.

File

./node_revision_delete.drush.inc, line 403

Code

function drush_node_revision_delete_nrd_minimum_age_to_delete_time() {
  $args = func_get_args();

  // Getting or setting values?
  if (isset($args[0])) {

    // Saving the values in the config.
    $node_revision_delete_minimum_age_to_delete_time['max_number'] = $args[0];
    $node_revision_delete_minimum_age_to_delete_time['time'] = $args[1];
    variable_set('node_revision_delete_minimum_age_to_delete_time', $node_revision_delete_minimum_age_to_delete_time);

    // We need to update the max_number in the existing content type
    // configuration if the new value is lower than the actual.
    _node_revision_delete_update_time_max_number_config('minimum_age_to_delete', $args[0]);

    // Is singular or plural?
    $time = _node_revision_delete_time_number_string($args[0], $args[1]);
    $message = dt('The maximum time for the minimum age was set to @max_number @time.', array(
      '@max_number' => $args[0],
      '@time' => $time,
    ));
    drush_log($message, 'success');
  }
  else {

    // Getting the values from the config.
    $node_revision_delete_minimum_age_to_delete_time = variable_get('node_revision_delete_minimum_age_to_delete_time');
    $max_number = $node_revision_delete_minimum_age_to_delete_time['max_number'];
    $time = $node_revision_delete_minimum_age_to_delete_time['time'];

    // Is singular or plural?
    $time = _node_revision_delete_time_number_string($max_number, $time);
    $message = dt('The maximum time for the minimum age is: @max_number @time.', array(
      '@max_number' => $max_number,
      '@time' => $time,
    ));
    drush_print($message);
  }
}