function views_ui_cache_load

3.x views_ui.module views_ui_cache_load($name)
2.x views_ui.module views_ui_cache_load($name)

Specialized menu callback to load a view and check its locked status.

Parameters

$name: The machine name of the view.

Return value

The view object, with a "locked" property indicating whether or not someone else is already editing the view.

2 calls to views_ui_cache_load()
views_ui::load_item in plugins/export_ui/views_ui.class.php
views_ui_edit_form_submit_preview in includes/admin.inc
Submit handler when Preview button is clicked.

File

./views_ui.module, line 289
Provide structure for the administrative interface to Views.

Code

function views_ui_cache_load($name) {
  ctools_include('object-cache');
  views_include('view');
  $view = ctools_object_cache_get('view', $name);
  $original_view = views_get_view($name);

  if (empty($view)) {
    $view = $original_view;
    if (!empty($view)) {
      // Check to see if someone else is already editing this view.
      $view->locked = ctools_object_cache_test('view', $view->name);
      // Set a flag to indicate that this view is being edited.
      // This flag will be used e.g. to determine whether strings
      // should be localized.
      $view->editing = TRUE;
    }
  }
  else {
    // Keep disabled/enabled status real.
    if ($original_view) {
      $view->disabled = !empty($original_view->disabled);
    }
  }

  if (empty($view)) {
    return FALSE;
  }

  else {
    return $view;
  }
}