You are here

function node_authlink_form_node_type_form_alter in Node authorize link 7

Same name and namespace in other branches
  1. 8 node_authlink.module \node_authlink_form_node_type_form_alter()

Implements hook_form_node_type_form_alter().

File

./node_authlink.module, line 11
Provides functionality for the node_authlink module.

Code

function node_authlink_form_node_type_form_alter(&$form, &$form_state) {
  $form['node_authlink'] = array(
    '#type' => 'fieldset',
    '#title' => t('Node authorize link'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'additional_settings',
  );
  $form['node_authlink']['node_authlink_enable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable'),
    '#default_value' => variable_get('node_authlink_enable_' . $form['#node_type']->type, FALSE),
    '#description' => t('Disable of this feature will cost erase of authorization keys of all nodes in this node type.'),
  );
  $form['node_authlink']['node_authlink_grants'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Grants to give'),
    '#default_value' => variable_get('node_authlink_grants_' . $form['#node_type']->type, array()),
    '#options' => array(
      'view' => t('View'),
      'update' => t('Update'),
      'delete' => t('Delete'),
    ),
    '#description' => t('What operations will be temporarily given to authorised user for the node. This not affect users who is authorised yet.'),
  );

  // Time periods: none, 1 day, 1 week, 4 weeks, 3 months, 6 months, 1 year.
  $period = drupal_map_assoc(array(
    0,
    86400,
    604800,
    2419200,
    7776000,
    15552000,
    31536000,
  ), 'format_interval');
  $period[0] = '<' . t('disabled') . '>';
  $form['node_authlink']['node_authlink_expire'] = array(
    '#type' => 'select',
    '#title' => t('Regenerate authkeys after'),
    '#default_value' => variable_get('node_authlink_expire_' . $form['#node_type']->type, 0),
    '#options' => $period,
    '#description' => t('Keys older than selected time will be regenerated by cron run.'),
  );
  $form['node_authlink']['node_authlink_batch'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#title' => t('Batch operations'),
    '#description' => t('Affects all nodes in this node type.'),
  );
  $form['node_authlink']['node_authlink_batch']['generate'] = array(
    '#type' => 'submit',
    '#value' => t('Generate authkeys'),
    '#submit' => array(
      'node_authlink_batch_generate',
    ),
  );
  $form['node_authlink']['node_authlink_batch']['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete all authkeys'),
    '#submit' => array(
      'node_authlink_batch_delete',
    ),
  );
  $form['#submit'][] = 'node_authlink_form_node_type_form_alter_submit';
}