示例#1
0
        public List <DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search)
        {
            Hashtable param = new Hashtable();

            param["Search"] = search;

            Hashtable respData = XmlRpcCall(requestingAgentID, "groups.findGroups", param);

            List <DirGroupsReplyData> findings = new List <DirGroupsReplyData>();

            if (!respData.Contains("error"))
            {
                Hashtable results = (Hashtable)respData["results"];
                foreach (Hashtable groupFind in results.Values)
                {
                    DirGroupsReplyData data = new DirGroupsReplyData();
                    data.groupID   = new UUID((string)groupFind["GroupID"]);;
                    data.groupName = (string)groupFind["Name"];
                    data.members   = int.Parse((string)groupFind["Members"]);
                    // data.searchOrder = order;

                    findings.Add(data);
                }
            }

            return(findings);
        }
示例#2
0
        public List <DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search, int StartQuery, uint queryflags)
        {
            string        whereClause = " Name LIKE '%" + search + "%' LIMIT " + StartQuery + ",50 ";
            List <string> retVal      = data.Query(whereClause, "osgroup", "GroupID,Name,ShowInList,AllowPublish,MaturePublish");

            List <DirGroupsReplyData> Reply    = new List <DirGroupsReplyData>();
            DirGroupsReplyData        dirgroup = new DirGroupsReplyData();

            for (int i = 0; i < retVal.Count; i += 5)
            {
                if (retVal[i + 2] == "0") // (ShowInList param) They don't want to be shown in search.. respect this
                {
                    continue;
                }

                if ((queryflags & (uint)DirectoryManager.DirFindFlags.IncludeMature) != (uint)DirectoryManager.DirFindFlags.IncludeMature)
                {
                    if (retVal[i + 4] == "1")// (MaturePublish param) Check for pg,mature
                    {
                        continue;
                    }
                }
                dirgroup.groupID   = UUID.Parse(retVal[i]);
                dirgroup.groupName = retVal[i + 1];
                dirgroup.members   = int.Parse(data.Query(new string[] { "GroupID" }, new object[] { dirgroup.groupID }, "osgroupmembership", "count(AgentID)")[0]);
                Reply.Add(dirgroup);
                dirgroup = new DirGroupsReplyData();
            }
            return(Reply);
        }
示例#3
0
        void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
        {
            if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
            {
                m_log.InfoFormat("[Groups] {0} called with queryText({1}) queryFlags({2}) queryStart({3})", System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);

                List <DirGroupsReplyData> ReplyData = new List <DirGroupsReplyData>();
                int order = 0;
                foreach (osGroup group in m_Groups.Values)
                {
                    if (group.Name.ToLower().Contains(queryText.ToLower()))
                    {
                        if (queryStart <= order)
                        {
                            DirGroupsReplyData data = new DirGroupsReplyData();
                            data.groupID     = group.GroupID;
                            data.groupName   = group.Name;
                            data.members     = group.GroupMembershipCount;
                            data.searchOrder = order;
                            ReplyData.Add(data);
                        }

                        order += 1;
                    }
                }

                remoteClient.SendDirGroupsReply(queryID, ReplyData.ToArray());
            }
        }
        public static Dictionary <string, object> DirGroupsReplyData(DirGroupsReplyData g)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict["GroupID"]     = g.groupID;
            dict["Name"]        = g.groupName;
            dict["NMembers"]    = g.members;
            dict["SearchOrder"] = g.searchOrder;

            return(dict);
        }
示例#5
0
        public List <DirGroupsReplyData> FindGroups(string RequestingAgentID, string search)
        {
            List <DirGroupsReplyData> groups = new List <DirGroupsReplyData>();

            GroupData[] data = m_Database.RetrieveGroups(search);

            if (data != null && data.Length > 0)
            {
                foreach (GroupData d in data)
                {
                    // Don't list group proxies
                    if (d.Data.ContainsKey("Location") && d.Data["Location"] != string.Empty)
                    {
                        continue;
                    }

                    int nmembers = m_Database.MemberCount(d.GroupID);
                    if (nmembers == 0)
                    {
                        continue;
                    }

                    DirGroupsReplyData g = new DirGroupsReplyData();

                    if (d.Data.ContainsKey("Name"))
                    {
                        g.groupName = d.Data["Name"];
                    }
                    else
                    {
                        m_log.DebugFormat("[Groups]: Key Name not found");
                        continue;
                    }

                    g.groupID = d.GroupID;
                    g.members = nmembers;

                    groups.Add(g);
                }
            }

            return(groups);
        }
        public List <DirGroupsReplyData> FindGroups(string RequestingAgentID, string query)
        {
            List <DirGroupsReplyData> hits = new List <DirGroupsReplyData>();

            if (string.IsNullOrEmpty(query))
            {
                return(hits);
            }

            Dictionary <string, object> sendData = new Dictionary <string, object>();

            sendData["Query"]             = query;
            sendData["RequestingAgentID"] = RequestingAgentID;

            Dictionary <string, object> ret = MakeRequest("FINDGROUPS", sendData);

            if (ret == null)
            {
                return(hits);
            }

            if (!ret.ContainsKey("RESULT"))
            {
                return(hits);
            }

            if (ret["RESULT"].ToString() == "NULL")
            {
                return(hits);
            }

            foreach (object v in ((Dictionary <string, object>)ret["RESULT"]).Values)
            {
                DirGroupsReplyData m = GroupsDataUtils.DirGroupsReplyData((Dictionary <string, object>)v);
                hits.Add(m);
            }

            return(hits);
        }
        public List<DirGroupsReplyData> FindGroups(UUID requestingAgentID, string search, int StartQuery,
                                                   uint queryflags)
        {
            string whereClause = " Name LIKE '%" + search.MySqlEscape(50) + "%' LIMIT " + StartQuery + ",50 ";
            List<string> retVal = data.Query(whereClause, "osgroup",
                                             "GroupID,Name,ShowInList,AllowPublish,MaturePublish");

            List<DirGroupsReplyData> Reply = new List<DirGroupsReplyData>();
            DirGroupsReplyData dirgroup = new DirGroupsReplyData();
            for (int i = 0; i < retVal.Count; i += 5)
            {
                if (retVal[i + 2] == "0") // (ShowInList param) They don't want to be shown in search.. respect this
                    continue;

                if ((queryflags & (uint) DirectoryManager.DirFindFlags.IncludeMature) !=
                    (uint) DirectoryManager.DirFindFlags.IncludeMature)
                    if (retVal[i + 4] == "1") // (MaturePublish param) Check for pg,mature
                        continue;
                dirgroup.groupID = UUID.Parse(retVal[i]);
                dirgroup.groupName = retVal[i + 1];
                dirgroup.members =
                    int.Parse(
                        data.Query(new[] {"GroupID"}, new object[] {dirgroup.groupID}, "osgroupmembership",
                                   "count(AgentID)")[0]);
                Reply.Add(dirgroup);
                dirgroup = new DirGroupsReplyData();
            }
            return Reply;
        }
示例#8
0
        void OnDirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
        {
            if (!string.IsNullOrEmpty(queryText))
            {
                queryText = queryText.Trim();
                queryText = queryText.ToLowerInvariant();
            }

            if (((DirFindFlags)queryFlags & DirFindFlags.People) == DirFindFlags.People)
            {
                if (string.IsNullOrEmpty(queryText))
                {
                    remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]);
                }

                List <UserAccount> accounts;
                if (!queryPeopleCache.TryGetValue(queryText, out accounts))
                {
                    accounts = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, queryText);
                }

                queryPeopleCache.AddOrUpdate(queryText, accounts, 30.0);

                if (accounts.Count == 0)
                {
                    remoteClient.SendDirPeopleReply(queryID, new DirPeopleReplyData[0]);
                    return;
                }

                DirPeopleReplyData[] hits = new DirPeopleReplyData[accounts.Count];
                int count = 0;
                foreach (UserAccount acc in accounts)
                {
                    DirPeopleReplyData d = new DirPeopleReplyData();
                    d.agentID   = acc.PrincipalID;
                    d.firstName = acc.FirstName;
                    d.lastName  = acc.LastName;
                    d.online    = false;

                    hits[count++] = d;
                }

                // viewers don't sent sorting, so results they show are a nice mess
                if ((queryStart > 0) && (queryStart < count))
                {
                    int len = count - queryStart;
                    if (len > 101) // a viewer page is 100
                    {
                        len = 101;
                    }
                    DirPeopleReplyData[] tmp = new DirPeopleReplyData[len];
                    Array.Copy(hits, queryStart, tmp, 0, len);
                    hits = tmp;
                }
                else if (count > 101)
                {
                    DirPeopleReplyData[] tmp = new DirPeopleReplyData[101];
                    Array.Copy(hits, 0, tmp, 0, 101);
                    hits = tmp;
                }
                // TODO: This currently ignores pretty much all the query flags including Mature and sort order
                remoteClient.SendDirPeopleReply(queryID, hits);
            }
            else if (((DirFindFlags)queryFlags & DirFindFlags.Groups) == DirFindFlags.Groups)
            {
                if (m_GroupsService == null)
                {
                    m_log.Warn("[BASIC SEARCH MODULE]: Groups service is not available. Unable to search groups.");
                    remoteClient.SendAlertMessage("Groups search is not enabled");
                    return;
                }

                if (string.IsNullOrEmpty(queryText))
                {
                    remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
                }

                List <DirGroupsReplyData> answer;
                if (!queryGroupCache.TryGetValue(queryText, out answer))
                {
                    answer = m_GroupsService.FindGroups(remoteClient, queryText);
                }

                queryGroupCache.AddOrUpdate(queryText, answer, 30.0);

                if (answer.Count == 0)
                {
                    remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
                    return;
                }

                // filter out groups
                DirGroupsReplyData[] result = new DirGroupsReplyData[answer.Count];
                int count = 0;
                foreach (DirGroupsReplyData dgrd in answer)
                {
                    if (dgrd.members > 0)
                    {
                        result[count++] = dgrd;
                    }
                }
                answer = null;

                // viewers don't sent sorting, so results they show are a nice mess
                if ((queryStart > 0) && (queryStart < count))
                {
                    int len = count - queryStart;
                    if (len > 101) // a viewer page is 100
                    {
                        len = 101;
                    }
                    DirGroupsReplyData[] tmp = new DirGroupsReplyData[len];
                    Array.Copy(result, queryStart, tmp, 0, len);
                    result = tmp;
                }
                else if (count > 101)
                {
                    DirGroupsReplyData[] tmp = new DirGroupsReplyData[101];
                    Array.Copy(result, 0, tmp, 0, 101);
                    result = tmp;
                }

                // TODO: This currently ignores pretty much all the query flags including Mature and sort order
                remoteClient.SendDirGroupsReply(queryID, result);
            }
        }