- Comments: Adding another setting for akismet.

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4041575
This commit is contained in:
suhacan
2009-11-20 18:08:26 +00:00
parent ba6af5ac4e
commit 6e2d2f5add
3 changed files with 11 additions and 1 deletions

View File

@@ -13,6 +13,7 @@ namespace Orchard.Comments.Models {
public virtual bool EnableCommentsOnPosts { get; set; }
public virtual bool EnableSpamProtection { get; set; }
public virtual string AkismetKey { get; set; }
public virtual string AkismetUrl { get; set; }
}
public class CommentSettingsHandler : ContentHandler {

View File

@@ -32,6 +32,7 @@ namespace Orchard.Comments.Services {
public bool ValidateComment(Comment comment) {
CommentSettingsRecord commentSettingsRecord = CurrentSite.As<CommentSettings>().Record;
string akismetKey = commentSettingsRecord.AkismetKey;
string akismetUrl = commentSettingsRecord.AkismetUrl;
bool enableSpamProtection = commentSettingsRecord.EnableSpamProtection;
if (enableSpamProtection == false) {
return true;
@@ -40,7 +41,10 @@ namespace Orchard.Comments.Services {
_notifer.Information(T("Please configure your Akismet key for spam protection"));
return true;
}
Akismet akismetApi = new Akismet(akismetKey, "http://www.orchardproject.net", null);
if (String.IsNullOrEmpty(akismetUrl)) {
akismetUrl = "http://www.orchardproject.net";
}
Akismet akismetApi = new Akismet(akismetKey, akismetUrl, null);
AkismetComment akismetComment = new AkismetComment {
CommentAuthor = comment.Author,
CommentAuthorEmail = comment.Email,

View File

@@ -26,4 +26,9 @@
<%= Html.EditorFor(x=>x.AkismetKey) %>
<%= Html.ValidationMessage("AkismetKey", "*")%>
</li>
<li>
<%= Html.LabelFor(x=>x.AkismetUrl) %>
<%= Html.EditorFor(x=>x.AkismetUrl) %>
<%= Html.ValidationMessage("AkismetUrl", "*")%>
</li>
</ol>