aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL
diff options
context:
space:
mode:
authorBlueWall2013-12-06 02:52:13 -0500
committerBlueWall2013-12-06 02:52:13 -0500
commit1842388bb4dcf5ecd57732ffa877b6ca1a3dec7b (patch)
tree0d1feaac1a3ae79aa11cc435553f086a3d581581 /OpenSim/Data/MySQL
parentAdding profile partners fix to SQLite and PgSQL drivers (diff)
downloadopensim-SC_OLD-1842388bb4dcf5ecd57732ffa877b6ca1a3dec7b.zip
opensim-SC_OLD-1842388bb4dcf5ecd57732ffa877b6ca1a3dec7b.tar.gz
opensim-SC_OLD-1842388bb4dcf5ecd57732ffa877b6ca1a3dec7b.tar.bz2
opensim-SC_OLD-1842388bb4dcf5ecd57732ffa877b6ca1a3dec7b.tar.xz
Add support for user preferences (im via email)
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 dc88f94..63492c2 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -895,7 +895,7 @@ namespace OpenSim.Data.MySQL
895 } 895 }
896 896
897 #region User Preferences 897 #region User Preferences
898 public OSDArray GetUserPreferences(UUID avatarId) 898 public bool GetUserPreferences(ref UserPreferences pref, ref string result)
899 { 899 {
900 string query = string.Empty; 900 string query = string.Empty;
901 901
@@ -912,19 +912,16 @@ namespace OpenSim.Data.MySQL
912 dbcon.Open(); 912 dbcon.Open();
913 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 913 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
914 { 914 {
915 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 915 cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString());
916 916
917 using (MySqlDataReader reader = cmd.ExecuteReader()) 917 using (MySqlDataReader reader = cmd.ExecuteReader())
918 { 918 {
919 if(reader.HasRows) 919 if(reader.HasRows)
920 { 920 {
921 reader.Read(); 921 reader.Read();
922 OSDMap record = new OSDMap(); 922 bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail);
923 923 bool.TryParse((string)reader["visible"], out pref.Visible);
924 record.Add("imviaemail",OSD.FromString((string)reader["imviaemail"])); 924 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 } 925 }
929 else 926 else
930 { 927 {
@@ -947,17 +944,19 @@ namespace OpenSim.Data.MySQL
947 { 944 {
948 m_log.DebugFormat("[PROFILES_DATA]" + 945 m_log.DebugFormat("[PROFILES_DATA]" +
949 ": Get preferences exception {0}", e.Message); 946 ": Get preferences exception {0}", e.Message);
947 result = e.Message;
948 return false;
950 } 949 }
951 return data; 950 return true;
952 } 951 }
953 952
954 public bool UpdateUserPreferences(bool emailIm, bool visible, UUID avatarId ) 953 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
955 { 954 {
956 string query = string.Empty; 955 string query = string.Empty;
957 956
958 query += "UPDATE userpsettings SET "; 957 query += "UPDATE usersettings SET ";
959 query += "imviaemail=?ImViaEmail, "; 958 query += "imviaemail=?ImViaEmail, ";
960 query += "visible=?Visible,"; 959 query += "visible=?Visible ";
961 query += "WHERE useruuid=?uuid"; 960 query += "WHERE useruuid=?uuid";
962 961
963 try 962 try
@@ -967,14 +966,11 @@ namespace OpenSim.Data.MySQL
967 dbcon.Open(); 966 dbcon.Open();
968 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 967 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
969 { 968 {
970 cmd.Parameters.AddWithValue("?ImViaEmail", emailIm.ToString().ToLower ()); 969 cmd.Parameters.AddWithValue("?ImViaEmail", pref.IMViaEmail);
971 cmd.Parameters.AddWithValue("?WantText", visible.ToString().ToLower ()); 970 cmd.Parameters.AddWithValue("?Visible", pref.Visible);
972 cmd.Parameters.AddWithValue("?uuid", avatarId.ToString()); 971 cmd.Parameters.AddWithValue("?uuid", pref.UserId.ToString());
973 972
974 lock(Lock) 973 cmd.ExecuteNonQuery();
975 {
976 cmd.ExecuteNonQuery();
977 }
978 } 974 }
979 } 975 }
980 } 976 }
@@ -982,6 +978,7 @@ namespace OpenSim.Data.MySQL
982 { 978 {
983 m_log.DebugFormat("[PROFILES_DATA]" + 979 m_log.DebugFormat("[PROFILES_DATA]" +
984 ": AgentInterestsUpdate exception {0}", e.Message); 980 ": AgentInterestsUpdate exception {0}", e.Message);
981 result = e.Message;
985 return false; 982 return false;
986 } 983 }
987 return true; 984 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