<?php
class BlogcategoryAction extends PublicAction {

    public function insert() {
    	if(!isset($_SESSION[C('USER_AUTH_KEY')])) {
			$this->assign('jumpUrl',__APP__.'/Public/login');
			$this->error('没有登录');
		}else{
        $Cate = D('Blogcategory');
        if ($blogcategory = $Cate->create()) {
            $list = $Cate->add();
            if ($list) {
                $blogcategory["id"] = $list;
               
                $this->ajaxReturn($blogcategory,"类别增加成功！",1);
            }else {
                $this->error("类别增加失败!");
            }
        }else {
            $this->error($Cate->getError());
        }
	 }
    }

    public function delete() {
    	if(!isset($_SESSION[C('USER_AUTH_KEY')])) {
			$this->assign('jumpUrl',__APP__.'/Public/login');
			$this->error('没有登录');
		}else{
        $Cate = M('Blogcategory');
        $id = $_REQUEST[$Cate->getPk()];
        if (isset($id)) {
            $condition[$Cate->getPk()] = $id;
            if ($Cate->where($condition)->delete()) {
                $this->ajaxReturn($id, $id."分类删除成功！", 1);
            }else {
                $this->error($Cate->getError());
            }
        }
	 } 
    }
}
?>