internal OCL.Groups AllVisibleGroups(OCL.User TargetUser,OCL.User AccessingUser) { try { string sSQL = ""; OCL.Group DG = (OCL.Group)GetUnassignedObject(OCL.OysterUnassignedObjects.Group); if(AccessingUser.mvarIsSuperUser) { /// This will return every group that is visible to TargetUser sSQL = "Select DISTINCT GroupId FROM tblGroupTokens WHERE UserId = " + TargetUser.mvarID + " AND ObjectTypeId = " + Convert.ToInt32(OCL.OysterObjectType.User) + " AND IsDefault = 0" + " AND GroupId <> " + DG.mvarID; } else { /// This will return every group that is visible to both TargetUser that Accessing User can also see sSQL = "Select DISTINCT GroupId FROM tblGroupTokens WHERE UserId = " + AccessingUser.ID + " AND ObjectTypeId = " + Convert.ToInt32(OCL.OysterObjectType.User) + " AND ObjectId = " + TargetUser.ID + " AND IsDefault = 0" + " AND GroupId <> " + DG.mvarID + " AND IsVisible <> 0"; } DataSet DS = RF.GetDataSet(sSQL); DataTable DT = DS.Tables[0]; Groups X = new Groups(); foreach(DataRow r in DT.Rows) { int GroupID = Convert.ToInt32(r[0]); Group NG = GetGroup(GroupID); X.Add(NG); } sSQL = "Select Id FROM tblGroup WHERE IsPublicAccess <> 0 AND IsDefault = 0"; DS = RF.GetDataSet(sSQL); DT = DS.Tables[0]; foreach(DataRow r in DT.Rows) { int GroupID = Convert.ToInt32(r[0]); // Make certain we are not adding a duplicate entry for group bool AddIt = true; foreach(OCL.Group ChkGroup in X) { if(ChkGroup.mvarID == GroupID) { AddIt = false; break; } } if(AddIt) { Group NG = GetGroup(GroupID); X.Add(NG); } } DT.Dispose(); return X; } catch(Exception Err) { throw new ApplicationException(Err.Message); } }
/// <summary> /// Returns all Access Groups or only Public Access Groups /// </summary> /// <returns></returns> internal Groups GetGroups(bool PublicOnly) { Groups GS = null; string sSQL = ""; if(PublicOnly == true) sSQL = "SELECT * FROM tblGroup WHERE IsPublicAccess <> 0" + " AND IsDefault = 0"; else sSQL = "SELECT * FROM tblGroup WHERE IsDefault = 0"; DataSet DS = RF.GetDataSet(sSQL); DataTable DT = DS.Tables[0]; GS = new Groups(); foreach(DataRow R in DT.Rows) { int GroupId = Convert.ToInt32(R[0]); Group G = GetGroup(GroupId); GS.Add(G); } DT.Dispose(); return GS; }
/// <summary> /// Returns all the Groups a User is in /// </summary> /// <param name="AccessingUser"></param> /// <returns>OCL.Groups</returns> /// internal OCL.Groups AllVisibleGroups(OCL.User AccessingUser) { try { OCL.Group DG = (OCL.Group)GetUnassignedObject(OCL.OysterUnassignedObjects.Group); string sSQL = ""; if(AccessingUser.mvarIsSuperUser) { sSQL= "SELECT ID from tblGroup WHERE IsDefault = 0"; } else { sSQL = "Select DISTINCT GroupId FROM tblGroupTokens WHERE UserId = " + AccessingUser.ID + " AND ObjectTypeId = " + Convert.ToInt32(OCL.OysterObjectType.Group) + " AND ObjectId = " + ((OCL.Group)GetUnassignedObject(OCL.OysterUnassignedObjects.Group)).ID + " AND IsDefault <> 0" + " AND GroupId <> " + DG.mvarID + " AND IsVisible <> 0"; } DataSet DS = RF.GetDataSet(sSQL); DataTable DT = DS.Tables[0]; Groups X = new Groups(); foreach(DataRow r in DT.Rows) { int GroupID = Convert.ToInt32(r[0]); Group NG = GetGroup(GroupID); X.Add(NG); } sSQL = "Select Id FROM tblGroup WHERE IsPublicAccess <> 0 AND IsDefault = 0"; DS = RF.GetDataSet(sSQL); DT = DS.Tables[0]; foreach(DataRow r in DT.Rows) { int GroupID = Convert.ToInt32(r[0]); Group NG = GetGroup(GroupID); X.Add(NG); } DT.Dispose(); return X; } catch(Exception Err) { throw new ApplicationException(Err.Message); } }