From a3fc3f85be9c72c0080370608dbe9dc333fe10a8 Mon Sep 17 00:00:00 2001
From: saynone <5660782@qq.com>
Date: Tue, 26 Nov 2019 14:38:54 +0800
Subject: [PATCH] 修复分类管理中可将父id设置为自己的错误

---
 application/admin/controller/Category.php | 4 ++--
 application/admin/lang/zh-cn/category.php | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/application/admin/controller/Category.php b/application/admin/controller/Category.php
index c2d4882..306320f 100644
--- a/application/admin/controller/Category.php
+++ b/application/admin/controller/Category.php
@@ -102,9 +102,9 @@ class Category extends Backend
                 $params = $this->preExcludeFields($params);
 
                 if ($params['pid'] != $row['pid']) {
-                    $childrenIds = Tree::instance()->init(collection(\app\common\model\Category::select())->toArray())->getChildrenIds($row['id']);
+                    $childrenIds = Tree::instance()->init(collection(\app\common\model\Category::select())->toArray())->getChildrenIds($row['id'], true);
                     if (in_array($params['pid'], $childrenIds)) {
-                        $this->error(__('Can not change the parent to child'));
+                        $this->error(__('Can not change the parent to child or itself'));
                     }
                 }
 
diff --git a/application/admin/lang/zh-cn/category.php b/application/admin/lang/zh-cn/category.php
index e7dae0e..2092274 100644
--- a/application/admin/lang/zh-cn/category.php
+++ b/application/admin/lang/zh-cn/category.php
@@ -13,6 +13,6 @@ return [
     'Updatetime'                         => '更新时间',
     'Weigh'                              => '权重',
     'Category warmtips'                  => '温馨提示:栏目类型请前往<b>常规管理</b>-><b>系统配置</b>-><b>字典配置</b>中进行管理',
-    'Can not change the parent to child' => '父组别不能是它的子组别',
+    'Can not change the parent to child or itself' => '父组别不能是它的子组别或它自己',
     'Status'                             => '状态'
 ];
--
libgit2 0.24.0