You are here

function protected_node_node_type_form_alter in Protected Node 7

Same name and namespace in other branches
  1. 6 protected_node.settings.inc \protected_node_node_type_form_alter()
  2. 1.0.x protected_node.settings.inc \protected_node_node_type_form_alter()

Implements hook_form_FORM_ID_alter().

Add protected node options on node type form.

Adds a fieldset to each node type to let user decide whether a node type is always protected, is never protected, or is protect-able. If protect-able, then one can choose whether the protected node field set should be always open, always closed, or smart (i.e. open if the node is protected.)

@param[in,out] $form The node type form where our field set is added.

1 call to protected_node_node_type_form_alter()
protected_node_form_node_type_form_alter in ./protected_node.module
Implements hook_form_FORM_ID_alter().

File

./protected_node.settings.inc, line 969
Configuration file for the protected_node module.

Code

function protected_node_node_type_form_alter(&$form) {
  $form['protected_node'] = array(
    '#type' => 'fieldset',
    '#title' => t('Protected node settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'additional_settings',
  );
  $options = array(
    PROTECTED_NODE_PROTECTION_NEVER => t('Never protected'),
    PROTECTED_NODE_PROTECTION_PROTECTABLE => t('Protectable (default is unprotected)'),
    PROTECTED_NODE_PROTECTION_PROTECTED => t('Protectable (default is protected)'),
    PROTECTED_NODE_PROTECTION_ALWAYS => t('Always protected'),
  );
  $form['protected_node']['protected_node_protection'] = array(
    '#type' => 'radios',
    '#title' => t('Protected mode for nodes of this type'),
    '#default_value' => variable_get('protected_node_protection_' . $form['#node_type']->type, PROTECTED_NODE_PROTECTION_PROTECTABLE),
    '#options' => $options,
    '#description' => t('Select the protection mode for nodes of this type:<ul>
      <li>Never protected &mdash; the nodes cannot be protected</li>
      <li>Protectable &mdash; lets users choose whether the node is protected, defaults to protected or unprotected.</li>
      <li>Always protected &mdash; the node is automatically protected, the author has no choice.</li>
    </ul>'),
  );
  $form['protected_node']['protected_node_node_type_password_field'] = array(
    '#type' => 'password_confirm',
    '#description' => t('Enter a node type password. This password is the default for all the nodes of this type.'),
    '#size' => 20,
    '#after_build' => array(
      'protected_node_autocomplete_off',
    ),
    '#title' => t('A default (global) password for nodes of this type'),
  );
  $options = array(
    PROTECTED_NODE_FIELDSET_OPEN => t('Always open'),
    PROTECTED_NODE_FIELDSET_SMART => t('Smart mode (Open when protected)'),
    PROTECTED_NODE_FIELDSET_CLOSE => t('Always closed'),
  );
  $form['protected_node']['protected_node_fieldset'] = array(
    '#type' => 'radios',
    '#title' => t('How to show the protected node fieldset'),
    '#default_value' => variable_get('protected_node_fieldset_' . $form['#node_type']->type, PROTECTED_NODE_FIELDSET_SMART),
    '#options' => $options,
    '#description' => t('Select whether the "Protected node" field set should be opened or closed when editing a node.'),
  );
  $form['protected_node']['protected_node_description'] = array(
    '#type' => 'textarea',
    '#title' => t('Password page description (inside the field set with the password form)'),
    '#default_value' => variable_get('protected_node_description_' . $form['#node_type']->type, ''),
    '#description' => t('Enter custom description for the protected node page of this content type to override the global setting. This description is displayed inside the fieldset with the password form. HTML is accepted. You can use node type tokens provided by the token module if installed.'),
  );
  $form['#validate'][] = '_protected_node_node_type_validate';
  $form['#submit'][] = '_protected_node_node_type_submit';
}