diff --git a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs index f773da4bb9..478e8b59d8 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLInventoryData.cs @@ -349,5 +349,14 @@ namespace OpenSim.Framework.Data.MySQL { addInventoryFolder(folder); } + + + /// + /// Delete an inventory folder + /// + /// Id of folder to delete + public void deleteInventoryFolder(LLUUID folderID) + { + } } } diff --git a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs index d664e982a1..4c9c467009 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteInventoryStore.cs @@ -195,7 +195,7 @@ namespace OpenSim.Framework.Data.SQLite /// A list of folder objects public List getUserRootFolders(LLUUID user) { - return null; + return new List(); } /// @@ -234,6 +234,22 @@ namespace OpenSim.Framework.Data.SQLite return null; } + /// + /// Append a list of all the child folders of a parent folder + /// + /// list where folders will be appended + /// ID of parent + protected void getInventoryFolders(ref List folders, LLUUID parentID) + { + DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; + string selectExp = "parentID = '" + parentID.ToString() + "'"; + DataRow[] rows = inventoryFolderTable.Select(selectExp); + foreach (DataRow row in rows) + { + folders.Add(buildFolder(row)); + } + } + /// /// Returns a list of inventory folders contained in the folder 'parentID' /// @@ -242,14 +258,23 @@ namespace OpenSim.Framework.Data.SQLite public List getInventoryFolders(LLUUID parentID) { List folders = new List(); - DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; - string selectExp = "parentID = '" + parentID.ToString() + "'"; - DataRow[] rows = inventoryFolderTable.Select(selectExp); - foreach (DataRow row in rows) - { - folders.Add(this.buildFolder(row)); - } - // System.Console.WriteLine("found " + folders.Count + " inventory folders"); + getInventoryFolders(ref folders, parentID); + return folders; + } + + /// + /// Returns all child folders in the hierarchy from the parent folder and down + /// + /// The folder to get subfolders for + /// A list of inventory folders + protected List getFolderHierarchy(LLUUID parentID) + { + List folders = new List(); + getInventoryFolders(ref folders, parentID); + + for(int i=0; i @@ -344,6 +369,40 @@ namespace OpenSim.Framework.Data.SQLite } + /// + /// Delete a folder + /// + /// + /// This will clean-up any child folders and child items as well + /// + /// + public void deleteInventoryFolder(LLUUID folderID) + { + List subFolders = getFolderHierarchy(folderID); + + DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; + DataRow inventoryRow; + + //Delete all sub-folders + foreach (InventoryFolderBase f in subFolders) + { + inventoryRow = inventoryFolderTable.Rows.Find(f.folderID); + if (inventoryRow != null) + { + inventoryRow.Delete(); + } + } + + //Delete the actual row + inventoryRow = inventoryFolderTable.Rows.Find(folderID); + if (inventoryRow != null) + { + inventoryRow.Delete(); + } + + this.invFoldersDa.Update(ds, "inventoryfolders"); + } + /*********************************************************************** * * Data Table definitions @@ -494,3 +553,4 @@ namespace OpenSim.Framework.Data.SQLite } } + diff --git a/OpenSim/Framework/General/Types/InventoryItemBase.cs b/OpenSim/Framework/General/Types/InventoryItemBase.cs index e3dbe714c4..7f59bcc734 100644 --- a/OpenSim/Framework/General/Types/InventoryItemBase.cs +++ b/OpenSim/Framework/General/Types/InventoryItemBase.cs @@ -218,5 +218,12 @@ namespace OpenSim.Framework.Types /// /// The inventory folder void updateInventoryFolder(InventoryFolderBase folder); + + /// + /// Deletes a folder based on its ID with folder + /// + /// The id of the folder + void deleteInventoryFolder(LLUUID folder); + } } \ No newline at end of file