From fe49c96ee0db0974a91b9b175ac1b00aef035797 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 3 Mar 2008 08:30:36 +0000 Subject: * Applying Ahzz's profile patch. Thanks Ahzz! * Fixed a few bugs in the patch that are sim crashers. * There's still a bug in mySQL mode/ grid mode where the main userprofile text doesn't save. --- OpenSim/Framework/Data.MySQL/MySQLManager.cs | 113 ++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 4 deletions(-) (limited to 'OpenSim/Framework/Data.MySQL/MySQLManager.cs') diff --git a/OpenSim/Framework/Data.MySQL/MySQLManager.cs b/OpenSim/Framework/Data.MySQL/MySQLManager.cs index 1a90eea..ea11aa0 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLManager.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLManager.cs @@ -452,11 +452,25 @@ namespace OpenSim.Framework.Data.MySQL retval.profileCanDoMask = Convert.ToUInt32(reader["profileCanDoMask"].ToString()); retval.profileWantDoMask = Convert.ToUInt32(reader["profileWantDoMask"].ToString()); - retval.profileAboutText = (string) reader["profileAboutText"]; - retval.profileFirstText = (string) reader["profileFirstText"]; + if (reader.IsDBNull(reader.GetOrdinal("profileAboutText"))) + retval.profileAboutText = ""; + else + retval.profileAboutText = (string) reader["profileAboutText"]; - LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage); - LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage); + if (reader.IsDBNull( reader.GetOrdinal( "profileFirstText" ) ) ) + retval.profileFirstText = ""; + else + retval.profileFirstText = (string)reader["profileFirstText"]; + + if (reader.IsDBNull( reader.GetOrdinal( "profileImage" ) ) ) + retval.profileImage = LLUUID.Zero; + else + LLUUID.TryParse((string)reader["profileImage"], out retval.profileImage); + + if (reader.IsDBNull( reader.GetOrdinal( "profileFirstImage" ) ) ) + retval.profileFirstImage = LLUUID.Zero; + else + LLUUID.TryParse((string)reader["profileFirstImage"], out retval.profileFirstImage); if( reader.IsDBNull( reader.GetOrdinal( "webLoginKey" ) ) ) { @@ -553,6 +567,7 @@ namespace OpenSim.Framework.Data.MySQL string aboutText, string firstText, LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey) { + m_log.Debug("[MySQLManager]: Fetching profile for " + uuid.ToString()); string sql = "INSERT INTO users (`UUID`, `username`, `lastname`, `passwordHash`, `passwordSalt`, `homeRegion`, "; sql += @@ -610,9 +625,99 @@ namespace OpenSim.Framework.Data.MySQL return false; } + m_log.Debug("[MySQLManager]: Fetch user retval == " + returnval.ToString()); return returnval; } + /// + /// Creates a new user and inserts it into the database + /// + /// User ID + /// First part of the login + /// Second part of the login + /// A salted hash of the users password + /// The salt used for the password hash + /// A regionHandle of the users home region + /// Home region position vector + /// Home region position vector + /// Home region position vector + /// Home region 'look at' vector + /// Home region 'look at' vector + /// Home region 'look at' vector + /// Account created (unix timestamp) + /// Last login (unix timestamp) + /// Users inventory URI + /// Users asset URI + /// I can do mask + /// I want to do mask + /// Profile text + /// Firstlife text + /// UUID for profile image + /// UUID for firstlife image + /// Success? + public bool updateUserRow(LLUUID uuid, string username, string lastname, string passwordHash, + string passwordSalt, UInt64 homeRegion, float homeLocX, float homeLocY, float homeLocZ, + float homeLookAtX, float homeLookAtY, float homeLookAtZ, int created, int lastlogin, + string inventoryURI, string assetURI, uint canDoMask, uint wantDoMask, + string aboutText, string firstText, + LLUUID profileImage, LLUUID firstImage, LLUUID webLoginKey) + { + string sql = "UPDATE users SET `username` = ?username , `lastname` = ?lastname "; + sql += ", `passwordHash` = ?passwordHash , `passwordSalt` = ?passwordSalt , "; + sql += "`homeRegion` = ?homeRegion , `homeLocationX` = ?homeLocationX , "; + sql += "`homeLocationY` = ?homeLocationY , `homeLocationZ` = ?homeLocationZ , "; + sql += "`homeLookAtX` = ?homeLookAtX , `homeLookAtY` = ?homeLookAtY , "; + sql += "`homeLookAtZ` = ?homeLookAtZ , `created` = ?created , `lastLogin` = ?lastLogin , "; + sql += "`userInventoryURI` = ?userInventoryURI , `userAssetURI` = ?userAssetURI , "; + sql += "`profileCanDoMask` = ?profileCanDoMask , `profileWantDoMask` = ?profileWantDoMask , "; + sql += "`profileAboutText` = ?profileAboutText , `profileFirstText` = ?profileFirstText, "; + sql += "`profileImage` = ?profileImage , `profileFirstImage` = ?profileFirstImage , "; + sql += "`webLoginKey` = ?webLoginKey WHERE UUID = ?UUID"; + + Dictionary parameters = new Dictionary(); + parameters["?UUID"] = uuid.ToString(); + parameters["?username"] = username.ToString(); + parameters["?lastname"] = lastname.ToString(); + parameters["?passwordHash"] = passwordHash.ToString(); + parameters["?passwordSalt"] = passwordSalt.ToString(); + parameters["?homeRegion"] = homeRegion.ToString(); + parameters["?homeLocationX"] = homeLocX.ToString(); + parameters["?homeLocationY"] = homeLocY.ToString(); + parameters["?homeLocationZ"] = homeLocZ.ToString(); + parameters["?homeLookAtX"] = homeLookAtX.ToString(); + parameters["?homeLookAtY"] = homeLookAtY.ToString(); + parameters["?homeLookAtZ"] = homeLookAtZ.ToString(); + parameters["?created"] = created.ToString(); + parameters["?lastLogin"] = lastlogin.ToString(); + parameters["?userInventoryURI"] = inventoryURI; + parameters["?userAssetURI"] = assetURI; + parameters["?profileCanDoMask"] = "0"; + parameters["?profileWantDoMask"] = "0"; + parameters["?profileAboutText"] = aboutText; + parameters["?profileFirstText"] = firstText; + parameters["?profileImage"] = profileImage.ToString(); + parameters["?profileFirstImage"] = firstImage.ToString(); + parameters["?webLoginKey"] = webLoginKey.ToString(); + + bool returnval = false; + try + { + IDbCommand result = Query(sql, parameters); + + if (result.ExecuteNonQuery() == 1) + returnval = true; + + result.Dispose(); + } + catch (Exception e) + { + m_log.Error(e.ToString()); + return false; + } + + m_log.Debug("[MySQLManager]: update user retval == " + returnval.ToString()); + return returnval; + } /// /// Inserts a new region into the database -- cgit v1.1