diff options
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteUserProfilesData.cs')
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteUserProfilesData.cs | 83 |
1 files changed, 83 insertions, 0 deletions
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; |