? og-og_views-member-count-link-558134-21.patch
Index: modules/og_views/includes/og_views_handler_field_og_member_count.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/og/modules/og_views/includes/Attic/og_views_handler_field_og_member_count.inc,v
retrieving revision 1.3
diff -u -p -r1.3 og_views_handler_field_og_member_count.inc
--- modules/og_views/includes/og_views_handler_field_og_member_count.inc	29 Oct 2008 20:01:07 -0000	1.3
+++ modules/og_views/includes/og_views_handler_field_og_member_count.inc	22 Oct 2010 16:49:44 -0000
@@ -1,5 +1,25 @@
 <?php
 class og_views_handler_field_og_member_count extends views_handler_field_numeric {
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['link_to_members'] = array('default' => TRUE);
+    return $options;
+  }
+  
+  /**
+   * Provide link to members option
+   */
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+    $form['link_to_members'] = array(
+      '#title' => t('Link this field to a groups members'),
+      '#description' => t('This will override any other link you have set.'),
+      '#type' => 'checkbox',
+      '#default_value' => !empty($this->options['link_to_members']),
+    );
+  }
+  
   function query() {
     $table = $this->query->ensure_table('og');
     $sql = og_list_users_sql(1, 0, NULL, TRUE);
@@ -8,15 +28,20 @@ class og_views_handler_field_og_member_c
     $this->field_alias = 'member_count';
   }
   
-  function render($values) {
-    $nid = $values->nid;
-    $txt = $values->member_count;
-    if (og_is_group_member($nid)) {
-      $value = og_is_picture() ? l($txt, "og/users/$nid/faces") : l($txt, "og/users/$nid");
-      return check_plain($this->options['prefix']) . $value . check_plain($this->options['suffix']);
-    }
-    else {
-      return parent::render($values);
+  /**
+   * Render data as a link to group members.
+   *
+   * Data should be made XSS safe prior to calling this function.
+   */
+  function render_link($data, $values) {
+    if (!empty($this->options['link_to_members']) && $data !== NULL && $data !== ''  && og_is_group_member($this->aliases['nid'])) {
+      $this->options['alter']['make_link'] = TRUE;
+      $this->options['alter']['path'] = "og/users/" . $values->{$this->aliases['nid'] . "/faces"};
     }
+    return $data;
+  }
+
+  function render($values) {
+    return $this->render_link(check_plain($values->{$this->field_alias}), $values);
   }
-}
\ No newline at end of file
+}
