You are here

function simple_access_profile_form in Simple Access 5.2

Same name and namespace in other branches
  1. 6.2 simple_access.admin.inc \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.module, line 642
This module allows administrators to make nodes viewable by specific 'access groups'. Each access group can contain any number of roles. If a node is not assigned to any access groups, it will remain viewable by all users.

Code

function simple_access_profile_form($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;
}