You are here

function userpoints_filter_cat_select in User Points 5.3

Same name and namespace in other branches
  1. 6 userpoints.module \userpoints_filter_cat_select()
3 string references to 'userpoints_filter_cat_select'
theme_userpoints_list_users in ./userpoints.module
userpoints_admin_manage in ./userpoints.module
userpoints_admin_points in ./userpoints.module

File

./userpoints.module, line 1353

Code

function userpoints_filter_cat_select($path, $tid) {
  $current_cat = url($path . $tid);
  $form = array();
  $formname = 'catselect';
  $sql = "SELECT DISTINCT p.tid, t.name\n          FROM {userpoints_txn} p \n          LEFT JOIN {term_data} t on p.tid = t.tid";
  $cats = userpoints_get_categories();
  $options = array();
  $options[url($path)] = t('Display all');
  foreach ($cats as $key => $value) {
    $options[url($path . $key)] = $value;
  }
  $form['catselect'] = array(
    '#type' => 'select',
    '#name' => $formname,
    '#id' => $formname,
    '#title' => t('Filter by category'),
    '#default_value' => $current_cat,
    '#options' => $options,
    '#multiple' => false,
    '#required' => false,
    '#attributes' => array(
      'onChange' => "top.location.href=document.getElementById('{$formname}').options[document.getElementById('{$formname}').selectedIndex].value",
    ),
  );
  return $form;
}