diff options
Diffstat (limited to 'OpenSim/Data/MySQL/MySQLUserProfilesData.cs')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs index c213dd1..c241e90 100644 --- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs +++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs | |||
@@ -896,16 +896,16 @@ namespace OpenSim.Data.MySQL | |||
896 | } | 896 | } |
897 | 897 | ||
898 | #region User Preferences | 898 | #region User Preferences |
899 | public OSDArray GetUserPreferences(UUID avatarId) | 899 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) |
900 | { | 900 | { |
901 | string query = string.Empty; | 901 | string query = string.Empty; |
902 | 902 | ||
903 | query += "SELECT imviaemail,visible,email FROM "; | 903 | query += "SELECT imviaemail,visible,email FROM "; |
904 | query += "usersettings WHERE "; | 904 | query += "usersettings WHERE "; |
905 | query += "useruuid = ?Id"; | 905 | query += "useruuid = ?Id"; |
906 | 906 | ||
907 | OSDArray data = new OSDArray(); | 907 | OSDArray data = new OSDArray(); |
908 | 908 | ||
909 | try | 909 | try |
910 | { | 910 | { |
911 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | 911 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) |
@@ -913,33 +913,30 @@ namespace OpenSim.Data.MySQL | |||
913 | dbcon.Open(); | 913 | dbcon.Open(); |
914 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) | 914 | using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) |
915 | { | 915 | { |
916 | cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); | 916 | cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); |
917 | 917 | ||
918 | using (MySqlDataReader reader = cmd.ExecuteReader()) | 918 | using (MySqlDataReader reader = cmd.ExecuteReader()) |
919 | { | 919 | { |
920 | if(reader.HasRows) | 920 | if (reader.HasRows) |
921 | { | 921 | { |
922 | reader.Read(); | 922 | reader.Read(); |
923 | OSDMap record = new OSDMap(); | 923 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); |
924 | 924 | bool.TryParse((string)reader["visible"], out pref.Visible); | |
925 | record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); | 925 | pref.EMail = (string)reader["email"]; |
926 | record.Add("visible",OSD.FromString((string)reader["visible"])); | ||
927 | record.Add("email",OSD.FromString((string)reader["email"])); | ||
928 | data.Add(record); | ||
929 | } | 926 | } |
930 | else | 927 | else |
931 | { | 928 | { |
932 | dbcon.Close(); | 929 | dbcon.Close(); |
933 | dbcon.Open(); | 930 | dbcon.Open(); |
934 | 931 | ||
935 | query = "INSERT INTO usersettings VALUES "; | 932 | query = "INSERT INTO usersettings VALUES "; |
936 | query += "(?uuid,'false','false', ?Email)"; | 933 | query += "(?uuid,'false','false', ?Email)"; |
937 | 934 | ||
938 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) | 935 | using (MySqlCommand put = new MySqlCommand(query, dbcon)) |
939 | { | 936 | { |
940 | 937 | ||
941 | // put.Parameters.AddWithValue("?Email", pref.EMail); | 938 | put.Parameters.AddWithValue("?Email", pref.EMail); |
942 | // put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); | 939 | put.Parameters.AddWithValue("?uuid", pref.UserId.ToString()); |
943 | 940 | ||
944 | put.ExecuteNonQuery(); | 941 | put.ExecuteNonQuery(); |
945 | } | 942 | } |
@@ -952,20 +949,22 @@ namespace OpenSim.Data.MySQL | |||
952 | { | 949 | { |
953 | m_log.ErrorFormat("[PROFILES_DATA]" + | 950 | m_log.ErrorFormat("[PROFILES_DATA]" + |
954 | ": Get preferences exception {0}", e.Message); | 951 | ": Get preferences exception {0}", e.Message); |
952 | result = e.Message; | ||
953 | return false; | ||
955 | } | 954 | } |
956 | return data; | 955 | return true; |
957 | } | 956 | } |
958 | 957 | ||
959 | public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) | 958 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) |
960 | { | 959 | { |
961 | string query = string.Empty; | 960 | string query = string.Empty; |
962 | 961 | ||
963 | query += "UPDATE userpsettings SET "; | 962 | query += "UPDATE usersettings SET "; |
964 | query += "imviaemail=?ImViaEmail, "; | 963 | query += "imviaemail=?ImViaEmail, "; |
965 | query += "visible=?Visible, "; | 964 | query += "visible=?Visible, "; |
966 | query += "email=?EMail "; | 965 | query += "email=?EMail "; |
967 | query += "WHERE useruuid=?uuid"; | 966 | query += "WHERE useruuid=?uuid"; |
968 | 967 | ||
969 | try | 968 | try |
970 | { | 969 | { |
971 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) | 970 | using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) |
@@ -986,6 +985,7 @@ namespace OpenSim.Data.MySQL | |||
986 | { | 985 | { |
987 | m_log.ErrorFormat("[PROFILES_DATA]" + | 986 | m_log.ErrorFormat("[PROFILES_DATA]" + |
988 | ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException); | 987 | ": UserPreferencesUpdate exception {0} {1}", e.Message, e.InnerException); |
988 | result = e.Message; | ||
989 | return false; | 989 | return false; |
990 | } | 990 | } |
991 | return true; | 991 | return true; |