class og_views_handler_field_og_uid_groups in Organic groups 6
Same name and namespace in other branches
- 6.2 modules/og_views/includes/og_views_handler_field_og_uid_groups.inc \og_views_handler_field_og_uid_groups
Field handler for displaying a list of groups for a user.
Hierarchy
- class \og_views_handler_field_og_uid_groups extends \views_handler_field_prerender_list
Expanded class hierarchy of og_views_handler_field_og_uid_groups
1 string reference to 'og_views_handler_field_og_uid_groups'
- og_views_data_og_uid in modules/
og_views/ og_views.views.inc
File
- modules/
og_views/ includes/ og_views_handler_field_og_uid_groups.inc, line 5
View source
class og_views_handler_field_og_uid_groups extends views_handler_field_prerender_list {
/**
* Fake the field alias -- we don't want to actually join.
*/
function init(&$view, $options) {
parent::init($view, $options);
switch ($view->base_table) {
case 'node':
$this->additional_fields['users_uid'] = array(
'table' => 'users',
'field' => 'uid',
);
$this->field_alias = 'users_uid';
break;
case 'users':
$this->field_alias = 'uid';
break;
}
}
/**
* Add this term to the query
*/
function query() {
$this
->add_additional_fields();
}
/**
* Query in pre_render to grab what we need.
*/
function pre_render($values) {
$uids = array();
foreach ($values as $row) {
if (!empty($row->{$this->field_alias})) {
$uids[] = $row->{$this->field_alias};
}
}
if (!empty($uids)) {
$placeholders = db_placeholders($uids, 'int');
$result = db_query(db_rewrite_sql("SELECT n.nid, n.title, ogu.uid FROM {node} n JOIN {og_uid} ogu ON ogu.nid = n.nid WHERE ogu.uid IN ({$placeholders}) AND n.status = 1"), $uids);
while ($row = db_fetch_object($result)) {
$this->items[$row->uid][$row->nid] = l($row->title, "node/{$row->nid}");
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
og_views_handler_field_og_uid_groups:: |
function | Fake the field alias -- we don't want to actually join. | ||
og_views_handler_field_og_uid_groups:: |
function | Query in pre_render to grab what we need. | ||
og_views_handler_field_og_uid_groups:: |
function | Add this term to the query |