You are here

function user_badges_roles_form in User Badges 6.2

Same name and namespace in other branches
  1. 5 user_badges.module \user_badges_roles_form()
  2. 6 user_badges.admin.inc \user_badges_roles_form()
  3. 7.4 includes/user_badges.admin.inc \user_badges_roles_form()
  4. 7 user_badges.admin.inc \user_badges_roles_form()
  5. 7.2 user_badges.admin.inc \user_badges_roles_form()
  6. 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 471
@brief User Badges admin functions

Code

function user_badges_roles_form() {

  // 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' => $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:') . ' ' . $badges[$rid]->image : '',
    );
  }
  $form[] = array(
    '#type' => 'submit',
    '#value' => t('Save Role Badges'),
  );
  return $form;
}