public PostListPlusPositionStructure(PostListStructure postList, int position)
 {
     PostCount = postList.PostCount;
     ForumId = postList.ForumId;
     ForumName = postList.ForumName;
     TopicId = postList.TopicId;
     Subject = postList.Subject;
     IsSubscribed = postList.IsSubscribed;
     CanSubscribe = postList.CanSubscribe;
     IsLocked = postList.IsLocked;
     CanReply = postList.CanReply;
     Posts = postList.Posts;
     Breadcrumbs = postList.Breadcrumbs;
     Position = position;
 }
Exemple #2
0
 public PostListPlusPositionStructure(PostListStructure postList, int position)
 {
     PostCount    = postList.PostCount;
     ForumId      = postList.ForumId;
     ForumName    = postList.ForumName;
     TopicId      = postList.TopicId;
     Subject      = postList.Subject;
     IsSubscribed = postList.IsSubscribed;
     CanSubscribe = postList.CanSubscribe;
     IsLocked     = postList.IsLocked;
     CanReply     = postList.CanReply;
     Posts        = postList.Posts;
     Breadcrumbs  = postList.Breadcrumbs;
     Position     = position;
 }
        private PostListStructure GetThread(int topicId, int startIndex, int endIndex, bool returnHtml)
        {
            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 forumId = fc.GetTopicForumId(topicId);

            if (forumId <= 0)
                throw new XmlRpcFaultException(100, "Invalid Topic");

            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 forumPostSummary = fc.GetForumPostSummary(aftContext.Module.PortalID, aftContext.ModuleSettings.ForumModuleId, forumId, topicId, aftContext.UserId);
            var forumPosts = fc.GetForumPosts(aftContext.Module.PortalID, aftContext.ModuleSettings.ForumModuleId, forumId, topicId, aftContext.UserId, startIndex, maxRows);

            var breadCrumbs = new List<BreadcrumbStructure>
                                  {
                                      new BreadcrumbStructure
                                          {
                                              ForumId = 'G' + forumPostSummary.ForumGroupId.ToString(),
                                              IsCategory = true,
                                              Name = forumPostSummary.GroupName.ToBytes()
                                          },
                                  };

            // If we're in a sub forum, add the parent to the breadcrumb
            if (forumPostSummary.ParentForumId > 0)
                breadCrumbs.Add(new BreadcrumbStructure
                {
                    ForumId = forumPostSummary.ParentForumId.ToString(),
                    IsCategory = false,
                    Name = forumPostSummary.ParentForumName.ToBytes()
                });

            breadCrumbs.Add(new BreadcrumbStructure
            {
                ForumId = forumId.ToString(),
                IsCategory = false,
                Name = forumPostSummary.ForumName.ToBytes()
            });

            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 result = new PostListStructure
                             {
                                 PostCount = forumPostSummary.ReplyCount + 1,
                                 CanReply = ActiveForums.Permissions.HasPerm(aftContext.ForumUser.UserRoles, fp.CanReply),
                                 CanSubscribe = ActiveForums.Permissions.HasPerm(aftContext.ForumUser.UserRoles, fp.CanSubscribe),
                                 ForumId = forumId,
                                 ForumName = forumPostSummary.ForumName.ToBytes(),
                                 IsLocked = forumPostSummary.IsLocked,
                                 IsSubscribed = forumPostSummary.SubscriptionType > 0,
                                 Subject = forumPostSummary.Subject.ToBytes(),
                                 TopicId = topicId,
                                 Posts = forumPosts.Select(p => new PostStructure
                                    {
                                        PostID = p.ContentId.ToString(),
                                        AuthorAvatarUrl = string.Format("{0}?userId={1}&w=64&h=64", profilePath, p.AuthorId),
                                        AuthorName = GetAuthorName(mainSettings, p).ToBytes(),
                                        AuthorId = p.AuthorId.ToString(),
                                        Body = HtmlToTapatalk(p.Body, returnHtml).ToBytes(),
                                        CanEdit = false, // TODO: Fix this
                                        IsOnline = p.IsUserOnline,
                                        PostDate = p.DateCreated,
                                        Subject = p.Subject.ToBytes()
                                    }).ToArray(),
                                 Breadcrumbs = breadCrumbs.ToArray()

                             };

            return result;
        }