예제 #1
0
        public virtual void Process(AddDbItemArgs args)
        {
            var item = args.DbItem;

            var rules = new AccessRuleCollection();

            this.FillAccessRules(rules, item.Access, AccessRight.ItemRead, a => a.CanRead);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemWrite, a => a.CanWrite);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemRename, a => a.CanRename);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemCreate, a => a.CanCreate);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemDelete, a => a.CanDelete);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemAdmin, a => a.CanAdmin);

            if (!rules.Any())
            {
                return;
            }

            var serializer = new AccessRuleSerializer();

            // TODO: Should not require to check if Security field is exists
            if (item.Fields.Any(f => f.ID == FieldIDs.Security))
            {
                item.Fields[FieldIDs.Security].Value = serializer.Serialize(rules);
            }
            else
            {
                item.Fields.Add(new DbField("__Security", FieldIDs.Security)
                {
                    Value = serializer.Serialize(rules)
                });
            }
        }
예제 #2
0
        public virtual void Process(AddDbItemArgs args)
        {
            var item = args.DbItem;

            var rules = new AccessRuleCollection();

            this.FillAccessRules(rules, item.Access, AccessRight.ItemRead, a => a.CanRead);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemWrite, a => a.CanWrite);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemRename, a => a.CanRename);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemCreate, a => a.CanCreate);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemDelete, a => a.CanDelete);
            this.FillAccessRules(rules, item.Access, AccessRight.ItemAdmin, a => a.CanAdmin);

            if (!rules.Any())
            {
                return;
            }

            var serializer = new AccessRuleSerializer();

            item.Fields.Add(new DbField("__Security", FieldIDs.Security)
            {
                Value = serializer.Serialize(rules)
            });
        }
        public virtual string BuildSecurityValue(ProductCatalog catalog)
        {
            AccessRuleCollection accessRulesForUsers = BuildAccessRuleCollectionForUsers(catalog);

            var serializer = new AccessRuleSerializer();
            var value      = serializer.Serialize(accessRulesForUsers);

            return(value);
        }
예제 #4
0
    public virtual void Process(AddDbItemArgs args)
    {
      var item = args.DbItem;

      var rules = new AccessRuleCollection();

      this.FillAccessRules(rules, item.Access, AccessRight.ItemRead, a => a.CanRead);
      this.FillAccessRules(rules, item.Access, AccessRight.ItemWrite, a => a.CanWrite);
      this.FillAccessRules(rules, item.Access, AccessRight.ItemRename, a => a.CanRename);
      this.FillAccessRules(rules, item.Access, AccessRight.ItemCreate, a => a.CanCreate);
      this.FillAccessRules(rules, item.Access, AccessRight.ItemDelete, a => a.CanDelete);
      this.FillAccessRules(rules, item.Access, AccessRight.ItemAdmin, a => a.CanAdmin);

      if (!rules.Any())
      {
        return;
      }

      var serializer = new AccessRuleSerializer();
      item.Fields.Add(new DbField("__Security", FieldIDs.Security) { Value = serializer.Serialize(rules) });
    }