You are here

function _shoutbox_block_view in Shoutbox 6

Same name and namespace in other branches
  1. 5 shoutbox.module \_shoutbox_block_view()

Returns the themed HTML to be displayed in the block.

Return value

Themed HTML content.

1 call to _shoutbox_block_view()
shoutbox_block in ./shoutbox.module
Make the shout box block available. (Standard Drupal hook).

File

./shoutbox.module, line 809
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_block_view() {

  // Output the existing shoutbox posts.
  $show_amount = variable_get('shoutbox_showamount', '20');
  $shoutbox_ascending = variable_get('shoutbox_ascending', FALSE);
  $shoutbox_posts_data = _shoutbox_display_posts($show_amount);
  $output = $shoutbox_posts_data['output'];

  // Output the shoutbox form.
  if (_shoutbox_user_access('post shouts') || _shoutbox_user_access('post shouts without approval')) {
    $output .= drupal_get_form('shoutbox_add_form');
  }
  else {
    $output .= theme('shoutbox_post_forbidden');
  }
  $default_nick = t('Your Name/Nick');
  $default_msg = t('Enter Message');
  $default_url = t('Your Website URL');

  // Variable needed by javascript code.
  $js_settings = array(
    'showAmount' => $show_amount,
    // Convert to milliseconds.
    'refreshDelay' => 1000 * variable_get('shoutbox_refresh', 0),
    'ascending' => $shoutbox_ascending,
    'shownAmount' => $shoutbox_posts_data['count'],
    'defaultNick' => $default_nick,
    'defaultMsg' => $default_msg,
    'defaultUrl' => $default_url,
    'refreshPath' => url('shoutbox/js/view'),
  );
  drupal_add_js(array(
    'shoutbox' => $js_settings,
  ), 'setting');
  $output .= l(t('All Shouts'), 'shoutbox');
  return theme('shoutbox_page', $output, $title);
}