diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLUserProfilesData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index dc88f94..6ed3b06 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -546,6 +546,10 @@ namespace OpenSim.Data.MySQL | |||
546 | reader.Read(); | 546 | reader.Read(); |
547 | notes.Notes = OSD.FromString((string)reader["notes"]); | 547 | notes.Notes = OSD.FromString((string)reader["notes"]); |
548 | } | 548 | } |
549 | else | ||
550 | { | ||
551 | notes.Notes = OSD.FromString(""); | ||
552 | } | ||
549 | } | 553 | } |
550 | } | 554 | } |
551 | } | 555 | } |
@@ -895,7 +899,7 @@ namespace OpenSim.Data.MySQL | |||
895 | } | 899 | } |
896 | 900 | ||
897 | #region User Preferences | 901 | #region User Preferences |
898 | public OSDArray GetUserPreferences(UUID avatarId) | 902 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) |
899 | { | 903 | { |
900 | string query = string.Empty; | 904 | string query = string.Empty; |
901 | 905 | ||
@@ -912,31 +916,32 @@ namespace OpenSim.Data.MySQL | |||
912 | dbcon.Open(); | 916 | dbcon.Open(); |
913 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 917 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
914 | { | 918 | { |
915 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | 919 | cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); |
916 | 920 | ||
917 | using (MySqlDataReader reader = cmd.ExecuteReader()) | 921 | using (MySqlDataReader reader = cmd.ExecuteReader()) |
918 | { | 922 | { |
919 | if(reader.HasRows) | 923 | if(reader.HasRows) |
920 | { | 924 | { |
921 | reader.Read(); | 925 | reader.Read(); |
922 | OSDMap record = new OSDMap(); | 926 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); |
923 | 927 | bool.TryParse((string)reader["visible"], out pref.Visible); | |
924 | record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); | 928 | pref.EMail = (string)reader["email"]; |
925 | record.Add("visible",OSD.FromString((string)reader["visible"])); | ||
926 | record.Add("email",OSD.FromString((string)reader["email"])); | ||
927 | data.Add(record); | ||
928 | } | 929 | } |
929 | else | 930 | else |
930 | { | 931 | { |
932 | dbcon.Close(); | ||
933 | dbcon.Open(); | ||
934 | |||
935 | query = "INSERT INTO usersettings VALUES "; | ||
936 | query += "(?uuid,'false','false', ?Email)"; | ||
937 | |||
931 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | 938 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) |
932 | { | 939 | { |
933 | query = "INSERT INTO usersettings VALUES "; | ||
934 | query += "(?Id,'false','false', '')"; | ||
935 | 940 | ||
936 | lock(Lock) | 941 | put.Parameters.AddWithValue("?Email", pref.EMail); |
937 | { | 942 | put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); |
938 | put.ExecuteNonQuery(); | 943 | |
939 | } | 944 | put.ExecuteNonQuery(); |
940 | } | 945 | } |
941 | } | 946 | } |
942 | } | 947 | } |
@@ -947,17 +952,19 @@ namespace OpenSim.Data.MySQL | |||
947 | { | 952 | { |
948 | m_log.DebugFormat("[PROFILES_DATA]" + | 953 | m_log.DebugFormat("[PROFILES_DATA]" + |
949 | ": Get preferences exception {0}", e.Message); | 954 | ": Get preferences exception {0}", e.Message); |
955 | result = e.Message; | ||
956 | return false; | ||
950 | } | 957 | } |
951 | return data; | 958 | return true; |
952 | } | 959 | } |
953 | 960 | ||
954 | public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) | 961 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) |
955 | { | 962 | { |
956 | string query = string.Empty; | 963 | string query = string.Empty; |
957 | 964 | ||
958 | query += "UPDATE userpsettings SET "; | 965 | query += "UPDATE usersettings SET "; |
959 | query += "imviaemail=?ImViaEmail, "; | 966 | query += "imviaemail=?ImViaEmail, "; |
960 | query += "visible=?Visible,"; | 967 | query += "visible=?Visible "; |
961 | query += "WHERE useruuid=?uuid"; | 968 | query += "WHERE useruuid=?uuid"; |
962 | 969 | ||
963 | try | 970 | try |
@@ -967,14 +974,11 @@ namespace OpenSim.Data.MySQL | |||
967 | dbcon.Open(); | 974 | dbcon.Open(); |
968 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 975 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
969 | { | 976 | { |
970 | cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ()); | 977 | cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail); |
971 | cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ()); | 978 | cmd.Parameters.AddWithValue("?Visible", pref.Visible); |
972 | cmd.Parameters.AddWithValue("?uuid", avatarId.ToString()); | 979 | cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); |
973 | 980 | ||
974 | lock(Lock) | 981 | cmd.ExecuteNonQuery(); |
975 | { | ||
976 | cmd.ExecuteNonQuery(); | ||
977 | } | ||
978 | } | 982 | } |
979 | } | 983 | } |
980 | } | 984 | } |
@@ -982,6 +986,7 @@ namespace OpenSim.Data.MySQL | |||
982 | { | 986 | { |
983 | m_log.DebugFormat("[PROFILES_DATA]" + | 987 | m_log.DebugFormat("[PROFILES_DATA]" + |
984 | ": AgentInterestsUpdate exception {0}", e.Message); | 988 | ": AgentInterestsUpdate exception {0}", e.Message); |
989 | result = e.Message; | ||
985 | return false; | 990 | return false; |
986 | } | 991 | } |
987 | return true; | 992 | return true; |