diff options
author | onefang | 2019-07-31 20:22:55 +1000 |
---|---|---|
committer | onefang | 2019-07-31 20:22:55 +1000 |
commit | 19d90af82d26e424171761f411cca7cede8738a9 (patch) | |
tree | 529dd095578af1a4738b73177e0dbf64ddce1617 /OpenSim/Region/Framework/Scenes | |
parent | OpenSim found a new way for archiving to be spammy. (diff) | |
download | opensim-SC_OLD-19d90af82d26e424171761f411cca7cede8738a9.zip opensim-SC_OLD-19d90af82d26e424171761f411cca7cede8738a9.tar.gz opensim-SC_OLD-19d90af82d26e424171761f411cca7cede8738a9.tar.bz2 opensim-SC_OLD-19d90af82d26e424171761f411cca7cede8738a9.tar.xz |
Automatically add members to certain groups, and HGers from specific grids to certain other groups.
It doesn't let them know, though the last group added will be their
active group. This replaces a PHP script I used to use, that got broken
by a PHP update. It also didn't let people know, no one complained.
This is better.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 119 |
1 files changed, 113 insertions, 6 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f3b76c8..b0a7300 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -334,6 +334,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
334 | protected ICapabilitiesModule m_capsModule; | 334 | protected ICapabilitiesModule m_capsModule; |
335 | protected IGroupsModule m_groupsModule; | 335 | protected IGroupsModule m_groupsModule; |
336 | 336 | ||
337 | // The lists of groups to automatically add to logging in users. | ||
338 | private Dictionary<string, string[]> m_AutoGroups; | ||
339 | |||
337 | private Dictionary<string, string> m_extraSettings; | 340 | private Dictionary<string, string> m_extraSettings; |
338 | 341 | ||
339 | /// <summary> | 342 | /// <summary> |
@@ -1137,6 +1140,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
1137 | 1140 | ||
1138 | #endregion Interest Management | 1141 | #endregion Interest Management |
1139 | 1142 | ||
1143 | #region Group | ||
1144 | |||
1145 | IConfig groupsConfig = m_config.Configs["Groups"]; | ||
1146 | m_AutoGroups = new Dictionary<string, string[]>(); | ||
1147 | if (groupsConfig != null) | ||
1148 | { | ||
1149 | string groups = groupsConfig.GetString("AddDefaultGroup", string.Empty); | ||
1150 | if (groups.Length > 0) | ||
1151 | { | ||
1152 | try | ||
1153 | { | ||
1154 | m_AutoGroups.Add("local", groups.Split('|')); | ||
1155 | } | ||
1156 | catch (ArgumentException) | ||
1157 | { | ||
1158 | m_log.Warn("[SCENE]: Duplicated AddDefaultGroup option."); | ||
1159 | } | ||
1160 | } | ||
1161 | string[] keys = groupsConfig.GetKeys(); | ||
1162 | if (0 < keys.Length) | ||
1163 | { | ||
1164 | foreach (string k in keys) | ||
1165 | { | ||
1166 | if (k.StartsWith("AddHGDefaultGroup_")) | ||
1167 | { | ||
1168 | groups = groupsConfig.GetString(k, string.Empty); | ||
1169 | if (groups.Length > 0) | ||
1170 | { | ||
1171 | try | ||
1172 | { | ||
1173 | m_AutoGroups.Add(k.Substring(18), groups.Split('|')); | ||
1174 | } | ||
1175 | catch (ArgumentException) | ||
1176 | { | ||
1177 | m_log.WarnFormat("[SCENE]: Duplicated {0} option.", k); | ||
1178 | } | ||
1179 | } | ||
1180 | } | ||
1181 | } | ||
1182 | } | ||
1183 | } | ||
1184 | |||
1185 | #endregion Group | ||
1186 | |||
1140 | StatsReporter = new SimStatsReporter(this); | 1187 | StatsReporter = new SimStatsReporter(this); |
1141 | 1188 | ||
1142 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1189 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
@@ -4346,6 +4393,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
4346 | return false; | 4393 | return false; |
4347 | } | 4394 | } |
4348 | 4395 | ||
4396 | List<UUID> agentGroups = new List<UUID>(); | ||
4397 | GroupMembershipData[] GroupMembership = m_groupsModule.GetMembershipData(agent.AgentID); | ||
4398 | |||
4399 | if (null != GroupMembership) | ||
4400 | { | ||
4401 | for(int i = 0;i < GroupMembership.Length;i++) | ||
4402 | agentGroups.Add(GroupMembership[i].GroupID); | ||
4403 | // We get called twice, the first time the name is set to a single space. | ||
4404 | // if (" " != agent.Name) | ||
4405 | { | ||
4406 | try | ||
4407 | { | ||
4408 | // Check for auto add groups here and add them if needed. | ||
4409 | if (UserManagementModule.IsLocalGridUser(agent.AgentID)) | ||
4410 | { | ||
4411 | string[] groupIDs = m_AutoGroups["local"]; | ||
4412 | foreach(string name in groupIDs) | ||
4413 | { | ||
4414 | GroupRecord g = m_groupsModule.GetGroupRecord(name); | ||
4415 | if (null != g) | ||
4416 | { | ||
4417 | UUID group = g.GroupID; | ||
4418 | if(!agentGroups.Contains(group)) | ||
4419 | { | ||
4420 | m_groupsModule.JoinGroup(agent.AgentID.ToString(), group); | ||
4421 | agentGroups.Add(group); | ||
4422 | m_log.InfoFormat("[CONNECTION BEGIN]: Automatically added {0} to group {1}.", agent.AgentID, name); | ||
4423 | } | ||
4424 | } | ||
4425 | else | ||
4426 | m_log.ErrorFormat("[CONNECTION BEGIN]: Bogus group {0}, not adding {1}.", name, agent.AgentID); | ||
4427 | } | ||
4428 | } | ||
4429 | else | ||
4430 | { | ||
4431 | // agent.AgentID should look like this - @grid.com:8002 01234567-89ab-cdef-0123-456789abcdef | ||
4432 | string grid = agent.AgentID.ToString().Split(':')[0]; | ||
4433 | grid = grid.Substring(1); | ||
4434 | m_log.InfoFormat("[CONNECTION BEGIN]: HYPERGRID agent {0} from grid {1}, checking auto groups.", agent.AgentID, grid); | ||
4435 | string[] groupIDs = m_AutoGroups[grid]; | ||
4436 | foreach(string name in groupIDs) | ||
4437 | { | ||
4438 | GroupRecord g = m_groupsModule.GetGroupRecord(name); | ||
4439 | if (null != g) | ||
4440 | { | ||
4441 | UUID group = g.GroupID; | ||
4442 | if(!agentGroups.Contains(group)) | ||
4443 | { | ||
4444 | m_groupsModule.JoinGroup(agent.AgentID.ToString(), group); | ||
4445 | agentGroups.Add(group); | ||
4446 | m_log.InfoFormat("[CONNECTION BEGIN]: Automatically added HYPERGRIDDER {0} @ {1} to group {2}.", agent.AgentID, grid, name); | ||
4447 | } | ||
4448 | } | ||
4449 | else | ||
4450 | m_log.ErrorFormat("[CONNECTION BEGIN]: Bogus group {0} for HYPERGRIDDERS, not adding {1}.", name, agent.AgentID); | ||
4451 | } | ||
4452 | } | ||
4453 | } | ||
4454 | catch (KeyNotFoundException) | ||
4455 | { | ||
4456 | // Do nothing. | ||
4457 | } | ||
4458 | |||
4459 | } | ||
4460 | } | ||
4461 | |||
4349 | // public access | 4462 | // public access |
4350 | if (RegionInfo.EstateSettings.PublicAccess) | 4463 | if (RegionInfo.EstateSettings.PublicAccess) |
4351 | return true; | 4464 | return true; |
@@ -4372,9 +4485,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4372 | if(estateGroups.Length == 0) | 4485 | if(estateGroups.Length == 0) |
4373 | goto Label_GroupsDone; | 4486 | goto Label_GroupsDone; |
4374 | 4487 | ||
4375 | List<UUID> agentGroups = new List<UUID>(); | ||
4376 | GroupMembershipData[] GroupMembership = m_groupsModule.GetMembershipData(agent.AgentID); | ||
4377 | |||
4378 | if(GroupMembership == null) | 4488 | if(GroupMembership == null) |
4379 | { | 4489 | { |
4380 | m_log.ErrorFormat("[CONNECTION BEGIN]: GroupMembership is null!"); | 4490 | m_log.ErrorFormat("[CONNECTION BEGIN]: GroupMembership is null!"); |
@@ -4384,9 +4494,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4384 | if(GroupMembership.Length == 0) | 4494 | if(GroupMembership.Length == 0) |
4385 | goto Label_GroupsDone; | 4495 | goto Label_GroupsDone; |
4386 | 4496 | ||
4387 | for(int i = 0;i < GroupMembership.Length;i++) | ||
4388 | agentGroups.Add(GroupMembership[i].GroupID); | ||
4389 | |||
4390 | foreach(UUID group in estateGroups) | 4497 | foreach(UUID group in estateGroups) |
4391 | { | 4498 | { |
4392 | if(agentGroups.Contains(group)) | 4499 | if(agentGroups.Contains(group)) |