aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/SQLite/SQLiteEstateData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/SQLite/SQLiteEstateData.cs')
-rw-r--r--OpenSim/Data/SQLite/SQLiteEstateData.cs91
1 files changed, 69 insertions, 22 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteEstateData.cs b/OpenSim/Data/SQLite/SQLiteEstateData.cs
index 1be99ee..bd6b776 100644
--- a/OpenSim/Data/SQLite/SQLiteEstateData.cs
+++ b/OpenSim/Data/SQLite/SQLiteEstateData.cs
@@ -80,11 +80,8 @@ namespace OpenSim.Data.SQLite
80 get { return new List<string>(m_FieldMap.Keys).ToArray(); } 80 get { return new List<string>(m_FieldMap.Keys).ToArray(); }
81 } 81 }
82 82
83 public EstateSettings LoadEstateSettings(UUID regionID) 83 public EstateSettings LoadEstateSettings(UUID regionID, bool create)
84 { 84 {
85 EstateSettings es = new EstateSettings();
86 es.OnSave += StoreEstateSettings;
87
88 string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID"; 85 string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_map left join estate_settings on estate_map.EstateID = estate_settings.EstateID where estate_settings.EstateID is not null and RegionID = :RegionID";
89 86
90 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand(); 87 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
@@ -92,6 +89,14 @@ namespace OpenSim.Data.SQLite
92 cmd.CommandText = sql; 89 cmd.CommandText = sql;
93 cmd.Parameters.Add(":RegionID", regionID.ToString()); 90 cmd.Parameters.Add(":RegionID", regionID.ToString());
94 91
92 return DoLoad(cmd, regionID, create);
93 }
94
95 private EstateSettings DoLoad(SqliteCommand cmd, UUID regionID, bool create)
96 {
97 EstateSettings es = new EstateSettings();
98 es.OnSave += StoreEstateSettings;
99
95 IDataReader r = cmd.ExecuteReader(); 100 IDataReader r = cmd.ExecuteReader();
96 101
97 if (r.Read()) 102 if (r.Read())
@@ -120,17 +125,15 @@ namespace OpenSim.Data.SQLite
120 } 125 }
121 r.Close(); 126 r.Close();
122 } 127 }
123 else 128 else if (create)
124 { 129 {
125 // Migration case
126 //
127 r.Close(); 130 r.Close();
128 131
129 List<string> names = new List<string>(FieldList); 132 List<string> names = new List<string>(FieldList);
130 133
131 names.Remove("EstateID"); 134 names.Remove("EstateID");
132 135
133 sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")"; 136 string sql = "insert into estate_settings ("+String.Join(",", names.ToArray())+") values ( :"+String.Join(", :", names.ToArray())+")";
134 137
135 cmd.CommandText = sql; 138 cmd.CommandText = sql;
136 cmd.Parameters.Clear(); 139 cmd.Parameters.Clear();
@@ -176,20 +179,6 @@ namespace OpenSim.Data.SQLite
176 { 179 {
177 } 180 }
178 181
179 // Munge and transfer the ban list
180 //
181 cmd.Parameters.Clear();
182 cmd.CommandText = "insert into estateban select "+es.EstateID.ToString()+", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = :UUID";
183 cmd.Parameters.Add(":UUID", regionID.ToString());
184
185 try
186 {
187 cmd.ExecuteNonQuery();
188 }
189 catch (Exception)
190 {
191 }
192
193 es.Save(); 182 es.Save();
194 } 183 }
195 184
@@ -336,5 +325,63 @@ namespace OpenSim.Data.SQLite
336 325
337 return uuids.ToArray(); 326 return uuids.ToArray();
338 } 327 }
328
329 public EstateSettings LoadEstateSettings(int estateID)
330 {
331 string sql = "select estate_settings."+String.Join(",estate_settings.", FieldList)+" from estate_settings where estate_settings.EstateID :EstateID";
332
333 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
334
335 cmd.CommandText = sql;
336 cmd.Parameters.Add(":EstateID", estateID.ToString());
337
338 return DoLoad(cmd, UUID.Zero, false);
339 }
340
341 public List<int> GetEstates(string search)
342 {
343 List<int> result = new List<int>();
344
345 string sql = "select EstateID from estate_settings where estate_settings.EstateName :EstateName";
346
347 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
348
349 cmd.CommandText = sql;
350 cmd.Parameters.Add(":EstateName", search);
351
352 IDataReader r = cmd.ExecuteReader();
353
354 while (r.Read())
355 {
356 result.Add(Convert.ToInt32(r["EstateID"]));
357 }
358 r.Close();
359
360 return result;
361 }
362
363 public bool LinkRegion(UUID regionID, int estateID)
364 {
365 SqliteCommand cmd = (SqliteCommand)m_connection.CreateCommand();
366
367 cmd.CommandText = "insert into estate_map values (:RegionID, :EstateID)";
368 cmd.Parameters.Add(":RegionID", regionID.ToString());
369 cmd.Parameters.Add(":EstateID", estateID.ToString());
370
371 if (cmd.ExecuteNonQuery() == 0)
372 return false;
373
374 return true;
375 }
376
377 public List<UUID> GetRegions(int estateID)
378 {
379 return new List<UUID>();
380 }
381
382 public bool DeleteEstate(int estateID)
383 {
384 return false;
385 }
339 } 386 }
340} 387}