<?php
class DeleteAction extends BaseAction
{
    public function run()
    {
        if (Yii::app()->request->isAjaxRequest)
        {
            $fid = intval(Yii::app()->request->getQuery('fid'));
            $id = intval(Yii::app()->request->getQuery('id'));
            $type = TopicTypes::model()->findByPk($id);
            if (empty($type))
            {
                echo '不存在的分类';
                Yii::app()->end();
            }
            if ($type->fid != $fid)
            {
                echo '此分类不属于本版块，不能删除';
                Yii::app()->end();
            }
            
            $type->delete();
            Yii::app()->end();
        }
    }
}