29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
33 using OpenSim.Framework;
34 using OpenSim.Data.MySQL;
37 using MySql.Data.MySqlClient;
39 namespace OpenSim.Data.MySQL
65 return m_Groups.Store(data);
70 GroupData[] groups = m_Groups.Get(
"GroupID", groupID.ToString());
71 if (groups.Length > 0)
79 GroupData[] groups = m_Groups.Get(
"Name", name);
80 if (groups.Length > 0)
88 if (
string.IsNullOrEmpty(pattern))
91 pattern = string.Format(
"Name LIKE '%{0}%'", MySqlHelper.EscapeString(pattern));
93 return m_Groups.Get(string.Format(
"ShowInList=1 AND ({0}) ORDER BY Name LIMIT 100", pattern));
98 return m_Groups.Delete(
"GroupID", groupID.ToString());
103 return (
int)m_Groups.GetCount(
"Location=\"\"");
108 #region membership table
111 return m_Membership.Get(
"GroupID", groupID.ToString());
116 MembershipData[] m = m_Membership.Get(
new string[] {
"GroupID",
"PrincipalID" },
117 new string[] { groupID.ToString(), pricipalID });
118 if (m != null && m.Length > 0)
126 return m_Membership.Get(
"PrincipalID", pricipalID.ToString());
131 return m_Membership.Store(data);
136 return m_Membership.Delete(
new string[] {
"GroupID",
"PrincipalID" },
137 new string[] { groupID.ToString(), pricipalID });
142 return (
int)m_Membership.GetCount(
"GroupID", groupID.ToString());
149 return m_Roles.Store(data);
154 RoleData[] data = m_Roles.Get(
new string[] {
"GroupID",
"RoleID" },
155 new string[] { groupID.ToString(), roleID.ToString() });
157 if (data != null && data.Length > 0)
166 return m_Roles.Get(
"GroupID", groupID.ToString());
171 return m_Roles.Delete(
new string[] {
"GroupID",
"RoleID" },
172 new string[] { groupID.ToString(), roleID.ToString() });
177 return (
int)m_Roles.GetCount(
"GroupID", groupID.ToString());
183 #region rolememberhip table
193 RoleMembershipData[] data = m_RoleMembership.Get(
new string[] {
"GroupID",
"RoleID" },
194 new string[] { groupID.ToString(), roleID.ToString() });
201 RoleMembershipData[] data = m_RoleMembership.Get(
new string[] {
"GroupID",
"PrincipalID" },
202 new string[] { groupID.ToString(), principalID.ToString() });
209 RoleMembershipData[] data = m_RoleMembership.Get(
new string[] {
"GroupID",
"RoleID",
"PrincipalID" },
210 new string[] { groupID.ToString(), roleID.ToString(), principalID.ToString() });
212 if (data != null && data.Length > 0)
220 return (
int)m_RoleMembership.GetCount(
new string[] {
"GroupID",
"RoleID" },
221 new string[] { groupID.ToString(), roleID.ToString() });
226 return m_RoleMembership.Store(data);
231 return m_RoleMembership.Delete(
new string[] {
"GroupID",
"RoleID",
"PrincipalID"},
232 new string[] { data.GroupID.ToString(), data.
RoleID.ToString(), data.PrincipalID });
237 return m_RoleMembership.Delete(
new string[] {
"GroupID",
"PrincipalID" },
238 new string[] { groupID.ToString(), principalID });
243 #region principals table
246 return m_Principals.Store(data);
251 PrincipalData[] p = m_Principals.Get(
"PrincipalID", principalID);
252 if (p != null && p.Length > 0)
260 return m_Principals.Delete(
"PrincipalID", principalID);
264 #region invites table
268 return m_Invites.Store(data);
273 InvitationData[] invites = m_Invites.Get(
"InviteID", inviteID.ToString());
275 if (invites != null && invites.Length > 0)
283 InvitationData[] invites = m_Invites.Get(
new string[] {
"GroupID",
"PrincipalID" },
284 new string[] { groupID.ToString(), principalID });
286 if (invites != null && invites.Length > 0)
294 return m_Invites.Delete(
"InviteID", inviteID.ToString());
299 m_Invites.DeleteOld();
304 #region notices table
308 return m_Notices.Store(data);
313 NoticeData[] notices = m_Notices.Get(
"NoticeID", noticeID.ToString());
315 if (notices != null && notices.Length > 0)
323 NoticeData[] notices = m_Notices.Get(
"GroupID", groupID.ToString());
330 return m_Notices.Delete(
"NoticeID", noticeID.ToString());
335 m_Notices.DeleteOld();
357 protected override Assembly Assembly
360 get {
return GetType().Assembly; }
364 : base(connectionString, realm, store)
372 protected override Assembly Assembly
375 get {
return GetType().Assembly; }
379 : base(connectionString, realm, string.Empty)
387 protected override Assembly Assembly
390 get {
return GetType().Assembly; }
394 : base(connectionString, realm, string.Empty)
402 protected override Assembly Assembly
405 get {
return GetType().Assembly; }
409 : base(connectionString, realm, string.Empty)
417 protected override Assembly Assembly
420 get {
return GetType().Assembly; }
424 : base(connectionString, realm, string.Empty)
430 uint now = (uint)Util.UnixTimeSinceEpoch();
432 using (MySqlCommand cmd =
new MySqlCommand())
434 cmd.CommandText = String.Format(
"delete from {0} where TMStamp < ?tstamp", m_Realm);
435 cmd.Parameters.AddWithValue(
"?tstamp", now - 14 * 24 * 60 * 60);
437 ExecuteNonQuery(cmd);
445 protected override Assembly Assembly
448 get {
return GetType().Assembly; }
452 : base(connectionString, realm, string.Empty)
458 uint now = (uint)Util.UnixTimeSinceEpoch();
460 using (MySqlCommand cmd =
new MySqlCommand())
462 cmd.CommandText = String.Format(
"delete from {0} where TMStamp < ?tstamp", m_Realm);
463 cmd.Parameters.AddWithValue(
"?tstamp", now - 14 * 24 * 60 * 60);
465 ExecuteNonQuery(cmd);
473 protected override Assembly Assembly
476 get {
return GetType().Assembly; }
480 : base(connectionString, realm, string.Empty)
InvitationData RetrieveInvitation(UUID groupID, string principalID)
bool StoreGroup(GroupData data)
RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID)
bool DeleteInvite(UUID inviteID)
GroupData RetrieveGroup(string name)
int RoleMemberCount(UUID groupID, UUID roleID)
InvitationData RetrieveInvitation(UUID inviteID)
RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID)
MySqlGroupsMembershipHandler(string connectionString, string realm)
bool StoreRoleMember(RoleMembershipData data)
bool DeleteMemberAllRoles(UUID groupID, string principalID)
bool DeleteRole(UUID groupID, UUID roleID)
MySqlGroupsNoticesHandler(string connectionString, string realm)
MySqlGroupsGroupsHandler(string connectionString, string realm, string store)
bool StoreInvitation(InvitationData data)
RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID)
MembershipData RetrieveMember(UUID groupID, string pricipalID)
bool StoreRole(RoleData data)
MembershipData[] RetrievePrincipalGroupMemberships(string principalID)
bool DeleteRoleMember(RoleMembershipData data)
MembershipData[] RetrieveMemberships(string pricipalID)
MySqlGroupsPrincipalsHandler(string connectionString, string realm)
bool StoreMember(MembershipData data)
GroupData RetrieveGroup(UUID groupID)
GroupData[] RetrieveGroups(string pattern)
RoleData RetrieveRole(UUID groupID, UUID roleID)
int MemberCount(UUID groupID)
bool StoreNotice(NoticeData data)
bool DeleteGroup(UUID groupID)
RoleMembershipData[] RetrieveRolesMembers(UUID groupID)
MembershipData[] RetrieveMembers(UUID groupID)
MySQLGroupsData(string connectionString, string realm)
PrincipalData RetrievePrincipal(string principalID)
bool StorePrincipal(PrincipalData data)
NoticeData[] RetrieveNotices(UUID groupID)
bool DeleteNotice(UUID noticeID)
MySqlGroupsRolesHandler(string connectionString, string realm)
int RoleCount(UUID groupID)
MySqlGroupsRoleMembershipHandler(string connectionString, string realm)
MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID)
bool DeletePrincipal(string principalID)
bool DeleteMember(UUID groupID, string pricipalID)
NoticeData RetrieveNotice(UUID noticeID)
RoleData[] RetrieveRoles(UUID groupID)
MySqlGroupsInvitesHandler(string connectionString, string realm)