You are here

function _privatemsg_form_base_fields in Privatemsg 6.2

Same name and namespace in other branches
  1. 7.2 privatemsg.pages.inc \_privatemsg_form_base_fields()

Returns the common fields of the reply and new form.

2 calls to _privatemsg_form_base_fields()
privatemsg_form_reply in ./privatemsg.pages.inc
Form builder function; Write a reply to a thread.
privatemsg_new in ./privatemsg.pages.inc
Form builder function; Write a new private message.

File

./privatemsg.pages.inc, line 358
User menu callbacks for Privatemsg.

Code

function _privatemsg_form_base_fields(&$form_state) {
  global $user;
  if (isset($form_state['privatemsg_preview'])) {
    $form['message_header'] = array(
      '#type' => 'fieldset',
      '#title' => empty($form_state['validate_built_message']['thread_id']) ? check_plain($form_state['validate_built_message']['subject']) : t('Preview'),
      '#attributes' => array(
        'class' => 'preview',
      ),
      '#weight' => -10,
    );
    $form['message_header']['message_preview'] = array(
      '#value' => $form_state['privatemsg_preview'],
    );
  }
  $form['author'] = array(
    '#type' => 'value',
    '#value' => $user,
  );
  $form['body'] = array(
    '#type' => 'textarea',
    '#title' => t('Message'),
    '#rows' => 6,
    '#weight' => -3,
    '#resizable' => TRUE,
    // Avoid loosing the message body during preview.
    '#default_value' => isset($form_state['values']['body']) ? $form_state['values']['body'] : '',
  );
  $format = FILTER_FORMAT_DEFAULT;

  // The input filter widget looses the format during preview, specify it
  // explicitly.
  if (isset($form_state['values']) && array_key_exists('format', $form_state['values'])) {
    $format = $form_state['values']['format'];
  }
  $form['format'] = filter_form($format);
  $form['format']['#access'] = privatemsg_user_access('select text format for privatemsg');
  if (variable_get('privatemsg_display_preview_button', FALSE)) {
    $form['preview'] = array(
      '#type' => 'submit',
      '#value' => t('Preview message'),
      '#submit' => array(
        'privatemsg_new_preview',
      ),
      '#weight' => 10,
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send message'),
    '#weight' => 15,
  );
  $form['#validate'] = array(
    'privatemsg_new_validate',
  );
  $form['#submit'] = array(
    'privatemsg_new_submit',
  );
  return $form;
}