aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/InventoryService/XInventoryService.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index bb24292..f581f76 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -45,6 +45,7 @@ namespace OpenSim.Services.InventoryService
45 MethodBase.GetCurrentMethod().DeclaringType); 45 MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 protected IXInventoryData m_Database; 47 protected IXInventoryData m_Database;
48 protected bool m_AllowDelete = true;
48 49
49 public XInventoryService(IConfigSource config) : base(config) 50 public XInventoryService(IConfigSource config) : base(config)
50 { 51 {
@@ -60,6 +61,7 @@ namespace OpenSim.Services.InventoryService
60 { 61 {
61 dllName = authConfig.GetString("StorageProvider", dllName); 62 dllName = authConfig.GetString("StorageProvider", dllName);
62 connString = authConfig.GetString("ConnectionString", connString); 63 connString = authConfig.GetString("ConnectionString", connString);
64 m_AllowDelete = authConfig.GetBoolean("AllowDelete", true);
63 // realm = authConfig.GetString("Realm", realm); 65 // realm = authConfig.GetString("Realm", realm);
64 } 66 }
65 67
@@ -304,10 +306,15 @@ namespace OpenSim.Services.InventoryService
304 // 306 //
305 public virtual bool DeleteFolders(UUID principalID, List<UUID> folderIDs) 307 public virtual bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
306 { 308 {
309 if (!m_AllowDelete)
310 return false;
311
307 // Ignore principal ID, it's bogus at connector level 312 // Ignore principal ID, it's bogus at connector level
308 // 313 //
309 foreach (UUID id in folderIDs) 314 foreach (UUID id in folderIDs)
310 { 315 {
316 if (!ParentIsTrash(id))
317 continue;
311 InventoryFolderBase f = new InventoryFolderBase(); 318 InventoryFolderBase f = new InventoryFolderBase();
312 f.ID = id; 319 f.ID = id;
313 PurgeFolder(f); 320 PurgeFolder(f);
@@ -319,6 +326,12 @@ namespace OpenSim.Services.InventoryService
319 326
320 public virtual bool PurgeFolder(InventoryFolderBase folder) 327 public virtual bool PurgeFolder(InventoryFolderBase folder)
321 { 328 {
329 if (!m_AllowDelete)
330 return false;
331
332 if (!ParentIsTrash(folder.ID))
333 return false;
334
322 XInventoryFolder[] subFolders = m_Database.GetFolders( 335 XInventoryFolder[] subFolders = m_Database.GetFolders(
323 new string[] { "parentFolderID" }, 336 new string[] { "parentFolderID" },
324 new string[] { folder.ID.ToString() }); 337 new string[] { folder.ID.ToString() });
@@ -358,6 +371,9 @@ namespace OpenSim.Services.InventoryService
358 371
359 public virtual bool DeleteItems(UUID principalID, List<UUID> itemIDs) 372 public virtual bool DeleteItems(UUID principalID, List<UUID> itemIDs)
360 { 373 {
374 if (!m_AllowDelete)
375 return false;
376
361 // Just use the ID... *facepalms* 377 // Just use the ID... *facepalms*
362 // 378 //
363 foreach (UUID id in itemIDs) 379 foreach (UUID id in itemIDs)
@@ -519,5 +535,29 @@ namespace OpenSim.Services.InventoryService
519 535
520 return newItem; 536 return newItem;
521 } 537 }
538
539 private bool ParentIsTrash(UUID folderID)
540 {
541 XInventoryFolder[] folder = m_Database.GetFolders(new string[] {"folderID"}, new string[] {folderID.ToString()});
542 if (folder.Length < 1)
543 return false;
544
545 UUID parentFolder = folder[0].parentFolderID;
546
547 while (parentFolder != UUID.Zero)
548 {
549 XInventoryFolder[] parent = m_Database.GetFolders(new string[] {"folderID"}, new string[] {parentFolder.ToString()});
550 if (parent.Length < 1)
551 return false;
552
553 if (parent[0].type == (int)AssetType.TrashFolder)
554 return true;
555 if (parent[0].type == (int)AssetType.RootFolder)
556 return false;
557
558 parentFolder = parent[0].parentFolderID;
559 }
560 return false;
561 }
522 } 562 }
523} 563}