aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/MySQL')
-rw-r--r--OpenSim/Data/MySQL/MySQLUserProfilesData.cs39
-rw-r--r--OpenSim/Data/MySQL/Resources/UserProfiles.migrations10
2 files changed, 28 insertions, 21 deletions
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
index 4c6c8e3..dca80c3 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -897,7 +897,7 @@ namespace OpenSim.Data.MySQL
897 } 897 }
898 898
899 #region User Preferences 899 #region User Preferences
900 public OSDArray GetUserPreferences(UUID avatarId) 900 public bool GetUserPreferences(ref UserPreferences pref, ref string result)
901 { 901 {
902 string query = string.Empty; 902 string query = string.Empty;
903 903
@@ -914,19 +914,16 @@ namespace OpenSim.Data.MySQL
914 dbcon.Open(); 914 dbcon.Open();
915 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 915 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
916 { 916 {
917 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 917 cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString());
918 918
919 using (MySqlDataReader reader = cmd.ExecuteReader()) 919 using (MySqlDataReader reader = cmd.ExecuteReader())
920 { 920 {
921 if(reader.HasRows) 921 if(reader.HasRows)
922 { 922 {
923 reader.Read(); 923 reader.Read();
924 OSDMap record = new OSDMap(); 924 bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail);
925 925 bool.TryParse((string)reader["visible"], out pref.Visible);
926 record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); 926 pref.EMail = (string)reader["email"];
927 record.Add("visible",OSD.FromString((string)reader["visible"]));
928 record.Add("email",OSD.FromString((string)reader["email"]));
929 data.Add(record);
930 } 927 }
931 else 928 else
932 { 929 {
@@ -949,17 +946,19 @@ namespace OpenSim.Data.MySQL
949 { 946 {
950 m_log.DebugFormat("[PROFILES_DATA]" + 947 m_log.DebugFormat("[PROFILES_DATA]" +
951 ": Get preferences exception {0}", e.Message); 948 ": Get preferences exception {0}", e.Message);
949 result = e.Message;
950 return false;
952 } 951 }
953 return data; 952 return true;
954 } 953 }
955 954
956 public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) 955 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
957 { 956 {
958 string query = string.Empty; 957 string query = string.Empty;
959 958
960 query += "UPDATE userpsettings SET "; 959 query += "UPDATE usersettings SET ";
961 query += "imviaemail=?ImViaEmail, "; 960 query += "imviaemail=?ImViaEmail, ";
962 query += "visible=?Visible,"; 961 query += "visible=?Visible ";
963 query += "WHERE useruuid=?uuid"; 962 query += "WHERE useruuid=?uuid";
964 963
965 try 964 try
@@ -969,14 +968,11 @@ namespace OpenSim.Data.MySQL
969 dbcon.Open(); 968 dbcon.Open();
970 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 969 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
971 { 970 {
972 cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ()); 971 cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail);
973 cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ()); 972 cmd.Parameters.AddWithValue("?Visible", pref.Visible);
974 cmd.Parameters.AddWithValue("?uuid", avatarId.ToString()); 973 cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString());
975 974
976 lock(Lock) 975 cmd.ExecuteNonQuery();
977 {
978 cmd.ExecuteNonQuery();
979 }
980 } 976 }
981 } 977 }
982 } 978 }
@@ -984,6 +980,7 @@ namespace OpenSim.Data.MySQL
984 { 980 {
985 m_log.DebugFormat("[PROFILES_DATA]" + 981 m_log.DebugFormat("[PROFILES_DATA]" +
986 ": AgentInterestsUpdate exception {0}", e.Message); 982 ": AgentInterestsUpdate exception {0}", e.Message);
983 result = e.Message;
987 return false; 984 return false;
988 } 985 }
989 return true; 986 return true;
diff --git a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
index c29f1ab..bd325da 100644
--- a/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
+++ b/OpenSim/Data/MySQL/Resources/UserProfiles.migrations
@@ -81,3 +81,13 @@ CREATE TABLE IF NOT EXISTS `userdata` (
81 81
82commit; 82commit;
83 83
84:VERSION 3 # -------------------------------
85begin;
86CREATE TABLE IF NOT EXISTS `usersettings` (
87 `useruuid` varchar(36) NOT NULL,
88 `imviaemail` enum('true','false') NOT NULL,
89 `visible` enum('true','false') NOT NULL,
90 `email` varchar(254) NOT NULL,
91 PRIMARY KEY (`useruuid`)
92) ENGINE=MyISAM DEFAULT CHARSET=latin1;
93commit; \ No newline at end of file