public ForumTopicPostWrapper(Post post)
 {
     Id = post.ID;
     Text = post.Text;
     Created = (ApiDateTime) post.CreateDate;
     Updated = (ApiDateTime) post.EditDate;
     Subject = post.Subject;
     CreatedBy = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(post.PosterID));
     Attachments = post.Attachments.Select(x=>new ForumTopicPostAttachmentWrapper(x)).ToList();
 }
Example #2
0
 private static FeedComment ToFeedComment(Post comment)
 {
     return new FeedComment(comment.PosterID)
         {
             Id = comment.ID.ToString(CultureInfo.InvariantCulture),
             Description = HtmlSanitizer.Sanitize(comment.Text),
             Date = comment.CreateDate
         };
 }
Example #3
0
        private static Post ToPost(object[] r)
        {
            var post = new Post
                {
                    Topic = new Topic
                        {
                            ID = Convert.ToInt32(r[0]),
                            Title = Convert.ToString(r[1]),
                            Type = (TopicType)Convert.ToInt32(r[2]),
                            RecentPostID = Convert.ToInt32(r[3]),
                            CreateDate = Convert.ToDateTime(r[4]),
                            PosterID = new Guid(Convert.ToString(r[5]))
                        }
                };

            if (r[6] != null)
            {
                post.ID = Convert.ToInt32(r[6]);
                post.TopicID = Convert.ToInt32(r[7]);
                post.PosterID = new Guid(Convert.ToString(r[8]));
                post.CreateDate = Convert.ToDateTime(r[9]);
                post.Subject = Convert.ToString(r[10]);
                post.Text = Convert.ToString(r[11]);
            }
            return post;
        }
 private Feed ToFeed(Post post)
 {
     var itemUrl = "/products/community/modules/forum/posts.aspx?t=" + post.TopicID + "&post=" + post.ID;
     return new Feed(post.PosterID, post.CreateDate)
         {
             Item = item,
             ItemId = post.ID.ToString(CultureInfo.InvariantCulture),
             ItemUrl = CommonLinkUtility.ToAbsolute(itemUrl),
             Product = Product,
             Module = Name,
             Title = post.Subject,
             Description = HtmlSanitizer.Sanitize(post.Text),
             Keywords = string.Format("{0} {1}", post.Subject, post.Text),
             HasPreview = false,
             CanComment = false,
             GroupId = string.Format("{0}_{1}", item, post.ID)
         };
 }
        private static List<Post> ParsePost(IEnumerable<object[]> data, int tenantID)
        {

            var posts = new List<Post>();
            foreach (var row in data)
            {
                var post = posts.Find(p => p.ID.Equals(Convert.ToInt32(row[0])));
                if (post == null)
                {
                    post = new Post
                               {
                                   TenantID = tenantID,
                                   ID = Convert.ToInt32(row[0]),
                                   TopicID = Convert.ToInt32(row[1]),
                                   CreateDate = TenantUtil.DateTimeFromUtc(Convert.ToDateTime(row[2])),
                                   PosterID = new Guid(Convert.ToString(row[3])),
                                   Subject = Convert.ToString(row[4]),
                                   Text = Convert.ToString(row[5]),
                                   EditDate = (row[6] != null ? TenantUtil.DateTimeFromUtc(Convert.ToDateTime(row[6])) : DateTime.MinValue),
                                   EditCount = Convert.ToInt32(row[7]),
                                   IsApproved = Convert.ToBoolean(row[8]),
                                   ParentPostID = (row[9] != null ? Convert.ToInt32(row[9]) : 0),
                                   Formatter = (PostTextFormatter) Convert.ToInt32(row[10]),
                                   EditorID = (row[11] != null ? new Guid(Convert.ToString(row[11])) : Guid.Empty)
                               };
                    posts.Add(post);
                }

                if (row[12] != null)
                {
                    post.Attachments.Add(new Attachment
                                             {
                                                 TenantID = tenantID,
                                                 ID = Convert.ToInt32(row[12]),
                                                 Name = Convert.ToString(row[13]),
                                                 Size = Convert.ToInt32(row[14]),
                                                 DownloadCount = Convert.ToInt32(row[15]),
                                                 ContentType = (AttachmentContentType) Convert.ToInt32(row[16]),
                                                 MIMEContentType = Convert.ToString(row[17]),
                                                 CreateDate = (row[18] != null ? TenantUtil.DateTimeFromUtc(Convert.ToDateTime(row[18])) : DateTime.MinValue),
                                                 PostID = post.ID,
                                                 OffsetPhysicalPath = Convert.ToString(row[19])
                                             });
                }

            }
            return posts;
        }
        public static string AttachmentsList(Post post, Guid settingsID)
        {
            var forumManager = ForumManager.GetForumManager(settingsID);
            var sb = new StringBuilder();
            if (post.Attachments.Count <= 0)
                return "";

            var closedTopic = ForumDataProvider.GetTopicByID(TenantProvider.CurrentTenantID, post.TopicID).Closed;

            sb.Append("<div class=\"cornerAll borderBase forum_attachmentsBox\">");
            sb.Append("<div class='headerPanel'>" + Resources.ForumUCResource.AttachFiles + "</div>");
            foreach (var attachment in post.Attachments)
            {
                sb.Append("<div id=\"forum_attach_" + attachment.ID + "\" class=\"borderBase  forum_attachItem clearFix\">");
                sb.Append("<table cellspacing='0' cellpadding='0' style='width:100%;'><tr>");
                sb.Append("<td>");
                sb.Append("<a class = 'link' target=\"_blank\" href=\"" + forumManager.GetAttachmentWebPath(attachment) + "\">" + HttpUtility.HtmlEncode(attachment.Name) + "</a>");
                sb.Append("</td>");

                sb.Append("<td style=\"text-align:right;width:100px;\"><span class=\"text-medium-describe\">" + ((float) attachment.Size/1024f).ToString("####0.##") + " KB</span></td>");

                if (forumManager.ValidateAccessSecurityAction(ForumAction.AttachmentDelete, post) && !closedTopic)
                {
                    sb.Append("<td style=\"text-align:right;width:100px;\">");
                    sb.Append("<a class=\"link\" href=\"javascript:ForumManager.DeleteAttachment('" + attachment.ID + "','" + post.ID + "');\">" + Resources.ForumUCResource.DeleteButton + "</a>");
                    sb.Append("</td>");
                }

                sb.Append("</tr></table>");
                sb.Append("</div>");
            }
            sb.Append("</div>");
            return sb.ToString();
        }
Example #7
0
        public void RemoveAttachments(Post post)
        {
            if (post.Attachments == null)
                return;

            foreach (var attachment in post.Attachments)
            {
                RemoveAttachments(attachment.OffsetPhysicalPath);
            }
        }
        private Feed ToFeed(Post post)
        {
            var item = string.Empty;
            if (post.Topic.Type == TopicType.Informational)
            {
                item = "forumTopic";
            }
            else if (post.Topic.Type == TopicType.Poll)
            {
                item = "forumPoll";
            }

            var itemUrl = "/products/community/modules/forum/posts.aspx?t=" + post.Topic.ID + "&post=" + post.ID;
            var threadUrl = "/products/community/modules/forum/topics.aspx?f=" + post.Topic.ThreadID;
            return new Feed(post.Topic.PosterID, post.Topic.CreateDate)
                {
                    Item = item,
                    ItemId = post.Topic.ID.ToString(CultureInfo.InvariantCulture),
                    ItemUrl = CommonLinkUtility.ToAbsolute(itemUrl),
                    Product = Product,
                    Module = Name,
                    Title = post.Topic.Title,
                    Description = HtmlSanitizer.Sanitize(post.Text),
                    ExtraLocation = post.Topic.ThreadTitle,
                    ExtraLocationUrl = CommonLinkUtility.ToAbsolute(threadUrl),
                    Keywords = string.Format("{0} {1}", post.Topic.Title, post.Text),
                    HasPreview = false,
                    CanComment = false,
                    GroupId = GetGroupId(item, post.Topic.PosterID, post.Topic.ThreadID.ToString(CultureInfo.InvariantCulture))
                };
        }
        public static string AttachmentsList(Post post, Guid settingsID)
        {
            var forumManager = ForumManager.GetForumManager(settingsID);
            StringBuilder sb = new StringBuilder();
            if (post.Attachments.Count <= 0)
                return "";

            sb.Append("<div class=\"tintLight cornerAll borderBase forum_attachmentsBox\">");
            sb.Append("<div class='headerPanel'>" + Resources.ForumUCResource.AttachFiles + "</div>");
            foreach (Attachment attachment in post.Attachments)
            {
                sb.Append("<div id=\"forum_attach_" + attachment.ID + "\" class=\"borderBase  forum_attachItem clearFix\">");
                sb.Append("<table cellspacing='0' cellpadding='0' style='width:100%;'><tr>");
                sb.Append("<td style=\"width:350px;\">");
                sb.Append("<a target=\"_blank\" href=\"" + forumManager.GetAttachmentWebPath(attachment) + "\">" + HttpUtility.HtmlEncode(attachment.Name) + "</a>");
                sb.Append("</td>");

                if (forumManager.ValidateAccessSecurityAction(ForumAction.AttachmentDelete, post))
                {
                    sb.Append("<td style=\"width:100px;\">");
                    sb.Append("<a class=\"linkDescribe" + (SetupInfo.WorkMode == WorkMode.Promo ? " promoAction" : "") + "\" href=\"javascript:ForumManager.DeleteAttachment('" + attachment.ID + "','" + post.ID + "');\">" + Resources.ForumUCResource.DeleteButton + "</a>");
                    sb.Append("</td>");
                }
                sb.Append("<td style=\"text-align:right;\"><span class=\"textMediumDescribe\">" + ((float)attachment.Size / 1024f).ToString("####0.##") + " KB</span></td>");
                sb.Append("</tr></table>");
                sb.Append("</div>");
            }
            sb.Append("</div>");
            return sb.ToString();
        }
 internal void NewPost(Post post, string topicTitle, int threadID, string url)
 {
     UserActivityPublisher.Publish(this.GetType(), new ForumUserActivity()
     {
         ModuleID = _settings.ModuleID,
         ProductID = _settings.ProductID,
         URL = url,
         ActionType = UserActivityConstants.ActivityActionType,
         ContentID = post.ID.ToString(),
         BusinessValue = UserActivityConstants.NormalActivity,
         ActionText = Resources.ForumUCResource.PostActionText,
         Title = topicTitle,
         ContainerID = threadID.ToString()
     });
 }