Applied Patch 473, Inventory Patch from Tleiades (many thanks).

afrisby
MW 2007-10-06 08:23:51 +00:00
parent e8917c9e14
commit 4e6b68df13
3 changed files with 91 additions and 15 deletions

View File

@ -349,5 +349,14 @@ namespace OpenSim.Framework.Data.MySQL
{ {
addInventoryFolder(folder); addInventoryFolder(folder);
} }
/// <summary>
/// Delete an inventory folder
/// </summary>
/// <param name="folderId">Id of folder to delete</param>
public void deleteInventoryFolder(LLUUID folderID)
{
}
} }
} }

View File

@ -195,7 +195,7 @@ namespace OpenSim.Framework.Data.SQLite
/// <returns>A list of folder objects</returns> /// <returns>A list of folder objects</returns>
public List<InventoryFolderBase> getUserRootFolders(LLUUID user) public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
{ {
return null; return new List<InventoryFolderBase>();
} }
/// <summary> /// <summary>
@ -234,6 +234,22 @@ namespace OpenSim.Framework.Data.SQLite
return null; return null;
} }
/// <summary>
/// Append a list of all the child folders of a parent folder
/// </summary>
/// <param name="folders">list where folders will be appended</param>
/// <param name="parentID">ID of parent</param>
protected void getInventoryFolders(ref List<InventoryFolderBase> 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));
}
}
/// <summary> /// <summary>
/// Returns a list of inventory folders contained in the folder 'parentID' /// Returns a list of inventory folders contained in the folder 'parentID'
/// </summary> /// </summary>
@ -242,14 +258,23 @@ namespace OpenSim.Framework.Data.SQLite
public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID) public List<InventoryFolderBase> getInventoryFolders(LLUUID parentID)
{ {
List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
DataTable inventoryFolderTable = ds.Tables["inventoryfolders"]; getInventoryFolders(ref folders, parentID);
string selectExp = "parentID = '" + parentID.ToString() + "'"; return folders;
DataRow[] rows = inventoryFolderTable.Select(selectExp); }
foreach (DataRow row in rows)
{ /// <summary>
folders.Add(this.buildFolder(row)); /// Returns all child folders in the hierarchy from the parent folder and down
} /// </summary>
// System.Console.WriteLine("found " + folders.Count + " inventory folders"); /// <param name="parentID">The folder to get subfolders for</param>
/// <returns>A list of inventory folders</returns>
protected List<InventoryFolderBase> getFolderHierarchy(LLUUID parentID)
{
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
getInventoryFolders(ref folders, parentID);
for(int i=0; i<folders.Count; i++)
getInventoryFolders(ref folders, folders[i].folderID);
return folders; return folders;
} }
@ -282,12 +307,12 @@ namespace OpenSim.Framework.Data.SQLite
// that you don't get to see system textures why creating // that you don't get to see system textures why creating
// clothes and the like. :( // clothes and the like. :(
// DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder); DataRow row = ds.Tables["inventoryfolders"].Rows.Find(folder);
// if (row != null) { if (row != null) {
// return buildFolder(row); return buildFolder(row);
// } else { } else {
return null; return null;
// } }
} }
/// <summary> /// <summary>
@ -344,6 +369,40 @@ namespace OpenSim.Framework.Data.SQLite
} }
/// <summary>
/// Delete a folder
/// </summary>
/// <remarks>
/// This will clean-up any child folders and child items as well
/// </remarks>
/// <param name="item"></param>
public void deleteInventoryFolder(LLUUID folderID)
{
List<InventoryFolderBase> 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 * Data Table definitions
@ -494,3 +553,4 @@ namespace OpenSim.Framework.Data.SQLite
} }
} }

View File

@ -218,5 +218,12 @@ namespace OpenSim.Framework.Types
/// </summary> /// </summary>
/// <param name="folder">The inventory folder</param> /// <param name="folder">The inventory folder</param>
void updateInventoryFolder(InventoryFolderBase folder); void updateInventoryFolder(InventoryFolderBase folder);
/// <summary>
/// Deletes a folder based on its ID with folder
/// </summary>
/// <param name="folder">The id of the folder</param>
void deleteInventoryFolder(LLUUID folder);
} }
} }