/
og_context_plugin_argument_default_group_context.inc
54 lines (48 loc) · 1.49 KB
/
og_context_plugin_argument_default_group_context.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @file
* Contains the group context argument default plugin.
*/
/**
* The group context argument default handler.
*/
class og_context_plugin_argument_default_group_context extends views_plugin_argument_default {
/**
* Retrieve the options when this is a new access
* control plugin
*/
function option_definition() {
$options = parent::option_definition();
$options['group_type'] = array('default' => 'node');
return $options;
}
/**
* Provide the default form for setting options.
*/
function options_form(&$form, &$form_state) {
$form['group_type'] = array(
'#type' => 'select',
'#options' => og_get_all_group_entity(),
'#title' => t('Group type'),
'#default_value' => $this->options['group_type'],
'#description' => t('Determine what entity type that group should be of.')
);
$form['check_access'] = array(
'#type' => 'select',
'#options' => array(t('No'), t('Yes')),
'#title' => t('Check access'),
'#default_value' => $this->options['check_access'],
'#description' => t('Determines if access to the group should be done. Defaults to "Yes".')
);
}
/**
* Return the group context argument.
*/
function get_argument() {
$check_access = (isset($this->options['check_access']) && $this->options['check_access'] == 0) ? FALSE : TRUE;
if ($group = og_context($this->options['group_type'], NULL, NULL, $check_access)) {
return $group['gid'];
}
return FALSE;
}
}