function drush_rules_enable

Enable a rule on the site.

File

./rules.drush.inc, line 135

Code

function drush_rules_enable() {
    $args = func_get_args();
    $rule_name = !empty($args) && is_array($args) ? array_shift($args) : '';
    if (empty($rule_name)) {
        return drush_set_error('', 'No rule name given.');
    }
    $rule = rules_config_load($rule_name);
    if (empty($rule)) {
        return drush_set_error('', dt('Could not load rule named "!rule-name".', array(
            '!rule-name' => $rule_name,
        )));
    }
    if (empty($rule->active)) {
        $rule->active = TRUE;
        $rule->save();
        drush_log(dt('The rule "!name" has been enabled.', array(
            '!name' => $rule_name,
        )), 'success');
    }
    else {
        drush_log(dt('The rule "!name" is already enabled.', array(
            '!name' => $rule_name,
        )), 'warning');
    }
}