diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | 135 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 25 |
2 files changed, 157 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs index 1659493..59dd3bb 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | |||
@@ -39,6 +39,7 @@ using OpenSim.Framework.Console; | |||
39 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; | 39 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; |
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Services.Interfaces; | ||
42 | 43 | ||
43 | namespace OpenSim.Region.CoreModules.World.Estate | 44 | namespace OpenSim.Region.CoreModules.World.Estate |
44 | { | 45 | { |
@@ -50,9 +51,18 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 52 | ||
52 | protected EstateManagementModule m_module; | 53 | protected EstateManagementModule m_module; |
53 | 54 | ||
54 | protected Commander m_commander = new Commander("estate"); | 55 | protected Commander m_commander = new Commander("estate"); |
55 | 56 | ||
57 | // variable used in processing "estate set owner" | ||
58 | private static string[] m_ownerCmd = null; | ||
59 | |||
60 | // variable used in processing "estate set owner" | ||
61 | private static UserAccount m_ownerAccount; | ||
62 | |||
63 | // variable used in processing "estate set owner" | ||
64 | private static List<uint> m_ownerEstates; | ||
65 | |||
56 | public EstateManagementCommands(EstateManagementModule module) | 66 | public EstateManagementCommands(EstateManagementModule module) |
57 | { | 67 | { |
58 | m_module = module; | 68 | m_module = module; |
@@ -85,7 +95,12 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
85 | 95 | ||
86 | m_module.Scene.AddCommand( | 96 | m_module.Scene.AddCommand( |
87 | "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand); | 97 | "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand); |
88 | } | 98 | |
99 | m_module.Scene.AddCommand( | ||
100 | "Estates", m_module, "estate set owner", "estate set owner [ <UUID> | <Firstname> <Lastname> ]", | ||
101 | "Sets the owner of the current region's estate to the specified UUID or user. " + | ||
102 | "If called from root region, all estates will be prompted for change.", SetEstateOwnerCommand); | ||
103 | } | ||
89 | 104 | ||
90 | public void Close() {} | 105 | public void Close() {} |
91 | 106 | ||
@@ -226,5 +241,119 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
226 | 241 | ||
227 | MainConsole.Instance.Output(report.ToString()); | 242 | MainConsole.Instance.Output(report.ToString()); |
228 | } | 243 | } |
244 | |||
245 | protected void SetEstateOwnerCommand(string module, string[] args) | ||
246 | { | ||
247 | string response = null; | ||
248 | |||
249 | EstateSettings es = m_module.Scene.RegionInfo.EstateSettings; | ||
250 | |||
251 | if(args != m_ownerCmd) | ||
252 | { | ||
253 | // new command... clear out the old values | ||
254 | m_ownerCmd = args; | ||
255 | m_ownerEstates = new List<uint>(); | ||
256 | m_ownerAccount = null; | ||
257 | } | ||
258 | |||
259 | if (MainConsole.Instance.ConsoleScene == null) | ||
260 | { | ||
261 | if(m_ownerEstates.Contains(es.EstateID)) | ||
262 | { | ||
263 | // already checked this one | ||
264 | return; | ||
265 | } | ||
266 | else if(m_ownerEstates.Count > 0 && m_ownerAccount == null) | ||
267 | { | ||
268 | // lookup will have been tried and not found. | ||
269 | return; | ||
270 | } | ||
271 | // flag this estate, so it is not tried multiple times | ||
272 | m_ownerEstates.Add(es.EstateID); | ||
273 | } | ||
274 | else if(MainConsole.Instance.ConsoleScene != m_module.Scene) | ||
275 | { | ||
276 | // trying to process a single region, and this isn't it | ||
277 | return; | ||
278 | } | ||
279 | UserAccount account = null; | ||
280 | if(m_ownerAccount == null) | ||
281 | { | ||
282 | if(args.Length == 3) | ||
283 | { | ||
284 | response = "No user specified."; | ||
285 | } | ||
286 | else | ||
287 | { | ||
288 | // TODO: Is there a better choice here? | ||
289 | UUID scopeID = UUID.Zero; | ||
290 | |||
291 | string s1 = args[3]; | ||
292 | if(args.Length == 4) | ||
293 | { | ||
294 | // attempt to get account by UUID | ||
295 | UUID u; | ||
296 | if(UUID.TryParse(s1, out u)) | ||
297 | { | ||
298 | account = m_module.Scene.UserAccountService.GetUserAccount(scopeID, u); | ||
299 | if(account == null) | ||
300 | { | ||
301 | response = String.Format("Could not find user {0}", s1); | ||
302 | } | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | response = String.Format("Invalid UUID {0}", s1); | ||
307 | account = null; | ||
308 | } | ||
309 | } | ||
310 | else | ||
311 | { | ||
312 | // attempt to get account by Firstname, Lastname | ||
313 | string s2 = args[4]; | ||
314 | account = m_module.Scene.UserAccountService.GetUserAccount(scopeID, s1, s2); | ||
315 | if(account == null) | ||
316 | { | ||
317 | response = String.Format("Could not find user {0} {1}", s1, s2); | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | } | ||
322 | else | ||
323 | { | ||
324 | account = m_ownerAccount; | ||
325 | } | ||
326 | if(account != null) | ||
327 | { | ||
328 | if (MainConsole.Instance.ConsoleScene == null) | ||
329 | m_ownerAccount = account; | ||
330 | |||
331 | string choice; | ||
332 | do | ||
333 | { | ||
334 | // Get user confirmation, in case there are multiple estates involved (from root) | ||
335 | choice = MainConsole.Instance.CmdPrompt( | ||
336 | string.Format("Change owner of Estate {0} ({1}) [y/n]? ",es.EstateID, es.EstateName), | ||
337 | "Y"); | ||
338 | |||
339 | if("y".Equals(choice, StringComparison.OrdinalIgnoreCase)) | ||
340 | { | ||
341 | response = m_module.setEstateOwner((int)es.EstateID, account); | ||
342 | } | ||
343 | else if(!"n".Equals(choice, StringComparison.OrdinalIgnoreCase)) | ||
344 | { | ||
345 | MainConsole.Instance.Output("Invalid response. Please select y or n."); | ||
346 | choice = null; | ||
347 | } | ||
348 | } | ||
349 | while(choice == null); | ||
350 | } | ||
351 | |||
352 | |||
353 | // Give the user some feedback | ||
354 | if(response != null) | ||
355 | MainConsole.Instance.Output(response); | ||
356 | } | ||
357 | |||
229 | } | 358 | } |
230 | } \ No newline at end of file | 359 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index cb9ad4a..9e6d0fc 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -40,6 +40,7 @@ using OpenMetaverse; | |||
40 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | using OpenSim.Services.Interfaces; | ||
43 | using RegionFlags = OpenMetaverse.RegionFlags; | 44 | using RegionFlags = OpenMetaverse.RegionFlags; |
44 | 45 | ||
45 | namespace OpenSim.Region.CoreModules.World.Estate | 46 | namespace OpenSim.Region.CoreModules.World.Estate |
@@ -1202,6 +1203,30 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1202 | sendRegionInfoPacketToAll(); | 1203 | sendRegionInfoPacketToAll(); |
1203 | } | 1204 | } |
1204 | 1205 | ||
1206 | public string setEstateOwner(int estateID, UserAccount account) | ||
1207 | { | ||
1208 | string response; | ||
1209 | |||
1210 | // get the current settings from DB | ||
1211 | EstateSettings dbSettings = Scene.EstateDataService.LoadEstateSettings(estateID); | ||
1212 | if(account.PrincipalID != dbSettings.EstateOwner) { | ||
1213 | dbSettings.EstateOwner = account.PrincipalID; | ||
1214 | dbSettings.Save(); | ||
1215 | response = String.Format("Estate owner changed to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName); | ||
1216 | |||
1217 | // make sure there's a log entry to document the change | ||
1218 | m_log.InfoFormat("[ESTATE]: Estate Owner for {0} changed to {1} ({2} {3})", dbSettings.EstateName, | ||
1219 | account.PrincipalID, account.FirstName, account.LastName); | ||
1220 | |||
1221 | TriggerEstateInfoChange(); | ||
1222 | } | ||
1223 | else | ||
1224 | { | ||
1225 | response = String.Format("Estate already belongs to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName); | ||
1226 | } | ||
1227 | return response; | ||
1228 | } | ||
1229 | |||
1205 | #endregion | 1230 | #endregion |
1206 | 1231 | ||
1207 | private void EventManager_OnNewClient(IClientAPI client) | 1232 | private void EventManager_OnNewClient(IClientAPI client) |