'spaces', 'attribute' => 'feature', 'value' => 'shoutbox', 'spaces' => array( 'label' => t('Shoutbox'), 'description' => t('A shoutbox for informal message blasts.'), 'types' => array('og'), ), ); return $items; } /** * Implementation of hook_node_info() */ function spaces_shoutbox_node_info() { return array( 'shout' => array( 'name' => t('Shout'), 'module' => 'spaces_shoutbox', 'description' => t('A shoutbox shout.'), 'locked' => true, ) ); } /** * Implementation of hook_form() */ function spaces_shoutbox_form(&$node) { $form['title'] = array( '#type' => 'textfield', '#title' => t('Text'), '#required' => true, '#default_value' => $node->title, ); return $form; } /** * Implementation of hook_menu() */ function spaces_shoutbox_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'js/shoutbox', 'description' => t('Shoutbox AJAX submission callback.'), 'callback' => 'spaces_shoutbox_ajax', 'access' => user_access('access content'), 'type' => MENU_CALLBACK, ); } return $items; } /** * Shoutbox AJAX callback */ function spaces_shoutbox_ajax() { if (isset($_GET['shout']) && $space = spaces_get_space()) { if (check_plain($_GET['shout']) && !empty($_GET['shout'])) { global $user; $node = new stdClass(); $node->uid = $user->uid; $node->title = $_GET['shout']; $node->type = 'shout'; $node->status= 1; if ($gid = $space->sid) { $node->og_groups = array($gid); $node->og_public = 0; } node_validate($node); node_save($node); print theme('spaces_shout', array('name' => theme('username', $user), 'title' => $node->title)); exit; } } exit; } /** * Implementation of hook_block() */ 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'] = "
'.t('There are no shouts to view.').'
'; $view->block_empty_format = '1'; $view->block_type = 'list'; $view->nodes_per_block = '10'; $view->sort = array ( array ( 'tablename' => 'node', 'field' => 'created', 'sortorder' => 'DESC', 'options' => 'normal', ), ); $view->argument = array(); $view->field = array ( array ( 'tablename' => 'users', 'field' => 'name', 'label' => '', ), array ( 'tablename' => 'node', 'field' => 'title', 'label' => '', 'handler' => 'views_handler_field_nodelink', 'options' => 'nolink', ), ); $view->filter = array ( array ( 'tablename' => 'node', 'field' => 'type', 'operator' => 'OR', 'options' => '', 'value' => array ( 0 => 'shout', ), ), array ( 'tablename' => 'node', 'field' => 'status', 'operator' => '=', 'options' => '', 'value' => '1', ), array ( 'tablename' => 'og_ancestry', 'field' => 'picg', 'operator' => '=', 'options' => '', 'value' => '***CURRENT_GID***', ), array ( 'tablename' => 'node', 'field' => 'changed', 'operator' => '>', 'options' => -1*SPACES_ARCHIVE_TIMESTAMP, 'value' => 'now', ), ); $view->exposed_filter = array(); $view->requires = array(node, users); return $view; }