<?php

if (!defined('XOOPS_ROOT_PATH')) exit();

require_once XOOPS_ROOT_PATH."/class/XCube_Service.class.php";

/**
 * Sample class
 */
class LegacyPmService extends XCube_Service
{
	function doGetList(&$parameters)
	{
		$uid=$parameters['uid'];
		$pmHandler=&xoops_gethandler('privmessage');
		$pmObjects =& $pmHandler->getObjectsByFromUid($uid);
		return $pmObjects;
	}
	
	function doGetCountUnread(&$parameters)
	{
		$uid=$parameters['uid'];
		$pmHandler=&xoops_gethandler('privmessage');
		return $pmHandler->getUnreadCountByFromUid($uid);
	}
	
	function doSend(&$parameters)
	{
		$pmHandler=&xoops_gethandler('privmessage');
		$pm=&$pmHandler->create();
		$pm->setVar("to_userid",$parameters['to_uid']);
		$pm->setVar("to_userid",$parameters['from_uid']);
		$pm->setVar("subject",$parameters['subject']);
		$pm->setVar("msg_text",$parameters['message']);
		
		if(!$pmHandler->insert($pm)) {
			$this->setError("Sending error");
		}
	}
}

?>