Commit 3edf19ce authored by dawehner's avatar dawehner Committed by tim.plunkett

Change the status of a view in the UI

parent 74e8a3db
......@@ -361,7 +361,13 @@ function add_template_page($js, $input, $name, $step = NULL) {
}
function set_item_state($state, $js, $input, $item) {
ctools_export_set_object_status($item, $state);
if (!$state) {
$item->enable();
}
else {
$item->disable();
}
$item->save();
menu_router_rebuild();
if (!$js) {
......
......@@ -38,6 +38,7 @@ function views_schema() {
'load all callback' => 'views_get_all_views',
'load callback' => 'views_storage_load',
'save callback' => 'views_storage_save',
'status callback' => 'views_storage_status',
'subrecords callback' => 'views_load_display_records',
// the variable that holds enabled/disabled status
'status' => 'views_defaults',
......
......@@ -1575,7 +1575,7 @@ function views_get_all_views($reset = FALSE) {
}
/**
* Loads a view with the storage controller.
* Load a view with the storage controller.
*
* @param string $id
* The view name to load.
......@@ -1589,11 +1589,36 @@ function views_storage_load($id) {
return reset($result);
}
/**
* Save a view with the storage controller.
*
* @param Drupal\views\View $view
* The view which is saved.
*
* @return
* SAVED_NEW or SAVED_UPDATED is returned depending on the operation
* performed.
*/
function views_storage_save(View $view) {
$controller = entity_get_controller('view');
return $controller->save($view);
}
/**
* Change the status of a view.
*
* @param Drupal\views\View $view
* The view which gets a different status.
*/
function views_storage_status(View $view, $status) {
if (!$status) {
$view->enable();
}
else {
$view->disable();
}
}
/**
* Returns an array of all enabled views, as fully loaded $view objects.
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment