1 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 configuring the view.

File

core/modules/views_ui/views_ui.module, line 336
Provide structure for the administrative interface to Views.

Code

function views_ui_cache_load($name) {
  global $user;

  $view = tempstore_get('views.view', $name);
  $original_view = views_get_view($name);

  if (empty($view)) {
    $view = $original_view;
    if (!empty($view)) {
      // Set a flag to indicate that this view is being configured.
      // 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);
    }
    // Remove the lock if being configured by the user that owns the lock.
    if (!empty($view->locked) && $view->locked->uid === $user->uid) {
      unset($view->locked);
    }
  }

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

  else {
    return $view;
  }
}