Exemplo n.º 1
0
        private Post AddNewBlog(BlogsEngine engine)
        {
            Guid authorId = SecurityContext.CurrentAccount.ID;

            if (CommunitySecurity.CheckPermissions(
                    new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(authorId)),
                    ASC.Blogs.Core.Constants.Action_AddPost))
            {
                Post newPost = new Post();
                newPost.Content = _mobileVer? (Request["mobiletext"] ?? "") : FCKeditor.Value;

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

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

                newPost.TagList = new List <ASC.Blogs.Core.Domain.Tag>();
                foreach (string tagName in txtTags.Text.Split(','))
                {
                    if (tagName != string.Empty && !IsExistsTagName(newPost, tagName))
                    {
                        ASC.Blogs.Core.Domain.Tag tag = new ASC.Blogs.Core.Domain.Tag();
                        tag.Content = GetLimitedText(tagName.Trim());
                        newPost.TagList.Add(tag);
                    }
                }


                var blog = engine.EnsurePersonalBlog(authorId);
                engine.SavePost(newPost, true, Request.Form["notify_comments"] == "on");

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

                return(newPost);
            }
            else
            {
                Response.Redirect("addblog.aspx");
                return(null);
            }
        }