You are here

function signature_forum_form_alter in Signatures for Forums 7

Same name and namespace in other branches
  1. 5.2 signature_forum.module \signature_forum_form_alter()
  2. 5 signature_forum.module \signature_forum_form_alter()
  3. 6 signature_forum.module \signature_forum_form_alter()

Implementation of hook_form_alter().

File

./signature_forum.module, line 971
Tweaks signatures in ways inspired by other traditional forum software:

Code

function signature_forum_form_alter(&$form, &$form_state, $form_id) {
  global $user;

  // Determine if it is a node or comment form and get settings.
  if (!empty($form['#node_edit_form'])) {
    $type = 'node';
    $object = $form['#node'];
    $bundle = $form['#bundle'];
  }
  elseif ($form['#id'] == 'comment-form') {
    $type = 'comment';
    $bundle = $form['#node']->type;
    $object = $form_state['comment'];
  }

  // Add a signature checkbox.
  if (isset($type) && variable_get('signature_forum_defaults_mode', SIGNATURE_FORUM_PER_POST_DISABLED) != SIGNATURE_FORUM_PER_POST_DISABLED) {
    $account = $object->uid;
    if (!$account) {
      $account = $user;
    }
    $form['signature_forum_status'] = array(
      '#type' => 'checkbox',
      '#title' => 'Show signature',
      '#default_value' => _signature_forum_get_default($account, $bundle, $object),
    );
  }
}