Implement avatar picker queries

slimupdates
Melanie 2009-12-31 02:26:00 +00:00
parent 99ad7aac7f
commit 01f6aee020
4 changed files with 53 additions and 3 deletions

View File

@ -48,5 +48,6 @@ namespace OpenSim.Data
{ {
UserAccountData[] Get(string[] fields, string[] values); UserAccountData[] Get(string[] fields, string[] values);
bool Store(UserAccountData data); bool Store(UserAccountData data);
UserAccountData[] GetUsers(UUID scopeID, string query);
} }
} }

View File

@ -194,5 +194,10 @@ namespace OpenSim.Data.MSSQL
{ {
return null; return null;
} }
public UserAccountData[] GetUsers(UUID scopeID, string query)
{
return null;
}
} }
} }

View File

@ -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);
} }
} }
} }

View File

@ -168,7 +168,17 @@ namespace OpenSim.Services.UserAccountService
public List<UserAccount> GetUserAccounts(UUID scopeID, string query) public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
{ {
return null; UserAccountData[] d = m_Database.GetUsers(scopeID, query);
if (d == null)
return new List<UserAccount>();
List<UserAccount> ret = new List<UserAccount>();
foreach (UserAccountData data in d)
ret.Add(MakeUserAccount(data));
return ret;
} }
} }
} }