Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.148
diff -u -r1.148 signup.module
--- signup.module	7 Oct 2008 08:20:08 -0000	1.148
+++ signup.module	8 Oct 2008 08:22:53 -0000
@@ -810,20 +810,29 @@
     }
   }
 
-  // If the user has the view signups perm, display the current signups.
+  // Should the list of signed-up users be displayed at the bottom of the page?
+  $display_list = variable_get('signup_views_signup_user_list', 0) > 0;
+  if (!module_exists('views')) {
+  	$display_list = TRUE;
+  }
+  
+  // If the user has the view signups perm and the admin decides to display
+  // the list at the bottom of the page, display the current signups.
   // Pull all users signed up for this event, and start table creation.
-  if (user_access('view all signups')) {
-    $registered_signups = db_query("SELECT u.uid, u.name, s.signup_time, s.form_data FROM {signup_log} s INNER JOIN {users} u ON u.uid = s.uid WHERE s.nid = %d AND u.uid <> 0", $node->nid);
-    $anon_signups = db_num_rows(db_query("SELECT anon_mail FROM {signup_log} WHERE nid = %d AND uid = 0", $node->nid));
-    $header = array(array('data' => t('!users signed up', array('!users' => format_plural((db_num_rows($registered_signups) + $anon_signups), '1 individual', '@count individuals')))));
-    $rows = array();
-    while ($signed_up_user = db_fetch_object($registered_signups)) {
-      $rows[] = array(theme('username', $signed_up_user));
-    }
-    if ($anon_signups) {
-      $rows[] = array(t('!count anonymous', array('!count' => $anon_signups)));
-    }
-    $output .= theme('table', $header, $rows);
+  if (user_access('view all signups') && $display_list) {
+    $registered_query = db_query("SELECT u.uid, u.name, s.signup_time, s.form_data FROM {signup_log} s INNER JOIN {users} u ON u.uid = s.uid WHERE s.nid = %d AND u.uid <> 0", $node->nid);
+    $registered_signups = array();
+    while ($signed_up_user = db_fetch_object($registered_query)) {
+      $registered_signups[] = $signed_up_user;
+    }
+    $anon_query = db_query("SELECT * FROM {signup_log} WHERE nid = %d AND uid = 0", $node->nid);
+    $anon_signups = array();
+    while ($signed_up_user = db_fetch_object($anon_query)) {
+      $anon_signups[] = $signed_up_user;
+    }
+    
+    include_once(SIGNUP_PATH .'/signup.theme');
+    $output .= theme('signup_user_list', $registered_signups, $anon_signups);
   }
   return $output;
 }
@@ -1284,6 +1293,23 @@
     '#description' => t('If the signup form is included at the bottom of each node, the signup form will be encapsulated in a collapsible fieldset. This setting controls if that fieldset is expanded or collapsed by default.'),
   );
 
+  // If views.module is enabled provide the option to display the list 
+  // of signed-up users in a tab and/or at the bottom of the node.
+  if (module_exists('views')) {
+  	$form['adv_settings']['signup_views_signup_user_list'] = array(
+  	  '#title' => t('How to display the list of signed-up users'),
+  	  '#type' => 'radios',
+  	  '#options' => array(
+  	    0 => t('On a separate %signup_list tab', array('%signup_list' => t('Signup list'))), 
+  	    1 => t('At the bottom of each node'), 
+  	    2 => t('At the bottom of each node and on a separate %signup_list tab', array('%signup_list' => t('Signup list')))
+  	  ),
+  	  '#default_value' => variable_get('signup_views_signup_user_list', 0),
+  	  '#description' => t('If views is enabled a view with the list of all signed-up users is provided as a tab on each signup enabled node. This setting controls if the user list can be shown additionally at the bottom of the node.'),
+  	);
+  }
+  
+  
   // Use our own submit handler, so we can do some processing before
   // we hand control to system_settings_form_submit.
   $form['#submit']['signup_settings_page_submit'] = array();
Index: signup.theme
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.theme,v
retrieving revision 1.14
diff -u -r1.14 signup.theme
--- signup.theme	30 Sep 2008 21:10:43 -0000	1.14
+++ signup.theme	8 Oct 2008 08:22:54 -0000
@@ -108,3 +108,25 @@
 function theme_signup_email_token_custom_data($signup_data) {
   return t('SIGNUP INFORMATION') . "\n\r" . $signup_data;
 }
+
+/**
+ * Formats the list of users signed up for a particular node.
+ *
+ * @param $registered_signups
+ *  Array of objects with data for each registered user signed up.
+ * @param $anon_signups
+ *  Array of objects with data for each anonymous user signed up.
+ */
+function theme_signup_user_list($registered_signups, $anon_signups) {
+  $output = '';
+  $header = array(array('data' => t('!users signed up', array('!users' => format_plural((count($registered_signups) + count($anon_signups)), '1 individual', '@count individuals')))));
+  $rows = array();
+  foreach ($registered_signups as $signup) {
+    $rows[] = array(theme('username', $signup));
+  }
+  if (!empty($anon_signups)) {
+    $rows[] = array(t('!count anonymous', array('!count' => count($anon_signups))));
+  }
+  $output .= theme('table', $header, $rows);
+  return $output;
+}
Index: signup_views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup_views.inc,v
retrieving revision 1.10
diff -u -r1.10 signup_views.inc
--- signup_views.inc	18 Sep 2008 17:47:45 -0000	1.10
+++ signup_views.inc	8 Oct 2008 08:22:54 -0000
@@ -528,5 +528,95 @@
   $view->requires = array(node, signup);
   $views[$view->name] = $view;
 
+  $view = new stdClass();
+  $view->name = 'signup_user_list';
+  $view->description = 'List all users signed up for a node';
+  $view->disabled = TRUE;
+  $view->access = array ();
+  $view->view_args_php = '';
+  $view->page = TRUE;
+  $view->page_title = '';
+  $view->page_header = '';
+  $view->page_header_format = '1';
+  $view->page_footer = '';
+  $view->page_footer_format = '1';
+  $view->page_empty = '';
+  $view->page_empty_format = '1';
+  $view->page_type = 'table';
+  $view->url = 'node/$signup/signup-list';
+  $view->use_pager = TRUE;
+  $view->nodes_per_page = '200';
+  $view->menu = TRUE;
+  $view->menu_title = 'Signup list';
+  $view->menu_tab = TRUE;
+  $view->menu_tab_weight = '0';
+  $view->menu_tab_default = FALSE;
+  $view->menu_tab_default_parent = NULL;
+  $view->menu_tab_default_parent_type = 'tab';
+  $view->menu_parent_tab_weight = '0';
+  $view->menu_parent_title = '';
+  $view->sort = array ();
+  $view->argument = array (
+    array (
+      'type' => 'nid',
+      'argdefault' => '1',
+      'title' => '%1',
+      'options' => '0',
+      'wildcard' => '',
+      'wildcard_substitution' => '',
+    ),
+  );
+  $view->field = array (
+    array (
+      'tablename' => 'signup_log',
+      'field' => 'uid',
+      'label' => 'Username',
+      'sortable' => '1',
+    ),
+    array (
+      'tablename' => 'signup_log',
+      'field' => 'signup_time',
+      'label' => 'Time signed up',
+      'handler' => 'views_handler_field_since',
+      'sortable' => '1',
+      'defaultsort' => 'DESC',
+    ),
+  );
+  $view->filter = array ();
+  $view->exposed_filter = array ();
+  $view->requires = array(signup_log);
+  $views[$view->name] = $view;
+
   return $views;
 }
+
+function signup_views_url_tokens() {
+  return array(
+    '$signup' => 'signup_url_node',
+  );
+}
+
+function signup_url_node($token, $argument, $arg) {
+  if (!is_numeric($arg)) {
+    return FALSE;
+  }
+
+  // If the list of signed-up users should be displayed at the 
+  // bottom of the page only do notprovide the tab.
+  if (variable_get('signup_views_signup_user_list', 0) == 1) {
+  	return FALSE;
+  }
+  
+  
+  $node = node_load($arg);
+  if (!$node) {
+    return FALSE;
+  }
+  
+  // This node is signup enabled
+  if ($node->signup) {
+    return TRUE;
+  }
+  
+  return FALSE;
+}
