You are here

function book_access_form_alter in Book access 7.2

Same name and namespace in other branches
  1. 5 book_access.module \book_access_form_alter()
  2. 6.2 book_access.module \book_access_form_alter()
  3. 6 book_access.module \book_access_form_alter()
  4. 1.x book_access.module \book_access_form_alter()

Implements hook_form_alter().

See also

book_outline_form()

book_access_outline_form_submit()

book_access_edit_form_submit()

File

./book_access.module, line 932
Allows to set the access control for book nodes on a per book basis. Based on forum_access.module and tac_lite.module.

Code

function book_access_form_alter(&$form, &$form_state, $form_id) {
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
    if (isset($form['book']['bid']['#options'])) {
      BookAccess::restrictOptions($form['book']['bid']['#options']);
    }
    $form['#submit'][] = 'book_access_edit_form_submit';
  }
  elseif ($form_id == 'book_outline_form') {
    if (isset($form['book']['bid']['#options'])) {
      BookAccess::restrictOptions($form['book']['bid']['#options']);
    }
    $form['#submit'][] = 'book_access_outline_form_submit';
    if (isset($form['remove'])) {
      $form['remove']['#submit'][] = 'book_access_edit_form_submit';
    }
  }
}