Exemplo n.º 1
0
        public static AccessControlToken GetNewItemPermissionsToken(Core core, IPermissibleItem item, string fieldName)
        {
            AccessControlToken token = new AccessControlToken(core, item);

            List<PrimitivePermissionGroup> groups = PermissionGroupSelectBox.FormPermissionGroups(core, fieldName);

            token.AddGroups(groups);

            return token;
        }
Exemplo n.º 2
0
        internal Access(Core core, ItemKey key, Primitive leafOwner)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            this.core = core;
            this.item = null;
            this.owner = leafOwner;
            this.itemKey = key;
            this.viewer = core.Session.LoggedInMember;
        }
Exemplo n.º 3
0
        public Access(Core core, IPermissibleItem item)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            this.core = core;
            this.item = item;
            this.owner = item.Owner;
            this.itemKey = item.ItemKey;
            this.viewer = core.Session.LoggedInMember;
        }
Exemplo n.º 4
0
 public AccessControlLists(Core core, IPermissibleItem item)
 {
     this.core = core;
     this.item = item;
 }
        public static List<AccessControlPermission> GetPermissions(Core core, IPermissibleItem item)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            List<AccessControlPermission> permissions = new List<AccessControlPermission>();

            SelectQuery sQuery = Item.GetSelectQueryStub(core, typeof(AccessControlPermission));
            sQuery.AddCondition("permission_item_type_id", item.ItemKey.TypeId);
            sQuery.AddSort(SortOrder.Ascending, "permission_type");

            System.Data.Common.DbDataReader permissionsReader = core.Db.ReaderQuery(sQuery);

            while (permissionsReader.Read())
            {
                permissions.Add(new AccessControlPermission(core, permissionsReader));
            }

            permissionsReader.Close();
            permissionsReader.Dispose();

            return permissions;
        }
Exemplo n.º 6
0
        public bool IsMemberOf(IPermissibleItem item, Type type, long subType)
        {
            if (ItemType.GetTypeId(core, type) == ItemType.GetTypeId(core, typeof(Friend)))
            {
                switch (subType)
                {
                    case -1:
                        if (IsFriend(core.Session.LoggedInMember.ItemKey))
                        {
                            return true;
                        }
                        break;
                    case -2:
                        if (IsFamily(core.Session.LoggedInMember.ItemKey))
                        {
                            return true;
                        }
                        break;
                    case -3:
                        if (IsBlocked(core.Session.LoggedInMember.ItemKey))
                        {
                            return true;
                        }
                        break;
                }
            }

            if (ItemType.GetTypeId(core, type) == ItemType.GetTypeId(core, typeof(User)))
            {
                switch (subType)
                {
                    case -1:
                        if (item.Owner.Id == core.LoggedInMemberId)
                        {
                            return true;
                        }
                        break;
                    case -2:
                        return true;
                    case -3:
                        if (core.Session.IsLoggedIn)
                        {
                            return true;
                        }
                        break;
                }
            }

            return false;
        }
Exemplo n.º 7
0
        public static void CreateGrantForPrimitive(Core core, IPermissibleItem item, ItemKey grantee, params string[] permissionNames)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            SelectQuery query = AccessControlPermission.GetSelectQueryStub(core, typeof(AccessControlPermission));
            query.AddCondition("permission_item_type_id", item.ItemKey.TypeId);
            query.AddCondition("permission_name", ConditionEquality.In, permissionNames);
            query.AddSort(SortOrder.Ascending, "permission_type");

            DataTable permissionDataTable = core.Db.Query(query);

            foreach (DataRow dr in permissionDataTable.Rows)
            {
                AccessControlPermission permission = new AccessControlPermission(core, dr);
                AccessControlGrant.Create(core, grantee, item.ItemKey, permission.PermissionId, AccessControlGrants.Allow);
            }
        }
Exemplo n.º 8
0
        internal AccessControlGrant(Core core, IPermissibleItem item, DataRow grantRow)
            : base(core)
        {
            this.item = item;
            ItemLoad += new ItemLoadHandler(AccessControlGrant_ItemLoad);

            loadItemInfo(grantRow);
        }
Exemplo n.º 9
0
        public static void CreateAllGrantsForOwner(Core core, IPermissibleItem item)
        {
            List<AccessControlPermission> permissions = AccessControlPermission.GetPermissions(core, item);

            foreach (AccessControlPermission permission in permissions)
            {
                AccessControlGrant.Create(core, item.Owner.ItemKey, item.ItemKey, permission.PermissionId, AccessControlGrants.Allow);
            }
        }
Exemplo n.º 10
0
        public static string BuildAclUri(Core core, IPermissibleItem item, bool simple)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            return core.Hyperlink.AppendAbsoluteSid(string.Format("/api/acl?id={0}&type={1}&aclmode={2}", item.Id, item.ItemKey.TypeId, (simple ? "simple" : "detailed")), true);
        }
Exemplo n.º 11
0
        public static string BuildAclUri(Core core, IPermissibleItem item)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            return core.Hyperlink.AppendAbsoluteSid(string.Format("/api/acl?id={0}&type={1}", item.Id, item.ItemKey.TypeId), true);
        }
Exemplo n.º 12
0
        public static List<AccessControlGrant> GetGrants(Core core, IPermissibleItem item, long permissionId)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            List<AccessControlGrant> grants = new List<AccessControlGrant>();

            SelectQuery sQuery = Item.GetSelectQueryStub(core, typeof(AccessControlGrant));
            sQuery.AddCondition("grant_item_id", item.ItemKey.Id);
            sQuery.AddCondition("grant_item_type_id", item.ItemKey.TypeId);
            sQuery.AddCondition("grant_permission_id", permissionId);

            System.Data.Common.DbDataReader grantsReader = core.Db.ReaderQuery(sQuery);

            while (grantsReader.Read())
            {
                grants.Add(new AccessControlGrant(core, item, grantsReader));
            }

            grantsReader.Close();
            grantsReader.Dispose();

            return grants;
        }
Exemplo n.º 13
0
 private AccessControlGrant(Core core, ItemKey primitiveKey, long itemId, long itemTypeId, long permissionId, sbyte grantAllow, IPermissibleItem item, Primitive owner, ItemKey itemKey)
     : base(core)
 {
     this.primitiveKey = primitiveKey;
     this.itemId = itemId;
     this.itemTypeId = itemTypeId;
     this.permissionId = permissionId;
     this.grantAllow = grantAllow;
     this.item = item;
     this.owner = owner;
     this.itemKey = itemKey;
 }
Exemplo n.º 14
0
        internal AccessControlGrant(Core core, IPermissibleItem item, System.Data.Common.DbDataReader grantRow)
            : base(core)
        {
            this.item = item;
            ItemLoad += new ItemLoadHandler(AccessControlGrant_ItemLoad);

            loadItemInfo(grantRow);
        }
Exemplo n.º 15
0
        public static void CreateDefaultSimpleGrantsForOthers(Core core, IPermissibleItem item)
        {
            List<AccessControlPermission> permissions = AccessControlPermission.GetPermissions(core, item);

            foreach (AccessControlPermission permission in permissions)
            {
                // View Permissions
                if (permission.PermissionType == PermissionTypes.View)
                {
                    //AccessControlGrant.Create(core, item.Owner.ItemKey, item.ItemKey, permission.PermissionId, AccessControlGrants.Allow);
                }
                // Interact Permissions
                if (permission.PermissionType == PermissionTypes.Interact)
                {
                    //AccessControlGrant.Create(core, item.Owner.ItemKey, item.ItemKey, permission.PermissionId, AccessControlGrants.Allow);
                }
            }
        }
Exemplo n.º 16
0
 public static List<AccessControlPermission> GetPermissions(Core core, IPermissibleItem item)
 {
     return GetPermissions(core, item.ItemKey);
 }
Exemplo n.º 17
0
        internal AccessControlGrant(Core core, DataRow grantRow)
            : base(core)
        {
            this.item = null;
            ItemLoad += new ItemLoadHandler(AccessControlGrant_ItemLoad);

            loadItemInfo(grantRow);
        }