You are here

function spaces_shoutbox_ajax in Spaces 5

Same name and namespace in other branches
  1. 5.2 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 63

Code

function spaces_shoutbox_ajax() {
  if (isset($_GET['shout'])) {
    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 = spaces_gid()) {
        $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;
}