You are here

function simple_access_profile_form in Simple Access 6.2

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

File

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

Code

function simple_access_profile_form($form_state, $pid = NULL) {
  $form = array();
  $access_profile = array();
  if (!empty($pid)) {
    $profiles = simple_access_get_profiles();
    if (!isset($profiles[$pid])) {
      drupal_not_found();
      exit;
    }
    $access_profile = $profiles[$pid];
    $form['pid'] = array(
      '#type' => 'value',
      '#value' => $access_profile['pid'],
    );
  }
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => isset($access_profile['name']) ? $access_profile['name'] : '',
    '#required' => TRUE,
  );
  $form['access'] = array(
    '#tree' => TRUE,
    '#theme' => 'simple_access_form',
  );
  $groups = simple_access_group_select();
  foreach ($groups as $gid => $group) {
    $form['access'][$gid] = simple_access_form_row($gid, $group, $access_profile['access']);
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => empty($pid) ? t('Submit') : t('Update'),
  );
  return $form;
}