예제 #1
0
        public 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)
        {
            reason = string.Empty;

            // Check if the group already exists
            if (m_Database.RetrieveGroup(name) != null)
            {
                reason = "A group with that name already exists";
                return UUID.Zero;
            }

            // Create the group
            GroupData data = new GroupData();
            data.GroupID = UUID.Random();
            data.Data = new Dictionary<string, string>();
            data.Data["Name"] = name;
            data.Data["Charter"] = charter;
            data.Data["InsigniaID"] = insigniaID.ToString();
            data.Data["FounderID"] = founderID.ToString();
            data.Data["MembershipFee"] = membershipFee.ToString();
            data.Data["OpenEnrollment"] = openEnrollment ? "1" : "0";
            data.Data["ShowInList"] = showInList ? "1" : "0";
            data.Data["AllowPublish"] = allowPublish ? "1" : "0";
            data.Data["MaturePublish"] = maturePublish ? "1" : "0";
            UUID roleID = UUID.Random();
            data.Data["OwnerRoleID"] = roleID.ToString();

            if (!m_Database.StoreGroup(data))
                return UUID.Zero;

            // Create Everyone role
            _AddOrUpdateGroupRole(RequestingAgentID, data.GroupID, UUID.Zero, "Everyone", "Everyone in the group", "Member of " + name, (ulong)DefaultEveryonePowers, true);

            // Create Owner role
            _AddOrUpdateGroupRole(RequestingAgentID, data.GroupID, roleID, "Owners", "Owners of the group", "Owner of " + name, (ulong)OwnerPowers, true);

            // Add founder to group
            _AddAgentToGroup(RequestingAgentID, founderID.ToString(), data.GroupID, roleID);

            return data.GroupID;
        }
예제 #2
0
        ExtendedGroupRecord _GroupDataToRecord(GroupData data)
        {
            if (data == null)
                return null;

            ExtendedGroupRecord rec = new ExtendedGroupRecord();
            rec.AllowPublish = data.Data["AllowPublish"] == "1" ? true : false;
            rec.Charter = data.Data["Charter"];
            rec.FounderID = new UUID(data.Data["FounderID"]);
            rec.GroupID = data.GroupID;
            rec.GroupName = data.Data["Name"];
            rec.GroupPicture = new UUID(data.Data["InsigniaID"]);
            rec.MaturePublish = data.Data["MaturePublish"] == "1" ? true : false;
            rec.MembershipFee = Int32.Parse(data.Data["MembershipFee"]);
            rec.OpenEnrollment = data.Data["OpenEnrollment"] == "1" ? true : false;
            rec.OwnerRoleID = new UUID(data.Data["OwnerRoleID"]);
            rec.ShowInList = data.Data["ShowInList"] == "1" ? true : false;
            rec.ServiceLocation = data.Data["Location"];
            rec.MemberCount = m_Database.MemberCount(data.GroupID);
            rec.RoleCount = m_Database.RoleCount(data.GroupID);

            return rec;
        }
예제 #3
0
        public bool CreateGroupProxy(string RequestingAgentID, string agentID,  string accessToken, UUID groupID, string serviceLocation, string name, out string reason)
        {
            reason = string.Empty;
            Uri uri = null;
            try
            {
                uri = new Uri(serviceLocation);
            }
            catch (UriFormatException)
            {
                reason = "Bad location for group proxy";
                return false;
            }

            // Check if it already exists
            GroupData grec = m_Database.RetrieveGroup(groupID);
            if (grec == null || 
                (grec != null && grec.Data["Location"] != string.Empty && grec.Data["Location"].ToLower() != serviceLocation.ToLower()))
            {
                // Create the group
                grec = new GroupData();
                grec.GroupID = groupID;
                grec.Data = new Dictionary<string, string>();
                grec.Data["Name"] = name + " @ " + uri.Authority;
                grec.Data["Location"] = serviceLocation;
                grec.Data["Charter"] = string.Empty;
                grec.Data["InsigniaID"] = UUID.Zero.ToString();
                grec.Data["FounderID"] = UUID.Zero.ToString();
                grec.Data["MembershipFee"] = "0";
                grec.Data["OpenEnrollment"] = "0";
                grec.Data["ShowInList"] = "0";
                grec.Data["AllowPublish"] = "0";
                grec.Data["MaturePublish"] = "0";
                grec.Data["OwnerRoleID"] = UUID.Zero.ToString();


                if (!m_Database.StoreGroup(grec))
                    return false;
            }

            if (grec.Data["Location"] == string.Empty)
            {
                reason = "Cannot add proxy membership to non-proxy group";
                return false;
            }

            UUID uid = UUID.Zero;
            string url = string.Empty, first = string.Empty, last = string.Empty, tmp = string.Empty;
            Util.ParseUniversalUserIdentifier(RequestingAgentID, out uid, out url, out first, out last, out tmp);
            string fromName = first + "." + last + "@" + url;

            // Invite to group again
            InviteToGroup(fromName, groupID, new UUID(agentID), grec.Data["Name"]);

            // Stick the proxy membership in the DB already
            // we'll delete it if the agent declines the invitation
            MembershipData membership = new MembershipData();
            membership.PrincipalID = agentID;
            membership.GroupID = groupID;
            membership.Data = new Dictionary<string, string>();
            membership.Data["SelectedRoleID"] = UUID.Zero.ToString();
            membership.Data["Contribution"] = "0";
            membership.Data["ListInProfile"] = "1";
            membership.Data["AcceptNotices"] = "1";
            membership.Data["AccessToken"] = accessToken;

            m_Database.StoreMember(membership);

            return true;
        }