Tried to add list of user groups for the faces page, didn't find solution...

Here my way changed og_user_roles_/views/handlers/ogur_handler_field_og_users_roles.inc :

class ogur_handler_field_og_users_roles extends views_handler_field_prerender_list {
  function construct() {
    parent::construct();
    $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');
    $this->additional_fields['gid'] = array('table' => 'og', 'field' => 'nid');
  }

  function query() {
    $this->add_additional_fields();
    $this->field_alias = $this->aliases['uid'];
  }

  function pre_render($values) {
    $uids = array();
    $this->items = array();
    $group_id = false;

    foreach ($values as $result) {
      $uids[] = $result->{$this->aliases['uid']};
      if(!$group_id)
     {
        $group_id = $result->{$this->aliases['gid']};
     }
    }

    if ($uids) {
      $result = db_query("SELECT u.uid, u.rid, r.name FROM {role} r INNER JOIN {og_users_roles} u ON u.rid = r.rid WHERE u.uid IN (" . implode(', ', $uids) . ") AND u.gid = {$group_id} ORDER BY r.name");
      while ($role = db_fetch_object($result)) {
//        $this->items[$role->uid][$role->rid] = check_plain($role->name);
          $this->items[$role->uid][$role->rid] = l(t($role->name), "og/users/$group_id/roles", array('query' => drupal_get_destination()));
      }
    }
  }
}

It works for me.

Comments

somebodysysop’s picture

Assigned: Unassigned » somebodysysop
Status: Active » Postponed (maintainer needs more info)

Thanks for the code.

This issue was resolved here: http://drupal.org/node/406762

Did you try using OGUR Groups: OGUR: Roles in current group?

Question for you: With this code, is it still possible to see what roles a user has in *all* groups? In other words, right now we can see all the roles a user has in one group (the current group). But, suppose we want to see what roles a user has in all groups he belongs to? Does your code allow for that, or does it require a group context in order to return anything?

Again, thanks.

cisur’s picture

My goal was to display for each group user his roles :)

OGUR Groups: OGUR: Roles in current group? using this field generate SQL error because of current group content is gotten using og_get_group_context().

->Does your code allow for that, or does it require a group context in order to return anything?
No, I'm not so experience with Views :)

HTH

sun’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

With the rise of the rewritten OGUR 4.x for Drupal 6, in which many unrelated features of OGUR were removed, and nearing a release of Drupal 7, I'm closing down old issues.

somebodysysop’s picture

Status: Closed (won't fix) » Postponed (maintainer needs more info)

The person who changed the status of these issues to "won't fix" was not authorized to do so: http://drupal.org/node/352139#comment-2352234

OGUR 6.x-1.x will continue to be maintained by me.