You are here

function book_access_ui_form_book_admin_settings_alter in Book access 7.2

Same name and namespace in other branches
  1. 6.2 book_access_ui.module \book_access_ui_form_book_admin_settings_alter()

Implements hook_form_FORM_ID_alter() for book_admin_settings().

See also

theme_book_access_ui_settings()

File

./book_access_ui.module, line 27
User interface for the Book access module.

Code

function book_access_ui_form_book_admin_settings_alter(&$form, &$form_state) {
  $roles = user_roles();
  $options = array(
    'grant_admin_access' => '',
    'grant_update' => '',
    'grant_delete' => '',
    'grant_add_child' => '',
    'grant_edit_outline' => '',
    'grant_view' => '',
  );
  $form['book_access_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Book access settings'),
    '#collapsible' => TRUE,
    '#theme' => 'book_access_ui_settings',
  );
  $form['book_access_settings']['#options'] = array(
    'grant_view' => t('View book'),
    'grant_update' => t('Edit pages'),
    'grant_delete' => t('Delete pages'),
    'grant_admin_access' => t('Administer access'),
    'grant_add_child' => t('Add child pages'),
    'grant_edit_outline' => t('Edit book outlines'),
  );
  $form['book_access_settings']['info'] = array(
    '#markup' => '<em>' . t('These are the default access rules for authors and roles.  Users can only be specified on a per-book basis.') . '<br/><br/>' . t('<strong>Warning:</strong> these defaults only apply to books that have yet to be created.  Books that already exist must be manually changed.') . '</em><br/><br/>',
  );
  $form['book_access_settings']['grants']['book_access_default_author_access'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Default author\'s access'),
    '#default_value' => variable_get('book_access_default_author_access'),
    '#options' => $options,
  );
  foreach ($roles as $rid => $rname) {
    $form['book_access_settings']['grants']["book_access_default_role_{$rid}_access"] = array(
      '#type' => 'checkboxes',
      '#title' => t('Default access for <em>@role</em>', array(
        '@role' => $rname,
      )),
      '#default_value' => variable_get("book_access_default_role_{$rid}_access"),
      '#options' => $options,
    );
  }
  $form['buttons']['#weight'] = 100;
  $form['reset'] = array(
    '#type' => 'submit',
    '#value' => t('Save and reset all books to defaults'),
    '#submit' => array(
      'book_access_ui_reset_all_submit',
    ),
    '#weight' => 110,
  );
}