1 views_handler_filter.inc views_handler_filter::store_exposed_input($input, $status)

If set to remember exposed input in the session, store it there.

Overrides views_handler::store_exposed_input

File

core/modules/views/handlers/views_handler_filter.inc, line 1325
@todo.

Class

views_handler_filter
Base class for filters.

Code

function store_exposed_input($input, $status) {
  if (empty($this->options['exposed']) || empty($this->options['expose']['identifier'])) {
    return TRUE;
  }

  if (empty($this->options['expose']['remember'])) {
    return;
  }

  // Check if we store exposed value for current user.
  global $user;
  $allowed_rids = empty($this->options['expose']['remember_roles']) ? array() : array_filter($this->options['expose']['remember_roles']);
  $intersect_rids = array_intersect($allowed_rids, $user->roles);
  if (empty($intersect_rids)) {
    return;
  }

  // Figure out which display id is responsible for the filters, so we
  // know where to look for session stored values.
  $display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;

  // shortcut test.
  $operator = !empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']);

  // false means that we got a setting that means to recuse ourselves,
  // so we should erase whatever happened to be there.
  if (!$status && isset($_SESSION['views'][$this->view->name][$display_id])) {
    $session = &$_SESSION['views'][$this->view->name][$display_id];
    if ($operator && isset($session[$this->options['expose']['operator_id']])) {
      unset($session[$this->options['expose']['operator_id']]);
    }

    if (isset($session[$this->options['expose']['identifier']])) {
      unset($session[$this->options['expose']['identifier']]);
    }
  }

  if ($status) {
    if (!isset($_SESSION['views'][$this->view->name][$display_id])) {
      $_SESSION['views'][$this->view->name][$display_id] = array();
    }

    $session = &$_SESSION['views'][$this->view->name][$display_id];

    if ($operator && isset($input[$this->options['expose']['operator_id']])) {
      $session[$this->options['expose']['operator_id']] = $input[$this->options['expose']['operator_id']];
    }

    $session[$this->options['expose']['identifier']] = $input[$this->options['expose']['identifier']];
  }
}