function _views_drush_changestatus
Same name in other branches
- 7.x-3.x drush/views.drush.inc \_views_drush_changestatus()
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 436
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 $key => $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');
menu_rebuild();
drush_log(dt("Menu cache was cleared"), 'ok');
}
}
}