function _views_drush_changestatus

Helper function to enable / disable views.

Parameters

array $viewnames: Names of the views to process.

bool $status: TRUE to disable or FALSE to enable the view.

2 calls to _views_drush_changestatus()
drush_views_disable in drush/views.drush.inc
Disables views.
drush_views_enable in drush/views.drush.inc
Enables views.

File

drush/views.drush.inc, line 492

Code

function _views_drush_changestatus($viewnames = array(), $status = NULL) {
    if ($status !== NULL && !empty($viewnames)) {
        $changed = FALSE;
        $processed = $status ? dt('disabled') : dt('enabled');
        $views_status = variable_get('views_defaults', array());
        foreach ($viewnames as $viewname) {
            if ($views_status[$viewname] !== $status) {
                $views_status[$viewname] = $status;
                $changed = TRUE;
                drush_log(dt("The view '!name' has been !processed", array(
                    '!name' => $viewname,
                    '!processed' => $processed,
                )), 'success');
            }
            else {
                drush_set_error(dt("The view '!name' is already !processed", array(
                    '!name' => $viewname,
                    '!processed' => $processed,
                )));
            }
        }
        // If we made changes to views status, save them and clear caches.
        if ($changed) {
            variable_set('views_defaults', $views_status);
            views_invalidate_cache();
            drush_log(dt("Views cache was cleared"), 'ok');
            drush_log(dt("Menu cache is set to be rebuilt on the next request."), 'ok');
        }
    }
}