? apply_for_role.patch Index: apply_for_role.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apply_for_role/apply_for_role.admin.inc,v retrieving revision 1.2 diff -u -p -r1.2 apply_for_role.admin.inc --- apply_for_role.admin.inc 29 Sep 2008 16:36:03 -0000 1.2 +++ apply_for_role.admin.inc 15 Jul 2009 06:04:23 -0000 @@ -36,6 +36,14 @@ function apply_for_role_settings_form(&$ '#description' => t("Choosing 'optional' will allow users to apply for roles when creating a new account. Choosing 'required' will require users to apply for roles when creating a new account."), '#required' => TRUE, ); + $form['options']['display_approved'] = array( + '#type' => 'radios', + '#title' => t('Display approved roles in an application form'), + '#options' => array(t('No'), t('Yes')), + '#default_value' => variable_get('apply_for_role_display_approved', 0), + '#description' => t("Choosing 'yes' will allow a user to see which role applications where approved."), + '#required' => TRUE, + ); $roles = (user_roles(TRUE)); unset($roles[DRUPAL_AUTHENTICATED_RID]); $form['roles'] = array( @@ -65,6 +73,7 @@ function apply_for_role_settings_form_su variable_set('users_apply_roles', $selected_roles); variable_set('apply_for_role_multiple', $form['options']['multiple']['#value']); variable_set('apply_for_role_register', $form['options']['register']['#value']); + variable_set('apply_for_role_display_approved', $form_state['values']['display_approved']); drupal_set_message(t('Apply for role settings have been saved.')); $form_state['redirect'] = 'admin/settings/apply_for_role'; Index: apply_for_role.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apply_for_role/apply_for_role.module,v retrieving revision 1.37 diff -u -p -r1.37 apply_for_role.module --- apply_for_role.module 13 Jan 2009 06:08:58 -0000 1.37 +++ apply_for_role.module 15 Jul 2009 06:04:25 -0000 @@ -136,6 +136,13 @@ function apply_for_role_apply_form(&$for '#type' => 'value', '#value' => $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:')), + ); + } $form['rid'] = array( '#type' => variable_get('apply_for_role_multiple', 0) ? 'checkboxes' : 'select', '#title' => variable_get('apply_for_role_multiple', 0) ? t('Select a role or roles') : t('Select a role'), @@ -510,3 +517,24 @@ function apply_for_role_process_applicat drupal_set_message(t('%message %roles', array('%message' => format_plural(count($not_received), t('There was a problem processing your application for the following role:'), t('There was a problem processing your applications for the following roles:')), '%roles' => implode(', ', $not_received))), 'error'); } } + +/** + * Return an array of roles that were approved for this user. + * + * @param $user User object. + */ +function apply_for_role_approved_roles(&$user) { + $approved = array(); + + $roles = user_roles(TRUE); + + $result = db_query("SELECT rid FROM {users_roles_apply} WHERE uid = %d and approved = %d", $user->uid, APPLY_FOR_ROLE_APPROVED); + while ($row = db_fetch_object($result)) { + if (isset($roles[$row->rid]) && isset($user->roles[$row->rid])) + $approved[$row->rid] = $roles[$row->rid]; + else + continue; + } + + return $approved; +} \ No newline at end of file