You are here

function simple_access_group_form in Simple Access 6.2

Same name and namespace in other branches
  1. 5.2 simple_access.module \simple_access_group_form()
  2. 5 simple_access.module \simple_access_group_form()
  3. 7.2 simple_access.admin.inc \simple_access_group_form()
1 string reference to 'simple_access_group_form'
simple_access_menu in ./simple_access.module
Implementation of hook_menu().

File

./simple_access.admin.inc, line 56
House all the admin functions in inc to make the foot print a lot smaller.

Code

function simple_access_group_form(&$form_state, $gid = NULL) {
  $roles = array();
  if ($gid) {
    drupal_set_title(t('Edit Access Group'));
    $group = db_fetch_object(db_query('SELECT name, weight FROM {simple_access_groups} WHERE gid = %d', $gid));
    $name = $group->name;
    $weight = $group->weight;
    $roles = simple_access_get_roles($gid);
    $form['gid'] = array(
      '#type' => 'value',
      '#value' => $gid,
    );
  }
  else {
    drupal_set_title(t('Create Access Group'));
    $weight = 0;
  }
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => $name,
    '#size' => 40,
    '#maxlength' => 80,
    '#description' => t('The name for the access group as it will appear on the content editing form.'),
    '#attributes' => $attributes = NULL,
    '#required' => TRUE,
  );
  $form['roles'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Roles'),
    '#default_value' => $roles,
    '#options' => user_roles(),
    '#description' => t('Roles that can view'),
  );
  $form['weight'] = array(
    '#type' => 'weight',
    '#title' => 'Weight',
    '#default_value' => $weight,
    '#delta' => 10,
    '#description' => t('When setting permissions, heavier names will sink and lighter names will be positioned nearer the top.'),
  );
  $form[] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );
  return $form;
}