You are here

og_views_handler_field_og_group_nids.inc in Organic groups 6.2

Same filename and directory in other branches
  1. 6 modules/og_views/includes/og_views_handler_field_og_group_nids.inc

File

modules/og_views/includes/og_views_handler_field_og_group_nids.inc
View source
<?php

class og_views_handler_field_og_group_nids extends views_handler_field_prerender_list {
  function init(&$view, $options) {
    parent::init($view, $options);
    $this->additional_fields['og_ancestry_nid'] = array(
      'table' => 'og_ancestry',
      'field' => 'nid',
    );
  }

  /**
   * Add this term to the query
   */
  function query() {
    $this
      ->add_additional_fields();
  }

  // we have to query to get all the groups into a single element
  function pre_render($values) {

    // field_alias is used by our render method.
    $this->field_alias = $this->aliases['og_ancestry_nid'];
    foreach ($values as $value) {
      $result = og_get_node_groups_result($value->{$this->field_alias});
      while ($row = db_fetch_object($result)) {
        $this->items[$value->{$this->field_alias}][$row->group_nid] = l($row->title, "node/{$row->group_nid}");
      }
    }
  }

}