Index: volunteer.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/volunteer/volunteer.module,v
retrieving revision 1.53
diff -u -r1.53 volunteer.module
--- volunteer.module	12 Feb 2006 00:59:52 -0000	1.53
+++ volunteer.module	16 Feb 2006 19:27:22 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: volunteer.module,v 1.53 2006/02/12 00:59:52 killes Exp $
+// $Id: volunteer.module,v 1.52 2005/12/31 00:44:51 killes Exp $
 
 
 /**
@@ -81,7 +81,7 @@
         $profile = crm_uf_get_profile_fields($id, TRUE);
         $has_correct_email = FALSE;
         foreach($profile as $field) {
-          if (strpos($field['name'], 'email-') === 0) {
+          if ($field['name'] == 'email') {
             $email_exists = TRUE;
             if ($field['is_required'] == 1) {
               $has_correct_email = TRUE;
@@ -95,18 +95,18 @@
       }
       if ($email_exists) {
         if ($correct_email_exists) {
-          $group_form .= form_select(t('CiviCRM profile form for volunteers'), 'volunteer_form', variable_get('volunteer_form', ''), $forms, t('Select a CiviCRM Profile form for volunteers. Users will fill out required fields in this form when volunteering for an event. You can <a href="%url">add</a> a volunteer specific profile. The profile needs at least an email field and it needs to be set to "Required" and "Active".', array('%url' => url('civicrm/admin/uf/group'))), 0, FALSE, TRUE);
+          $group_form .= form_select(t('CiviCRM profile form for volunteers'), 'volunteer_form', variable_get('volunteer_form', ''), $forms, t('Select a CiviCRM Profile form for volunteers. Users will fill out required fields in this form when volunteering for an event. You can <a href="%url">add</a> a volunteer specific profile. The profile needs at least an email field and it needs to be set to "Required", "Display in Registration Form", and "Active".', array('%url' => url('civicrm/admin/uf/group'))), 0, FALSE, TRUE);
         }
         else {
-          drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required" and "Active". A profile with an email field could be found, but it does not have the correct settings. ', array('%url' => url('civicrm/admin/uf/group'))), 'error');
+          drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required", "Display in Registration Form", and "Active". A profile with an email field could be found, but it does not have the correct settings. ', array('%url' => url('civicrm/admin/uf/group'))), 'error');
         }
       }
       else {
-        drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required" and "Active". No profile with an email field could be found.', array('%url' => url('civicrm/admin/uf/group'))), 'error');
+        drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required", "Display in Registration Form", and "Active". No profile with an email field could be found.', array('%url' => url('civicrm/admin/uf/group'))), 'error');
       }
     }
     else {
-      drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required" and "Active".', array('%url' => url('civicrm/admin/uf/group'))), 'error');
+      drupal_set_message(t('You need to <a href="%url">define</a> a CiviCRM profile for use with the volunteer module. The profile needs at least an email field and it needs to be set to "Required", "Display in Registration Form",  and "Active".', array('%url' => url('civicrm/admin/uf/group'))), 'error');
     }
     $output .= form_group(t('Contact Settings'), $group_form);
   }
@@ -429,27 +429,29 @@
 
   db_set_active('civicrm');
   $title = crm_uf_get_profile_title(variable_get('volunteer_form', ''));
+  $reset = true;
   db_set_active();
+
   if ( $user->uid ) {
     db_set_active('civicrm');
     $userID = crm_uf_get_match_id( $user->uid );
-    $register = TRUE;
+    $register = $userID ? false : true;
     if (!$userID && count($edit)) {
       civicrm_register_data($edit, $user, $title, FALSE);
       $userID = crm_uf_get_match_id( $user->uid );
       $register = FALSE;
     }
-    $form = crm_uf_get_profile_html( $userID, $title, null, FALSE, $register );
+    $form = crm_uf_get_profile_html( $userID, $title, null, $register, $reset );
     db_set_active();
-    $form .= form_submit(t('Volunteer'));
-    $url = url("node/$nid");
   }
   else {
     db_set_active('civicrm');
-    $_POST['postURL'] = url("volunteer/volunteer/$nid");
-    $form = crm_uf_get_create_html(TRUE);
+    $register = true; //always for anonymous user
+    //As per Lobo: right call is
+    $form = crm_uf_get_profile_html( null, $title, null, $register, $reset ); 
     db_set_active();
   }
+  $form .= form_submit(t('Volunteer'));
   $url = url("volunteer/volunteer/$nid");
 
   return form($form, 'post', $url);
