Task IReadModifyWriteObject.SaveChanges() { // Validate that all referenced groups are there. // (race condition but fine as this is just a convenience validation) // (btw, you could also just implement custom group objects to trick this check) if (!ACL.Cast <ChanACL>().All(x => x.TargetGroup == null || SysGroups.Values.Contains(x.TargetGroup) || Groups.Concat(InheritedGroups).Any(y => y.Name == ((ChanGroup)x.TargetGroup).Name))) { throw new InvalidOperationException("Referencing groups that weren't added!"); } return(Server.SetACL(ChannelId, new Wrapped.Server.ACLData { Inherit = Inherit, ACLs = ACL.Select(x => new Murmur.ACL { allow = (int)x.Allow, deny = (int)x.Deny, applyHere = x.ApplyOnThisChannel, applySubs = x.ApplyOnSubchannels, userid = x.TargetUser ?? -1, group = x.TargetGroup == null ? String.Empty : (x.TargetGroup is ChanGroup ? ((ChanGroup)x.TargetGroup).Name : SysGroups.Single(y => y.Value == x.TargetGroup).Key), }).ToArray(), Groups = InheritedGroups.Concat(Groups).Cast <ChanGroup>().Select(x => new Murmur.Group { name = x.Name, inherited = x._Inherited, inherit = (x is IChannelUserGroupInherited) ? ((IChannelUserGroupInherited)x).IncludeMembersFromParentChannels : false, inheritable = x.Inheritable, add = x.Members.ToArray(), remove = x.NegativeMembers.ToArray(), }).ToArray(), })); }
public List <ThemeGroupModel> GetAllGroups() { var topThemes = GetAllThemes().Where(t => t.ShowAsTop).ToList(); var currentTheme = GetAllThemes().First(t => t.Name == Utils.CurrentTheme); if (!topThemes.Contains(currentTheme)) { topThemes.Add(currentTheme); } var firstGroup = new ThemeGroupModel() { Name = "FirstGroup", Themes = topThemes }; return(Groups.Concat(new[] { firstGroup }).ToList()); }
public IChannelUserGroup CreateGroup(string name) { if (name.Except(Alphanumeric).Any()) { throw new ArgumentException("Group names must be alphanumeric!", "name"); } if (Groups.Concat(InheritedGroups).Any(x => x.Name == name)) { throw new ArgumentException("A group with that name already exists!", "name"); } return(new ChanGroup { Name = name, Inheritable = true, Members = new HashSet <int>(), NegativeMembers = new HashSet <int>(), _Inherited = false, }); }
public IEnumerable <Group.Group> GetUserGroups() => Groups.Concat(GroupMembers.Where(m => m.IsAccepted).Select(m => m.Group));