You are here

function acl_save_form in ACL 8

Same name and namespace in other branches
  1. 5 acl.module \acl_save_form()
  2. 6 acl.admin.inc \acl_save_form()
  3. 7 acl.admin.inc \acl_save_form()

Write the results of a form.

The module that embedded our form must call this function!

File

./acl.admin.inc, line 157
Implementations of administration functions for the acl module.

Code

function acl_save_form($form, $priority = NULL) {
  $database = \Drupal::database();
  $users = acl_edit_form_get_user_list($form);
  $database
    ->delete('acl_user')
    ->condition('acl_id', $form['acl_id'])
    ->execute();
  $insert = $database
    ->insert('acl_user')
    ->fields([
    'acl_id',
    'uid',
  ]);
  foreach ($users as $uid => $name) {
    $insert
      ->values([
      'acl_id' => $form['acl_id'],
      'uid' => $uid,
    ]);
  }
  $insert
    ->execute();
  if (isset($priority)) {
    $database
      ->update('acl_node')
      ->fields([
      'priority' => $priority,
    ])
      ->condition('acl_id', $form['acl_id'])
      ->execute();
  }
}