SearchTopics() public method

public SearchTopics ( int portalId, int moduleId, int userId, string forumIds, string searchText, int rowIndex, int maxRows, string searchId, DotNetNuke.Modules.ActiveForums.SettingsInfo mainSettings ) : TopicSearchResults
portalId int
moduleId int
userId int
forumIds string
searchText string
rowIndex int
maxRows int
searchId string
mainSettings DotNetNuke.Modules.ActiveForums.SettingsInfo
return TopicSearchResults
        private XmlRpcStruct SearchTopics(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.SearchTopics(portalId, forumModuleId, userId, forumIds, searchString, startIndex, maxRows, searchId, mainSettings);

            if (searchResults == null)
                throw new XmlRpcFaultException(101, "Search Error");

            return new XmlRpcStruct
            {
                {"total_topic_num", searchResults.TotalTopics },
                {"search_id", searchResults.SearchId.ToString() },
                {"topics", searchResults.Topics.Select(t => new ExtendedTopicStructure { 
                                        TopicId = t.TopicId.ToString(),
                                        AuthorAvatarUrl = GetAvatarUrl(t.LastReplyAuthorId),
                                        AuthorId = t.LastReplyAuthorId.ToString(),
                                        AuthorName = GetLastReplyAuthorName(mainSettings, t).ToBytes(),
                                        ForumId = t.ForumId.ToString(),
                                        ForumName = t.ForumName.ToBytes(),
                                        HasNewPosts =  (t.LastReplyId < 0 && t.TopicId > t.UserLastTopicRead) || t.LastReplyId > t.UserLastReplyRead,
                                        IsLocked = t.IsLocked,
                                        IsSubscribed = t.SubscriptionType > 0,
                                        CanSubscribe = ActiveForums.Permissions.HasPerm(aftContext.ForumUser.UserRoles, fc.GetForumPermissions(t.ForumId).CanSubscribe), // GetforumPermissions uses cache so it shouldn't be a performance issue
                                        ReplyCount = t.ReplyCount,
                                        Summary = GetSummary(null, t.LastReplyBody).ToBytes(),
                                        ViewCount = t.ViewCount,
                                        DateCreated = t.LastReplyDate,
                                        Title = HttpUtility.HtmlDecode(t.Subject + string.Empty).ToBytes()
                                    }).ToArray()}
            };
        }