Пример #1
0
        /// <summary>
        /// Updates an Object within a supplied Group
        /// Object must be an object that is recognized by OysterObjectType values;
        /// </summary>
        /// <param name="AccessingUser"></param>
        /// <param name="Obj"></param>
        /// <param name="CurrentGroup"></param>
        /// <param name="UpdatedValues"></param>
        /// <returns>Returns true if success otherwise false means access denied</returns>
        internal bool UpdateObjectInGroup(OCL.User AccessingUser, object Obj, OCL.Group CurrentGroup, OCL.Permission UpdatedValues)
        {
            OCL.User DefaultUser = (OCL.User)GetUnassignedObject(OCL.OysterUnassignedObjects.User);
            OCL.OysterObjectType OBT = OCL.OysterObjectType.None;
            int ObjectTypeId = 0;
            int ObjectId = 0;
            string sType = "Unknown Type";
            if(Obj is OCL.User)
            {
                if(!CurrentGroup.CanEditUserPermissions(AccessingUser))
                    return false;
                sType = "User";
                OCL.User U = (OCL.User)Obj;
                ObjectTypeId = (int)U.ObjectType;
                ObjectId = U.ID;
                OBT = OCL.OysterObjectType.User;
            }
            else if(Obj is OCL.Recording)
            {
                if(!CurrentGroup.CanEditRecordingPermissions(AccessingUser))
                    return false;
                sType = "Recording";
                OCL.Recording R = (OCL.Recording)Obj;
                ObjectTypeId = (int)R.ObjectType;
                ObjectId = R.ID;
                OBT = OCL.OysterObjectType.Recording;

            }
            else if(Obj is OCL.Source)
            {
                if(!CurrentGroup.CanEditSourcePermissions(AccessingUser))
                    return false;
                sType = "Source";
                OCL.Source S = (OCL.Source)Obj;
                ObjectTypeId = (int)S.ObjectType;
                ObjectId = S.ID;
                OBT = OCL.OysterObjectType.Source;

            }
            else if(Obj is OCL.Control)
            {
                if(!CurrentGroup.CanEditControlPermissions(AccessingUser))
                    return false;
                sType = "Control";
                OCL.Control C = (OCL.Control)Obj;
                ObjectTypeId = (int)C.ObjectType;
                ObjectId = C.ID;
                OBT = OCL.OysterObjectType.Control;

            }
            else if(Obj is OCL.Scene)
            {
                if(!CurrentGroup.CanEditScenePermissions(AccessingUser))
                    return false;
                sType = "Scene";
                OCL.Scene S = (OCL.Scene)Obj;
                ObjectTypeId = (int)S.ObjectType;
                ObjectId = S.ID;
                OBT = OCL.OysterObjectType.Scene;

            }
            else if(Obj is OCL.Note)
            {
                if(!CurrentGroup.CanEditNotePermissions(AccessingUser))
                    return false;
                sType = "Note";
                OCL.Note N = (OCL.Note)Obj;
                ObjectTypeId = (int)N.ObjectType;
                ObjectId = N.ID;
                OBT = OCL.OysterObjectType.Note;
            }
            else if(Obj is OCL.RecordingSession)
            {
                if(!CurrentGroup.CanEditRecordingSessionPermissions(AccessingUser))
                    return false;
                sType = "RecordingSession";
                OCL.RecordingSession RS = (OCL.RecordingSession)Obj;
                ObjectTypeId = (int)RS.ObjectType;
                OBT = RS.ObjectType;
                ObjectId = RS.ID;
            }
            else if(Obj is OCL.Attachment)
            {
                if(!CurrentGroup.CanEditAttachmentPermissions(AccessingUser))
                    return false;
                sType = "Attachment";
                OCL.Attachment A = (OCL.Attachment)Obj;
                ObjectTypeId = (int)A.ObjectType;
                ObjectId = A.ID;
                OBT = A.ObjectType;
            }
            else if(Obj is OCL.Group)
            {
                if(!CurrentGroup.CanEditGroupPermissions(AccessingUser))
                    return false;
                sType = "Group";
                OCL.Group G = (OCL.Group)Obj;
                ObjectTypeId = (int)G.ObjectType;
                ObjectId = G.ID;
                OBT = G.ObjectType;
            }
            else if(Obj is OCL.VideoStorageServer)
            {
                if(!CurrentGroup.CanEditVideoStorageServerPermissions(AccessingUser))
                    return false;
                sType = "VideoStorageServer";
                OCL.VideoStorageServer V = (OCL.VideoStorageServer)Obj;
                ObjectTypeId = (int)V.ObjectType;
                ObjectId = V.ID;
                OBT = V.ObjectType;
            }

            //Check to make sure Object is member of Group
            string sSQL = "SELECT GroupId FROM tblGroupTokens WHERE GroupId = " + CurrentGroup.ID +
                " AND UserId = " + AccessingUser.ID +
                " AND ObjectTypeId = " + ObjectTypeId +
                " AND ObjectId = " + ObjectId;
            int numrecs = RF.ExecuteCommandNonQuery(sSQL);

            if(numrecs < 1)
                throw new Exception( sType + " does not exist in Group");

            return UpdatePermission(CurrentGroup,DefaultUser,OBT,ObjectId,UpdatedValues.mvarIsVisible,
                UpdatedValues.mvarCanAdd, UpdatedValues.mvarCanEdit, UpdatedValues.mvarCanDelete, UpdatedValues.mvarIsUsable,
                UpdatedValues.CanEditPermission,UpdatedValues.CanSeePermission,
                UpdatedValues.CanAddObjectA,UpdatedValues.CanEditObjectA,UpdatedValues.CanDeleteObjectA,
                UpdatedValues.CanAddObjectB,UpdatedValues.CanEditObjectB,UpdatedValues.CanDeleteObjectB,
                Convert.ToInt32(UpdatedValues.mvarAddedByUserId));
        }