<?php
class PostAction extends ForumAction
{
    public function run()
    {
        $this->getController()->isLogin();
        if (isset($_POST['message']))
    	{
    	    $message = S::gp('message','P');
            if (empty($message))
            {
                throw new iSystemException('聊天要言之有物^ ^');
            }
            if (mb_strlen($message, 'utf-8') > 200)
            {
                throw new iSystemException('内容不能超过200字');
            }
            
            $chat = Chat::single($this->id());
            $chat->isCanPost($this->id());
            $data = array(
                'message' => $message,
                'uid' => $this->uid(),
                'username' => $this->userName(),
            );
            $chat->create($data);
            //BookForum::single()->addSelf(array('income'=>0.5), $this->id());
    	}
    	iforward($this->getController()->url('system',array('s'=>'forum','c'=>'chat','id'=>$this->id())));
    }
}