You are here

function simple_access_form_row in Simple Access 7.2

Same name and namespace in other branches
  1. 5.2 simple_access.module \simple_access_form_row()
  2. 6.2 simple_access.module \simple_access_form_row()

Create a single row in the form.

2 calls to simple_access_form_row()
simple_access_form in ./simple_access.module
Simple Access form.
simple_access_profile_form in ./simple_access.admin.inc
Simple Access profile form.

File

./simple_access.module, line 537
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_form_row($gid, $group, $access, $admin = FALSE) {
  if ($admin) {
    $display = array(
      'view' => 1,
      'update' => 1,
      'delete' => 1,
    );
  }
  else {
    $display = variable_get('simple_access_display', array(
      'view' => 1,
      'update' => 0,
      'delete' => 0,
    ));
  }
  $defaults = array(
    'sa_view' => NULL,
    'sa_update' => NULL,
    'sa_delete' => NULL,
  );
  if (empty($access[$gid])) {
    $access[$gid] = $defaults;
  }
  else {
    $access[$gid] += $defaults;
  }
  $priv = $group['access'] || user_access('administer nodes');
  $form = array(
    '#access' => $priv,
  );
  if ($admin) {
    $form['#admin'] = $admin;
  }
  $form['name'] = array(
    '#markup' => $group['name'],
    '#access' => $priv,
  );
  $form['sa_view'] = array(
    '#type' => 'checkbox',
    '#default_value' => isset($access[$gid]['sa_view']) ? $access[$gid]['sa_view'] : 0,
    '#access' => $priv && $display['view'],
  );
  $form['sa_update'] = array(
    '#type' => 'checkbox',
    '#default_value' => isset($access[$gid]['sa_update']) ? $access[$gid]['sa_update'] : 0,
    '#access' => $priv && $display['update'],
  );
  $form['sa_delete'] = array(
    '#type' => 'checkbox',
    '#default_value' => isset($access[$gid]['sa_delete']) ? $access[$gid]['sa_delete'] : 0,
    '#access' => $priv && $display['delete'],
  );
  return $form;
}