From 3507005d9decdbf579fb2b7b9928a7d97bd6cf5b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 31 Dec 2009 01:16:16 +0000 Subject: Remove CreateUserAccount. Rename SetUserAccount to StoreUserAccount. Implement the fetch operations fully. Rename one last UserService file to UserAccountService --- .../UserAccountService/UserAccountService.cs | 82 ++++++++++++++++++---- 1 file changed, 67 insertions(+), 15 deletions(-) (limited to 'OpenSim/Services/UserAccountService/UserAccountService.cs') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 0270f9d..706da84 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -62,33 +62,85 @@ namespace OpenSim.Services.UserAccountService if (d.Length < 1) return null; + return MakeUserAccount(d[0]); + } + + private UserAccount MakeUserAccount(UserAccountData d) + { UserAccount u = new UserAccount(); - u.FirstName = d[0].FirstName; - u.LastName = d[0].LastName; - u.PrincipalID = d[0].PrincipalID; - u.ScopeID = d[0].ScopeID; - u.Email = d[0].Data["Email"].ToString(); - u.Created = Convert.ToInt32(d[0].Data["Created"].ToString()); + u.FirstName = d.FirstName; + u.LastName = d.LastName; + u.PrincipalID = d.PrincipalID; + u.ScopeID = d.ScopeID; + u.Email = d.Data["Email"].ToString(); + u.Created = Convert.ToInt32(d.Data["Created"].ToString()); - return null; + string[] URLs = d.Data["ServiceURLs"].ToString().Split(new char[] {' '}); + u.ServiceURLs = new Dictionary(); + + foreach(string url in URLs) + { + string[] parts = url.Split(new char[] {'='}); + + if (parts.Length != 2) + continue; + + string name = System.Web.HttpUtility.UrlDecode(parts[0]); + string val = System.Web.HttpUtility.UrlDecode(parts[1]); + + u.ServiceURLs[name] = val; + } + + return u; } public UserAccount GetUserAccount(UUID scopeID, string email) { - return null; + UserAccountData[] d; + + if (scopeID != UUID.Zero) + { + d = m_Database.Get( + new string[] {"ScopeID", "Email"}, + new string[] {scopeID.ToString(), email}); + } + else + { + d = m_Database.Get( + new string[] {"Email"}, + new string[] {email}); + } + + if (d.Length < 1) + return null; + + return MakeUserAccount(d[0]); } - public UserAccount GetUserAccount(UUID scopeID, UUID userID) + public UserAccount GetUserAccount(UUID scopeID, UUID principalID) { - return null; - } + UserAccountData[] d; - public bool SetUserAccount(UserAccount data) - { - return false; + if (scopeID != UUID.Zero) + { + d = m_Database.Get( + new string[] {"ScopeID", "PrincipalID"}, + new string[] {scopeID.ToString(), principalID.ToString()}); + } + else + { + d = m_Database.Get( + new string[] {"PrincipalID"}, + new string[] {principalID.ToString()}); + } + + if (d.Length < 1) + return null; + + return MakeUserAccount(d[0]); } - public bool CreateUserAccount(UserAccount data) + public bool StoreUserAccount(UserAccount data) { return false; } -- cgit v1.1