Пример #1
0
        public void SetRestriction(long userId, string restName, UserRestrictionState state)
        {
            if (restName == name)
            {
                if (restrictions.ContainsKey(userId))
                {
                    restrictions [userId].State = state;
                }
                else
                {
                    restrictions.Add(userId, new UserRestriction(userId, restName, state));
                }

                return;
            }

            RestrictionNode node = FindNode(restName);

            if (node == null)
            {
                return;
            }

            node.SetRestriction(userId, restName, state);
        }
Пример #2
0
        public void SetRestriction(UserAccessLevel level, string restName, UserRestrictionState state)
        {
            if (restName == name)
            {
                int levelId = GetAccessLevelId(level);
                if (restrictions.ContainsKey(levelId))
                {
                    restrictions [levelId].State = state;
                }
                else
                {
                    restrictions.Add(levelId, new UserRestriction(levelId, restName, state));
                }

                return;
            }

            RestrictionNode node = FindNode(restName);

            if (node == null)
            {
                return;
            }

            node.SetRestriction(level, restName, state);
        }
Пример #3
0
        public void ApplyRestriction(long userId)
        {
            UserRestrictionState r = GetRestriction(userId);

            item.Visible   = r != UserRestrictionState.Restricted;
            item.Sensitive = r != UserRestrictionState.Disabled;

            SubItems.ApplyRestriction(userId);
        }
        private void SetRestriction(TreeIter parent, bool val)
        {
            string nodeName            = (string)restsTreeStore.GetValue(parent, 2);
            UserRestrictionState state = val ? UserRestrictionState.Allowed : UserRestrictionState.Restricted;

            if (selectedUserId != null)
            {
                restsRoot.SetRestriction(selectedUserId.Value, nodeName, state);
            }
            else if (selectedAccessLevel != null)
            {
                restsRoot.SetRestriction(selectedAccessLevel.Value, nodeName, state);
            }

            restsTreeStore.SetValue(parent, 1, val);
        }
Пример #5
0
        private void WriteRestrictionToXML(XContainer parent, UserAccessLevel accessLevel)
        {
            UserRestrictionState state = GetRestriction(accessLevel);

            if (state != GetDefaultRestriction(accessLevel))
            {
                XElement restrictionElement = new XElement("restriction");
                restrictionElement.Add(new XAttribute("name", name));
                restrictionElement.Add(new XAttribute("value", state));
                parent.Add(restrictionElement);
            }

            foreach (RestrictionNode child in children)
            {
                child.WriteRestrictionToXML(parent, accessLevel);
            }
        }
Пример #6
0
        public void ResetLevelRestrictions(long userId, UserAccessLevel level)
        {
            UserRestrictionState state = GetRestriction(level);

            if (restrictions.ContainsKey(userId))
            {
                restrictions [userId].State = state;
            }
            else if (state != UserRestrictionState.Allowed)
            {
                restrictions.Add(userId, new UserRestriction(userId, name, state));
            }

            foreach (RestrictionNode child in Children)
            {
                child.ResetLevelRestrictions(userId, level);
            }
        }
Пример #7
0
        private void ReloadAccessLevelDefaults(UserAccessLevel level)
        {
            UserRestrictionState state = GetDefaultRestriction(level);
            int levelId = GetAccessLevelId(level);

            if (restrictions.ContainsKey(levelId))
            {
                restrictions [levelId].State = state;
            }
            else if (state != UserRestrictionState.Allowed)
            {
                restrictions.Add(levelId, new UserRestriction(levelId, name, state));
            }

            foreach (RestrictionNode child in Children)
            {
                child.ReloadAccessLevelDefaults(level);
            }
        }
Пример #8
0
 public void SetRestriction(long userId, UserRestrictionState state)
 {
     SetRestriction(new UserRestriction(userId, Name, state));
 }
Пример #9
0
 public UserRestriction(long userId, string name, UserRestrictionState state)
 {
     this.userId = userId;
     this.name   = name;
     this.state  = state;
 }