class views_content_cache_key_og in Views content cache 6.2
Same name and namespace in other branches
- 7.3 plugins/views_content_cache/og.inc \views_content_cache_key_og
Views content cache plugin for Organic Groups.
This plugin allows using OG as a cache segment, views caching can depend on the current group context, and/or all the groups that the current user belongs to.
Hierarchy
- class \views_content_cache_key
- class \views_content_cache_key_og
Expanded class hierarchy of views_content_cache_key_og
1 string reference to 'views_content_cache_key_og'
- views_content_cache_views_content_cache_plugins in ./
views_content_cache.module - Implementation of hook_context_plugins().
File
- plugins/
og.inc, line 10
View source
class views_content_cache_key_og extends views_content_cache_key {
function options_form($value, &$handler) {
return array(
'#title' => t('Organic Groups'),
'#description' => t('Checks for updates related to Organic Groups'),
'#type' => 'checkboxes',
'#options' => array_merge(array(
'current' => t('Current group'),
'user' => t("Member's groups"),
), $this
->additional_options_for_arguments($handler->view)),
'#default_value' => $value,
);
}
function content_key($object, $object_type) {
$keys = array();
if ($object_type === 'node' && !empty($object->og_groups)) {
foreach ($object->og_groups as $gid) {
$keys[] = $gid;
}
}
elseif ($object_type === 'comment' && !empty($object['nid']) && ($node = node_load($object['nid'])) && !empty($node->og_groups)) {
foreach ($node->og_groups as $gid) {
$keys[] = $gid;
}
}
return $keys;
}
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);
}
function view_key_from_arguments() {
return array(
'og_views_handler_argument_og_group_nid',
);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
views_content_cache_key:: |
function | Handy helper method that scans the given view looking for arguments. | ||
views_content_cache_key:: |
function | The method by which this plugin's where clause will be combined with others. | 2 | |
views_content_cache_key:: |
function | Replaces values corresponding to argument values set dynamically. | ||
views_content_cache_key_og:: |
function |
Builds an array of keys for the cache segment. Overrides views_content_cache_key:: |
||
views_content_cache_key_og:: |
function |
Optionally provides a option form for the user to use this segment. Overrides views_content_cache_key:: |
||
views_content_cache_key_og:: |
function |
An array of keys to check in this cache segment when viewing the view. Overrides views_content_cache_key:: |
||
views_content_cache_key_og:: |
function |
Returns an array of views arguments that can supply valid key values. Overrides views_content_cache_key:: |