You are here

function shoutbox_edit_form in Shoutbox 6

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

Form for editing shouts.

Parameters

shout_id: The shout id of the shout being edited.

1 string reference to 'shoutbox_edit_form'
shoutbox_menu in ./shoutbox.module
Implementation of hook_menu().

File

./shoutbox.module, line 516
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_edit_form(&$form_state, $shout) {
  global $user;
  if (_shoutbox_user_access('administer shoutbox')) {
    $form[] = array(
      '#type' => 'item',
      '#title' => t('Created'),
      '#value' => date('m/d/y h:i:sa', $shout->created),
    );
    $form[] = array(
      '#type' => 'item',
      '#title' => t('Changed'),
      '#value' => date('m/d/y h:i:sa', $shout->changed),
    );
    $form['moderate'] = array(
      '#type' => 'radios',
      '#title' => t('Moderation Status'),
      '#default_value' => $shout->moderate,
      '#options' => array(
        'not published',
        'published',
      ),
    );
    $users[0] = variable_get('anonymous', 'Anonymous');
    $result = db_query("SELECT uid, name FROM {users} WHERE name <> '' ORDER BY name");
    while ($usr = db_fetch_object($result)) {
      $users[$usr->uid] = $usr->name;
    }
    $form['uid'] = array(
      '#type' => 'select',
      '#title' => t('Author'),
      '#default_value' => $shout->uid,
      '#options' => $users,
    );
  }
  if (_shoutbox_user_access('edit own shouts', $shout)) {
    if (!variable_get('shoutbox_shownamefield', 1) && $user->uid) {
      $form['nick'] = array(
        '#type' => 'hidden',
        '#value' => $shout->nick,
      );
    }
    else {
      $form['nick'] = array(
        '#type' => 'textfield',
        '#title' => t('Name/Nick'),
        '#default_value' => $shout->nick,
        '#size' => 16,
        '#maxlength' => 55,
      );
    }
    $form['shout'] = array(
      '#type' => 'textarea',
      '#title' => t('Shout'),
      '#default_value' => $shout->shout,
      '#cols' => 13,
      '#rows' => 7,
    );
    if (variable_get('shoutbox_showurlfield', 1)) {
      $form['url'] = array(
        '#type' => 'textfield',
        '#title' => t('URL'),
        '#default_value' => $shout->url,
        '#size' => 16,
        '#maxlength' => 55,
      );
    }
    $form['shout_id'] = array(
      '#type' => 'hidden',
      '#value' => $shout->shout_id,
    );
  }
  $form = confirm_form($form, t(''), t(''), t(''), t('Update'), t('Cancel'));
  return $form;
}