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"); }