function user_badges_roles_form in User Badges 7.2
Same name and namespace in other branches
- 5 user_badges.module \user_badges_roles_form()
- 6.2 user_badges.admin.inc \user_badges_roles_form()
- 6 user_badges.admin.inc \user_badges_roles_form()
- 7.4 includes/user_badges.admin.inc \user_badges_roles_form()
- 7 user_badges.admin.inc \user_badges_roles_form()
- 7.3 user_badges.admin.inc \user_badges_roles_form()
Form to associated badges with roles.
1 string reference to 'user_badges_roles_form'
- user_badges_menu in ./
user_badges.module - Implements hook_menu().
File
- ./
user_badges.admin.inc, line 604 - @brief User Badges admin functions
Code
function user_badges_roles_form($form, &$form_state) {
// No badges for the anonymous role.
$roles = user_roles(TRUE);
$badges = user_badges_get_roles(NULL, array(
'returnbadges' => TRUE,
));
$form['blocked'] = array(
'#type' => 'fieldset',
'#title' => t('Blocked Badge'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
$form['blocked'][0] = array(
'#type' => 'textfield',
'#title' => t('blocked user'),
'#size' => 40,
'#maxlength' => 255,
'#autocomplete_path' => 'user_badges/autocomplete',
'#default_value' => isset($badges[0]) ? $badges[0]->name . ' ' . t('(Badge ID') . ' ' . $badges[0]->bid . ')' : '',
'#field_suffix' => isset($badges[0]) ? ' ' . t('Current:') . ' ' . $badges[0]->image : '',
);
$form['roles'] = array(
'#type' => 'fieldset',
'#title' => t('Role Badges'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
foreach ($roles as $rid => $role) {
$form['roles'][$rid] = array(
'#type' => 'textfield',
'#title' => check_plain($role),
'#maxlength' => 255,
'#autocomplete_path' => 'user_badges/autocomplete',
'#default_value' => isset($badges[$rid]) ? $badges[$rid]->name . ' ' . t('(Badge ID') . ' ' . $badges[$rid]->bid . ')' : '',
'#field_suffix' => isset($badges[$rid]) ? ' ' . t('Current:') . ' ' . _user_badges_build_image($badges[$rid]) : '',
);
}
$form[] = array(
'#type' => 'submit',
'#value' => t('Save Role Badges'),
);
return $form;
}