You are here

function shoutbox_edit_form in Shoutbox 5

Same name and namespace in other branches
  1. 6.2 shoutbox.pages.inc \shoutbox_edit_form()
  2. 6 shoutbox.module \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_callback in ./shoutbox.module
Function to handle shoutbox callbacks that require a shout_id. Does some sanity checking on on the id before forwarding to the actual callback.

File

./shoutbox.module, line 548
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($shout_id) {
  global $user;
  $shout = db_fetch_object(db_query('SELECT * FROM {shoutbox} WHERE shout_id = %d', $shout_id));
  if (_shoutbox_user_access('administer shouts')) {
    $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(
        'published',
        'not 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;
}