예제 #1
0
        /// <summary>
        /// Removes the supplied User from the given Group
        /// Also Removes all User's resources from the Group
        /// </summary>
        /// <param name="CurrentUser"></param>
        /// <param name="CurrentGroup"></param>
        internal bool RemoveUserFromGroup(OCL.User AccessingUser,OCL.User CurrentUser, OCL.Group CurrentGroup)
        {
            if(!AccessingUser.mvarIsSuperUser)
                {
                    OCL.Group GlobalGroup = (OCL.Group)GetUnassignedObject(OCL.OysterUnassignedObjects.Group);
                    if(!GlobalGroup.GetDefaultGroupAccessPermission(AccessingUser).CanEdit)
                    {
                        if(!CurrentGroup.GetObjectPermission(AccessingUser,CurrentUser).CanDelete)
                        {
                            return false;
                        }
                    }
                }

                string sSQL = "DELETE FROM tblGroupTokens WHERE UserId = " + CurrentUser.ID +
                    " AND GroupId = " + CurrentGroup.ID;

                try
                {

                    int numrecs = RF.ExecuteCommand(sSQL);

                }
                catch(Exception Err)
                {
                    throw new ApplicationException(Err.Message,Err.InnerException);
                }
                try
                {
                    sSQL = "DELETE FROM tblGroupTokens WHERE GroupId = " + CurrentGroup.ID +
                        " AND AddedByUserId = " + CurrentUser.ID;
                    int numdeleted = RF.ExecuteCommandNonQuery(sSQL);

                }
                catch(Exception Err)
                {
                    throw new ApplicationException(Err.Message);
                }
                sSQL = "DELETE FROM tblGroupTokens WHERE GroupId = " + CurrentGroup.ID +
                              " AND ObjectTypeId = 1 AND ObjectId = " + CurrentUser.ID;
                try
                {
                    int numrecs = RF.ExecuteCommand(sSQL);
                }
                catch(Exception Err)
                {
                    throw new ApplicationException(Err.Message,Err.InnerException);
                }
                return true;
        }