예제 #1
0
파일: Group.cs 프로젝트: CarverLab/Oyster
        public void Update(string Description)
        {
            try
            {
                string sSQL = "UPDATE tblGroup SET Description = '" + Description + "' WHERE Id =" + mvarID;

                OCL.Functions F = new OCL.Functions();

                int numrecs = F.ExecuteSqlCommand(sSQL);
            }
            catch(Exception Err)
            {
                throw new ApplicationException(Err.Message,Err.InnerException);
            }
        }
예제 #2
0
파일: Source.cs 프로젝트: CarverLab/Oyster
        public bool RemoveFromScene(OCL.User AccessingUser, OCL.Scene TargetScene,out string ErrorMessage)
        {
            OCL.Functions F = new OCL.Functions();
            ErrorMessage = "";
            if(TargetScene.mvarID != this.SceneID)
            {
                ErrorMessage = "Source is not assigned to TargetScene.";
                return false;
            }
            if(!AccessingUser.IsSystemAdministrator)
            {
                OCL.Group DefaultGroup = (OCL.Group)F.GetUnassignedObject(OCL.OysterUnassignedObjects.Group);
                OCL.Permission P = DefaultGroup.GetObjectPermission(AccessingUser,this);
                if(!P.CanEdit)
                {
                    ErrorMessage = AccessingUser.Description + " does not have permission to edit this source.";
                    return false;
                }
                P = DefaultGroup.GetObjectPermission(AccessingUser,TargetScene);
                if(!P.CanEdit)
                {
                    ErrorMessage = AccessingUser.Description + " does not have permission to edit target scene.";
                    return false;
                }

            }
            OCL.Scene DefaultScene = (OCL.Scene)F.GetUnassignedObject(OCL.OysterUnassignedObjects.Scene);
            string sSQL = "UPDATE tblSource SET SceneID = " + DefaultScene.mvarID +
                " WHERE ID = " + mvarID;

            int results = F.ExecuteSqlCommand(sSQL);
            if(results > 0)
                return true;

            ErrorMessage = "remove source from scene failed for unknown reason.";
            return false;
        }
예제 #3
0
파일: User.cs 프로젝트: CarverLab/Oyster
        public bool Update(OCL.User AccessingUser, string Password)
        {
            if(this.mvarIsPublicAccess)
            {
                return false;
            }
            bool CanUpdate = false;
            if(AccessingUser.mvarIsSuperUser)
            {
                CanUpdate = true;
            }
            OCL.Functions F = new OCL.Functions();
            OCL.Group DefaultGroup = (OCL.Group)F.GetUnassignedObject(OCL.OysterUnassignedObjects.Group);
            OCL.Permission CP = DefaultGroup.GetObjectPermission(AccessingUser,AccessingUser,this);
            if(CP != null)
            {
                CanUpdate = CP.CanEdit; // Specifies that this accessing User can edit this user.
            }
            else
            {
                CanUpdate = false;
            }
            if(CanUpdate)
            {

                string sCommand = "UPDATE tblUSER SET Password = '******' WHERE ID = " + mvarID;

                int orow = F.ExecuteSqlCommand(sCommand);

                if(orow == 0)
                    return false;
                else
                    return true;
            }
            return false;
        }
예제 #4
0
파일: Source.cs 프로젝트: CarverLab/Oyster
        public bool AssignToScene(OCL.User AccessingUser, OCL.Scene TargetScene, out string ErrorMessage)
        {
            OCL.Functions F = new OCL.Functions();
            ErrorMessage = "";
            if(!AccessingUser.IsSystemAdministrator)
            {
                OCL.Group DefaultGroup = (OCL.Group)F.GetUnassignedObject(OCL.OysterUnassignedObjects.Group);
                OCL.Permission P = DefaultGroup.GetObjectPermission(AccessingUser,this);
                if(!P.CanEdit)
                {
                    ErrorMessage = AccessingUser.Description + " does not have permission to edit this source.";
                    return false;
                }
                P = DefaultGroup.GetObjectPermission(AccessingUser,TargetScene);
                if(!P.CanEdit)
                {
                    ErrorMessage = AccessingUser.Description + " does not have permission to edit target scene.";
                    return false;
                }

                //Check to see source can be moved.
                OCL.Scene DefaultScene = (OCL.Scene)F.GetUnassignedObject(OCL.OysterUnassignedObjects.Scene);
                if(this.SceneID != DefaultScene.mvarID)
                {
                    OCL.Scene CScene = this.CurrentScene;

                    P = DefaultGroup.GetObjectPermission(AccessingUser,CScene);
                    if(!P.CanEdit)
                    {
                        ErrorMessage = AccessingUser.Description + " does not have permission to edit source's current scene.";
                        return false;
                    }
                }
            }

            string sSQL = "UPDATE tblSource SET SceneID = " + TargetScene.mvarID +
                " WHERE ID = " + mvarID;

            int results = F.ExecuteSqlCommand(sSQL);
            if(results > 0)
                return true;

            ErrorMessage = "Update source failed for unknown reason.";
            return false;
        }
예제 #5
0
파일: User.cs 프로젝트: CarverLab/Oyster
        public bool Update(OCL.User AccessingUser,string FirstName, string MiddleName, string LastName,
                    string LoginName, string Password, string CardNumber)
        {
            if(this.mvarIsPublicAccess)
            {
                return false;
            }
            bool CanUpdate = false;
            if(AccessingUser.mvarIsSuperUser)
            {
                CanUpdate = true;
            }
            OCL.Functions F = new OCL.Functions();
            OCL.Group DefaultGroup = (OCL.Group)F.GetUnassignedObject(OCL.OysterUnassignedObjects.Group);
            OCL.Permission CP = DefaultGroup.GetObjectPermission(AccessingUser,AccessingUser,this);
            if(CP != null)
            {
                CanUpdate = CP.CanEdit; // Specifies that this accessing User can edit this user.
            }
            else
            {
                CanUpdate = false;
            }
            if(CanUpdate)
            {

                string Description = LastName + ", " + FirstName + " " + MiddleName;

                string sCommand = "UPDATE tblUSER SET Name = '" + Description +
                    "' , FirstName = '" + FirstName +
                    "' , MiddleName = '" + MiddleName +
                    "' , LastName = '" + LastName +
                    "' , LoginName = '" + LoginName +
                    "' , Password = '******' , CanRecord = " + Convert.ToInt32(CanRecord) +
                    "'  , CardNumber = '" + CardNumber +
                    "' WHERE ID = " + mvarID;

                int orow = F.ExecuteSqlCommand(sCommand);

                if(orow == 0)
                    return false;

                /// For compatibility We allow the user the chance to give this user the ability to Make Recordings
                /// CanRecord has been removed from the User to be held with all other permissions in the Groups and
                /// GroupTokens tables
                try
                {
                    if(this.CanEditPermissions(AccessingUser))
                    {
                        OCL.Group DG = (OCL.Group)F.GetUnassignedObject(OCL.OysterUnassignedObjects.Group);
                        OCL.Permission CP2 = DG.GetDefaultUserPermission(this);
                        OCL.User DU = (OCL.User)F.GetUnassignedObject(OCL.OysterUnassignedObjects.User);
                        DG.UpdateDefaultUserPermission(this,AccessingUser,CP2.mvarIsVisible,CanUpdate,CP2.mvarCanEdit,CP2.mvarCanDelete,CP2.CanEditPermission,CP2.CanSeePermission,false);
                    }
                }
                catch(Exception Err)
                {
                    string peekError = Err.Message;
                }
                return true;
            }
            return false;
        }