You are here

function book_access_ui_user_add_submit in Book access 6.2

Same name and namespace in other branches
  1. 7.2 book_access_ui.admin.inc \book_access_ui_user_add_submit()

Form submission callback for book_access_ui_grants_form().

See also

book_access_ui_grants_form()

1 string reference to 'book_access_ui_user_add_submit'
book_access_ui_grants_form in ./book_access_ui.admin.inc
Form builder for the book access configuration page.

File

./book_access_ui.admin.inc, line 231
Administration interface for the Book access module.

Code

function book_access_ui_user_add_submit($form, &$form_state) {
  $username = $form_state['values']['user']['username'];
  if ($user = user_load(array(
    'name' => $username,
  ))) {
    $uid = $user->uid;
    $grants = array();
    $grants['grant_view'][$uid] = $form_state['values']['user']['grant_view'];
    $grants['grant_update'][$uid] = $form_state['values']['user']['grant_update'];
    $grants['grant_delete'][$uid] = $form_state['values']['user']['grant_delete'];
    $grants['grant_admin_access'][$uid] = $form_state['values']['user']['grant_admin_access'];
    $grants['grant_add_child'][$uid] = $form_state['values']['user']['grant_add_child'];
    $grants['grant_edit_outline'][$uid] = $form_state['values']['user']['grant_edit_outline'];
    BookAccess::addUserGrants($form['#bid'], array(
      $uid,
    ), $grants);
    _book_access_ui_permissions_warning();
  }
  else {
    drupal_set_message(t("User %user has not been found.", array(
      '%user' => $username,
    )), 'error');
  }
}