You are here

function shoutbox_callback in Shoutbox 5

Function to handle shoutbox callbacks that require a shout_id. Does some sanity checking on on the id before forwarding to the actual callback.

Parameters

shout_id: The shout id the action is being performed on.

callback: The callback being called. Options are

  • edit: Editting the shout
  • delete: deleting the shout
  • publish: publishing/unmoderating the shout
  • unpublish: unpublish/moderating the shout

Return value

The callback form.

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

File

./shoutbox.module, line 220
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_callback($shout_id, $callback) {
  $output = '';
  if (!is_numeric($shout_id)) {
    $output = drupal_not_found();
  }
  else {
    $shout = db_fetch_object(db_query('SELECT * FROM {shoutbox} WHERE shout_id = %d', $shout_id));
    $output = theme('shoutbox_post', $shout);
    switch ($callback) {
      case 'edit':
        $output = drupal_get_form('shoutbox_edit_form', $shout_id);
        break;
      case 'delete':
        _shoutbox_sanitize_shout($shout);
        $output .= drupal_get_form('shoutbox_delete_form', $shout_id);
        break;
      case 'publish':
        _shoutbox_sanitize_shout($shout);
        $output .= drupal_get_form('shoutbox_publish_form', $shout_id);
        break;
      case 'unpublish':
        _shoutbox_sanitize_shout($shout);
        $output .= drupal_get_form('shoutbox_unpublish_form', $shout_id);
        break;
      default:
        $output = drupal_not_found();
        break;
    }
  }
  return $output;
}