? dif
? dif.1.1.2.20
? foo
? patches
? signup_patches.tgz
cvs diff: Diffing .
Index: signup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/signup/signup.module,v
retrieving revision 1.1.2.22
diff -u -F^f -r1.1.2.22 signup.module
--- signup.module	25 Jan 2006 04:49:04 -0000	1.1.2.22
+++ signup.module	1 Feb 2006 06:55:20 -0000
@@ -336,7 +336,7 @@ function signup_nodeapi(&$node, $op, $ar
           }
 
           //check here to see if the user is already signed up for this node
-          $result = db_query("SELECT signup_time, form_data FROM {signup_log} WHERE uid = %d AND nid =%d",
+          $result = db_query("SELECT signup_time, form_data, reply FROM {signup_log} WHERE uid = %d AND nid =%d",
           $user->uid, $node->nid);
           $hidden = form_hidden('nid', $node->nid) . form_hidden('uid', $user->uid);
 
@@ -345,7 +345,10 @@ function signup_nodeapi(&$node, $op, $ar
             //user isn't signed up, so check to make sure they have signup
             //permissions.  if this is the case, then print the themed signup form
             if (user_access('allow signups')) {
-              $form_data = theme('signup_user_form') . $hidden . form_submit(t('Sign up'));
+              $form_data = form_select(t('Can you attend?'), 'reply', '0', array('0'=>_signup_reply_str(0), '3'=>_signup_reply_str(3), '5'=>_signup_reply_str(5), '7'=>_signup_reply_str(7), '10'=>_signup_reply_str(10)), NULL, 0, FALSE, TRUE );
+              $form_data .= theme('signup_user_form');
+              $form_data .= $hidden;
+              $form_data .= form_submit(t('Sign up'));
               $form = form($form_data, 'post', url('signup', drupal_get_destination()));
               $output = form_group(t('Sign up for %title', array('%title'=> check_plain($node->title))), $form);
             }
@@ -356,6 +359,7 @@ function signup_nodeapi(&$node, $op, $ar
             $form_data = unserialize($result->form_data);
             $header = array(array('data' => t('Your signup information'), 'colspan' => 2));
             $rows = array();
+            $rows[] = array( 'Reply: ', _signup_reply_str($result->reply) );
             if(is_array($form_data)) {
               foreach ($form_data as $key => $value) {
                 $rows[] = array($key . ':', check_plain($value));
@@ -369,18 +373,24 @@ function signup_nodeapi(&$node, $op, $ar
         //if user has signup perm, and signup_user_view is enabled, then display the current signups
         //pull all user signed up for this event, and start table creation
         if (user_access('allow signups') && variable_get('signup_user_view', 0)) {
-          $signups = db_query("SELECT u.uid, u.name, s.signup_time, s.form_data FROM {signup_log} s INNER JOIN {users} u ON
+          $signups = db_query("SELECT u.uid, u.name, s.signup_time, s.reply, s.form_data FROM {signup_log} s INNER JOIN {users} u ON
     u.uid = s.uid WHERE s.nid =%d", $node->nid);
-          $header = array(array('data' => t('%d individual(s) signed up', array('%d' => db_num_rows($signups)))));
           $rows = array();
+          $header = array(array('data' => t('%d individual(s) signed up', array('%d' => db_num_rows($signups)))),'Reply');
 
+          $total_attending = 0;
           //loop through the users
           while ($signed_up_user = db_fetch_object($signups)) {
-
+            $total_attending += $signed_up_user->reply;
             //build the row for this user
-            $rows[] = array(l(check_plain($signed_up_user->name), "user/$signed_up_user->uid"));
+            $rows[] = array(l(check_plain($signed_up_user->name), "user/$signed_up_user->uid"),_signup_reply_str($signed_up_user->reply));
           }
           $output .= theme('table', $header, $rows);
+          // At the bottom of the table, we'll print out our estimate for
+          // how many will attend, based on their replies.  The numeric
+          // values for the replies are from 0 to 10, so we just divide
+          // the $total_attending variable by 10 to normalize it...
+          $output .= "<b>Total attendance estimate: " . $total_attending/10 . "</b><br/>\n";
         }
         $node->body .= $output;
       }
@@ -781,8 +791,8 @@ function _signup_sign_up_user($edit = NU
     array('%number' => $event->reminder_days_before, '%days' => format_plural($event->reminder_days_before, t('day'), t('days')))) : '';
 
     //insert the user into the signup_log
-    db_query("INSERT INTO {signup_log} (uid, nid, signup_time, form_data) VALUES
-        (%d, %d, %d, '%s')", $edit['uid'], $edit['nid'], $curtime, $signup_form_data);
+    db_query("INSERT INTO {signup_log} (uid, nid, signup_time, reply, form_data) VALUES
+    (%d, %d, %d, %d, '%s')", $edit['uid'], $edit['nid'], $curtime, $edit['reply'], $signup_form_data);
 
     //load the node, format the start time, and compose the user's signup data for later use in the emails
     $node = node_load(array('nid'=> $edit['nid']));
@@ -853,4 +863,33 @@ function _signup_user_conflicts($uid) {
   }
   return $return;
 }
+
+
+/**
+ * Returns a string corresponding to the user's signup reply value
+ * @ingroup signup_internal
+ */
+function _signup_reply_str($value) {
+  switch ($value) {
+    case '0' :
+      return 'No';
+      break;
+    case '3' :
+      return 'Probably No';
+      break;
+    case '5' :
+      return 'Maybe';
+      break;
+    case '7' :
+      return 'Probably';
+      break;
+    case '10' :
+      return 'Yes';
+      break;
+    default :
+      return 'Unrecognized';
+      break;
+  }
+}
+
 ?>
\ No newline at end of file
cvs diff: Diffing contrib
cvs diff: Diffing contrib/signup_ecommerce
cvs diff: Diffing po
