You are here

function og_handler_post_count in Organic groups 5

Same name and namespace in other branches
  1. 5.8 og_views.inc \og_handler_post_count()
  2. 5.3 og_views.inc \og_handler_post_count()
  3. 5.7 og_views.inc \og_handler_post_count()

Views handler to display the number of posts in the group

1 string reference to 'og_handler_post_count'
og_views_tables in ./og_views.inc
Implementation of the hook_views_tables()

File

./og_views.inc, line 1296

Code

function og_handler_post_count($fieldinfo, $fielddata, $value, $data) {
  $where = '';
  if ($fielddata['options'] != 'all') {
    $where = " AND n.type = '%s'";
  }

  // the $where at end is harmless even when not used.
  // we specify COUNT(n.nid) instead of COUNT(*) so that dupe nids are omitted.
  $cnt = db_result(db_query(db_rewrite_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 {$where}"), $data->nid, $fielddata['options']));
  return $cnt;
}