zoukankan      html  css  js  c++  java
  • 重构代码

    function sync_dept_delete($dept_info, $sir_domain, $dept_id = 0){
        // 查出域名对应的id
        if($dept_id == 0 || $dept_id == ""){
            $dept_id = Check_Address_Sort_Menu_Import($sir_domain);
        }
        echo "dept_id is $dept_id
    ";
    
        // 删除员工
        $member_arr = $dept_info["members"];
        if(count($member_arr) > 0){
            for($i = 0; $i < count($member_arr); $i++){
                $loginname = $member_arr[$i];//用户名
                $email = strtolower(trim($loginname . "@" . $sir_domain));
                remove_employee($email, $dept_id, $sir_domain);
            }
            return true;
        }
    
        // 删除子部门
        $sub_dept_infos = $dept_info["subdepts"];
        if(count($sub_dept_infos) > 0){
            $sub_dept_name = $sub_dept_infos[0]["name"];
            $sub_dept_id = Get_Address_Sort_Menu_Import_Dept($sub_dept_name, $dept_id);
    
            if(sync_dept_delete( $sub_dept_infos[0], $sir_domain, $sub_dept_id)){
                return true;
            }
        }
    
        // 不能删除名为全体人员的部门,它是特殊部门
        $dept_name = $dept_info["name"];
        if($dept_name != "全体人员"){
            remove_dept($dept_id, $dept_name, $sir_domain);
            return true;
        }
    
        echo "the directory $dept_name can not remove 
    ";
        return false;
    }
    
    function remove_employee($email, $dept_id, $sir_domain){
        global $obj_db;
        echo "remove employee $email
    ";
    
        $query = "select id from user where uid='$email'";
        $rs = $obj_db->simplequery($query);
        $num = $obj_db->numrows($rs);
    
        if($num > 0){
            $row = $obj_db->fetchrow($rs, $fetchmode = DB_FETCHMODE_ASSOC);
            $id = $row["id"];
            Operate_Manage_User("delete", $id);
        }
    
    
        Operate_Address_Tree( $dept_id,  "", $email,  "", "", $sir_domain, "delete");
        // Operate_Address_Tree($it_id,$name,$email,$tel,$dept,$User_Domain,$operate_type)
        // "delete from address_tree where it_id='$it_id' and email='$email';"
    }
    
    function remove_dept($dept_id, $dept_name, $sir_domain){
        echo "remove dept $dept_id
    ";
        Operate_Address_Item_Tree($dept_id, $dept_name, $sir_domain, "delete");
    }
  • 相关阅读:
    python自动化测试(2)--读取excel中的测试用例并使用列表进行存放
    Numpy学习记录
    Tensorflow环境安装记录--无法识别GPU的问题
    Tensorflow框架学习(1)--CNN的实现
    IDEA创建springboot项目总是创建失败问题的解决
    java_集合知识点小结
    java易错知识点汇总_1
    struts2 中文件的位置问题
    struts2 action中的私有变量
    span 标记 width 设置
  • 原文地址:https://www.cnblogs.com/code-style/p/4415484.html
Copyright © 2011-2022 走看看