You are here

function advpoll_electoral_list_form in Advanced Poll 6

Same name and namespace in other branches
  1. 5 advpoll.module \advpoll_electoral_list_form()
  2. 6.3 advpoll.module \advpoll_electoral_list_form()
  3. 6.2 advpoll.module \advpoll_electoral_list_form()
  4. 7.3 includes/advpoll.pages.inc \advpoll_electoral_list_form()
  5. 7 includes/advpoll.pages.inc \advpoll_electoral_list_form()
  6. 7.2 includes/advpoll.pages.inc \advpoll_electoral_list_form()

Build electorial list form.

1 string reference to 'advpoll_electoral_list_form'
advpoll_electoral_list_page in ./advpoll.pages.inc
Display the electoral list page.

File

./advpoll.module, line 894
Advanced Poll - a sophisticated polling module for voting, elections, and group decision-making.

Code

function advpoll_electoral_list_form(&$form_state, $nid) {
  $form['electoral_list'] = array(
    '#type' => 'fieldset',
    '#tree' => TRUE,
    '#title' => t('Administer electoral list'),
    '#collapsible' => TRUE,
    '#weight' => 2,
  );
  $form['electoral_list']['add_user'] = array(
    '#type' => 'textfield',
    '#title' => t('Add user'),
    '#size' => 40,
    '#description' => t('Add an individual user to the electoral list.'),
  );

  // Enable autocompletion if user has required permission.
  if (user_access('access user profiles')) {
    $form['electoral_list']['add_user']['#autocomplete_path'] = 'user/autocomplete';
  }

  // List all roles with "vote on polls" permission, but don't include anonymous users.
  $result = db_query("SELECT r.name, r.rid FROM {role} r LEFT JOIN {permission} p ON p.rid = r.rid WHERE p.perm LIKE '%vote on polls%' AND r.rid <> 1 ORDER BY r.name");
  $role_options = array(
    0 => t('(Select a role)'),
  );
  while ($role = db_fetch_object($result)) {
    $role_options[$role->rid] = $role->name;
  }
  $form['electoral_list']['add_role'] = array(
    '#type' => 'select',
    '#title' => t('Add users by role'),
    '#description' => t('Only roles that have the "vote on polls" permission are listed.'),
    '#options' => $role_options,
  );
  $form['electoral_list']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add to electoral list'),
  );
  $form['electoral_list']['reset'] = array(
    '#type' => 'button',
    '#value' => t('Clear electoral list'),
  );
  $form['nid'] = array(
    '#type' => 'hidden',
    '#value' => $nid,
  );
  return $form;
}