og_views_handler_field_og_post_count.inc in Organic groups 6
File
modules/og_views/includes/og_views_handler_field_og_post_count.inc
View source
<?php
class og_views_handler_field_og_post_count extends views_handler_field_numeric {
function query() {
$table = $this->query
->ensure_table('og');
$sql = "SELECT COUNT(n.nid) FROM {node} n INNER JOIN {og_ancestry} oga ON n.nid = oga.nid WHERE n.status = 1 AND oga.group_nid = %d";
$sql = str_replace('%d', 'og.nid', $sql);
$this->query
->add_field('', "({$sql})", 'post_count');
$this->field_alias = 'post_count';
}
}