Beispiel #1
0
        public static TimMenu FilterUserMenu(TimMenu menu, string userId)
        {
            TimMenu timMenu = new TimMenu();

            timMenu.Id       = menu.Id;
            timMenu.Name     = menu.Name;
            timMenu.Order    = menu.Order;
            timMenu.FatherId = menu.FatherId;
            timMenu.Type     = menu.Type;
            timMenu.Url      = menu.Url;
            foreach (TimMenu menu2 in menu.Children)
            {
                bool flag = menu2.Type == ModuleType.C;
                if (flag)
                {
                    TimMenu timMenu2 = FuncModelUtils.FilterUserMenu(menu2, userId);
                    bool    flag2    = timMenu2 != null && timMenu2.Children.Count > 0;
                    if (flag2)
                    {
                        timMenu.Children.Add(timMenu2);
                    }
                }
                else
                {
                    UserModulePermission modulePermission = PermissionUtils.GetUserModulePermission(userId, menu2.Id);
                    bool flag3 = modulePermission != null && modulePermission.View;
                    if (flag3)
                    {
                        timMenu.Children.Add(menu2);
                    }
                }
            }
            return(timMenu);
        }
Beispiel #2
0
        public static UserModulePermission GetUserModulePermission(string userId, int amId)
        {
            UserModulePermission modulePermission = new UserModulePermission();
            User user = UserUtils.GetUser(userId);
            bool flag = user == null;
            UserModulePermission result;

            if (flag)
            {
                result = modulePermission;
            }
            else
            {
                Module module = ModuleUtils.GetModule(amId);
                bool   flag2  = module == null;
                if (flag2)
                {
                    result = modulePermission;
                }
                else
                {
                    modulePermission.UserId = user.UserId;
                    modulePermission.AmId   = module.MdId;
                    bool flag3 = (user.Type == UserType.S && amId >= 102010001 && amId <= 102019999) || !ModuleUtils.IsRequirePermission(module);
                    if (flag3)
                    {
                        modulePermission.View = (modulePermission.Insert = (modulePermission.Edit = (modulePermission.Delete = (modulePermission.Print = (modulePermission.Design = true)))));
                        result = modulePermission;
                    }
                    else
                    {
                        Permission permission = PermissionUtils.GetPermission(PermissionType.U, userId, amId);
                        bool       flag4      = permission != null;
                        if (flag4)
                        {
                            modulePermission.Insert = permission.Insert;
                            modulePermission.Edit   = permission.Edit;
                            modulePermission.Delete = permission.Delete;
                            modulePermission.Print  = permission.Print;
                            modulePermission.View   = permission.View;
                            modulePermission.Design = permission.Design;
                            modulePermission.View   = (modulePermission.Insert || modulePermission.Edit || modulePermission.Delete || modulePermission.Print || modulePermission.View || modulePermission.Design);
                        }
                        foreach (RoleUser roleUser in RoleUserUtils.GetRoles(userId))
                        {
                            Permission permission2 = PermissionUtils.GetPermission(PermissionType.R, roleUser.RoleId, amId);
                            bool       flag5       = permission2 != null;
                            if (flag5)
                            {
                                modulePermission.Insert = (permission2.Insert || modulePermission.Insert);
                                modulePermission.Edit   = (permission2.Edit || modulePermission.Edit);
                                modulePermission.Delete = (permission2.Delete || modulePermission.Delete);
                                modulePermission.Print  = (permission2.Print || modulePermission.Print);
                                modulePermission.View   = (permission2.View || modulePermission.View);
                                modulePermission.Design = (permission2.Design || modulePermission.Design);
                                modulePermission.View   = (modulePermission.Insert || modulePermission.Edit || modulePermission.Delete || modulePermission.Print || modulePermission.View || modulePermission.Design);
                            }
                        }
                        result = modulePermission;
                    }
                }
            }
            return(result);
        }