diff options
author | BlueWall | 2013-12-06 02:52:13 -0500 |
---|---|---|
committer | BlueWall | 2013-12-06 14:30:37 -0500 |
commit | 5745aa0f865542b3cfdb0c656bd440dc7c2614b7 (patch) | |
tree | bce17900c7a761bb589bddec60b7923ea377ebe7 /OpenSim/Data | |
parent | Added support for attachments to group notices when using Flotsam groups. (diff) | |
download | opensim-SC_OLD-5745aa0f865542b3cfdb0c656bd440dc7c2614b7.zip opensim-SC_OLD-5745aa0f865542b3cfdb0c656bd440dc7c2614b7.tar.gz opensim-SC_OLD-5745aa0f865542b3cfdb0c656bd440dc7c2614b7.tar.bz2 opensim-SC_OLD-5745aa0f865542b3cfdb0c656bd440dc7c2614b7.tar.xz |
Backport profile fixes
Diffstat (limited to 'OpenSim/Data')
-rw-r--r-- | OpenSim/Data/IProfilesData.cs | 2 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/MySQLUserProfilesData.cs | 39 | ||||
-rw-r--r-- | OpenSim/Data/MySQL/Resources/UserProfiles.migrations | 10 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/Resources/UserProfiles.migrations | 12 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | 83 |
5 files changed, 125 insertions, 21 deletions
diff --git a/OpenSim/Data/IProfilesData.cs b/OpenSim/Data/IProfilesData.cs index 0de7f68..7fb075d 100644 --- a/OpenSim/Data/IProfilesData.cs +++ b/OpenSim/Data/IProfilesData.cs | |||
@@ -48,6 +48,8 @@ namespace OpenSim.Data | |||
48 | bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result); | 48 | bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result); |
49 | bool UpdateAvatarInterests(UserProfileProperties up, ref string result); | 49 | bool UpdateAvatarInterests(UserProfileProperties up, ref string result); |
50 | bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result); | 50 | bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result); |
51 | bool UpdateUserPreferences(ref UserPreferences pref, ref string result); | ||
52 | bool GetUserPreferences(ref UserPreferences pref, ref string result); | ||
51 | bool GetUserAppData(ref UserAppData props, ref string result); | 53 | bool GetUserAppData(ref UserAppData props, ref string result); |
52 | bool SetUserAppData(UserAppData props, ref string result); | 54 | bool SetUserAppData(UserAppData props, ref string result); |
53 | OSDArray GetUserImageAssets(UUID avatarId); | 55 | OSDArray GetUserImageAssets(UUID avatarId); |
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 | ||
82 | commit; | 82 | commit; |
83 | 83 | ||
84 | :VERSION 3 # ------------------------------- | ||
85 | begin; | ||
86 | CREATE 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; | ||
93 | commit; \ No newline at end of file | ||
diff --git a/OpenSim/Data/SQLite/Resources/UserProfiles.migrations b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations index 16581f6..86434e8 100644 --- a/OpenSim/Data/SQLite/Resources/UserProfiles.migrations +++ b/OpenSim/Data/SQLite/Resources/UserProfiles.migrations | |||
@@ -88,3 +88,15 @@ CREATE TABLE IF NOT EXISTS userdata ( | |||
88 | 88 | ||
89 | commit; | 89 | commit; |
90 | 90 | ||
91 | |||
92 | :VERSION 3 # ------------------------------- | ||
93 | |||
94 | begin; | ||
95 | CREATE TABLE IF NOT EXISTS usersettings ( | ||
96 | useruuid char(36) NOT NULL, | ||
97 | imviaemail binary(1) NOT NULL, | ||
98 | visible binary(1) NOT NULL, | ||
99 | email varchar(254) NOT NULL, | ||
100 | PRIMARY KEY (useruuid) | ||
101 | ) | ||
102 | commit; \ No newline at end of file | ||
diff --git a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs index cc1dac1..70ce07c 100644 --- a/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs +++ b/OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | |||
@@ -749,6 +749,89 @@ namespace OpenSim.Data.SQLite | |||
749 | } | 749 | } |
750 | return true; | 750 | return true; |
751 | } | 751 | } |
752 | |||
753 | public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) | ||
754 | { | ||
755 | string query = string.Empty; | ||
756 | |||
757 | query += "UPDATE usersettings SET "; | ||
758 | query += "imviaemail=:ImViaEmail, "; | ||
759 | query += "visible=:Visible "; | ||
760 | query += "WHERE useruuid=:uuid"; | ||
761 | |||
762 | try | ||
763 | { | ||
764 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
765 | { | ||
766 | cmd.CommandText = query; | ||
767 | cmd.Parameters.AddWithValue(":ImViaEmail", pref.IMViaEmail); | ||
768 | cmd.Parameters.AddWithValue(":Visible", pref.Visible); | ||
769 | cmd.Parameters.AddWithValue(":uuid", pref.UserId.ToString()); | ||
770 | |||
771 | cmd.ExecuteNonQuery(); | ||
772 | } | ||
773 | } | ||
774 | catch (Exception e) | ||
775 | { | ||
776 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
777 | ": AgentInterestsUpdate exception {0}", e.Message); | ||
778 | result = e.Message; | ||
779 | return false; | ||
780 | } | ||
781 | return true; | ||
782 | } | ||
783 | |||
784 | public bool GetUserPreferences(ref UserPreferences pref, ref string result) | ||
785 | { | ||
786 | IDataReader reader = null; | ||
787 | string query = string.Empty; | ||
788 | |||
789 | query += "SELECT imviaemail,visible,email FROM "; | ||
790 | query += "usersettings WHERE "; | ||
791 | query += "useruuid = :Id"; | ||
792 | |||
793 | OSDArray data = new OSDArray(); | ||
794 | |||
795 | try | ||
796 | { | ||
797 | using (SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand()) | ||
798 | { | ||
799 | cmd.CommandText = query; | ||
800 | cmd.Parameters.AddWithValue("?Id", pref.UserId.ToString()); | ||
801 | |||
802 | using (reader = cmd.ExecuteReader(CommandBehavior.SingleRow)) | ||
803 | { | ||
804 | if(reader.Read()) | ||
805 | { | ||
806 | bool.TryParse((string)reader["imviaemail"], out pref.IMViaEmail); | ||
807 | bool.TryParse((string)reader["visible"], out pref.Visible); | ||
808 | pref.EMail = (string)reader["email"]; | ||
809 | } | ||
810 | else | ||
811 | { | ||
812 | query = "INSERT INTO usersettings VALUES "; | ||
813 | query += "(:Id,'false','false', '')"; | ||
814 | |||
815 | using (SqliteCommand put = (SqliteCommand)m_connection.CreateCommand()) | ||
816 | { | ||
817 | put.Parameters.AddWithValue(":Id", pref.UserId.ToString()); | ||
818 | put.ExecuteNonQuery(); | ||
819 | |||
820 | } | ||
821 | } | ||
822 | } | ||
823 | } | ||
824 | } | ||
825 | catch (Exception e) | ||
826 | { | ||
827 | m_log.DebugFormat("[PROFILES_DATA]" + | ||
828 | ": Get preferences exception {0}", e.Message); | ||
829 | result = e.Message; | ||
830 | return false; | ||
831 | } | ||
832 | return true; | ||
833 | } | ||
834 | |||
752 | public bool GetUserAppData(ref UserAppData props, ref string result) | 835 | public bool GetUserAppData(ref UserAppData props, ref string result) |
753 | { | 836 | { |
754 | IDataReader reader = null; | 837 | IDataReader reader = null; |