diff options
author | Geir Nøklebye | 2015-07-25 20:35:25 +0200 |
---|---|---|
committer | Oren Hurvitz | 2015-07-26 11:59:15 +0100 |
commit | a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e (patch) | |
tree | e1db8a02d0c706535af733ccd75d9f4fd1c56230 /OpenSim/Data/PGSQL/PGSQLGroupsData.cs | |
parent | Add LogFile option in OpenSimDefaults.ini. It was omitted accidentally (diff) | |
download | opensim-SC-a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e.zip opensim-SC-a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e.tar.gz opensim-SC-a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e.tar.bz2 opensim-SC-a7fccbcf6fc4a6b42ce6381c65c85b3ca7fdee3e.tar.xz |
Update PGSQL groups handler to accept search queries from the viewer
Update PGSQL groups handler to accept search queries from the viewer.
Fixed malformed query strings.
Signed-off-by: Oren Hurvitz <orenh@kitely.com>
Diffstat (limited to 'OpenSim/Data/PGSQL/PGSQLGroupsData.cs')
-rwxr-xr-x[-rw-r--r--] | OpenSim/Data/PGSQL/PGSQLGroupsData.cs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs index 669e3c8..e257e7c 100644..100755 --- a/OpenSim/Data/PGSQL/PGSQLGroupsData.cs +++ b/OpenSim/Data/PGSQL/PGSQLGroupsData.cs | |||
@@ -31,12 +31,13 @@ using System.Collections.Generic; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using log4net; | ||
34 | using Npgsql; | 35 | using Npgsql; |
35 | 36 | ||
36 | namespace OpenSim.Data.PGSQL | 37 | namespace OpenSim.Data.PGSQL |
37 | { | 38 | { |
38 | public class PGSQLGroupsData : IGroupsData | 39 | public class PGSQLGroupsData : IGroupsData |
39 | { | 40 | { |
40 | private PGSqlGroupsGroupsHandler m_Groups; | 41 | private PGSqlGroupsGroupsHandler m_Groups; |
41 | private PGSqlGroupsMembershipHandler m_Membership; | 42 | private PGSqlGroupsMembershipHandler m_Membership; |
42 | private PGSqlGroupsRolesHandler m_Roles; | 43 | private PGSqlGroupsRolesHandler m_Roles; |
@@ -82,14 +83,17 @@ namespace OpenSim.Data.PGSQL | |||
82 | 83 | ||
83 | public GroupData[] RetrieveGroups(string pattern) | 84 | public GroupData[] RetrieveGroups(string pattern) |
84 | { | 85 | { |
86 | |||
85 | if (string.IsNullOrEmpty(pattern)) // True for where clause | 87 | if (string.IsNullOrEmpty(pattern)) // True for where clause |
86 | { | 88 | { |
87 | pattern = " true ORDER BY lower(\"Name\") LIMIT 100"; | 89 | pattern = " 1 ORDER BY lower(\"Name\") LIMIT 100"; |
90 | |||
88 | return m_Groups.Get(pattern); | 91 | return m_Groups.Get(pattern); |
89 | } | 92 | } |
90 | else | 93 | else |
91 | { | 94 | { |
92 | pattern = " lower(\"Name\") LIKE lower('%:pattern%') ORDER BY lower(\"Name\") LIMIT 100"; | 95 | pattern = " \"ShowInList\" = 1 AND lower(\"Name\") LIKE lower('%" + pattern + "%') ORDER BY lower(\"Name\") LIMIT 100"; |
96 | |||
93 | return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern)); | 97 | return m_Groups.Get(pattern, new NpgsqlParameter("pattern", pattern)); |
94 | } | 98 | } |
95 | } | 99 | } |
@@ -428,13 +432,11 @@ namespace OpenSim.Data.PGSQL | |||
428 | 432 | ||
429 | public void DeleteOld() | 433 | public void DeleteOld() |
430 | { | 434 | { |
431 | uint now = (uint)Util.UnixTimeSinceEpoch(); | ||
432 | 435 | ||
433 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | 436 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
434 | { | 437 | { |
435 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm); | 438 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); |
436 | cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old | 439 | |
437 | |||
438 | ExecuteNonQuery(cmd); | 440 | ExecuteNonQuery(cmd); |
439 | } | 441 | } |
440 | 442 | ||
@@ -456,13 +458,11 @@ namespace OpenSim.Data.PGSQL | |||
456 | 458 | ||
457 | public void DeleteOld() | 459 | public void DeleteOld() |
458 | { | 460 | { |
459 | uint now = (uint)Util.UnixTimeSinceEpoch(); | ||
460 | 461 | ||
461 | using (NpgsqlCommand cmd = new NpgsqlCommand()) | 462 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
462 | { | 463 | { |
463 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < :tstamp", m_Realm); | 464 | cmd.CommandText = String.Format("delete from {0} where \"TMStamp\" < CURRENT_DATE - INTERVAL '2 week'", m_Realm); |
464 | cmd.Parameters.AddWithValue("tstamp", now - 14 * 24 * 60 * 60); // > 2 weeks old | 465 | |
465 | |||
466 | ExecuteNonQuery(cmd); | 466 | ExecuteNonQuery(cmd); |
467 | } | 467 | } |
468 | 468 | ||