og_plugin_argument_validate_group.inc in Organic groups 7.2
File
includes/views/handlers/og_plugin_argument_validate_group.inc
View source
<?php
class og_plugin_argument_validate_group extends views_plugin_argument_validate {
function option_definition() {
$options = parent::option_definition();
$groups = og_get_all_group_entity();
$options['group_type'] = array(
'default' => key($groups),
);
return $options;
}
function options_form(&$form, &$form_state) {
$form['group_type'] = array(
'#type' => 'select',
'#title' => t('Group type'),
'#description' => t('Select the group type.'),
'#options' => og_get_all_group_entity(),
'#default_value' => $this->options['group_type'],
'#required' => og_get_all_group_entity(),
);
}
function validate_argument($argument) {
if (empty($argument)) {
return;
}
$group_type = $this->options['group_type'];
$entity = entity_load_single($group_type, $argument);
if (!$entity || !og_is_group($group_type, $entity)) {
return FALSE;
}
$this->argument->argument = $argument;
$this->argument->validated_title = entity_label($group_type, $entity);
return TRUE;
}
}