You are here

function privatemsg_form_reply in Privatemsg 6.2

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

Form builder function; Write a reply to a thread.

1 string reference to 'privatemsg_form_reply'
privatemsg_view in ./privatemsg.pages.inc
Menu callback for viewing a thread.

File

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

Code

function privatemsg_form_reply(&$form_state, $thread) {
  $form = array(
    '#access' => privatemsg_user_access('write privatemsg') || privatemsg_user_access('reply only privatemsg'),
  );
  $to = _privatemsg_get_allowed_recipients($thread['participants'], $thread['thread_id']);
  if (!empty($to)) {
    $recipients = _privatemsg_format_participants($to);
  }
  else {

    // Display a message if some users are blocked.
    // @todo: Move this check out of the form, don't use the form in that case.
    if (count(_privatemsg_blocked_messages())) {
      $blocked = t('You can not reply to this conversation because all recipients are blocked.');
      $blocked .= theme('item_list', _privatemsg_blocked_messages());
      $form['blocked']['#value'] = $blocked;
    }
    else {
      $form['#access'] = FALSE;
    }
    return $form;
  }
  $form += _privatemsg_form_base_fields($form_state);
  $form['cancel'] = array(
    '#value' => l(t('Clear'), $_GET['q'], array(
      'attributes' => array(
        'id' => 'edit-cancel',
      ),
    )),
    '#weight' => 20,
  );
  $form['thread_id'] = array(
    '#type' => 'value',
    '#value' => $thread['thread_id'],
  );
  $form['subject'] = array(
    '#type' => 'value',
    '#default_value' => $thread['subject'],
  );
  $form['reply'] = array(
    '#value' => '<h2 class="privatemsg-reply">' . t('Reply') . '</h2>',
    '#weight' => -10,
  );
  $form['recipient_display'] = array(
    '#value' => '<p>' . t('<strong>Reply to thread</strong>:<br /> Recipients: !to', array(
      '!to' => $recipients,
    )) . '</p>',
    '#weight' => -10,
  );
  $form['read_all'] = array(
    '#type' => 'value',
    '#value' => $thread['read_all'],
  );
  return $form;
}