예제 #1
0
 //- @AuthorizeComment -//
 public String AuthorizeComment(String commentGuid)
 {
     try
     {
         CommentAgent.AuthorizeComment(commentGuid);
     }
     catch
     {
         return("Invalid guid or error.");
     }
     //+
     return("Comment authorized.");
 }
예제 #2
0
        //- @PostNewComment -//
        public Int32 PostNewComment(Int32 captchaValue, String blogEntryGuid, String author, String email, String website, String text)
        {
            Int32 returnStatus;

            //+
            if (captchaValue == HttpData.GetScopedSessionItem <Int32>("Captcha", "ExpectedValue"))
            {
                CommentReportCreator creator = new CommentReportCreator();
                creator.Formatter = new Themelia.Reporting.HtmlFormatter();
                Themelia.Map map = new Themelia.Map();
                map.Add("BlogEntryTitle", "{BlogEntryTitle}");
                map.Add("Guid", blogEntryGuid);
                map.Add("Author", author);
                map.Add("Email", email);
                map.Add("WebSite", website);
                map.Add("DateTime", DateTime.Now.ToString());
                map.Add("Text", text);
                map.Add("Link", UrlCleaner.FixWebPathTail(Minima.Configuration.BlogSection.GetConfigSection().Domain) + @"/services/comment/{CommentGuid}");
                String emailBodyTemplate = creator.Create(map);
                Themelia.Configuration.SystemSection systemSection = Themelia.Configuration.SystemSection.GetConfigSection();
                String emailSubject = String.Format("{0} ({1})", BlogSection.GetConfigSection().Comment.Subject, systemSection.AppInfo.Name);
                //+
                String commentGuid = String.Empty;
                returnStatus = 0;
                try
                {
                    commentGuid = CommentAgent.PostNewComment(blogEntryGuid, text, author, email, website, DateTime.Now, emailBodyTemplate, emailSubject);
                }
                catch (Exception ex)
                {
                    if (ex.Message != "Failure sending mail.")
                    {
                        returnStatus = 1;
                    }
                }
            }
            else
            {
                returnStatus = 2;
            }
            //+
            return(returnStatus);
        }
예제 #3
0
        //- #OnLoad -//
        protected override void OnLoad(EventArgs e)
        {
            List <BlogEntry> blogEntryList = this.DataSource;

            if (this.AccessType != AccessType.Index)
            {
                //+ were there any entries at all?
                if (blogEntryList == null || blogEntryList.Count < 1)
                {
                    rptPosts.Visible         = false;
                    phNoEntries.Visible      = true;
                    litNoEntriesMessage.Text = BlogSection.GetConfigSection().Display.BlankMessage;
                }
                else
                {
                    rptPosts.DataSource = blogEntryList.Select(p => new
                    {
                        Url                  = Themelia.Web.WebDomain.GetUrl() + Themelia.Web.UrlCleaner.FixWebPathHead(p.MappingNameList.First()), // BlogEntryHelper.BuildBlogEntryLink(p.PostDateTime, p.MappingNameList.First(), Themelia.Web.WebDomain.Current),
                        Content              = this.CodeParserSeries.ParseCode(p.Content),
                        Title                = p.Title,
                        AuthorList           = p.AuthorList,
                        AllowCommentStatus   = p.AllowCommentStatus,
                        CommentList          = p.CommentList,
                        Guid                 = p.Guid,
                        LabelList            = p.LabelList,
                        AuthorSeries         = SeriesHelper.GetBlogEntryAuthorSeries(p),
                        LabelSeries          = SeriesHelper.GetBlogEntryLabelSeries(p),
                        ViewableCommentCount = p.CommentList != null ? p.CommentList.Count : 0,
                        DateTimeString       = String.Format("{0}, {1} {2}, {3}", p.PostDateTime.DayOfWeek, p.PostDateTime.ToString("MMMM"), p.PostDateTime.Day, p.PostDateTime.Year),
                        DateTimeDisplay      = String.Format("{0}/{1}/{2} {3}", p.PostDateTime.Month, p.PostDateTime.Day, p.PostDateTime.Year, p.PostDateTime.ToShortTimeString())
                    });
                    rptPosts.DataBind();
                    //+
                    if (this.AccessType == AccessType.Link && this.SupportCommenting)
                    {
                        BlogEntry blogEntry = blogEntryList[0];
                        if (blogEntry.AllowCommentStatus == AllowCommentStatus.Disabled)
                        {
                            mvCommentContent.SetActiveView(vCommentsDisabled);
                        }
                        else
                        {
                            mvCommentContent.SetActiveView(vShowComments);
                            List <Comment> commentList = CommentAgent.GetCommentList(this.BlogEntryGuid, false);
                            if (commentList.Count > 0)
                            {
                                htmlCommentListHeader.Visible = true;
                                litCommentCount.Text          = commentList.Count.ToString();
                            }
                            rptComments.DataSource = commentList;
                            rptComments.DataBind();
                            //+
                            CommentInputBase commentInput = vCommentForm.FindControl("CommentInput") as CommentInputBase;
                            if (commentInput != null)
                            {
                                HiddenField hfBlogEntryGuid = commentInput.FindControl("hfBlogEntryGuid") as HiddenField;
                                if (hfBlogEntryGuid != null)
                                {
                                    hfBlogEntryGuid.Value = this.BlogEntryGuid;
                                }
                            }
                            //+
                            if (blogEntry.AllowCommentStatus == AllowCommentStatus.Closed)
                            {
                                mvCommentInput.SetActiveView(vCommentClosed);
                            }
                            else
                            {
                                mvCommentInput.SetActiveView(vCommentForm);
                            }
                        }
                    }
                }
            }
            //+
            SetPageTitle();
            //+
            base.OnLoad(e);
        }