diff --git a/sites/all/modules/apply_for_role_webform/apply_for_role_webform.module b/sites/all/modules/apply_for_role_webform/apply_for_role_webform.module
index 6004d42..2c25fcf 100644
--- a/sites/all/modules/apply_for_role_webform/apply_for_role_webform.module
+++ b/sites/all/modules/apply_for_role_webform/apply_for_role_webform.module
@@ -1,6 +1,7 @@
 <?php
 
 define('DISABLED_KEY','disabled');
+define('ALL_KEY','all');
 
 /* Implementation of hook_form_alter
 Add an option to select webforms to allow applications to go through */
@@ -12,7 +13,7 @@ function apply_for_role_webform_form_alter(&$form, &$form_state, $form_id) {
   if ($form_id == "webform_configure_form") {
       
 		// Get all available roles
-		$available_roles = array(DISABLED_KEY => '-- DISABLED --') + variable_get('users_apply_roles',array());
+		$available_roles = array(DISABLED_KEY => '-- DISABLED --') + variable_get('users_apply_roles',array()) + array(ALL_KEY=>'-- ALL --');
 
     // Get role ID if already filled out
     $roleid = variable_get('apply_for_role_webform_'.$form['nid']['#value'],'disabled');
@@ -20,7 +21,7 @@ function apply_for_role_webform_form_alter(&$form, &$form_state, $form_id) {
     $form['webform_bridge'] = array(
       '#type' => 'fieldset',
       '#title' => t('Role Applications'),
-      '#description' => t("Connect this webform to the Apply for Role module. If a role is selected, the user who submits the webform will also apply for the role. <em><b>NOTE:</b> If you don't see a role here, check the Apply for role administration page to make sure it is checked.</em>"),
+      '#description' => t("Connect this webform to the Apply for Role module. If a role is selected, the user who submits the webform will also apply for the role. If 'all' is selected, the user who submits the form will have to choose roles among a list inside the webform.<em><b>NOTE:</b> If you don't see a role here, check the Apply for role administration page to make sure it is checked.</em>"),
       '#weight' => -2,
       '#collapsible' => TRUE,
     );
@@ -41,9 +42,38 @@ function apply_for_role_webform_form_alter(&$form, &$form_state, $form_id) {
   	$form['#submit'][] = '_afrwebform_admin_submit';
   	
 	}
-	// If this form is a submission form of a webform, add our validation handler
+	// If this form is a submission form of a webform:
 	elseif (substr($form_id,0,20) == "webform_client_form_") {
-		$form['#validate'][] = '_afrwebform_validate_submission';
+            global $user;
+            
+            // - List of roles that were already approved.
+            $approved = apply_for_role_approved_roles($user);
+            if (variable_get('apply_for_role_display_approved', 0) && count($approved)) {
+                $form['approved'] = array(
+                    '#value' => theme('item_list', $approved, t('You have applied for these roles and were approved:')),
+                );
+            }
+            
+            //  - add role field if necessary
+            $wid = $form['#node']->nid;
+            $apply_for_role_id = variable_get('apply_for_role_webform_'.$wid,DISABLED_KEY);
+            
+            $available_roles = apply_for_role_available_roles($user);
+            
+            if ($apply_for_role_id == ALL_KEY) {
+                $role_field = array(
+                    '#type' => variable_get('apply_for_role_multiple', 0) ? 'checkboxes' : 'radios',
+                    '#title' => variable_get('apply_for_role_multiple', 0) ? t('Select a role or roles') : t('Select a role'),
+                    '#options' => $available_roles,
+                    '#weight' => -1,
+                    '#required' => 1,
+                );
+                $form['submitted']['role'] = $role_field;
+            }
+            
+            
+            //  - add our validation handler
+            $form['#validate'][] = '_afrwebform_validate_submission';
 	}
 }
 
@@ -63,12 +93,25 @@ function _afrwebform_validate_submission($form, &$form_state) {
 	// Only validate webform submissions that the admin set to validate for role application
 	if ($apply_for_role_id != DISABLED_KEY) {
 
+            if ($apply_for_role_id == ALL_KEY) {
+                $apply_for_role_id = $form['submitted']['role']['#value'];
+            }
     $available_roles = apply_for_role_available_roles($user);
     if ($user->uid != 0) {
       // Can user apply for this role?
-      if (!array_key_exists($apply_for_role_id, $available_roles)) {
-        form_set_error('',check_plain(variable_get('apply_for_role_webform_'.$wid.'_errormsg','')));
+      if(variable_get('apply_for_role_multiple', 0)) {
+          // if multiple-roles application: $apply_for_role_id is actually an array: have to check each value:
+          if (count (array_intersect($apply_for_role_id,array_keys($available_roles))) != count($apply_for_role_id)) {
+             form_set_error('',check_plain(variable_get('apply_for_role_webform_'.$wid.'_errormsg','')));
+          } else {
+          }
+      } else {
+          // $apply_for_role_id is just one value:
+        if (!array_key_exists($apply_for_role_id, $available_roles)) {
+            form_set_error('',check_plain(variable_get('apply_for_role_webform_'.$wid.'_errormsg','')));
+        }
       }
+        
     } else {
       form_set_error('',t('You must first be registered to submit this form.'));
     }
@@ -83,8 +126,22 @@ function apply_for_role_webform_webform_submission_insert($node, $submission) {
   // Role application attached to webform?
   $apply_for_role_id = variable_get('apply_for_role_webform_'.$node->nid,DISABLED_KEY);
   if ($apply_for_role_id != DISABLED_KEY) {
-	  // Attempt to add the role application
-		if (apply_for_role_add_apply($user,$apply_for_role_id)) {
+            // if role_id = ALL_KEY : we have to look for the real role_id in submission object:
+            if ($apply_for_role_id == ALL_KEY) {
+                // submitted_role is located at the end of array 'data' inside object 'submission', without a named index:
+                // TODO: put submitted_role in a better place inside the object 'submission'.
+                $submitted_role = end(array_values($submission->data));
+                // if multiple-roles application: $submitted_role is actually an array of n role: have to process each role:
+                // else : $submitted_role is an array of 1 role
+                // in  both case we will be able to just iterate on the array $apply_for_role_id_array:
+                $apply_for_role_id_array = $submitted_role['value'];
+            } else {
+                $apply_for_role_id_array = array(0 => $apply_for_role_id);
+            }
+            foreach ($apply_for_role_id_array as $role_id) {
+            // Attempt to add the role application
+                if ($role_id==0) { continue; } // it's mean we are in the situation where apply_for_role_multiple==1 and this proposal role hadn't been actually choose by the user, so no insertion.
+		if (apply_for_role_add_apply($user,$role_id)) {
 			// Get application ID of just-inserted role application
 			$id = db_result(db_query("SELECT MAX(aid) as maxid FROM {users_roles_apply}"));
 			  
@@ -97,6 +154,7 @@ function apply_for_role_webform_webform_submission_insert($node, $submission) {
 			// because we can't stop the form submission from within this function anyway
 			watchdog('apply_for_role_webform','Could not add role application on webform submission. RID: @rid, UID: @uid, NID: @nid',array('@rid'=>$apply_for_role_id,'@uid'=>$user->uid, '@nid' => $node->nid),WATCHDOG_ERROR);
 		}
+            }
 	}
 }
 
@@ -111,8 +169,7 @@ function apply_for_role_webform_webform_submission_insert($node, $submission) {
 function apply_for_role_webform_webform_submission_delete($node, $submission) {
   // Check to see if this submission was associated with a role application
   $result = db_query("SELECT uraw.*, ura.rid, ura.uid FROM {users_roles_apply_webforms} uraw INNER JOIN {users_roles_apply} ura ON uraw.aid = ura.aid WHERE uraw.sid = %d", $submission->sid);
-  $webform_role_app = db_fetch_object($result);
-  if (!empty($webform_role_app)) {
+  while ($webform_role_app = db_fetch_object($result)) {
     // Delete the application
     $applicant = user_load($webform_role_app->uid);
     apply_for_role_remove_apply($applicant, $webform_role_app->rid);
