You are here

function _option_cfs_newadmin in Node and Comments Form Settings 7.3

Same name and namespace in other branches
  1. 6.3 commentformsettings/includes/option_cfs_newadmin.inc \_option_cfs_newadmin()
  2. 6.2 commentformsettings/includes/option_cfs_newadmin.inc \_option_cfs_newadmin()
  3. 7.2 commentformsettings/includes/option_cfs_newadmin.inc \_option_cfs_newadmin()

@file Hide the Revision log field.

File

commentformsettings/includes/option_cfs_newadmin.inc, line 8
Hide the Revision log field.

Code

function _option_cfs_newadmin(&$form, &$form_state, $settings, $node) {
  if ($settings['cfs_newadmin'] == 0 && empty($form['cid']['value']) && user_access('administer comments')) {
    global $user;

    // Hide author info.
    $form['author']['#access'] = FALSE;

    // Wrap the fields in a fieldset.
    $form['admin'] = array(
      '#type' => 'fieldset',
      '#title' => t('Administration'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#weight' => -2,
    );

    // Only allow registered users to be used.
    $form['admin']['author'] = array(
      '#type' => 'textfield',
      '#title' => t('Authored by'),
      '#size' => 30,
      '#maxlength' => 60,
      '#autocomplete_path' => 'user/autocomplete',
      '#default_value' => !empty($form_state['comment']->name) ? $form_state['comment']->name : $user->name,
      '#weight' => -1,
    );

    // Date field.
    $form['admin']['date'] = array(
      '#type' => 'textfield',
      '#parents' => array(
        'date',
      ),
      '#title' => t('Authored on'),
      '#size' => 20,
      '#maxlength' => 25,
      '#default_value' => !empty($form_state['comment']->created) ? format_date($form_state['comment']->created, 'custom', 'Y-m-d H:i O') : format_date(REQUEST_TIME, 'custom', 'Y-m-d H:i O'),
      '#weight' => -1,
    );

    // Status field.
    $form['admin']['status'] = array(
      '#type' => 'radios',
      '#parents' => array(
        'status',
      ),
      '#title' => t('Status'),
      '#default_value' => isset($form_state['comment']->status) ? $form_state['comment']->status : 1,
      '#options' => array(
        1 => t('Published'),
        0 => t('Not published'),
      ),
      '#weight' => -1,
    );

    // Comment presave does not carry the above form fields, so use validate here.
    $form['#validate'][] = '_option_cfs_newadmin_validate';
  }
  return $form;
}