You are here

function shoutbox_add_form in Shoutbox 6

Same name and namespace in other branches
  1. 5 shoutbox.module \shoutbox_add_form()
  2. 6.2 shoutbox.module \shoutbox_add_form()
  3. 7.2 shoutbox.module \shoutbox_add_form()
  4. 7 shoutbox.module \shoutbox_add_form()

Generates form for adding shouts.

1 string reference to 'shoutbox_add_form'
_shoutbox_block_view in ./shoutbox.module
Returns the themed HTML to be displayed in the block.

File

./shoutbox.module, line 450
shoutbox module displays a block for users to create short messages for thw whole site. Uses AHAH to update the database and display content.

Code

function shoutbox_add_form() {
  global $user;
  if (isset($_COOKIE['shoutinfo'])) {
    $info = explode("|", $_COOKIE['shoutinfo']);
    $last_nick = $info[0];
    $last_url = $info[1];
  }
  if (variable_get('shoutbox_defaultname', 1) && $user->uid) {
    $default_nick = $user->name;
  }
  else {
    $default_nick = t('Your Name/Nick');
  }
  $default_msg = t('Enter Message');
  $default_url = t('Your Website URL');
  $form = '';
  if (!variable_get('shoutbox_shownamefield', 1) && $user->uid) {
    $form['nick'] = array(
      '#type' => 'hidden',
      '#value' => $user->name,
    );
  }
  else {
    $form['nick'] = array(
      '#type' => 'textfield',
      '#default_value' => $last_nick ? $last_nick : $default_nick,
      '#size' => 15,
      '#maxlength' => 30,
    );
  }
  $form['message'] = array(
    '#type' => 'textfield',
    '#default_value' => $default_msg,
    '#size' => 15,
  );
  if (variable_get('shoutbox_showurlfield', 1)) {
    $form['url'] = array(
      '#type' => 'textfield',
      '#default_value' => $last_url ? $last_url : $default_url,
      '#size' => 15,
      '#maxlength' => 255,
    );
  }
  $form['#attributes'] = array(
    'name' => 'shoutbox_add',
  );
  $form['#prefix'] = '<div class="shoutbox-add-form">';
  $form['#suffix'] = '</div>';
  $form['ajax'] = array(
    '#type' => 'hidden',
    '#default_value' => 0,
  );
  $form['nextcolor'] = array(
    '#type' => 'hidden',
    '#default_value' => $color,
  );
  $form[] = array(
    '#type' => 'submit',
    '#value' => t('Shout'),
  );
  return $form;
}