Home\Controller\CatalogController::delete PHP Метод

delete() публичный Метод

删除目录
public delete ( )
    public function delete()
    {
        $cat_id = I("cat_id/d") ? I("cat_id/d") : 0;
        $cat = D("Catalog")->where(" cat_id = '{$cat_id}' ")->find();
        $item_id = $cat['item_id'];
        $login_user = $this->checkLogin();
        if (!$this->checkItemPermn($login_user['uid'], $item_id)) {
            $return['error_code'] = -1;
            $return['error_message'] = L('no_permissions');
            $this->sendResult($return);
            return;
        }
        if (D("Page")->where(" cat_id = '{$cat_id}' ")->find()) {
            $return['error_code'] = -1;
            $return['error_message'] = L('no_delete_empty_catalog');
            $this->sendResult($return);
            return;
        }
        if ($cat_id > 0) {
            $ret = D("Catalog")->where(" cat_id = '{$cat_id}' ")->delete();
        }
        if ($ret) {
            $this->sendResult($ret);
        } else {
            $return['error_code'] = -1;
            $return['error_message'] = 'request  fail';
            $this->sendResult($return);
        }
    }