function og_handler_field_user_roles::query in Organic groups 7.2
Same name and namespace in other branches
- 7 includes/views/og_handler_field_user_roles.inc \og_handler_field_user_roles::query()
Called to add the field to a query.
Overrides views_handler_field::query
File
- includes/
views/ handlers/ og_handler_field_user_roles.inc, line 8
Class
- og_handler_field_user_roles
- Field handler to provide a list of OG roles of a user.
Code
function query() {
// Get a user table we can relate to.
// @todo: Make the used user relationship configurable.
foreach ($this->query->relationships as $alias => $info) {
if ($info['table'] == 'users') {
$user_table_alias = $alias;
}
elseif ($info['table'] == 'og_membership') {
$og_membership_table_alias = $alias;
}
if (!empty($user_table_alias) && !empty($og_membership_table_alias)) {
break;
}
}
// If there is a users table present use its uid. Else, skip this field.
if (!empty($user_table_alias)) {
$this->aliases['uid'] = $this->query
->add_field($user_table_alias, 'uid');
}
if (!empty($og_membership_table_alias)) {
$this->aliases['group_type'] = $this->query
->add_field($og_membership_table_alias, 'group_type');
}
parent::query();
}