From 99ad7aac7f854eaae075e93880c39796183ba7e4 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 01:34:03 +0000 Subject: Implement saving user account data --- OpenSim/Data/IUserAccountData.cs | 4 ++-- OpenSim/Data/MSSQL/MSSQLUserAccountData.cs | 2 +- OpenSim/Data/MySQL/MySQLUserAccountData.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/IUserAccountData.cs b/OpenSim/Data/IUserAccountData.cs index 5ebe7d3..e350a18 100644 --- a/OpenSim/Data/IUserAccountData.cs +++ b/OpenSim/Data/IUserAccountData.cs @@ -38,7 +38,7 @@ namespace OpenSim.Data public UUID ScopeID; public string FirstName; public string LastName; - public Dictionary Data; + public Dictionary Data; } /// @@ -47,6 +47,6 @@ namespace OpenSim.Data public interface IUserAccountData { UserAccountData[] Get(string[] fields, string[] values); - bool Store(UserAccountData data, UUID principalID, string token); + bool Store(UserAccountData data); } } diff --git a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs index 01750d8..ca09029 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs @@ -65,7 +65,7 @@ namespace OpenSim.Data.MSSQL public UserAccountData Get(UUID principalID, UUID scopeID) { UserAccountData ret = new UserAccountData(); - ret.Data = new Dictionary(); + ret.Data = new Dictionary(); string sql = string.Format("select * from {0} where UUID = @principalID", m_Realm); if (scopeID != UUID.Zero) diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index e2ce6d1..ae7d5ca 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -42,7 +42,7 @@ namespace OpenSim.Data.MySQL { } - public bool Store(UserAccountData data, UUID principalID, string token) + public bool Store(UserAccountData data) { return Store(data); } -- cgit v1.1 From 01f6aee020eddb46893cbfbcf3b1e114a85ac261 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 02:26:00 +0000 Subject: Implement avatar picker queries --- OpenSim/Data/IUserAccountData.cs | 1 + OpenSim/Data/MSSQL/MSSQLUserAccountData.cs | 5 ++++ OpenSim/Data/MySQL/MySQLUserAccountData.cs | 38 ++++++++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) (limited to 'OpenSim/Data') diff --git a/OpenSim/Data/IUserAccountData.cs b/OpenSim/Data/IUserAccountData.cs index e350a18..6ee5995 100644 --- a/OpenSim/Data/IUserAccountData.cs +++ b/OpenSim/Data/IUserAccountData.cs @@ -48,5 +48,6 @@ namespace OpenSim.Data { UserAccountData[] Get(string[] fields, string[] values); bool Store(UserAccountData data); + UserAccountData[] GetUsers(UUID scopeID, string query); } } diff --git a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs index ca09029..01c64dc 100644 --- a/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs +++ b/OpenSim/Data/MSSQL/MSSQLUserAccountData.cs @@ -194,5 +194,10 @@ namespace OpenSim.Data.MSSQL { return null; } + + public UserAccountData[] GetUsers(UUID scopeID, string query) + { + return null; + } } } diff --git a/OpenSim/Data/MySQL/MySQLUserAccountData.cs b/OpenSim/Data/MySQL/MySQLUserAccountData.cs index ae7d5ca..aa69d68 100644 --- a/OpenSim/Data/MySQL/MySQLUserAccountData.cs +++ b/OpenSim/Data/MySQL/MySQLUserAccountData.cs @@ -42,9 +42,43 @@ namespace OpenSim.Data.MySQL { } - public bool Store(UserAccountData data) + public UserAccountData[] GetUsers(UUID scopeID, string query) { - return Store(data); + string[] words = query.Split(new char[] {' '}); + + for (int i = 0 ; i < words.Length ; i++) + { + if (words[i].Length < 3) + { + if (i != words.Length - 1) + Array.Copy(words, i + 1, words, i, words.Length - i - 1); + Array.Resize(ref words, words.Length - 1); + } + } + + if (words.Length == 0) + return new UserAccountData[0]; + + if (words.Length > 2) + return new UserAccountData[0]; + + MySqlCommand cmd = new MySqlCommand(); + + if (words.Length == 1) + { + cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?search or LastName like ?search)", m_Realm); + cmd.Parameters.AddWithValue("?search", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); + } + else + { + cmd.CommandText = String.Format("select * from {0} where (ScopeID=?ScopeID or ScopeID='00000000-0000-0000-0000-000000000000') and (FirstName like ?searchFirst or LastName like ?searchLast)", m_Realm); + cmd.Parameters.AddWithValue("?searchFirst", "%" + words[0] + "%"); + cmd.Parameters.AddWithValue("?searchLast", "%" + words[1] + "%"); + cmd.Parameters.AddWithValue("?ScopeID", scopeID.ToString()); + } + + return DoQuery(cmd); } } } -- cgit v1.1