public GetForumTopicSummary ( int portalId, int moduleId, int forumId, int userId, string mode ) : |
||
portalId | int | |
moduleId | int | |
forumId | int | |
userId | int | |
mode | string | |
Résultat |
private TopicListStructure GetTopic(int forumId, int startIndex, int endIndex, string mode = null) { 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 fc = new AFTForumController(); var fp = fc.GetForumPermissions(forumId); if (!ActiveForums.Permissions.HasPerm(aftContext.ForumUser.UserRoles, fp.CanRead)) throw new XmlRpcFaultException(100, "No Read Permissions"); var maxRows = endIndex + 1 - startIndex; var forumTopicsSummary = fc.GetForumTopicSummary(portalId, forumModuleId, forumId, aftContext.UserId, mode); var forumTopics = fc.GetForumTopics(portalId, forumModuleId, forumId, aftContext.UserId, startIndex, maxRows, mode); var canSubscribe = ActiveForums.Permissions.HasPerm(aftContext.ForumUser.UserRoles, fp.CanSubscribe); var mainSettings = new SettingsInfo { MainSettings = new Entities.Modules.ModuleController().GetModuleSettings(forumModuleId) }; var profilePath = string.Format("{0}://{1}{2}", Context.Request.Url.Scheme, Context.Request.Url.Host, VirtualPathUtility.ToAbsolute("~/profilepic.ashx")); var forumTopicsStructure = new TopicListStructure { CanPost = ActiveForums.Permissions.HasPerm(aftContext.ForumUser.UserRoles, fp.CanCreate), ForumId = forumId.ToString(), ForumName = forumTopicsSummary.ForumName.ToBytes(), TopicCount = forumTopicsSummary.TopicCount, Topics = forumTopics.Select(t => new TopicStructure{ TopicId = t.TopicId.ToString(), AuthorAvatarUrl = string.Format("{0}?userId={1}&w=64&h=64", profilePath, t.AuthorId), AuthorName = GetAuthorName(mainSettings, t).ToBytes(), CanSubscribe = canSubscribe, ForumId = forumId.ToString(), HasNewPosts = (t.LastReplyId < 0 && t.TopicId > t.UserLastTopicRead) || t.LastReplyId > t.UserLastReplyRead, IsLocked = t.IsLocked, IsSubscribed = t.SubscriptionType > 0, LastReplyDate = t.LastReplyDate, ReplyCount = t.ReplyCount, Summary = GetSummary(t.Summary, t.Body).ToBytes(), ViewCount = t.ViewCount, Title = HttpUtility.HtmlDecode(t.Subject + string.Empty).ToBytes() }).ToArray() }; return forumTopicsStructure; }