public SearchPosts ( int portalId, int moduleId, int userId, string forumIds, string searchText, int rowIndex, int maxRows, string searchId, DotNetNuke.Modules.ActiveForums.SettingsInfo mainSettings ) : |
||
portalId | int | |
moduleId | int | |
userId | int | |
forumIds | string | |
searchText | string | |
rowIndex | int | |
maxRows | int | |
searchId | string | |
mainSettings | DotNetNuke.Modules.ActiveForums.SettingsInfo | |
Résultat |
private XmlRpcStruct SearchPosts(string searchString, int startIndex, int endIndex, string searchId) { var aftContext = ActiveForumsTapatalkModuleContext.Create(Context); if (aftContext == null || aftContext.Module == null) throw new XmlRpcFaultException(100, "Invalid Context"); Context.Response.AddHeader("Mobiquo_is_login", aftContext.UserId > 0 ? "true" : "false"); var portalId = aftContext.Module.PortalID; var forumModuleId = aftContext.ModuleSettings.ForumModuleId; var userId = aftContext.UserId; // Verify Search Permissions var searchPermissions = aftContext.ModuleSettings.SearchPermission; if (searchPermissions == ActiveForumsTapatalkModuleSettings.SearchPermissions.Disabled || (userId <= 0 && searchPermissions == ActiveForumsTapatalkModuleSettings.SearchPermissions.RegisteredUsers)) throw new XmlRpcFaultException(102, "Insufficent Search Permissions"); // Build a list of forums the user has access to var fc = new AFTForumController(); var forumIds = fc.GetForumsForUser(aftContext.ForumUser.UserRoles, portalId, forumModuleId, "CanRead"); var mainSettings = new SettingsInfo { MainSettings = new Entities.Modules.ModuleController().GetModuleSettings(forumModuleId) }; var maxRows = endIndex + 1 - startIndex; var searchResults = fc.SearchPosts(portalId, forumModuleId, userId, forumIds, searchString, startIndex, maxRows, searchId, mainSettings); if (searchResults == null) throw new XmlRpcFaultException(101, "Search Error"); return new XmlRpcStruct { {"total_post_num", searchResults.TotalPosts }, {"search_id", searchResults.SearchId.ToString() }, {"posts", searchResults.Topics.Select(t => new ExtendedPostStructure { TopicId = t.TopicId.ToString(), AuthorAvatarUrl = GetAvatarUrl(t.AuthorId), AuthorId = t.AuthorId.ToString(), AuthorName = GetAuthorName(mainSettings, t).ToBytes(), ForumId = t.ForumId.ToString(), ForumName = t.ForumName.ToBytes(), PostID = t.ContentId.ToString(), Summary = GetSummary(null, t.Body).ToBytes(), PostDate = t.DateCreated, TopicTitle = HttpUtility.HtmlDecode(t.Subject + string.Empty).ToBytes(), PostTitle = HttpUtility.HtmlDecode(t.PostSubject + string.Empty).ToBytes() }).ToArray()} }; }