<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class HistoryAction extends BbsAction
{
    public function run()
    {
        $visitThreads = array();
        $cValue = explode(',', getCookieValue('tlist'));
        if (!empty($cValue))
        {
            foreach ($cValue as $cv)
            {
                if ($cv && is_numeric($cv))
                {
                    $visitThreads[] = $cv;
                }
            }
        }

        if (array() === $visitThreads)
        {
            throw new iSystemException('您还没有浏览过帖子');
        }

        $in = implode(',', $visitThreads);
        $sql = 'SELECT id,subject,createdate,uid,replies,hits FROM '.Threads::table().' WHERE id IN ('.$in.') ORDER BY field (id,'.$in.')';
        $threads = $this->db()->setQueryString($sql)->find();

        $this->getController()->render('history', array('threads' => $threads));
    }
}
