You are here

function views_content_cache_key_og::view_key in Views content cache 6.2

Same name and namespace in other branches
  1. 7.3 plugins/views_content_cache/og.inc \views_content_cache_key_og::view_key()

An array of keys to check in this cache segment when viewing the view.

As a user views a view, we are asked for the keys that views content cache should consider in our segment. Normally we'd just return the values as set by the user from our options_form().

Parameters

$values: An array of values that was stored from our form element in options_form().

Return value

An array of keys in our cache segment.

Overrides views_content_cache_key::view_key

File

plugins/og.inc, line 39

Class

views_content_cache_key_og
Views content cache plugin for Organic Groups.

Code

function view_key($values, &$handler) {
  $values = array_filter($values);
  $groups = array();
  if (!empty($values['current']) && ($current = og_get_group_context())) {
    $groups[] = $current->nid;
  }
  if (!empty($values['user'])) {
    global $user;
    if (!empty($user->og_groups)) {
      $groups = array_merge($groups, array_keys($user->og_groups));
    }
  }
  unset($values['current'], $values['user']);

  // Add in the arguments.
  foreach ($this
    ->view_key_replace_arguments($values, $handler) as $gid) {
    $groups[] = $gid;
  }
  return array_unique($groups);
}