function spaces_shoutbox_block in Spaces 5.2
Same name and namespace in other branches
- 5 spaces_shoutbox/spaces_shoutbox.module \spaces_shoutbox_block()
Implementation of hook_block()
File
- spaces_shoutbox/
spaces_shoutbox.module, line 95
Code
function spaces_shoutbox_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[1] = array(
'info' => t('Spaces: Shoutbox'),
'region' => 'right',
'status' => 1,
);
return $blocks;
}
else {
if ($op == 'view') {
switch ($delta) {
case 1:
// If this isn't a groups site, or if it is and the shoutbox feature is enabled...
$space = spaces_get_space();
if ($space && $space->features['shoutbox'] != SPACES_FEATURE_DISABLED && $space
->feature_access('shoutbox')) {
drupal_add_css(drupal_get_path('module', 'spaces_shoutbox') . '/spaces_shoutbox.css');
drupal_add_js(drupal_get_path('module', 'spaces_shoutbox') . '/spaces_shoutbox.js');
$shoutbox_url = url('js/shoutbox');
$js = "Drupal.extend({shout: {shout_url:'{$shoutbox_url}'}})";
drupal_add_js($js, 'inline');
$view = views_get_view('spaces_shouts');
$block['content'] = "<div id='spaces-shouts'>" . views_build_view('block', $view, array(), false, $view->nodes_per_block) . "</div>";
$block['content'] .= drupal_get_form('spaces_shoutbox_ajaxform');
$block['subject'] = t('Shoutbox');
return $block;
}
break;
}
}
}
}