You are here

function nodeaccess_userreference_form_content_field_edit_form_alter in Node access user reference 6.3

Same name and namespace in other branches
  1. 6 nodeaccess_userreference.module \nodeaccess_userreference_form_content_field_edit_form_alter()
  2. 6.2 nodeaccess_userreference.module \nodeaccess_userreference_form_content_field_edit_form_alter()

Implementation of hook_form-FORM-ID_alter().

File

./nodeaccess_userreference.module, line 17

Code

function nodeaccess_userreference_form_content_field_edit_form_alter(&$form, $form_state) {
  if ($form['#field']['type'] == "userreference") {
    $data = nodeaccess_userreference_field_settings($form['#field']['type_name'], $form['#field']['field_name']);
    $form['widget']['nodeaccess_userreference'] = array(
      '#type' => 'fieldset',
      '#title' => t('Node access user reference'),
      '#tree' => TRUE,
    );
    $form['widget']['nodeaccess_userreference']['referenced'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Grants for referenced users'),
      '#default_value' => isset($data['referenced']) ? $data['referenced'] : array(),
      '#options' => array(
        'view' => t('View'),
        'update' => t('Update'),
        'delete' => t('Delete'),
      ),
      '#description' => t('These content access permissions will be granted to users referenced in the field.'),
    );
    $form['widget']['nodeaccess_userreference']['author'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Grants for author'),
      '#default_value' => isset($data['author']) ? $data['author'] : array(),
      '#options' => array(
        'view' => t('View'),
        'update' => t('Update'),
        'delete' => t('Delete'),
      ),
      '#description' => t('These content access permissions will be granted to the authors of nodes.'),
    );
    $form['widget']['nodeaccess_userreference']['all'] = array(
      '#type' => 'checkboxes',
      '#title' => t('Grants for all users'),
      '#default_value' => isset($data['all']) ? $data['all'] : array(),
      '#options' => array(
        'view' => t('View'),
      ),
      '#description' => t('These content access permissions will be granted to all users.'),
    );
    $form['widget']['nodeaccess_userreference']['unused'] = array(
      '#type' => 'radios',
      '#title' => t('When to set grants'),
      '#default_value' => isset($data['unused']) ? $data['unused'] : 0,
      '#options' => array(
        0 => t('When the user reference field is in use'),
        1 => t('Always'),
      ),
      '#description' => t('Determines whether to set grants when the field is not in use.'),
    );
    $form['widget']['nodeaccess_userreference']['priority'] = array(
      '#type' => 'weight',
      '#title' => t('Priority'),
      '#default_value' => isset($data['priority']) ? $data['priority'] : 0,
      '#description' => t('It is recommended to always leave this set to 0.'),
    );
    $form['#submit'][] = 'nodeaccess_userreference_content_field_edit_form_submit';
  }
}