You are here

function drush_modules_weight_mw_show_system_modules in Modules weight 7

Same name and namespace in other branches
  1. 8.2 modules_weight.drush.inc \drush_modules_weight_mw_show_system_modules()
  2. 8 modules_weight.drush.inc \drush_modules_weight_mw_show_system_modules()

Callback for the mw-show-system-modules command.

File

./modules_weight.drush.inc, line 121
Drush commands related to the Modules weight module.

Code

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

  // Getting the values from the config.
  $show_system_modules = variable_get('modules_weight_show_system_modules');

  // Giving colors to the messages.
  $activated = sprintf(MODULES_WEIGHT_GREEN_OUTPUT, dt('Activated'));
  $disabled = sprintf(MODULES_WEIGHT_RED_OUTPUT, dt('Disabled'));
  if (isset($args[0])) {
    list($value, $status) = $args[0] == 'on' ? array(
      1,
      strtolower($activated),
    ) : array(
      0,
      strtolower($disabled),
    );

    // Is already configured?
    if ($show_system_modules == $value) {

      // If is configured stop the command execution with a warning message.
      $message = dt('The core modules reorder option is already @status.', array(
        '@status' => $status,
      ));
      drush_log($message, 'warning');

      // Returning here to stop the function execution.
      return;
    }

    // Saving the values in the config.
    variable_set('modules_weight_show_system_modules', $value);
    $message = dt('You have @status the core modules reorder option.', array(
      '@status' => $status,
    ));
    drush_log($message, 'success');
  }
  else {
    $status = $show_system_modules ? $activated : $disabled;
    $message = dt('The core modules reorder option is: @status', array(
      '@status' => $status,
    ));
    drush_print($message);
  }
}