public BlogPostWrapperFull(Post post)
 {
     CreatedBy = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(post.UserID));
     Updated = Created = (ApiDateTime) post.Datetime;
     Id = post.ID;
     Tags = post.TagList.Select(x=>x.Content).ToList();
     Title = post.Title;
     Text = post.Content;
 }
        public BlogPostWrapperSummary(Post post)
        {
            CreatedBy = EmployeeWraper.Get(Core.CoreContext.UserManager.GetUsers(post.UserID));
            Created = (ApiDateTime)post.Datetime;
            Updated = (ApiDateTime) post.Updated;

            Id = post.ID;
            Tags = post.TagList.Select(x => x.Content).ToList();
            Title = post.Title;
            Preview = post.GetPreviewText(100);
        }
        public static void EditPost(Post post, Guid authorID)
        {
            var ua =
                ApplyCustomeActivityParams(
                    ComposeActivityByPost(post),
                    ASC.Blogs.Core.Resources.BlogsResource.UserActivity_EditPost,
                    authorID,
                    UserActivityConstants.ActivityActionType,
                    Constants.EditPostBusinessValue);

            PublishInternal(ua);
        }
        public static void DeletePost(Post post, UserInfo author)
        {
            var ua =
                ApplyCustomeActivityParams(
                    ComposeActivityByPost(post),
                    ASC.Blogs.Core.Resources.BlogsResource.UserActivity_DeletePost,
                    author.ID,
                    UserActivityConstants.ActivityActionType,
                    Constants.DeletePostBusinessValue);

            PublishInternal(ua);
        }
 public static void AddPost(Post post)
 {
     var ua =
         ApplyCustomeActivityParams(
             ComposeActivityByPost(post),
             ASC.Blogs.Core.Resources.BlogsResource.UserActivity_AddPost,
             post.UserID,
             UserActivityConstants.ContentActionType,
             Constants.AddPersonalPostBusinessValue 
         );
     ua.HtmlPreview = post.Content;
     PublishInternal(ua);
 }
        internal static UserActivity ComposeActivityByPost(Post post)
        {
            UserActivity ua = new UserActivity();
            ua.ContentID = GetContentID(post);
            ua.Date = ASC.Core.Tenants.TenantUtil.DateTimeNow();
            ua.ModuleID = BlogsSettings.ModuleID;
            ua.ProductID = ASC.Web.Community.Product.CommunityProduct.ID;
            ua.TenantID = CoreContext.TenantManager.GetCurrentTenant().TenantId;
            ua.Title = post.Title;
            ua.URL = String.Format("{0}?blogID={1}", Constants.ViewBlogPageUrl, post.ID);

            return ua;
        }
        private void InitPreviewTemplate()
        {
            var post = new Post
                {
                    Datetime = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                    Title = string.Empty,
                    Content = string.Empty,
                    UserID = SecurityContext.CurrentAccount.ID
                };

            var control = (ViewBlogView)LoadControl("~/products/community/modules/blogs/views/viewblogview.ascx");
            control.IsPreview = true;
            control.post = post;

            PlaceHolderPreview.Controls.Add(new Literal { Text = "<div class='headerPanel' style='margin-top:25px;'>" + BlogsResource.PreviewButton + "</div>" });
            PlaceHolderPreview.Controls.Add(control);
            PlaceHolderPreview.Controls.Add(new Literal { Text = "<div style='margin-top:20px;'><a class='button blue big' href='javascript:void(0);' onclick='BlogsManager.HidePreview(); return false;'>" + BlogsResource.HideButton + "</a></div>" });
        }
        public static void UpdateComment(Comment comment, Post post, Guid authorID)
        {
            var ua =
                ApplyCustomeActivityParams(
                    ComposeActivityByPost(post),
                    ASC.Blogs.Core.Resources.BlogsResource.UserActivity_EditComment,
                    authorID,
                    UserActivityConstants.ActivityActionType,
                    Constants.EditCommentBusinessValue);
            ua.URL += "#" + comment.ID;

            PublishInternal(ua);
        }
        private static List<CommentInfo> BuildCommentsList(Post post, List<Comment> loaded, Guid parentId)
        {
            var result = new List<CommentInfo>();
            foreach (var comment in Comment.SelectChildLevel(parentId, loaded))
            {
                var info = new CommentInfo
                    {
                        CommentID = comment.ID.ToString(),
                        UserID = comment.UserID,
                        TimeStamp = comment.Datetime,
                        TimeStampStr = comment.Datetime.Ago(),
                        IsRead = true,
                        Inactive = comment.Inactive,
                        CommentBody = comment.Content,
                        UserFullName = DisplayUserSettings.GetFullUserName(comment.UserID),
                        UserAvatar = ImageHTMLHelper.GetHTMLUserAvatar(comment.UserID),
                        UserPost = CoreContext.UserManager.GetUsers(comment.UserID).Title,
                        IsEditPermissions = CommunitySecurity.CheckPermissions(comment, Constants.Action_EditRemoveComment),
                        IsResponsePermissions = CommunitySecurity.CheckPermissions(post, Constants.Action_AddComment),
                        CommentList = BuildCommentsList(post, loaded, comment.ID)
                    };

                result.Add(info);
            }
            return result;
        }
Example #10
0
        public void SavePost(Post post)
        {
            var isInsert = false;
            if (post.ID == Guid.Empty)
            {
                post.ID = Guid.NewGuid();
                isInsert = true;
            }

            using (var tx = Db.BeginTransaction())
            {
                var tagsForSave = new List<Tag>(post.TagList);
                var tagsForDelete = new List<Tag>();
                if (!isInsert)
                {
                    var savedTags = SelectTags(post.ID);
                    tagsForDelete.AddRange(savedTags);
                    tagsForDelete.RemoveAll(_1 => tagsForSave.Exists(_2 => String.Equals(_1.Content, _2.Content, StringComparison.CurrentCultureIgnoreCase)));
                    tagsForSave.RemoveAll(_1 => savedTags.Exists(_2 => String.Equals(_1.Content, _2.Content, StringComparison.CurrentCultureIgnoreCase)));
                }

                if (tagsForDelete.Count > 0)
                {
                    var deleteq = Delete("blogs_tags")
                        .Where("post_id", post.ID.ToString())
                        .Where(Exp.In("name", tagsForDelete.ConvertAll(_ => (object)_.Content)));

                    Db.ExecuteNonQuery(deleteq);
                }

                if (tagsForSave.Count > 0)
                {
                    foreach (var tag in tagsForSave)
                    {
                        var insertq = Insert("blogs_tags")
                            .InColumns("name", "post_id")
                            .Values(tag.Content, post.ID.ToString());
                        Db.ExecuteNonQuery(insertq);
                    }
                }

                var queryi = Insert("blogs_posts")
                           .InColumns("id", "title", "content", "created_by", "created_when", "blog_id")
                           .Values(post.ID.ToString(), post.Title, post.Content, post.UserID.ToString(), TenantUtil.DateTimeToUtc(post.Datetime), post.BlogId);

                Db.ExecuteNonQuery(queryi);

                tx.Commit();
            }
        }
Example #11
0
 private static bool IsExistsTagName(Post post, string tagName)
 {
     return post.TagList.Any(tag => tag.Content == tagName);
 }
Example #12
0
 public Comment(Post post)
 {
     _Post = post;
     //_Blog.AddComment(this);
 }
        public static void Voted(Post blog, Guid authorID)
        {
            var ua = 
                ApplyCustomeActivityParams(
                    ComposeActivityByPost(blog),
                    ASC.Blogs.Core.Resources.BlogsResource.UserActivity_Vote,
                    authorID,
                    UserActivityConstants.ActivityActionType,
                    Constants.VoteBusinessValue);

            PublishInternal(ua);
        }
 internal static string GetContentID(Post post)
 {
     return String.Format("blog#{0}", post.ID);
 }
        public void UpdateValuesOn(Post post)
        {


        }
Example #16
0
 public Comment(Post post)
 {
     this.post = post;
     //_Blog.AddComment(this);
 }
        private void ShowBlogDetails(Post post)
        {
            if (post == null)
            {

            }
            else
            {
                var sb = new StringBuilder();

                sb.Append("<div style=\"padding: 0px " + (IsPreview ? "" : " 14px;") + "\">");
                if (IsPreview)
                {
                    sb.Append("<div id=\"previewTitle\" class='containerHeaderBlock' style='padding:0px 0px 10px 0px;'>" + HttpUtility.HtmlEncode(post.Title) + "</div>");
                    //    //sb.Append("<script type=\"text/javascript\">jq(document).ready (function(){window.scrollTo(jq('#blogs_preview').position().top, {speed:500});});</script>");
                }
                sb.Append("<table class='MainBlogsTable' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top'>");
                sb.Append("<div style='padding-top:4px;'>" + ImageHTMLHelper.GetLinkUserAvatar(post.UserID) + "</div>");
                sb.Append("</td><td><div class='InfoMainBlog'>");

                sb.Append("<div class='clearFix CreaterMainBlog'>");

                sb.Append("<div style='float:left'>");
                sb.Append("<a class='linkHeaderSmall' href='" + VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID + "'><span style='font-weight:normal;'>" + ASC.Blogs.Core.Resources.BlogsResource.BlogOfTitle + ":&nbsp;&nbsp;</span>" + DisplayUserSettings.GetFullUserName(post.UserID) + "</a>");
                sb.Append("</div>");



                sb.Append("</div>");
                sb.Append("<div >");
                sb.Append("<span class='textMediumDescribe' style='margin-right:5px;'>" + ASC.Blogs.Core.Resources.BlogsResource.PostedTitle + ":</span> " + CoreContext.UserManager.GetUsers(post.UserID).RenderProfileLink(ASC.Web.Community.Product.CommunityProduct.ID));
                sb.Append("<span class='textMediumDescribe'>&nbsp;&nbsp;" + post.Datetime.Ago() + "</span>");
                sb.Append("</div>");

                sb.Append("</div>");

                //if (post.Question != null)
                //    sb.Append(PollForm(post));

                sb.Append("<div id='previewBody' class='longWordsBreak ContentMainBlog'>");

                sb.Append(HtmlUtility.GetFull(post.Content, Product.CommunityProduct.ID));

                sb.Append("</div>");

                if (!IsPreview)
                {
                    sb.Append("<div  class='clearFix CommentsMainBlog'>");
                    if (post.TagList.Count > 0)
                    {
                        sb.Append("<div class=\"textMediumDescribe TagsMainBlog\">");
                        sb.Append("<img class=\"TagsImgMainBlog\" src=\"" + WebImageSupplier.GetAbsoluteWebPath("tags.png", BlogsSettings.ModuleID) + "\">");

                        var j = 0;
                        foreach (var tag in post.TagList)
                        {
                            if (j != 0)
                                sb.Append(", ");
                            j++;
                            sb.Append("<a style='margin-left:5px;' class=\"linkDescribe\" href=\"./?tagname=" + HttpUtility.UrlEncode(tag.Content) + "\">" + HttpUtility.HtmlEncode(tag.Content) + "</a>");
                        }

                        sb.Append("</div>");
                    }

                    if (CommunitySecurity.CheckPermissions(post, ASC.Blogs.Core.Constants.Action_EditRemovePost) && !IsPreview)
                    {
                        sb.Append("<div class='FunctionsMainBlog'>");
                        sb.Append("<a class=\"linkAction" + (SetupInfo.WorkMode == WorkMode.Promo ? " promoAction" : "") + "\" href=\"editblog.aspx?blogid=" + Request.QueryString["blogID"] + "\" >" + ASC.Blogs.Core.Resources.BlogsResource.EditBlogLink + "</a>");
                        sb.Append("<span class=\"splitter\">|</span><a class=\"linkAction" + (SetupInfo.WorkMode == WorkMode.Promo ? " promoAction" : "") + "\" onclick=\"javascript:return confirm('" + ASC.Blogs.Core.Resources.BlogsResource.ConfirmRemovePostMessage + "');\" href=\"editblog.aspx?blogid=" + Request.QueryString["blogID"] + "&action=delete\" >" + ASC.Blogs.Core.Resources.BlogsResource.DeleteBlogLink + "</a>&nbsp;");
                        sb.Append("</div>");
                    }
                    sb.Append("</div>");
                }
                sb.Append("</td></tr></table>");
                sb.Append("</div>");

                ltrContent.Text = sb.ToString();
            }
        }
        private void ShowBlogDetails(Post post)
        {
            if (post == null) return;

            var sb = new StringBuilder();
            var user = CoreContext.UserManager.GetUsers(post.UserID);

            if (IsPreview)
            {
                sb.Append("<div style='margin-bottom: 20px'>");
                sb.Append("<div id=\"previewTitle\" class='containerHeaderBlock' style='padding: 0 8px;'>" + HttpUtility.HtmlEncode(post.Title) + "</div>");
            }
            else
            {
                sb.Append("<div>");
            }

            sb.Append("<table class='MainBlogsTable' cellspacing='0' cellpadding='8' border='0'>");
            sb.Append("<tr>");
            sb.Append("<td valign='top' class='avatarContainer'>");
            sb.Append("<div>" + ImageHTMLHelper.GetHTMLUserAvatar(post.UserID) + "</div>");
            sb.Append("</td>");

            sb.Append("<td valign='top'>");

            sb.Append("<div class=\"author-title describe-text\">" + BlogsResource.PostedTitle + ":</div>");
            sb.Append("<div class=\"author-name\">");
            sb.AppendFormat("<a class='linkMedium' href=\"{0}\">{1}</a>", user.GetUserProfilePageURL(), user.DisplayUserName());
            sb.Append("</div>");
            sb.Append("<div>");
            sb.AppendFormat("<a class='linkMedium gray-text' href='{0}?userid={1}'>{2}</a>",
                            VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath),
                            user.ID,
                            BlogsResource.AllRecordsOfTheAutor);
            sb.Append("</div>");
            sb.Append("<div class='describe-text' style='margin-top:10px'>");
            sb.AppendFormat("{0}<span style='margin-left:20px'>{1}</span>", post.Datetime.ToString("d"), post.Datetime.ToString("t"));
            sb.Append("</div>");

            if (!IsPreview)
            {
                sb.Append("<div id=\"blogActionsMenuPanel\" class=\"studio-action-panel\">");
                sb.Append("<ul class=\"dropdown-content\">");
                if (CommunitySecurity.CheckPermissions(post, ASC.Blogs.Core.Constants.Action_EditRemovePost))
                {
                    sb.Append("<li><a class=\"dropdown-item\" href=\"editblog.aspx?blogid=" + Request.QueryString["blogid"] + "\" >" + BlogsResource.EditBlogLink + "</a></li>");
                    sb.Append("<li><a class=\"dropdown-item\" onclick=\"javascript:return confirm('" + BlogsResource.ConfirmRemovePostMessage + "');\" href=\"editblog.aspx?blogid=" + Request.QueryString["blogid"] + "&action=delete\" >" + BlogsResource.DeleteBlogLink + "</a></li>");
                }
                sb.Append("</ul>");
                sb.Append("</div>");
            }
            sb.Append("</td></tr></table>");

            sb.Append("<div id='previewBody' class='longWordsBreak ContentMainBlog'>");

            sb.Append(HtmlUtility.GetFull(post.Content));

            sb.Append("</div>");

            if (!IsPreview)
            {
                sb.Append("<div  class='clearFix'>");
                if (post.TagList.Count > 0)
                {
                    sb.Append("<div class=\"text-medium-describe TagsMainBlog\">");
                    sb.Append("<img class=\"TagsImgMainBlog\" src=\"" + WebImageSupplier.GetAbsoluteWebPath("tags.png", BlogsSettings.ModuleID) + "\">");

                    var j = 0;
                    foreach (var tag in post.TagList)
                    {
                        if (j != 0)
                            sb.Append(", ");
                        j++;
                        sb.Append("<a style='margin-left:5px;' class=\"linkMedium gray-text\" href=\"./?tagname=" + HttpUtility.UrlEncode(tag.Content) + "\">" + HttpUtility.HtmlEncode(tag.Content) + "</a>");
                    }

                    sb.Append("</div>");
                }

                sb.Append("</div>");
            }

            sb.Append("</div>");

            ltrContent.Text = sb.ToString();
        }
Example #19
0
        public BlogPostWrapperFull CreatePost(string title, string content, string tags, bool subscribeComments)
        {
            var newPost = new Post
                              {
                                  Content = content,
                                  Datetime = Core.Tenants.TenantUtil.DateTimeNow(),
                                  Title = title,/*TODO: maybe we should trim this */
                                  UserID = SecurityContext.CurrentAccount.ID,
                                  TagList = !string.IsNullOrEmpty(tags) ? tags.Split(',').Distinct().Select(x => new Tag() {Content = x}).ToList() : new List<Tag>()
                              };

            BlogEngine.EnsurePersonalBlog(SecurityContext.CurrentAccount.ID);
            BlogEngine.SavePost(newPost, true, subscribeComments);
            return new BlogPostWrapperFull(newPost);
        }
Example #20
0
        private bool IsExistsTagName(Post post, string tagName)
        {
            foreach (Tag tag in post.TagList)
            {
                if (tag.Content == tagName)
                    return true;
            }

            return false;
        }
Example #21
0
        private void InitPreviewTemplate(Post post)
        {
            var control = (ViewBlogView)LoadControl("~/Products/Community/Modules/Blogs/Views/ViewBlogView.ascx");
            control.IsPreview = true;
            control.post = post;

            PlaceHolderPreview.Controls.Add(new Literal { Text = "<div class='headerPanel' style='margin-top:20px;'>" + BlogsResource.PreviewButton + "</div>" });
            PlaceHolderPreview.Controls.Add(control);
            PlaceHolderPreview.Controls.Add(new Literal { Text = "<div style='margin-top:25px;'><a class='button blue big' href='javascript:void(0);' onclick='BlogsManager.HidePreview(); return false;'>" + BlogsResource.HideButton + "</a></div>" });
        }
Example #22
0
        public void UpdatePost(Post post, BlogsEngine engine)
        {
            post.Title = GetLimitedText(txtTitle.Text);
            post.Content = _mobileVer ? (Request["mobiletext"]??"") : FCKeditor.Value;

            post.TagList = new List<Tag>();

            foreach (string tagName in txtTags.Text.Split(','))
            {
                if (tagName != string.Empty && !IsExistsTagName(post, tagName))
                {
                    Tag tag = new Tag(post);
                    tag.Content = GetLimitedText(tagName.Trim());
                    post.TagList.Add(tag);
                }
            }


            engine.SavePost(post,false,false);

            CommonControlsConfigurer.FCKEditingComplete("blogs", post.ID.ToString(), post.Content, true);



            Response.Redirect("viewblog.aspx?blogid=" + post.ID.ToString());

        }
Example #23
0
        public void UpdatePost(Post post, BlogsEngine engine)
        {
            post.Title = GetLimitedText(txtTitle.Text);
            post.Content = (Request["blog_text"] ?? "");

            post.TagList = new List<Tag>();

            foreach (var tagName in txtTags.Text.Split(','))
            {
                if (tagName == string.Empty || IsExistsTagName(post, tagName))
                    continue;

                var tag = new Tag(post)
                    {
                        Content = GetLimitedText(tagName.Trim())
                    };
                post.TagList.Add(tag);
            }

            engine.SavePost(post, false, false);

            CommonControlsConfigurer.FCKEditingComplete("blogs", post.ID.ToString(), post.Content, true);

            Response.Redirect("viewblog.aspx?blogid=" + post.ID.ToString());
        }
Example #24
0
 public Tag(Post blog)
 {
     _Post = blog;
     //_Blog.AddTag(this);
 }
Example #25
0
 private static List<CommentInfo> BuildCommentsList(Post post, List<Comment> loaded)
 {
     return BuildCommentsList(post, loaded, Guid.Empty);
 }
        private Post AddNewBlog(BlogsEngine engine)
        {
            var authorId = SecurityContext.CurrentAccount.ID;

            if (CommunitySecurity.CheckPermissions(
                new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(authorId)),
                Constants.Action_AddPost))
            {
                var newPost = new Post
                    {
                        Content = (Request["mobiletext"] ?? "")
                    };

                var dateNow = ASC.Core.Tenants.TenantUtil.DateTimeNow();

                newPost.Datetime = dateNow;
                newPost.Title = GetLimitedText(txtTitle.Text);
                newPost.UserID = authorId;

                newPost.TagList = new List<Tag>();
                foreach (var tagName in txtTags.Text.Split(','))
                {
                    if (tagName == string.Empty || IsExistsTagName(newPost, tagName))
                        continue;

                    var tag = new Tag
                        {
                            Content = GetLimitedText(tagName.Trim())
                        };
                    newPost.TagList.Add(tag);
                }
                engine.SavePost(newPost, true, Request.Form["notify_comments"] == "on");

                CommonControlsConfigurer.FCKEditingComplete("blogs", newPost.ID.ToString(), newPost.Content, false);

                return newPost;
            }

            Response.Redirect("addblog.aspx");
            return null;
        }
Example #27
0
        private static void ConfigureComments(CommentsList commentList, int totalCount, Post postToUpdate)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);

            commentList.IsShowAddCommentBtn = CommunitySecurity.CheckPermissions(postToUpdate, Constants.Action_AddComment);
            commentList.CommentsCountTitle = totalCount > 0 ? totalCount.ToString() : "";
            commentList.FckDomainName = commentList.ObjectID = postToUpdate != null ? postToUpdate.ID.ToString() : "";
            commentList.Simple = false;
            commentList.BehaviorID = "commentsObj";
            commentList.JavaScriptAddCommentFunctionName = "ViewBlog.AddComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "ViewBlog.LoadCommentBBCode";
            commentList.JavaScriptPreviewCommentFunctionName = "ViewBlog.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName = "ViewBlog.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName = "ViewBlog.UpdateComment";
            commentList.FckDomainName = "blogs_comments";

            commentList.TotalCount = totalCount;
        }
        public static void AddComment(Comment newComment,Post post)
        {
            var ua = 
                ApplyCustomeActivityParams(
                    ComposeActivityByPost(post),
                    ASC.Blogs.Core.Resources.BlogsResource.UserActivity_AddComment,
                    newComment.UserID,
                    UserActivityConstants.ActivityActionType,
                    Constants.AddCommentBusinessValue);
            ua.URL += "#" + newComment.ID;
            ua.HtmlPreview = newComment.Content;

            PublishInternal(ua);
        }