diff --git a/OpenSim/Data/IFriendsData.cs b/OpenSim/Data/IFriendsData.cs index 76189760e2..1f1a0316f6 100644 --- a/OpenSim/Data/IFriendsData.cs +++ b/OpenSim/Data/IFriendsData.cs @@ -45,7 +45,7 @@ namespace OpenSim.Data public interface IFriendsData { bool Store(FriendsData data); - bool Delete(UUID ownerID, UUID friendID); - FriendsData[] GetFriends(UUID owner); + bool Delete(UUID ownerID, string friend); + FriendsData[] GetFriends(UUID principalID); } } diff --git a/OpenSim/Data/MySQL/MySQLFriendsData.cs b/OpenSim/Data/MySQL/MySQLFriendsData.cs index 923810b4a7..9f7e850db5 100644 --- a/OpenSim/Data/MySQL/MySQLFriendsData.cs +++ b/OpenSim/Data/MySQL/MySQLFriendsData.cs @@ -38,19 +38,26 @@ namespace OpenSim.Data.MySQL public class MySqlFriendsData : MySQLGenericTableHandler, IFriendsData { public MySqlFriendsData(string connectionString, string realm) - : base(connectionString, realm, "Friends") + : base(connectionString, realm, "FriendsStore") { } - public bool Delete(UUID principalID, UUID friendID) + public bool Delete(UUID principalID, string friend) { - // We need to delete the row where PrincipalID=principalID AND FriendID=firnedID - return false; + MySqlCommand cmd = new MySqlCommand(); + + cmd.CommandText = String.Format("delete from {0} where PrincipalID = ?PrincipalID and Friend = ?Friend", m_Realm); + cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString()); + cmd.Parameters.AddWithValue("?Friend", friend); + + ExecuteNonQuery(cmd); + + return true; } - public FriendsData[] GetFriends(UUID userID) + public FriendsData[] GetFriends(UUID principalID) { - return Get("PrincipalID =\'" + userID.ToString() + "'"); + return Get("PrincipalID", principalID.ToString()); } } } diff --git a/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql b/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql new file mode 100644 index 0000000000..da2c59c6d0 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/001_FriendsStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +CREATE TABLE `Friends` (`PrincipalID` CHAR(36) NOT NULL, `Friend` VARCHAR(255) NOT NULL, `Flags` VARCHAR(16) NOT NULL DEFAULT 0, `Offered` VARCHAR(32) NOT NULL DEFAULT 0, PRIMARY KEY(`PrincipalID`, `Friend`), KEY(`PrincipalID`)); + +COMMIT; diff --git a/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql b/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql new file mode 100644 index 0000000000..a3638678c8 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/002_FriendsStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +INSERT INTO `Friends` SELECT `ownerID`, `friendID`, `friendPerms`, 0 FROM `userfriends`; + +COMMIT;