You are here

function spaces_shoutbox_ajax in Spaces 5.2

Same name and namespace in other branches
  1. 5 spaces_shoutbox/spaces_shoutbox.module \spaces_shoutbox_ajax()

Shoutbox AJAX callback

1 string reference to 'spaces_shoutbox_ajax'
spaces_shoutbox_menu in spaces_shoutbox/spaces_shoutbox.module
Implementation of hook_menu()

File

spaces_shoutbox/spaces_shoutbox.module, line 68

Code

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;
}