You are here

function user_badges_settings_form in User Badges 6

Same name and namespace in other branches
  1. 5 user_badges.module \user_badges_settings_form()
  2. 6.2 user_badges.admin.inc \user_badges_settings_form()
  3. 7.4 includes/user_badges.admin.inc \user_badges_settings_form()
  4. 7 user_badges.admin.inc \user_badges_settings_form()
  5. 7.2 user_badges.admin.inc \user_badges_settings_form()
  6. 7.3 user_badges.admin.inc \user_badges_settings_form()

Form for general module settings.

1 string reference to 'user_badges_settings_form'
user_badges_menu in ./user_badges.module
Implements hook_menu().

File

./user_badges.admin.inc, line 570
@brief User Badges admin functions

Code

function user_badges_settings_form() {
  $noyes = array(
    t('No'),
    t('Yes'),
  );
  $form['showone'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of badges to display'),
    '#size' => 4,
    '#maxlength' => 4,
    '#default_value' => variable_get('user_badges_showone', 0),
    '#description' => t('Only this many badges with the lightest weights will be shown.') . '<br/>' . t('Set to zero to apply no limit.') . '<br/>' . t('Note that if multiple badges have the same lightest weight, only one of them will appear (first by alphabetical order).'),
  );
  $form['showblocked'] = array(
    '#type' => 'radios',
    '#options' => $noyes,
    '#title' => t('Only show blocked user badge'),
    '#default_value' => variable_get('user_badges_showblocked', 0),
    '#description' => t('If checked, only the badge associated to blocked users will be shown, overriding other badges the user eventually has as well as any other settings.') . ' <br />' . t('Note that if there is no badge associated to blocked users, no badges will appear.') . ' <br />' . t('This option only acts on blocked users and has no repercussions on active user badges.'),
    '#attributes' => array(
      'class' => 'container-inline',
    ),
  );
  $form['userweight'] = array(
    '#type' => 'radios',
    '#options' => $noyes,
    '#title' => t('Allow users to reorder badges'),
    '#default_value' => variable_get('user_badges_userweight', 0),
    '#description' => t('If checked, users will have the ability to reweight their badges in their profile, enabling them to set what order their badges display, and also which badges will display if a limit is set above.') . ' <br />' . t('Note that you can make individual badges exempt from this function, allowing you to force them to the top or bottom of the list by giving them a very high or low weight value.') . ' <br />',
    '#attributes' => array(
      'class' => 'container-inline',
    ),
  );
  if (module_exists('imagecache')) {
    $form['imagecache'] = array(
      '#type' => 'radios',
      '#options' => $noyes,
      '#title' => t('Allow ImageCache to size badges'),
      '#default_value' => variable_get('user_badges_imagecache', 0),
      '#description' => t('The ImageCache module is available, if you choose this option, it will be used to format the badge image. The preset name is "user-badges".'),
      '#attributes' => array(
        'class' => 'container-inline',
      ),
    );
  }
  else {
    $form['imagecache'] = array(
      '#type' => 'value',
      '#value' => 0,
    );
  }
  $form['nobadges'] = array(
    '#type' => 'textfield',
    '#title' => t('"No badges" message'),
    '#size' => 60,
    '#maxlength' => 500,
    '#default_value' => variable_get('user_badges_nobadges', ''),
    '#description' => t('This provides this message if the user has no badges, rather than nothing. Leave it blank for no message.'),
  );
  $form['defaulthref'] = array(
    '#type' => 'textfield',
    '#title' => t('Default badge link URL'),
    '#size' => 60,
    '#maxlength' => 500,
    '#default_value' => variable_get('user_badges_defaulthref', ''),
    '#description' => t('Enter a default URL to link all badges to. You can override this for individual badges.'),
  );

  // Tokens help.
  if (module_exists('token')) {
    $form['token_help'] = array(
      '#title' => t('Replacement patterns'),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form['token_help']['help'] = array(
      '#value' => theme('token_help', array(
        'userbadge',
        'user',
      )),
    );
  }
  else {
    $form['token_help']['help'] = array(
      // Ignore Coder flag on link.
      '#value' => t('Install the !link module if you want this URL to include dynamic elements such as badge ID numbers.', array(
        '!link' => l('Token', 'http://drupal.org/project/token', array(
          'absolute' => TRUE,
        )),
      )),
    );
  }

  // Let the user select a vocabulary to associate with badges.
  if (module_exists('taxonomy')) {

    //Build the options for the element
    $vocabs = taxonomy_get_vocabularies();
    $selects = array(
      '' => t('&lt;none&gt;'),
    );
    foreach ($vocabs as $vid => $vocab) {
      $selects[$vid] = $vocab->name;
    }
    $form['vid'] = array(
      '#type' => 'radios',
      '#title' => t('Vocabulary'),
      '#default_value' => variable_get('user_badges_vid', ''),
      '#options' => $selects,
      '#description' => t('Optional. Select a vocabulary to associate badges with. You can optionally associate each badge with one term in this vocabulary.'),
      '#attributes' => array(
        'class' => 'container-inline',
      ),
    );
  }
  $form[] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  return $form;
}