You are here

function user_badges_badgelist_form in User Badges 6.2

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

Form builder; list of badges

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

File

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

Code

function user_badges_badgelist_form() {

  // Load the badges that we want to display.
  $form['header'] = array(
    '#type' => 'value',
    '#value' => array(
      array(
        'data' => t('Name'),
        'field' => 'name',
      ),
      array(
        'data' => t('Badge'),
      ),
      array(
        'data' => t('Weight'),
        'field' => 'weight',
        'sort' => 'asc',
      ),
      array(
        'data' => t('Edit'),
      ),
      array(
        'data' => t('Delete'),
      ),
    ),
  );
  $result = pager_query('SELECT bid, name, image, weight, href FROM {user_badges_badges} ubb ' . tablesort_sql($form['header']['#value']), 50);

  // Build a table listing the appropriate badges.
  while ($badge = db_fetch_object($result)) {
    $badge->class = 'badge ' . _user_badges_class($badge);
    $form['name'][$badge->bid] = array(
      '#value' => check_plain($badge->name),
    );
    $form['badge'][$badge->bid] = array(
      '#value' => theme('user_badge', $badge),
    );
    $form['weight'][$badge->bid] = array(
      '#type' => 'textfield',
      '#size' => 4,
      '#maxlength' => 255,
      '#default_value' => $badge->weight,
    );
    $form['edit'][$badge->bid] = array(
      '#value' => l(t('edit'), 'admin/user/user_badges/edit/' . $badge->bid),
    );
    $form['delete'][$badge->bid] = array(
      '#value' => l(t('delete'), 'admin/user/user_badges/delete/' . $badge->bid),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update'),
  );
  $form['pager'] = array(
    '#value' => theme('pager', NULL, 50, 0),
  );
  return $form;
}