/// <summary> /// 获取指定条件的用户组(推荐使用匿名委托来指定条件) /// </summary> /// <param name="resolver"></param> /// <returns></returns> public RoleCollection GetRoles(RoleResolver resolver) { RoleCollection roles = new RoleCollection(); foreach (Role role in Roles) { if (resolver(role)) { roles.Add(role); } } return(roles); }
/// <summary> /// 获取给后台作为自动加入的用户组列表。例如:作为任务奖励自动加入用户组,那么只能在这些用户组里面选择 /// </summary> /// <returns></returns> public RoleCollection GetRolesForAutoAdd() { RoleCollection roles = new RoleCollection(); foreach (Role r in Roles) { if ((r.Type & RoleType.Normal) == RoleType.Normal && (r.Type & RoleType.Virtual) != RoleType.Virtual && (r.Type & RoleType.System) != RoleType.System ) { roles.Add(r); } } return(roles); }
/// <summary> /// 获取所有用户组,但排除掉指定的用户组 /// </summary> /// <param name="exceptRoleIds"></param> /// <returns></returns> public RoleCollection GetRoles(params Role[] exceptRoles) { RoleCollection roles = new RoleCollection(); foreach (Role role in Roles) { bool isExcept = false; foreach (Role exceptRole in exceptRoles) { if (role == exceptRole) { isExcept = true; break; } } if (isExcept == false) { roles.Add(role); } } return(roles); }
public RoleSettings() { string iconPath = Globals.GetRelativeUrl(SystemDirecotry.Assets_RoleIcon); Roles = new RoleCollection(); Roles.Add(Role.Everyone); Roles.Add(Role.Guests); Roles.Add(Role.Users); Roles.Add(Role.ForumBannedUsers); Roles.Add(Role.FullSiteBannedUsers); Roles.Add(Role.NewUsers); Roles.Add(Role.EmailNotProvedUsers); Roles.Add(Role.RealnameNotProvedUsers); //Roles.Add(Role.InviteLessUsers); Roles.Add(Role.JackarooModerators); Roles.Add(Role.Moderators); Roles.Add(Role.CategoryModerators); Roles.Add(Role.SuperModerators); Roles.Add(Role.Administrators); Roles.Add(Role.Owners); Roles.Add(Role.NoLevel); LevelLieOn = LevelLieOn.Post; /*-----------------------默认图标------------------------*/ Role.CategoryModerators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips10.gif"); Role.Administrators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips10.gif"); Role.SuperModerators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips10.gif"); Role.Owners.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips10.gif"); Role.Moderators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips9.gif"); Role.JackarooModerators.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips8.gif"); /*-------------------默认等级用户组------------------*/ Role levelRole = new Role(); levelRole.Name = "新手上路"; levelRole.RequiredPoint = 0; levelRole.RoleID = new Guid(new byte[] { 74, 115, 163, 71, 186, 53, 83, 71, 183, 179, 236, 16, 210, 32, 146, 103 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips1.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "侠客"; levelRole.RequiredPoint = 50; levelRole.RoleID = new Guid(new byte[] { 248, 152, 64, 183, 181, 77, 53, 77, 182, 73, 89, 85, 162, 252, 146, 41 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips2.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "圣骑士"; levelRole.RequiredPoint = 200; levelRole.RoleID = new Guid(new byte[] { 29, 40, 140, 204, 235, 17, 207, 73, 174, 43, 138, 98, 96, 82, 219, 68 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips3.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "精灵"; levelRole.RequiredPoint = 500; levelRole.RoleID = new Guid(new byte[] { 26, 191, 38, 123, 38, 152, 103, 71, 171, 98, 16, 19, 63, 224, 29, 77 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips4.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "精灵王"; levelRole.RequiredPoint = 1000; levelRole.RoleID = new Guid(new byte[] { 92, 96, 198, 205, 96, 80, 220, 66, 172, 38, 16, 150, 6, 184, 0, 251 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips5.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "风云使者"; levelRole.RequiredPoint = 5000; levelRole.RoleID = new Guid(new byte[] { 165, 75, 133, 177, 234, 6, 16, 66, 162, 12, 235, 64, 5, 68, 248, 140 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips6.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "光明使者"; levelRole.RequiredPoint = 10000; levelRole.RoleID = new Guid(new byte[] { 185, 185, 243, 95, 132, 73, 233, 67, 128, 221, 168, 188, 74, 206, 151, 196 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips7.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "天使"; levelRole.RequiredPoint = 50000; levelRole.RoleID = new Guid(new byte[] { 164, 254, 210, 237, 225, 87, 214, 77, 171, 96, 92, 245, 221, 54, 78, 154 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips8.gif"); levelRole.IsNew = false; Roles.Add(levelRole); levelRole = new Role(); levelRole.Name = "法老"; levelRole.RequiredPoint = 100000; levelRole.RoleID = new Guid(new byte[] { 188, 159, 219, 20, 145, 63, 6, 67, 184, 52, 226, 115, 211, 207, 90, 98 }); levelRole.Title = levelRole.Name; levelRole.Type = RoleType.Custom | RoleType.Level | RoleType.Virtual; levelRole.IconUrlSrc = UrlUtil.JoinUrl(iconPath, "pips9.gif"); levelRole.IsNew = false; Roles.Add(levelRole); /*-----------------------end-------------------------*/ Roles.Sort(); }