<?php
/**
 * 添加新的表情组
 * @author yzxh24
 */
class AddCategoryAction extends BaseAction
{
    public function run()
    {
        if (Yii::app()->request->isPostRequest)
        {
            $smile = new Smiles();
            $smile->name = $_POST['smile']['name'];
            $smile->displayorder = $_POST['smile']['displayorder'];
            $smile->path = $_POST['smile']['path'];
            $smile->type = 0;
            
            $smilePath = $smile->getSmilePath($smile->path);
            if (!is_dir($smilePath))
            {
                throw new CHttpException(500, $smile->path.'目录不存在');
            }
            $smile->save();
            
            $this->getController()->redirect(array('index'));
        }
        else
        {
            throw new CHttpException(500, '非法操作');
        }
    }
}