private OSDMap GetProfile(OSDMap map)
{
OSDMap resp = new OSDMap();
string Name = map["Name"].AsString();
UUID userID = map["UUID"].AsUUID();
UserAccount account = Name != "" ?
m_registry.RequestModuleInterface<IUserAccountService>().GetUserAccount(null, Name) :
m_registry.RequestModuleInterface<IUserAccountService>().GetUserAccount(null, userID);
if (account != null)
{
OSDMap accountMap = new OSDMap();
accountMap["Created"] = account.Created;
accountMap["Name"] = account.Name;
accountMap["PrincipalID"] = account.PrincipalID;
accountMap["Email"] = account.Email;
TimeSpan diff = DateTime.Now - Util.ToDateTime(account.Created);
int years = (int)diff.TotalDays / 356;
int days = years > 0 ? (int)diff.TotalDays / years : (int)diff.TotalDays;
accountMap["TimeSinceCreated"] = years + " years, " + days + " days"; // if we're sending account.Created do we really need to send this string ?
IProfileConnector profileConnector = DataPlugins.RequestPlugin<IProfileConnector>();
IUserProfileInfo profile = profileConnector.GetUserProfile(account.PrincipalID);
if (profile != null)
{
resp["profile"] = profile.ToOSD(false);//not trusted, use false
if (account.UserFlags == 0)
account.UserFlags = 2; //Set them to no info given
string flags = ((IUserProfileInfo.ProfileFlags)account.UserFlags).ToString();
IUserProfileInfo.ProfileFlags.NoPaymentInfoOnFile.ToString();
accountMap["AccountInfo"] = (profile.CustomType != "" ? profile.CustomType :
account.UserFlags == 0 ? "Resident" : "Admin") + "\n" + flags;
UserAccount partnerAccount = m_registry.RequestModuleInterface<IUserAccountService>().GetUserAccount(null, profile.Partner);
if (partnerAccount != null)
{
accountMap["Partner"] = partnerAccount.Name;
accountMap["PartnerUUID"] = partnerAccount.PrincipalID;
}
else
{
accountMap["Partner"] = "";
accountMap["PartnerUUID"] = UUID.Zero;
}
}
IAgentConnector agentConnector = DataPlugins.RequestPlugin<IAgentConnector>();
IAgentInfo agent = agentConnector.GetAgent(account.PrincipalID);
if(agent != null)
{
OSDMap agentMap = new OSDMap();
agentMap["RLName"] = agent.OtherAgentInformation["RLName"].AsString();
agentMap["RLGender"] = agent.OtherAgentInformation["RLGender"].AsString();
agentMap["RLAddress"] = agent.OtherAgentInformation["RLAddress"].AsString();
agentMap["RLZip"] = agent.OtherAgentInformation["RLZip"].AsString();
agentMap["RLCity"] = agent.OtherAgentInformation["RLCity"].AsString();
agentMap["RLCountry"] = agent.OtherAgentInformation["RLCountry"].AsString();
resp["agent"] = agentMap;
}
resp["account"] = accountMap;
}
return resp;
}