You are here

function user_badges_has_badge_form in User Badges 6

Same name and namespace in other branches
  1. 6.2 user_badges.rules.inc \user_badges_has_badge_form()

Configuration form for user_badges_has_badge condition

File

./user_badges.rules.inc, line 72
Provide better integration into the rules module

Code

function user_badges_has_badge_form($settings = array(), &$form) {
  $form['badges'] = array(
    '#tree' => TRUE,
  );
  $badges = user_badges_get_badges('all');
  $settings['badges'] = is_array($settings['badges']) ? $settings['badges'] : array();
  $form['settings']['operator'] = array(
    '#type' => 'select',
    '#title' => t('Operator'),
    '#options' => array(
      'any' => t('Has one of'),
      'all' => t('Has all of'),
    ),
    '#default_value' => $settings['operator'],
  );
  foreach ($badges as $badge) {
    $form['settings']['badges'][$badge->bid] = array(
      '#type' => 'checkbox',
      '#title' => theme('user_badge', $badge),
      '#return_value' => 1,
      '#default_value' => $settings['badges'][$badge->bid],
      '#description' => check_plain($badge->name),
    );
  }
  return $form;
}