You are here

function user_badges_edit_form in User Badges 5

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

Define the edit form for userbadges.

1 string reference to 'user_badges_edit_form'
user_badges_settings_page in ./user_badges.module

File

./user_badges.module, line 605
@brief User Badges module file

Code

function user_badges_edit_form($bid = NULL) {
  if (is_numeric($bid)) {
    $edit = db_fetch_object(db_query('SELECT * FROM {user_badges_badges} WHERE bid = %d', $bid));
    if (is_numeric($edit->bid)) {
      $form['bid'] = array(
        '#type' => 'hidden',
        '#value' => $edit->bid,
      );
    }
  }
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => $edit->name,
    '#size' => 40,
    '#maxlength' => 100,
    '#description' => t('Name for the badge. Will be displayed as tooltip when rolling over badge image.'),
    '#attributes' => NULL,
    '#required' => TRUE,
  );
  $selects = user_badges_image_selects();
  if (count($selects)) {
    $form['image'] = array(
      '#type' => 'radios',
      '#title' => t('Image'),
      '#default_value' => $edit->image,
      '#options' => $selects,
      '#description' => t('Select an image to associate with this badge. You can upload additional images on the <a href="@url">Images page</a>.', array(
        '@url' => url("admin/user/user_badges/images"),
      )),
    );
  }
  else {
    drupal_set_message('<strong>' . t('You have to <a href="@upload_link">upload badge images</a> first.', array(
      '@upload_link' => url("admin/user/user_badges/images"),
    )) . '</strong>', 'error');
  }
  $form['weight'] = array(
    '#type' => 'weight',
    '#title' => t('Weight'),
    '#default_value' => $edit->weight,
    '#delta' => 10,
    '#description' => t('Lighter weighted items float to the top of lists. Heavier items go to the bottom.'),
  );
  $form['href'] = array(
    '#type' => 'textfield',
    '#title' => t('Description URL'),
    '#description' => t('You can specify here the link where your badge will redirect your user.
      This is useful for explanation pages about the badge, for instance. If you do not whish
      your badge to be clickable, please leave this field empty') . '<br />' . '<u>' . t('Tips:') . '</u>' . '<ul>' . '<li>' . t('If you provide the full URL, it will be considered an external URL.') . '</li>' . '<li>' . t('If you provide only the path (e.g. "admin/content/node"), it is considered an
          internal link.') . '</li>' . '</ul>',
    '#default_value' => $edit->href,
  );
  $form[] = array(
    '#type' => 'submit',
    '#value' => 'Submit',
  );
  return $form;
}