--- ./rsvp/rsvp.module	2005-07-29 18:02:36.000000000 -0700
+++ /home/jsaints/website/dsenyoarts/modules/rsvp/rsvp.module	2005-09-28 23:33:41.000000000 -0700
@@ -665,6 +665,8 @@
 function rsvp_message_form($rid) {
   global $user;
   if($user->uid) {
+    $options = array( 'all' => t('Entire RSVP List'), 'yes'=> t('Attending'), 'no'=> t('Not attending'), 'maybe'=> t('Might attend'), 'none'=> t('No reply') );
+    $form  =  form_radios(t('Message audience'), 'status', 'all', $options );
     $form .= form_textfield(t('Message Subject'), 'subject', '', 40, 40, t('This is the subject for your email message'));
     $form .= form_textarea(t('Message Body'), 'body', '', 70, 5, t('This is the body of the email message'));
     $form .= form_hidden('rid', $rid);
@@ -1044,8 +1046,11 @@
 * @param $rid The rid of the rsvp instance.
 * @return dbresultset of the requested attendees.
 */
-function _rsvp_get_attendees($rid) {
-  return db_query('SELECT * FROM {rsvp_invite} WHERE rid = %d', $rid);
+function _rsvp_get_attendees($rid, $status = 'all' ) {
+  if( $status == 'all' || !isset($status) )
+    return db_query('SELECT * FROM {rsvp_invite} WHERE rid = %d', $rid);
+  else
+    return db_query('SELECT * FROM {rsvp_invite} WHERE rid = %d and response="%s"', $rid, $status );
 }
 
 /**
@@ -1279,7 +1284,10 @@
   $status['success'] = array();
   $status['failed'] = array();
 
-  $attendees = _rsvp_get_attendees($edit['rid']);
+  $attendees = _rsvp_get_attendees($edit['rid'], $edit['status'] );
+  //if no attendees are returned set an error message
+  if( db_num_rows($attendees) == 0 )
+    drupal_set_message( t('There were not attendees with RSVP status "<strong>%status</strong>"', array('%status'=>$edit['status'] ) ), 'error' );
   while($attendee = db_fetch_object($attendees)) {
     $invite = _rsvp_get_invite($attendee->hash);
 
