This makes group search work (Groups V2).
parent
8dff05a897
commit
170a6f0563
|
@ -504,6 +504,30 @@ namespace OpenSim.Groups
|
||||||
|
|
||||||
return notice;
|
return notice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DirGroupsReplyData DirGroupsReplyData(Dictionary<string, object> dict)
|
||||||
|
{
|
||||||
|
DirGroupsReplyData g;
|
||||||
|
|
||||||
|
g.groupID = new UUID(dict["GroupID"].ToString());
|
||||||
|
g.groupName = dict["Name"].ToString();
|
||||||
|
Int32.TryParse(dict["NMembers"].ToString(), out g.members);
|
||||||
|
float.TryParse(dict["SearchOrder"].ToString(), out g.searchOrder);
|
||||||
|
|
||||||
|
return g;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,6 +314,10 @@ namespace OpenSim.Groups
|
||||||
"[Groups]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})",
|
"[Groups]: {0} called with queryText({1}) queryFlags({2}) queryStart({3})",
|
||||||
System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
|
System.Reflection.MethodBase.GetCurrentMethod().Name, queryText, (DirFindFlags)queryFlags, queryStart);
|
||||||
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(queryText))
|
||||||
|
remoteClient.SendDirGroupsReply(queryID, new DirGroupsReplyData[0]);
|
||||||
|
|
||||||
// TODO: This currently ignores pretty much all the query flags including Mature and sort order
|
// TODO: This currently ignores pretty much all the query flags including Mature and sort order
|
||||||
remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentIDStr(remoteClient), queryText).ToArray());
|
remoteClient.SendDirGroupsReply(queryID, m_groupData.FindGroups(GetRequestingAgentIDStr(remoteClient), queryText).ToArray());
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,36 @@ namespace OpenSim.Groups
|
||||||
return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
|
return GroupsDataUtils.GroupRecord((Dictionary<string, object>)ret["RESULT"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 GroupMembershipData AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
|
public GroupMembershipData AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
|
||||||
{
|
{
|
||||||
reason = string.Empty;
|
reason = string.Empty;
|
||||||
|
|
|
@ -199,7 +199,7 @@ namespace OpenSim.Groups
|
||||||
public List<DirGroupsReplyData> FindGroups(string RequestingAgentID, string search)
|
public List<DirGroupsReplyData> FindGroups(string RequestingAgentID, string search)
|
||||||
{
|
{
|
||||||
// TODO!
|
// TODO!
|
||||||
return new List<DirGroupsReplyData>();
|
return m_GroupsService.FindGroups(RequestingAgentID, search);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
|
public bool AddAgentToGroup(string RequestingAgentID, string AgentID, UUID GroupID, UUID RoleID, string token, out string reason)
|
||||||
|
|
|
@ -133,6 +133,8 @@ namespace OpenSim.Groups
|
||||||
return HandleAddNotice(request);
|
return HandleAddNotice(request);
|
||||||
case "GETNOTICES":
|
case "GETNOTICES":
|
||||||
return HandleGetNotices(request);
|
return HandleGetNotices(request);
|
||||||
|
case "FINDGROUPS":
|
||||||
|
return HandleFindGroups(request);
|
||||||
}
|
}
|
||||||
m_log.DebugFormat("[GROUPS HANDLER]: unknown method request: {0}", method);
|
m_log.DebugFormat("[GROUPS HANDLER]: unknown method request: {0}", method);
|
||||||
}
|
}
|
||||||
|
@ -740,6 +742,32 @@ namespace OpenSim.Groups
|
||||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] HandleFindGroups(Dictionary<string, object> request)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
if (!request.ContainsKey("RequestingAgentID") || !request.ContainsKey("Query"))
|
||||||
|
NullResult(result, "Bad network data");
|
||||||
|
|
||||||
|
List<DirGroupsReplyData> hits = m_GroupsService.FindGroups(request["RequestingAgentID"].ToString(), request["Query"].ToString());
|
||||||
|
|
||||||
|
if (hits == null || (hits != null && hits.Count == 0))
|
||||||
|
NullResult(result, "No hits");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Dictionary<string, object> dict = new Dictionary<string, object>();
|
||||||
|
int i = 0;
|
||||||
|
foreach (DirGroupsReplyData n in hits)
|
||||||
|
dict["n-" + i++] = GroupsDataUtils.DirGroupsReplyData(n);
|
||||||
|
|
||||||
|
result["RESULT"] = dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||||
|
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#region Helpers
|
#region Helpers
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace OpenSim.Data.MySQL
|
||||||
if (string.IsNullOrEmpty(pattern))
|
if (string.IsNullOrEmpty(pattern))
|
||||||
pattern = "1 ORDER BY Name LIMIT 100";
|
pattern = "1 ORDER BY Name LIMIT 100";
|
||||||
else
|
else
|
||||||
pattern = string.Format("Name LIKE %{0}% ORDER BY Name LIMIT 100", pattern);
|
pattern = string.Format("Name LIKE '%{0}%' ORDER BY Name LIMIT 100", pattern);
|
||||||
|
|
||||||
return m_Groups.Get(pattern);
|
return m_Groups.Get(pattern);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue