public GetTopicStatus ( int portalId, int moduleId, int userId, string forumIds, string topicIds ) : IEnumerable |
||
portalId | int | |
moduleId | int | |
userId | int | |
forumIds | string | |
topicIds | string | |
Résultat | IEnumerable |
private XmlRpcStruct GetTopicStatus(IEnumerable<int> topicIds) { 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; // 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 topicIdsString = topicIds.Aggregate(string.Empty, (current, topicId) => current + (topicId.ToString() + ";")); var unreadTopics = fc.GetTopicStatus(portalId, forumModuleId, userId, forumIds, topicIdsString).ToList(); return new XmlRpcStruct { {"result", true}, {"status", unreadTopics.Select(t => new TopicStatusStructure(){ TopicId = t.TopicId.ToString(), 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, ViewCount = t.ViewCount, LastReplyDate = t.LastReplyDate }).ToArray()} }; }