function apply_for_role_process_applications in Apply for role 5
Same name and namespace in other branches
- 6 apply_for_role.module \apply_for_role_process_applications()
- 7.2 apply_for_role.module \apply_for_role_process_applications()
- 7 apply_for_role.module \apply_for_role_process_applications()
Process an application and store it for admin review.
Parameters
$user User object.:
$applications Mixed, either a role id or an array keyed by role id.:
1 call to apply_for_role_process_applications()
- apply_for_role_user in ./
apply_for_role.module - Implementation of hook_user().
File
- ./
apply_for_role.module, line 576 - Allows users to apply for roles.
Code
function apply_for_role_process_applications($uid, $applications) {
$roles = user_roles(TRUE);
// They can hand in either an array keyed by role id or single role id.
// Ensure we've got an array keyed by role id with the name as the value.
if (is_array($applications)) {
// Filter out any thing with empty role names. And use the official role
// name.
$applications = array_intersect_key($roles, array_filter($applications));
}
else {
$applications = array(
$applications => $roles[$applications],
);
}
$received = array();
$not_received = array();
foreach ($applications as $rid => $role) {
if (apply_for_role_add_apply($uid, $rid)) {
$received[] = $role;
}
else {
$not_received[] = $role;
}
}
if (!empty($received)) {
drupal_set_message(t('%message %roles', array(
'%message' => format_plural(count($received), t('Your application was received for the following role:'), t('Your applications were received for the following roles:')),
'%roles' => implode(', ', $received),
)));
}
if (!empty($not_received)) {
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');
}
}