コード例 #1
0
 public ExportColumn(string id, string title, Func <Contact, string> getter, PartAccess access)
 {
     Id     = id;
     Title  = title;
     Getter = getter;
     Access = access;
 }
コード例 #2
0
 private void Add(string id, string title, Func <Contact, string> getter, PartAccess access)
 {
     Columns.Add(new ExportColumn(
                     id,
                     _translator.Get("Export.Column." + id, "Column '" + id + "' in the export", title),
                     getter,
                     access));
 }
コード例 #3
0
        private void AddPermission(Role role, SubjectAccess subject, PartAccess part, AccessRight right)
        {
            var permission = new Permission(Guid.NewGuid());

            permission.Role.Value    = role;
            permission.Subject.Value = subject;
            permission.Part.Value    = part;
            permission.Right.Value   = right;
            _db.Save(permission);
        }
コード例 #4
0
        public bool HasSystemWideAccess(PartAccess partAccess, AccessRight right)
        {
            var session = CurrentSession;

            if (session == null)
            {
                return(false);
            }
            else
            {
                return(session.HasSystemWideAccess(partAccess, right));
            }
        }
コード例 #5
0
        public bool HasAccess(Group group, PartAccess partAccess, AccessRight right)
        {
            var session = CurrentSession;

            if (session == null)
            {
                return(false);
            }
            else
            {
                return(session.HasAccess(group, partAccess, right));
            }
        }
コード例 #6
0
        public bool HasAccess(Contact contact, PartAccess partAccess, AccessRight right)
        {
            var session = CurrentSession;

            if (session == null)
            {
                return(false);
            }
            else
            {
                return(session.HasAccess(contact, partAccess, right));
            }
        }
コード例 #7
0
        public static string Translate(this PartAccess part, Translator translator)
        {
            switch (part)
            {
            case PartAccess.None:
                return(translator.Get("Enum.PartAccess.None", "Value 'None' in PartAccess enum", "None"));

            case PartAccess.Contact:
                return(translator.Get("Enum.PartAccess.Contact", "Value 'Contact' in PartAccess enum", "Contact"));

            case PartAccess.Subscription:
                return(translator.Get("Enum.PartAccess.Subscription", "Value 'Subscription' in PartAccess enum", "Subscription"));

            case PartAccess.TagAssignments:
                return(translator.Get("Enum.PartAccess.TagAssignments", "Value 'TagAssignments' in PartAccess enum", "TagAssignments"));

            case PartAccess.RoleAssignments:
                return(translator.Get("Enum.PartAccess.RoleAssignments", "Value 'RoleAssignments' in PartAccess enum", "RoleAssignments"));

            case PartAccess.Structure:
                return(translator.Get("Enum.PartAccess.Structure", "Value 'Structure' in PartAccess enum", "Structure"));

            case PartAccess.CustomDefinitions:
                return(translator.Get("Enum.PartAccess.CustomDefinitions", "Value 'Custom definitions' in PartAccess enum", "Custom definitions"));

            case PartAccess.Demography:
                return(translator.Get("Enum.PartAccess.Demography", "Value 'Demography' in PartAccess enum", "Demography"));

            case PartAccess.Documents:
                return(translator.Get("Enum.PartAccess.Documents", "Value 'Documents' in PartAccess enum", "Documents"));

            case PartAccess.Mailings:
                return(translator.Get("Enum.PartAccess.Mailings", "Value 'Mailings' in PartAccess enum", "Mailings"));

            case PartAccess.Anonymous:
                return(translator.Get("Enum.PartAccess.Anonymous", "Value 'Anonymous' in PartAccess enum", "Anonymous"));

            case PartAccess.Journal:
                return(translator.Get("Enum.PartAccess.Journal", "Value 'Journal' in PartAccess enum", "Journal"));

            case PartAccess.Crypto:
                return(translator.Get("Enum.PartAccess.Crypto", "Value 'Crypto' in PartAccess enum", "Crypto"));

            case PartAccess.Deleted:
                return(translator.Get("Enum.PartAccess.Deleted", "Value 'Deleted' in PartAccess enum", "Deleted"));

            default:
                throw new NotSupportedException();
            }
        }
コード例 #8
0
        public bool HasSystemWideAccess(PartAccess partAccess, AccessRight right)
        {
            foreach (var rolePermission in _access
                     .Where(rp => rp.Permission.Part.Value == partAccess)
                     .Where(rp => rp.Permission.Right.Value >= right))
            {
                switch (rolePermission.Permission.Subject.Value)
                {
                case SubjectAccess.SystemWide:
                    return(true);
                }
            }

            return(false);
        }
コード例 #9
0
        public bool HasAccess(Group group, PartAccess partAccess, AccessRight right)
        {
            foreach (var rolePermission in _access
                     .Where(rp => rp.Permission.Part.Value == partAccess)
                     .Where(rp => rp.Permission.Right.Value >= right))
            {
                switch (rolePermission.Permission.Subject.Value)
                {
                case SubjectAccess.SystemWide:
                    return(true);

                case SubjectAccess.Feed:
                    if (rolePermission.Role.Group.Value.Feed.Value
                        .Groups.Contains(group))
                    {
                        return(true);
                    }
                    break;

                case SubjectAccess.SubFeed:
                    if (rolePermission.Role.Group.Value.Feed.Value
                        .Groups.Contains(group))
                    {
                        return(true);
                    }
                    else if (rolePermission.Role.Group.Value.Feed.Value
                             .Subordinates.SelectMany(o => o.Groups).Contains(group))
                    {
                        return(true);
                    }
                    break;

                case SubjectAccess.Group:
                    if (rolePermission.Role.Group.Value == group)
                    {
                        return(true);
                    }
                    break;
                }
            }

            return(false);
        }
コード例 #10
0
        public bool HasAccess(Contact contact, PartAccess partAccess, AccessRight right)
        {
            if ((partAccess != PartAccess.Deleted) &&
                contact.Deleted &&
                !HasAccess(contact, PartAccess.Deleted, right))
            {
                return(false);
            }

            if (User == contact)
            {
                switch (partAccess)
                {
                case PartAccess.Anonymous:
                case PartAccess.Contact:
                    return(true);

                case PartAccess.Demography:
                case PartAccess.Documents:
                case PartAccess.Subscription:
                case PartAccess.RoleAssignments:
                case PartAccess.TagAssignments:
                case PartAccess.Journal:
                    if (right == AccessRight.Read)
                    {
                        return(true);
                    }
                    break;
                }
            }

            foreach (var subscription in contact.ActiveSubscriptions)
            {
                if (HasAccess(subscription.Feed.Value, partAccess, right))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #11
0
ファイル: PostStatus.cs プロジェクト: parat-schweiz/Publicus
 public bool HasSystemWideAccess(PartAccess partAccess, AccessRight right)
 {
     return(VerifyAccess(s => s.HasSystemWideAccess(partAccess, right)));
 }
コード例 #12
0
ファイル: PostStatus.cs プロジェクト: parat-schweiz/Publicus
 public bool HasAccess(Group group, PartAccess partAccess, AccessRight right)
 {
     return(VerifyAccess(s => s.HasAccess(group, partAccess, right)));
 }
コード例 #13
0
ファイル: PostStatus.cs プロジェクト: parat-schweiz/Publicus
 public bool HasAccess(Feed feed, PartAccess partAccess, AccessRight right)
 {
     return(VerifyAccess(s => s.HasAccess(feed, partAccess, right)));
 }
コード例 #14
0
ファイル: PostStatus.cs プロジェクト: parat-schweiz/Publicus
 public bool HasAccess(Contact contact, PartAccess partAccess, AccessRight right)
 {
     return(VerifyAccess(s => s.HasAccess(contact, partAccess, right)));
 }
コード例 #15
0
ファイル: PartManager.cs プロジェクト: kovacste/automuhely
 public PartManager(DbContextOptions <DomainModel.Models.CarMechanicContext> options)
 {
     _options    = options;
     _partAccess = new PartAccess(_options);
 }
コード例 #16
0
ファイル: PostStatus.cs プロジェクト: parat-schweiz/Publicus
 public bool HasAnyFeedAccess(PartAccess partAccess, AccessRight right)
 {
     return(VerifyAccess(s => s.HasAnyFeedAccess(partAccess, right)));
 }
コード例 #17
0
 public NamedIntViewModel(Translator translator, PartAccess part, bool selected)
     : this((int)part, part.Translate(translator), selected)
 {
 }