Exemple #1
0
        public virtual void DeleteRecordRight(DBSecurityEngine dbSecurityEngine, Guid entityRecordId,
                                              string entitySchemaName, Dictionary <string, object> recordRight)
        {
            bool canRead   = (bool)recordRight["CanRead"];
            bool canEdit   = (bool)recordRight["CanEdit"];
            bool canDelete = (bool)recordRight["CanDelete"];

            switch ((string)recordRight["Grantee"])
            {
            case "Role":
            case "Employee":
            case "DataSourceFilter":
                List <KeyValuePair <Guid, string> > adminUnitIds = GetAdminUnitIds(recordRight);
                foreach (KeyValuePair <Guid, string> adminUnitId in adminUnitIds)
                {
                    if (canRead)
                    {
                        dbSecurityEngine.ForceDeleteEntitySchemaRecordRightLevel(adminUnitId.Key,
                                                                                 EntitySchemaRecordRightOperation.Read, entitySchemaName, entityRecordId);
                    }
                    if (canEdit)
                    {
                        dbSecurityEngine.ForceDeleteEntitySchemaRecordRightLevel(adminUnitId.Key,
                                                                                 EntitySchemaRecordRightOperation.Edit, entitySchemaName, entityRecordId);
                    }
                    if (canDelete)
                    {
                        dbSecurityEngine.ForceDeleteEntitySchemaRecordRightLevel(adminUnitId.Key,
                                                                                 EntitySchemaRecordRightOperation.Delete, entitySchemaName, entityRecordId);
                    }
                }
                break;

            case "AllRolesAndUsers":
                if (canRead)
                {
                    dbSecurityEngine
                    .ForceDeleteAllEntitySchemaRecordRightLevel(EntitySchemaRecordRightOperation.Read,
                                                                entitySchemaName, entityRecordId);
                }
                if (canEdit)
                {
                    dbSecurityEngine
                    .ForceDeleteAllEntitySchemaRecordRightLevel(EntitySchemaRecordRightOperation.Edit,
                                                                entitySchemaName, entityRecordId);
                }
                if (canDelete)
                {
                    dbSecurityEngine
                    .ForceDeleteAllEntitySchemaRecordRightLevel(EntitySchemaRecordRightOperation.Delete,
                                                                entitySchemaName, entityRecordId);
                }
                break;
            }
        }
Exemple #2
0
 private void ForceDeleteEntitySchemaRecordRightLevel(Guid adminUnitId, string schemaName, Guid recordId)
 {
     foreach (EntitySchemaRecordRightOperation operation in Enum.GetValues(typeof(EntitySchemaRecordRightOperation)))
     {
         DBSecurityEngine.ForceDeleteEntitySchemaRecordRightLevel(adminUnitId, operation, schemaName, recordId);
     }
 }
Exemple #3
0
        private void DeleteSubscriberEditRight(SocialSubscription socialSubscription)
        {
            SysUserInfo currentUser             = UserConnection.CurrentUser;
            Guid        sysAdminUnitId          = socialSubscription.SysAdminUnitId;
            Guid        socialChannelOwnerId    = GetSocialChannelOwnerId(socialSubscription.Id, socialSubscription.EntityId);
            bool        currentUserIsOwner      = socialChannelOwnerId.Equals(currentUser.ContactId);
            bool        currentUserIsSubscriber = sysAdminUnitId.Equals(currentUser.Id);

            if ((currentUserIsSubscriber && currentUserIsOwner) || !currentUserIsSubscriber)
            {
                return;
            }
            var schemaName = "SocialSubscription";
            var schema     = UserConnection.EntitySchemaManager.GetInstanceByName(schemaName);

            if (!schema.AdministratedByRecords)
            {
                return;
            }
            DBSecurityEngine.ForceDeleteEntitySchemaRecordRightLevel(sysAdminUnitId, EntitySchemaRecordRightOperation.Edit, schemaName, socialSubscription.Id);
        }