<?php
// $Id: ajax_get.php 87 2006-09-01 02:51:52Z yosha_01 $
require './ajax_header.php';

// initialize response renderer
$discuss_handler  =& xoops_getmodulehandler("discuss");
$message_handler  =& xoops_getmodulehandler("message");
$attendee_handler =& xoops_getmodulehandler("attendee");
$response_handler =& xoops_getmodulehandler("response");

$discuss_id = !empty($_GET["discuss_id"]) ? intval($_GET["discuss_id"]) : 0;
$discuss_object =& $discuss_handler->get($discuss_id);

if(is_object($discuss_object)){

/////////////
// Message //
/////////////

    $message_limit = $GLOBALS['xoopsModuleConfig']['message_limit'];

    $message_objects =& $message_handler->getMessages($discuss_object->getVar('discuss_id'), $message_limit);
    $response_handler->addMessageXML($message_objects);

//////////////
// Attendee //
//////////////

    $attendee_obj =& $attendee_handler->create();

    $attendee_obj->setVar('discuss_id', $discuss_id);
    $attendee_obj->setVar('uid', $uid);
    $attendee_obj->setVar('uname', $uname);
    $attendee_obj->setVar('ip', $_SERVER['REMOTE_ADDR']);
    $attendee_obj->setVar('updated', time());
    $attendee_obj->setVar('status', 1);

    $attendee_handler->updateStatus($attendee_obj);
    $attendee_handler->garbageCollect(10);

    $attendee_objs =& $attendee_handler->getAttendees($discuss_id);
    $response_handler->addAttendeeXML($attendee_objs);

////////////////
// Render XML //
////////////////

    $response_handler->render();
}
?>