function drush_onlyone_disable in Allow a content type only once (Only One) 7
Same name and namespace in other branches
- 8 onlyone.drush.inc \drush_onlyone_disable()
Callback for the onlyone-disable command.
File
- ./onlyone.drush.inc, line 268 
- Drush commands related to the Only One module.
Code
function drush_onlyone_disable() {
  $args = array_unique(func_get_args());
  // Getting the configured content types to have only one content.
  $onlyone_content_types = variable_get('onlyone_node_types');
  // Deleting the values.
  $content_types_not_configured = array();
  foreach ($args as $content_type) {
    // Validating if the content types are configured.
    if (!in_array($content_type, $onlyone_content_types)) {
      $content_types_not_configured[] = $content_type;
    }
    else {
      // Loading the helper functions file.
      module_load_include('inc', 'onlyone', 'onlyone.helpers');
      // Deleting the content type configuration.
      _onlyone_delete_content_type_config($content_type);
    }
  }
  // Printing the content types that will not be deleted from the configuration
  // (they are not configured to have Only One content).
  if (count($content_types_not_configured)) {
    $names = implode(', ', $content_types_not_configured);
    $singular = "The following content type is not configured in 'Only One content' mode: @names";
    $plural = "The following content types are not configured in 'Only One content' mode: @names";
    $cant = count($content_types_not_configured);
    $message = _onlyone_drush_plural($cant, $singular, $plural, array(
      '@names' => $names,
    ));
    drush_log($message, 'warning');
  }
  // Printing the configured content types that comes from be disable from the
  // Only One configuration.
  $content_types_to_disable = array_diff($args, $content_types_not_configured);
  if (count($content_types_to_disable)) {
    $names = implode(', ', $content_types_to_disable);
    $singular = "In the following content type the 'Only One content' mode was disabled: @names";
    $plural = "In the following content types the 'Only One content' mode was disabled: @names";
    $cant = count($content_types_to_disable);
    $message = _onlyone_drush_plural($cant, $singular, $plural, array(
      '@names' => $names,
    ));
    drush_log($message, 'success');
  }
}