<?php
/**
 * 禁止某人回复自己的某个主题贴
 * User: yzxh24
 * Date: 11-9-19
 * Time: 上午10:05
 * To change this template use File | Settings | File Templates.
 */
class DenyReplyAction extends BbsAction
{
    public function run()
    {
        $tid = $this->getTid();
        $uid = S::gp('uid', 'G', 2);
        $thread = $this->getExistsThread($tid);
        $allows = $this->getAllows($thread);
        if (!$allows['dpreply'])
        {
            $this->NoPermission();
        }
        if (isGM($uid) || Forums::single()->isBM($thread['fid'], $uid))
        {
            throw new iSystemException('您无权禁止此人');
        }

        if (!empty($thread['denyreply']) && false !== strpos($thread['denyreply'],','.$uid.','))
        {
            throw new iSystemException('已在禁止名单，请不要重复禁止');
        }

        $update = empty($thread['denyreply']) ? ','.$uid.',' : $thread['denyreply'].$uid.',';
        $this->db()->update(ThreadsData::table())->value(array('denyreply'=>$update))->where('tid='.$tid)->q();

        iforward(url('system', array('s'=>'bbs','a'=>'thread','tid'=>$tid)));
    }
}
