Contacts Page & Comment Notification (Build

Aug 26, 2008 at 12:11 PM
Edited Aug 26, 2008 at 12:23 PM

The contacts page only gets submitted when the attachments are enabled. Is there a way to fix this? Also the notifications for the comments are not sent to the guy commenting if he has enabled it, however the admin gets a notification or is it that the checbox "Notify me when new comments are added" is for the admin only. Makes no sense though.

Ok just commented again, but this time the admin didn't get an e-mail. So sometimes the admin gets a notification and sometimes not, but the guy commenting does not get the notification at all.
You can test it here on a test blog:

Hopefully looking for a solution or a patch soon.

Aug 26, 2008 at 2:32 PM
There are couple of ways to fix the comment notification issue (same fix actually, just different ways to apply it).

Here's the easiest:

1. Open User Controls/CommentView.ascx
2. Find the method RaiseCallbackEvents
3. Scroll to find following block of code:

        if (!isPreview)
            SetCookie(author, email, website, country);

change to:

        if (!isPreview)
            if (comment.IsApproved)
            SetCookie(author, email, website, country);

This of course isn't the best fix. The best fix would be to change the Post.AddComment method and send notifications from that point based on IsApproved being true.

Anyway, the logic here is that if BlogSettings.Instance.EnableCommentsModeration is set to false, comments are automatically approved. Then it should be invoking the ApproveComment method.
Aug 26, 2008 at 4:36 PM
F**king perfecto!  This thing has been broken since day one.  While it may not be the best fix, it's a fix and I'll take it.  Thank you for the effort on YOUR part. 
Aug 27, 2008 at 8:00 AM
Thanks Sameera, will try the fix if it works. What about the issue with the Contacts page. It can only submit if attachments is enabled. Any fix for that?

FYI I checked out your site, tried commenting but gave a Compilation Error.
Aug 27, 2008 at 9:29 AM
I was gonna change my site's code to the proper method (changes in the Post.AddComment rather than in the comment view). Seems I have missed uploading all the code. Thanks :)
I'll upload the rest when I get home.
The code I've given you will work. I'm not a huge fan of it as AddComment + ApproveComment are going to cause 2 updates to the DB rather than being 1.
Aug 27, 2008 at 9:48 AM
Where can I find the Post.AddComment method? Please also let us know what changes to make in that method. By the way I changed the code in CommentView as you suggested, but the guy commenting and subscribing to "Notify me when new comments are added" does not get an e-mail, only the blog owner gets an e-mail. Where are these e-mails stored anyway?

Any luck with the Contacts page?

Looking forward to your response and thanks for all your support.
Aug 27, 2008 at 10:23 AM
Edited Aug 27, 2008 at 10:53 AM
Great! I managed to fix the problem with the Contacts page. Just had to remove the statement "&& txtAttachment.HasFile" in the btnSend_Click event in the contact.aspx.cs file. Also changed the code in the function beginSendMessage() to:

if ($('<%=txtAttachment.ClientID %>') != null)
        if ($('<%=txtAttachment.ClientID %>').value.length > 0)
          return true;

However when attachments are enabled, the Send button does not get disabled when clicked. May be someone could help me in fixing that.
Only thing remaining now is ability to send commenters a notification e-mail if they subscribed for it, then i'm all set.
Aug 27, 2008 at 2:14 PM

Sorry I wasn't paying attention to the contact page. Great that you got it working.

Post.AddComment is on the DotNetSlave.BusinessLogic\Post.cs
You need to get the full source code of BE.NET. If you just get the website source, you probably won't see this file.

I'm gonna make available the changes I made to get notification to work. You can download it here.
This only contains the CommentView control and the Post.cs file. Please put them in the right places and compile.

Let me know if you have any issues.
Aug 27, 2008 at 2:25 PM

First time I looked at the contacts page. Yes, your fixes are the way to go. Just applied it and uploading the fix. Thanks.
No idea why they made attachment field mandatory.