29 using System.Collections.Generic;
30 using System.Reflection;
37 using OpenSim.Framework;
38 using OpenSim.Services.Interfaces;
40 namespace OpenSim.Groups
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 public const GroupPowers DefaultEveryonePowers = GroupPowers.AllowSetHome |
47 GroupPowers.Accountable |
48 GroupPowers.JoinChat |
49 GroupPowers.AllowVoiceChat |
50 GroupPowers.ReceiveNotices |
51 GroupPowers.StartProposal |
52 GroupPowers.VoteOnProposal;
54 public const GroupPowers OwnerPowers = GroupPowers.Accountable |
55 GroupPowers.AllowEditLand |
56 GroupPowers.AllowFly |
57 GroupPowers.AllowLandmark |
58 GroupPowers.AllowRez |
59 GroupPowers.AllowSetHome |
60 GroupPowers.AllowVoiceChat |
61 GroupPowers.AssignMember |
62 GroupPowers.AssignMemberLimited |
63 GroupPowers.ChangeActions |
64 GroupPowers.ChangeIdentity |
65 GroupPowers.ChangeMedia |
66 GroupPowers.ChangeOptions |
67 GroupPowers.CreateRole |
68 GroupPowers.DeedObject |
69 GroupPowers.DeleteRole |
71 GroupPowers.FindPlaces |
72 GroupPowers.HostEvent |
74 GroupPowers.JoinChat |
75 GroupPowers.LandChangeIdentity |
76 GroupPowers.LandDeed |
77 GroupPowers.LandDivideJoin |
78 GroupPowers.LandEdit |
79 GroupPowers.LandEjectAndFreeze |
80 GroupPowers.LandGardening |
81 GroupPowers.LandManageAllowed |
82 GroupPowers.LandManageBanned |
83 GroupPowers.LandManagePasses |
84 GroupPowers.LandOptions |
85 GroupPowers.LandRelease |
86 GroupPowers.LandSetSale |
87 GroupPowers.ModerateChat |
88 GroupPowers.ObjectManipulate |
89 GroupPowers.ObjectSetForSale |
90 GroupPowers.ReceiveNotices |
91 GroupPowers.RemoveMember |
92 GroupPowers.ReturnGroupOwned |
93 GroupPowers.ReturnGroupSet |
94 GroupPowers.ReturnNonGroup |
95 GroupPowers.RoleProperties |
96 GroupPowers.SendNotices |
97 GroupPowers.SetLandingPoint |
98 GroupPowers.StartProposal |
99 GroupPowers.VoteOnProposal;
101 #region Daily Cleanup
103 private Timer m_CleanupTimer;
106 : base(config, configName)
111 : this(config, string.Empty)
114 m_CleanupTimer =
new Timer(24 * 60 * 60 * 1000);
115 m_CleanupTimer.AutoReset =
true;
116 m_CleanupTimer.Elapsed +=
new ElapsedEventHandler(m_CleanupTimer_Elapsed);
117 m_CleanupTimer.Enabled =
true;
118 m_CleanupTimer.Start();
121 private void m_CleanupTimer_Elapsed(
object sender, ElapsedEventArgs e)
123 m_Database.DeleteOldNotices();
124 m_Database.DeleteOldInvites();
129 public UUID
CreateGroup(
string RequestingAgentID,
string name,
string charter,
bool showInList, UUID insigniaID,
int membershipFee,
bool openEnrollment,
130 bool allowPublish,
bool maturePublish, UUID founderID, out
string reason)
132 reason = string.Empty;
135 if (m_Database.RetrieveGroup(name) != null)
137 reason =
"A group with that name already exists";
143 data.GroupID = UUID.Random();
144 data.Data =
new Dictionary<string, string>();
145 data.Data[
"Name"] = name;
146 data.Data[
"Charter"] = charter;
147 data.Data[
"InsigniaID"] = insigniaID.ToString();
148 data.Data[
"FounderID"] = founderID.ToString();
149 data.Data[
"MembershipFee"] = membershipFee.ToString();
150 data.Data[
"OpenEnrollment"] = openEnrollment ?
"1" :
"0";
151 data.Data[
"ShowInList"] = showInList ?
"1" :
"0";
152 data.Data[
"AllowPublish"] = allowPublish ?
"1" :
"0";
153 data.Data[
"MaturePublish"] = maturePublish ?
"1" :
"0";
154 UUID roleID = UUID.Random();
155 data.Data[
"OwnerRoleID"] = roleID.ToString();
157 if (!m_Database.StoreGroup(data))
161 _AddOrUpdateGroupRole(RequestingAgentID, data.
GroupID, UUID.Zero,
"Everyone",
"Everyone in the group",
"Member of " + name, (ulong)DefaultEveryonePowers,
true);
164 _AddOrUpdateGroupRole(RequestingAgentID, data.
GroupID, roleID,
"Owners",
"Owners of the group",
"Owner of " + name, (ulong)OwnerPowers,
true);
167 _AddAgentToGroup(RequestingAgentID, founderID.ToString(), data.GroupID, roleID);
172 public void UpdateGroup(
string RequestingAgentID, UUID groupID,
string charter,
bool showInList, UUID insigniaID,
int membershipFee,
bool openEnrollment,
bool allowPublish,
bool maturePublish)
174 GroupData data = m_Database.RetrieveGroup(groupID);
179 if (!HasPower(RequestingAgentID, groupID, GroupPowers.ChangeActions))
181 m_log.DebugFormat(
"[Groups]: ({0}) Attempt at updating group {1} denied because of lack of permission", RequestingAgentID, groupID);
185 data.GroupID = groupID;
186 data.Data[
"Charter"] = charter;
187 data.Data[
"ShowInList"] = showInList ?
"1" :
"0";
188 data.Data[
"InsigniaID"] = insigniaID.ToString();
189 data.Data[
"MembershipFee"] = membershipFee.ToString();
190 data.Data[
"OpenEnrollment"] = openEnrollment ?
"1" :
"0";
191 data.Data[
"AllowPublish"] = allowPublish ?
"1" :
"0";
192 data.Data[
"MaturePublish"] = maturePublish ?
"1" :
"0";
194 m_Database.StoreGroup(data);
200 GroupData data = m_Database.RetrieveGroup(GroupID);
202 return _GroupDataToRecord(data);
207 GroupData data = m_Database.RetrieveGroup(GroupName);
209 return _GroupDataToRecord(data);
212 public List<DirGroupsReplyData>
FindGroups(
string RequestingAgentID,
string search)
214 List<DirGroupsReplyData> groups =
new List<DirGroupsReplyData>();
216 GroupData[] data = m_Database.RetrieveGroups(search);
218 if (data != null && data.Length > 0)
223 if (d.
Data.ContainsKey(
"Location") && d.Data[
"Location"] != string.Empty)
227 g.groupID = d.GroupID;
229 if (d.
Data.ContainsKey(
"Name"))
232 m_log.DebugFormat(
"[Groups]: Key Name not found");
234 g.members = m_Database.MemberCount(d.GroupID);
243 public List<ExtendedGroupMembersData>
GetGroupMembers(
string RequestingAgentID, UUID GroupID)
245 List<ExtendedGroupMembersData> members =
new List<ExtendedGroupMembersData>();
247 GroupData group = m_Database.RetrieveGroup(GroupID);
254 UUID ownerRoleID =
new UUID(group.Data[
"OwnerRoleID"]);
256 RoleData[] roles = m_Database.RetrieveRoles(GroupID);
260 List<RoleData> rolesList =
new List<RoleData>(roles);
263 RoleData ownerRole = rolesList.Find(r => r.Data[
"Powers"] == ((long)OwnerPowers).ToString());
264 if (ownerRole != null)
265 ownerRoleID = ownerRole.RoleID;
269 bool checkVisibility = !RequestingAgentID.Equals(UUID.Zero.ToString());
274 bool isInGroup =
false;
275 if (m_Database.RetrieveMember(GroupID, RequestingAgentID) != null)
279 rolesList = rolesList.FindAll(r => (UInt64.Parse(r.Data[
"Powers"]) & (ulong)GroupPowers.MemberVisible) != 0);
283 if (datas == null || (datas != null && datas.Length == 0))
290 RoleMembershipData[] rolememberships = m_Database.RetrieveMemberRoles(GroupID, d.PrincipalID);
291 List<RoleMembershipData> rolemembershipsList =
new List<RoleMembershipData>(rolememberships);
296 UUID selectedRole =
new UUID(d.
Data[
"SelectedRoleID"]);
297 RoleData selected = rolesList.Find(r => r.RoleID == selectedRole);
299 if (selected != null)
301 m.Title = selected.Data[
"Title"];
302 m.AgentPowers = UInt64.Parse(selected.Data[
"Powers"]);
305 m.AgentID = d.PrincipalID;
306 m.AcceptNotices = d.Data[
"AcceptNotices"] ==
"1" ?
true :
false;
307 m.Contribution = Int32.Parse(d.Data[
"Contribution"]);
308 m.ListInProfile = d.Data[
"ListInProfile"] ==
"1" ?
true :
false;
310 GridUserData gud = m_GridUserService.Get(d.PrincipalID);
313 if (
bool.Parse(gud.
Data[
"Online"]))
315 m.OnlineStatus =
@"Online";
319 int unixtime = int.Parse(gud.Data[
"Login"]);
321 m.OnlineStatus = (unixtime == 0) ?
@"unknown" : Util.ToDateTime(unixtime).ToString(
"MM/dd/yyyy");
326 m.IsOwner = (rolemembershipsList.Find(r => r.RoleID == ownerRoleID) != null) ?
true :
false;
334 public bool AddGroupRole(
string RequestingAgentID, UUID groupID, UUID roleID,
string name,
string description,
string title, ulong powers, out
string reason)
336 reason = string.Empty;
338 if (!HasPower(RequestingAgentID, groupID, GroupPowers.CreateRole))
340 m_log.DebugFormat(
"[Groups]: ({0}) Attempt at creating role in group {1} denied because of lack of permission", RequestingAgentID, groupID);
341 reason =
"Insufficient permission to create role";
345 return _AddOrUpdateGroupRole(RequestingAgentID, groupID, roleID, name, description, title, powers,
true);
349 public bool UpdateGroupRole(
string RequestingAgentID, UUID groupID, UUID roleID,
string name,
string description,
string title, ulong powers)
352 if (!HasPower(RequestingAgentID, groupID, GroupPowers.ChangeActions))
354 m_log.DebugFormat(
"[Groups]: ({0}) Attempt at changing role in group {1} denied because of lack of permission", RequestingAgentID, groupID);
358 return _AddOrUpdateGroupRole(RequestingAgentID, groupID, roleID, name, description, title, powers,
false);
364 if (!HasPower(RequestingAgentID, groupID, GroupPowers.DeleteRole))
366 m_log.DebugFormat(
"[Groups]: ({0}) Attempt at deleting role from group {1} denied because of lack of permission", RequestingAgentID, groupID);
371 if (roleID == UUID.Zero)
373 m_log.DebugFormat(
"[Groups]: Attempt at deleting Everyone role from group {0} denied", groupID);
377 GroupData group = m_Database.RetrieveGroup(groupID);
380 m_log.DebugFormat(
"[Groups]: Attempt at deleting role from non-existing group {0}", groupID);
384 if (roleID ==
new UUID(group.
Data[
"OwnerRoleID"]))
386 m_log.DebugFormat(
"[Groups]: Attempt at deleting Owners role from group {0} denied", groupID);
390 _RemoveGroupRole(groupID, roleID);
393 public List<GroupRolesData>
GetGroupRoles(
string RequestingAgentID, UUID GroupID)
396 return _GetGroupRoles(GroupID);
404 bool isInGroup =
false;
405 if (m_Database.RetrieveMember(GroupID, RequestingAgentID) != null)
408 return _GetGroupRoleMembers(GroupID, isInGroup);
411 public bool AddAgentToGroup(
string RequestingAgentID,
string AgentID, UUID GroupID, UUID RoleID,
string token, out
string reason)
413 reason = string.Empty;
415 _AddAgentToGroup(RequestingAgentID, AgentID, GroupID, RoleID, token);
423 if (RequestingAgentID != AgentID && !HasPower(RequestingAgentID, GroupID, GroupPowers.Eject))
426 _RemoveAgentFromGroup(RequestingAgentID, AgentID, GroupID);
431 public bool AddAgentToGroupInvite(
string RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID,
string agentID)
439 if (!HasPower(RequestingAgentID, groupID, GroupPowers.Invite))
441 m_log.DebugFormat(
"[Groups]: ({0}) Attempt at inviting to group {1} denied because of lack of permission", RequestingAgentID, groupID);
446 InvitationData invite = m_Database.RetrieveInvitation(groupID, agentID);
448 m_Database.DeleteInvite(invite.InviteID);
451 invite.InviteID = inviteID;
452 invite.PrincipalID = agentID;
453 invite.GroupID = groupID;
454 invite.RoleID = roleID;
455 invite.Data =
new Dictionary<string, string>();
457 return m_Database.StoreInvitation(invite);
468 inviteInfo.AgentID = data.PrincipalID;
469 inviteInfo.GroupID = data.GroupID;
470 inviteInfo.InviteID = data.InviteID;
471 inviteInfo.RoleID = data.RoleID;
478 m_Database.DeleteInvite(inviteID);
487 bool limited = HasPower(RequestingAgentID, GroupID, GroupPowers.AssignMemberLimited);
488 bool unlimited = HasPower(RequestingAgentID, GroupID, GroupPowers.AssignMember) | IsOwner(RequestingAgentID, GroupID);
489 if (!limited || !unlimited)
491 m_log.DebugFormat(
"[Groups]: ({0}) Attempt at assigning {1} to role {2} denied because of lack of permission", RequestingAgentID, AgentID, RoleID);
496 if (!unlimited && limited)
499 RoleMembershipData rolemembership = m_Database.RetrieveRoleMember(GroupID, RoleID, AgentID);
500 if (rolemembership == null)
502 m_log.DebugFormat(
"[Groups]: ({0}) Attempt at assigning {1} to role {2} denied because of limited permission", RequestingAgentID, AgentID, RoleID);
507 _AddAgentToGroupRole(RequestingAgentID, AgentID, GroupID, RoleID);
515 if (RoleID == UUID.Zero)
519 bool unlimited = HasPower(RequestingAgentID, GroupID, GroupPowers.AssignMember) || IsOwner(RequestingAgentID, GroupID);
522 m_log.DebugFormat(
"[Groups]: ({0}) Attempt at removing {1} from role {2} denied because of lack of permission", RequestingAgentID, AgentID, RoleID);
526 RoleMembershipData rolemember = m_Database.RetrieveRoleMember(GroupID, RoleID, AgentID);
528 if (rolemember == null)
531 m_Database.DeleteRoleMember(rolemember);
534 UUID newRoleID = UUID.Zero;
539 if (r.
RoleID != UUID.Zero)
541 newRoleID = r.RoleID;
546 MembershipData member = m_Database.RetrieveMember(GroupID, AgentID);
549 member.Data[
"SelectedRoleID"] = newRoleID.ToString();
550 m_Database.StoreMember(member);
556 public List<GroupRolesData>
GetAgentGroupRoles(
string RequestingAgentID,
string AgentID, UUID GroupID)
558 List<GroupRolesData> roles =
new List<GroupRolesData>();
562 if (data == null || (data != null && data.Length ==0))
567 RoleData rdata = m_Database.RetrieveRole(GroupID, d.RoleID);
572 r.Name = rdata.Data[
"Name"];
573 r.Powers = UInt64.Parse(rdata.Data[
"Powers"]);
574 r.RoleID = rdata.RoleID;
575 r.Title = rdata.Data[
"Title"];
587 principal.PrincipalID = AgentID;
588 principal.ActiveGroupID = GroupID;
589 m_Database.StorePrincipal(principal);
591 return GetAgentGroupMembership(RequestingAgentID, AgentID, GroupID);
597 PrincipalData principal = m_Database.RetrievePrincipal(AgentID);
598 if (principal == null)
601 return GetAgentGroupMembership(RequestingAgentID, AgentID, principal.
ActiveGroupID);
606 return GetAgentGroupMembership(RequestingAgentID, AgentID, GroupID, null);
612 GroupData group = m_Database.RetrieveGroup(GroupID);
617 if (membership == null)
619 membership = m_Database.RetrieveMember(group.GroupID, AgentID);
620 if (membership == null)
625 UUID activeRoleID =
new UUID(membership.
Data[
"SelectedRoleID"]);
626 RoleData role = m_Database.RetrieveRole(group.GroupID, activeRoleID);
628 ExtendedGroupMembershipData data =
new ExtendedGroupMembershipData();
629 data.AcceptNotices = membership.Data[
"AcceptNotices"] ==
"1" ?
true :
false;
630 data.AccessToken = membership.Data[
"AccessToken"];
632 data.ActiveRole = activeRoleID;
633 data.AllowPublish = group.Data[
"AllowPublish"] ==
"1" ?
true :
false;
634 data.Charter = group.Data[
"Charter"];
635 data.Contribution = Int32.Parse(membership.Data[
"Contribution"]);
636 data.FounderID =
new UUID(group.
Data[
"FounderID"]);
637 data.GroupID =
new UUID(group.
GroupID);
638 data.GroupName = group.Data[
"Name"];
639 data.GroupPicture =
new UUID(group.
Data[
"InsigniaID"]);
642 data.GroupPowers = UInt64.Parse(role.Data[
"Powers"]);
643 data.GroupTitle = role.Data[
"Title"];
645 data.ListInProfile = membership.Data[
"ListInProfile"] ==
"1" ?
true :
false;
646 data.MaturePublish = group.Data[
"MaturePublish"] ==
"1" ?
true :
false;
647 data.MembershipFee = Int32.Parse(group.Data[
"MembershipFee"]);
648 data.OpenEnrollment = group.Data[
"OpenEnrollment"] ==
"1" ?
true :
false;
649 data.ShowInList = group.Data[
"ShowInList"] ==
"1" ?
true :
false;
656 List<GroupMembershipData> memberships =
new List<GroupMembershipData>();
661 if (mdata == null || (mdata != null && mdata.Length == 0))
669 memberships.Add(gmember);
680 MembershipData data = m_Database.RetrieveMember(GroupID, AgentID);
684 data.Data[
"SelectedRoleID"] = RoleID.ToString();
685 m_Database.StoreMember(data);
688 public void UpdateMembership(
string RequestingAgentID,
string AgentID, UUID GroupID,
bool AcceptNotices,
bool ListInProfile)
692 MembershipData membership = m_Database.RetrieveMember(GroupID, AgentID);
693 if (membership == null)
696 membership.Data[
"AcceptNotices"] = AcceptNotices ?
"1" :
"0";
697 membership.Data[
"ListInProfile"] = ListInProfile ?
"1" :
"0";
699 m_Database.StoreMember(membership);
702 public bool AddGroupNotice(
string RequestingAgentID, UUID groupID, UUID noticeID,
string fromName,
string subject,
string message,
703 bool hasAttachment, byte attType,
string attName, UUID attItemID,
string attOwnerID)
706 if (!HasPower(RequestingAgentID, groupID, GroupPowers.SendNotices))
708 m_log.DebugFormat(
"[Groups]: ({0}) Attempt at sending notice to group {1} denied because of lack of permission", RequestingAgentID, groupID);
712 return _AddNotice(groupID, noticeID, fromName, subject, message, hasAttachment, attType, attName, attItemID, attOwnerID);
717 NoticeData data = m_Database.RetrieveNotice(noticeID);
722 return _NoticeDataToInfo(data);
725 public List<ExtendedGroupNoticeData>
GetGroupNotices(
string RequestingAgentID, UUID groupID)
727 NoticeData[] data = m_Database.RetrieveNotices(groupID);
728 List<ExtendedGroupNoticeData> infos =
new List<ExtendedGroupNoticeData>();
730 if (data == null || (data != null && data.Length == 0))
764 #region Actions without permission checks
766 protected void _AddAgentToGroup(
string RequestingAgentID,
string AgentID, UUID GroupID, UUID RoleID)
768 _AddAgentToGroup(RequestingAgentID, AgentID, GroupID, RoleID,
string.Empty);
774 m_Database.DeleteMember(GroupID, AgentID);
777 m_Database.DeleteMemberAllRoles(GroupID, AgentID);
780 PrincipalData principal = m_Database.RetrievePrincipal(AgentID);
781 if (principal != null && principal.ActiveGroupID == GroupID)
783 principal.ActiveGroupID = UUID.Zero;
784 m_Database.StorePrincipal(principal);
788 protected void _AddAgentToGroup(
string RequestingAgentID,
string AgentID, UUID GroupID, UUID RoleID,
string accessToken)
791 MembershipData data = m_Database.RetrieveMember(GroupID, AgentID);
797 data.PrincipalID = AgentID;
798 data.GroupID = GroupID;
799 data.Data =
new Dictionary<string, string>();
800 data.Data[
"SelectedRoleID"] = RoleID.ToString();
801 data.Data[
"Contribution"] =
"0";
802 data.Data[
"ListInProfile"] =
"1";
803 data.Data[
"AcceptNotices"] =
"1";
804 data.Data[
"AccessToken"] = accessToken;
806 m_Database.StoreMember(data);
809 _AddAgentToGroupRole(RequestingAgentID, AgentID, GroupID, UUID.Zero);
812 if (RoleID != UUID.Zero)
813 _AddAgentToGroupRole(RequestingAgentID, AgentID, GroupID, RoleID);
817 pdata.PrincipalID = AgentID;
818 pdata.ActiveGroupID = GroupID;
819 m_Database.StorePrincipal(pdata);
823 protected bool _AddOrUpdateGroupRole(
string RequestingAgentID, UUID groupID, UUID roleID,
string name,
string description,
string title, ulong powers,
bool add)
825 RoleData data = m_Database.RetrieveRole(groupID, roleID);
827 if (add && data != null)
829 m_log.DebugFormat(
"[Groups]: Group {0} already exists. Can't create it again", groupID);
833 if (!add && data == null)
835 m_log.DebugFormat(
"[Groups]: Group {0} doesn't exist. Can't update it", groupID);
842 data.GroupID = groupID;
843 data.RoleID = roleID;
844 data.Data =
new Dictionary<string, string>();
845 data.Data[
"Name"] = name;
846 data.Data[
"Description"] = description;
847 data.Data[
"Title"] = title;
848 data.Data[
"Powers"] = powers.ToString();
850 return m_Database.StoreRole(data);
855 m_Database.DeleteRole(groupID, roleID);
865 data.GroupID = GroupID;
866 data.PrincipalID = AgentID;
867 data.RoleID = RoleID;
868 m_Database.StoreRoleMember(data);
871 MembershipData membership = m_Database.RetrieveMember(GroupID, AgentID);
872 if (membership == null)
874 m_log.DebugFormat(
"[Groups]: ({0}) No such member {0} in group {1}", AgentID, GroupID);
878 membership.Data[
"SelectedRoleID"] = RoleID.ToString();
879 m_Database.StoreMember(membership);
885 List<GroupRolesData> roles =
new List<GroupRolesData>();
887 RoleData[] data = m_Database.RetrieveRoles(groupID);
889 if (data == null || (data != null && data.Length == 0))
895 r.Description = d.Data[
"Description"];
896 r.Members = m_Database.RoleMemberCount(groupID, d.RoleID);
897 r.Name = d.Data[
"Name"];
898 r.Powers = UInt64.Parse(d.Data[
"Powers"]);
900 r.Title = d.Data[
"Title"];
910 List<ExtendedGroupRoleMembersData> rmembers =
new List<ExtendedGroupRoleMembersData>();
915 rdata = m_Database.RetrieveRoles(GroupID);
916 if (rdata == null || (rdata != null && rdata.Length == 0))
919 List<RoleData> rlist =
new List<RoleData>(rdata);
921 rlist = rlist.FindAll(r => (UInt64.Parse(r.Data[
"Powers"]) & (ulong)GroupPowers.MemberVisible) != 0);
925 if (data == null || (data != null && data.Length == 0))
932 RoleData rd = rlist.Find(_r => _r.RoleID == d.RoleID);
938 r.MemberID = d.PrincipalID;
947 protected bool _AddNotice(UUID groupID, UUID noticeID,
string fromName,
string subject,
string message,
948 bool hasAttachment, byte attType,
string attName, UUID attItemID,
string attOwnerID)
951 data.GroupID = groupID;
952 data.NoticeID = noticeID;
953 data.Data =
new Dictionary<string, string>();
954 data.Data[
"FromName"] = fromName;
955 data.Data[
"Subject"] = subject;
956 data.Data[
"Message"] = message;
957 data.Data[
"HasAttachment"] = hasAttachment ?
"1" :
"0";
960 data.Data[
"AttachmentType"] = attType.ToString();
961 data.Data[
"AttachmentName"] = attName;
962 data.Data[
"AttachmentItemID"] = attItemID.ToString();
963 data.Data[
"AttachmentOwnerID"] = attOwnerID;
965 data.Data[
"TMStamp"] = ((uint)Util.UnixTimeSinceEpoch()).ToString();
967 return m_Database.StoreNotice(data);
972 #region structure translations
979 rec.AllowPublish = data.Data[
"AllowPublish"] ==
"1" ?
true :
false;
980 rec.Charter = data.Data[
"Charter"];
981 rec.FounderID =
new UUID(data.
Data[
"FounderID"]);
982 rec.GroupID = data.GroupID;
983 rec.GroupName = data.Data[
"Name"];
984 rec.GroupPicture =
new UUID(data.
Data[
"InsigniaID"]);
985 rec.MaturePublish = data.Data[
"MaturePublish"] ==
"1" ?
true :
false;
986 rec.MembershipFee = Int32.Parse(data.Data[
"MembershipFee"]);
987 rec.OpenEnrollment = data.Data[
"OpenEnrollment"] ==
"1" ?
true :
false;
988 rec.OwnerRoleID =
new UUID(data.
Data[
"OwnerRoleID"]);
989 rec.ShowInList = data.Data[
"ShowInList"] ==
"1" ?
true :
false;
990 rec.ServiceLocation = data.Data[
"Location"];
991 rec.MemberCount = m_Database.MemberCount(data.GroupID);
992 rec.RoleCount = m_Database.RoleCount(data.GroupID);
997 GroupNoticeInfo _NoticeDataToInfo(
NoticeData data)
999 GroupNoticeInfo notice =
new GroupNoticeInfo();
1000 notice.GroupID = data.GroupID;
1001 notice.Message = data.Data[
"Message"];
1002 notice.noticeData = _NoticeDataToData(data);
1007 ExtendedGroupNoticeData _NoticeDataToData(
NoticeData data)
1009 ExtendedGroupNoticeData notice =
new ExtendedGroupNoticeData();
1010 notice.FromName = data.Data[
"FromName"];
1011 notice.NoticeID = data.NoticeID;
1012 notice.Subject = data.Data[
"Subject"];
1013 notice.Timestamp = uint.Parse((string)data.
Data[
"TMStamp"]);
1014 notice.HasAttachment = data.Data[
"HasAttachment"] ==
"1" ?
true :
false;
1015 if (notice.HasAttachment)
1017 notice.AttachmentName = data.Data[
"AttachmentName"];
1018 notice.AttachmentItemID =
new UUID(data.
Data[
"AttachmentItemID"].ToString());
1019 notice.AttachmentType = byte.Parse(data.Data[
"AttachmentType"].ToString());
1020 notice.AttachmentOwnerID = data.Data[
"AttachmentOwnerID"].ToString();
1030 private bool HasPower(
string agentID, UUID groupID, GroupPowers power)
1033 if (rmembership == null || (rmembership != null && rmembership.Length == 0))
1038 RoleData role = m_Database.RetrieveRole(groupID, rdata.RoleID);
1039 if ( (UInt64.Parse(role.
Data[
"Powers"]) & (ulong)power) != 0 )
1045 private bool IsOwner(
string agentID, UUID groupID)
1047 GroupData group = m_Database.RetrieveGroup(groupID);
1052 if (rmembership == null)
GroupNoticeInfo GetGroupNotice(string RequestingAgentID, UUID noticeID)
bool RemoveAgentFromGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
List< GroupMembershipData > GetAgentGroupMemberships(string RequestingAgentID, string AgentID)
void RemoveAgentToGroupInvite(string RequestingAgentID, UUID inviteID)
void AgentDroppedFromGroupChatSession(string agentID, UUID groupID)
void UpdateGroup(string RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
GroupInviteInfo GetAgentToGroupInvite(string RequestingAgentID, UUID inviteID)
Dictionary< string, string > Data
bool AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
void SetAgentActiveGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
Dictionary< string, string > Data
UUID CreateGroup(string RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID, out string reason)
ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, string GroupName)
void _AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
List< ExtendedGroupMembersData > GetGroupMembers(string RequestingAgentID, UUID GroupID)
Dictionary< string, string > Data
System.Timers.Timer Timer
List< ExtendedGroupNoticeData > GetGroupNotices(string RequestingAgentID, UUID groupID)
ExtendedGroupMembershipData GetAgentActiveMembership(string RequestingAgentID, string AgentID)
void _RemoveGroupRole(UUID groupID, UUID roleID)
bool _AddNotice(UUID groupID, UUID noticeID, string fromName, string subject, string message, bool hasAttachment, byte attType, string attName, UUID attItemID, string attOwnerID)
GroupsService(IConfigSource config)
List< DirGroupsReplyData > FindGroups(string RequestingAgentID, string search)
List< ExtendedGroupRoleMembersData > _GetGroupRoleMembers(UUID GroupID, bool isInGroup)
bool AddGroupNotice(string RequestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, bool hasAttachment, byte attType, string attName, UUID attItemID, string attOwnerID)
bool UpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers)
void RemoveGroupRole(string RequestingAgentID, UUID groupID, UUID roleID)
void _RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID)
List< GroupRolesData > GetAgentGroupRoles(string RequestingAgentID, string AgentID, UUID GroupID)
bool hasAgentDroppedGroupChatSession(string agentID, UUID groupID)
List< GroupRolesData > _GetGroupRoles(UUID groupID)
bool _AddOrUpdateGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, bool add)
void AgentInvitedToGroupChatSession(string agentID, UUID groupID)
ExtendedGroupRecord GetGroupRecord(string RequestingAgentID, UUID GroupID)
void ResetAgentGroupChatSessions(string agentID)
void _AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
ExtendedGroupMembershipData SetAgentActiveGroup(string RequestingAgentID, string AgentID, UUID GroupID)
bool hasAgentBeenInvitedToGroupChatSession(string agentID, UUID groupID)
List< ExtendedGroupRoleMembersData > GetGroupRoleMembers(string RequestingAgentID, UUID GroupID)
void _AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string accessToken)
bool AddAgentToGroupInvite(string RequestingAgentID, UUID inviteID, UUID groupID, UUID roleID, string agentID)
Dictionary< string, string > Data
void UpdateMembership(string RequestingAgentID, string AgentID, UUID GroupID, bool AcceptNotices, bool ListInProfile)
bool AddAgentToGroupRole(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID)
bool RemoveAgentFromGroup(string RequestingAgentID, string AgentID, UUID GroupID)
bool AddGroupRole(string RequestingAgentID, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, out string reason)
List< GroupRolesData > GetGroupRoles(string RequestingAgentID, UUID GroupID)
ExtendedGroupMembershipData GetAgentGroupMembership(string RequestingAgentID, string AgentID, UUID GroupID)
GroupsService(IConfigSource config, string configName)
Dictionary< string, string > Data