You are here

function access_grant_multiple_delete_confirm in Access Control Kit 7

Form constructor for the access grant multiple delete confirmation form.

See also

access_grant_multiple_delete_confirm_submit()

1 call to access_grant_multiple_delete_confirm()
access_overview_grants in ./access_grants.admin.inc
Menu page callback; the access grants overview page.

File

./access_grants.admin.inc, line 749
Access grants administrative UI for the access control kit module.

Code

function access_grant_multiple_delete_confirm($form, &$form_state, $selected) {
  $gids = array_keys($selected);
  $grants = access_grant_load_multiple($gids);
  $roles = user_roles();
  $schemes = access_scheme_names();
  $usernames = db_query('SELECT g.uid, u.name FROM {access_grant} g INNER JOIN {users} u ON g.uid = u.uid WHERE g.gid IN (:gids)', array(
    ':gids' => $gids,
  ))
    ->fetchAllKeyed();
  $form['grants'] = array(
    '#prefix' => '<ul>',
    '#suffix' => '</ul>',
    '#tree' => TRUE,
  );
  foreach ($grants as $grant) {
    $form['grants'][$grant->gid] = array(
      '#type' => 'hidden',
      '#value' => $grant->gid,
      '#prefix' => '<li>',
      '#suffix' => t("@scheme for @user's access as @role", array(
        '@user' => $usernames[$grant->uid],
        '@role' => $roles[$grant->rid],
        '@scheme' => $schemes[$grant->scheme],
      )) . "</li>\n",
    );
  }
  $form['operation'] = array(
    '#type' => 'hidden',
    '#value' => 'delete',
  );
  $form['#submit'][] = 'access_grant_multiple_delete_confirm_submit';
  $confirm_question = format_plural(count($grants), 'Are you sure you want to delete this access grant?', 'Are you sure you want to delete these access grants?');
  return confirm_form($form, $confirm_question, 'admin/access', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
}