Implement avatar picker queries
							parent
							
								
									99ad7aac7f
								
							
						
					
					
						commit
						01f6aee020
					
				| 
						 | 
				
			
			@ -48,5 +48,6 @@ namespace OpenSim.Data
 | 
			
		|||
    {
 | 
			
		||||
        UserAccountData[] Get(string[] fields, string[] values);
 | 
			
		||||
        bool Store(UserAccountData data);
 | 
			
		||||
        UserAccountData[] GetUsers(UUID scopeID, string query);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -194,5 +194,10 @@ namespace OpenSim.Data.MSSQL
 | 
			
		|||
        {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public UserAccountData[] GetUsers(UUID scopeID, string query)
 | 
			
		||||
        {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -168,7 +168,17 @@ namespace OpenSim.Services.UserAccountService
 | 
			
		|||
 | 
			
		||||
        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;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue