Explorar el Código

添加删除目录前、对非空目录的检查

star7th hace 10 años
padre
commit
78e58b8b43

+ 11 - 2
Application/Home/Controller/CatalogController.class.php

@@ -87,7 +87,16 @@ class CatalogController extends BaseController {
         
         $login_user = $this->checkLogin();
         if (!$this->checkItemPermn($login_user['uid'] , $item_id)) {
-            $this->message("你无权限");
+            $return['error_code'] = -1 ;
+            $return['error_message'] = '你无权限' ;
+            $this->sendResult($return);
+            return;
+        }
+
+        if (D("Page")->where(" cat_id = '$cat_id' ")->find()) {
+            $return['error_code'] = -1 ;
+            $return['error_message'] = '为了安全,不允许直接删除非空目录。请先删除或转移该目录下的所有页面' ;
+            $this->sendResult($return);
             return;
         }
 
@@ -99,7 +108,7 @@ class CatalogController extends BaseController {
         if ($ret) {
            $this->sendResult($ret);
         }else{
-            $return['error_code'] = 10103 ;
+            $return['error_code'] = -1 ;
             $return['error_message'] = 'request  fail' ;
             $this->sendResult($return);
         }

+ 7 - 2
Public/js/catalog/edit.js

@@ -68,14 +68,19 @@ $(function(){
                 function(data){
                   if (data.error_code == 0) {
                     alert("删除成功!");
+                    window.location.href="edit?item_id="+item_id;
                   }else{
-                    alert("删除失败!");
+                    if (data.error_message) {
+                      alert(data.error_message);
+                    }else{
+                      alert("删除失败!");
+                    }
+                    
                   }
                 },
                 "json"
               );
         }
-      window.location.href="edit?item_id="+item_id;
     }
 
       return false;