mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Shifting ReCaptchaSettingsPart
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.AntiSpam.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Localization;
|
||||
|
||||
namespace Orchard.AntiSpam.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class ReCaptchaSettingsPartHandler : ContentHandler {
|
||||
public ReCaptchaSettingsPartHandler(IRepository<ReCaptchaSettingsPartRecord> repository) {
|
||||
public ReCaptchaSettingsPartHandler() {
|
||||
T = NullLocalizer.Instance;
|
||||
Filters.Add(new ActivatingFilter<ReCaptchaSettingsPart>("Site"));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
Filters.Add(new TemplateFilterForRecord<ReCaptchaSettingsPartRecord>("ReCaptchaSettings", "Parts/AntiSpam.ReCaptchaSettings", "spam"));
|
||||
Filters.Add(new TemplateFilterForPart<ReCaptchaSettingsPart>("ReCaptchaSettings", "Parts/AntiSpam.ReCaptchaSettings", "spam"));
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
@@ -18,13 +18,6 @@ namespace Orchard.AntiSpam {
|
||||
.WithDescription("Ensures content items are submitted by humans only.")
|
||||
);
|
||||
|
||||
SchemaBuilder.CreateTable("ReCaptchaSettingsPartRecord",
|
||||
table => table.ContentPartVersionRecord()
|
||||
.Column<string>("PublicKey")
|
||||
.Column<string>("PrivateKey")
|
||||
.Column<bool>("TrustAuthenticatedUsers")
|
||||
);
|
||||
|
||||
ContentDefinitionManager.AlterPartDefinition("SpamFilterPart", cfg => cfg
|
||||
.Attachable()
|
||||
.WithDescription("Allows to filter submitted content items based on spam filters.")
|
||||
|
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.AntiSpam.Models {
|
||||
public class JavaScriptAntiSpamPart : ContentPart {
|
||||
|
@@ -1,20 +1,20 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.AntiSpam.Models {
|
||||
public class ReCaptchaSettingsPart : ContentPart<ReCaptchaSettingsPartRecord> {
|
||||
public class ReCaptchaSettingsPart : ContentPart {
|
||||
public string PublicKey {
|
||||
get { return Record.PublicKey; }
|
||||
set { Record.PublicKey = value; }
|
||||
get { return this.Retrieve(x => x.PublicKey); }
|
||||
set { this.Store(x => x.PublicKey, value); }
|
||||
}
|
||||
|
||||
public string PrivateKey {
|
||||
get { return Record.PrivateKey; }
|
||||
set { Record.PrivateKey = value; }
|
||||
get { return this.Retrieve(x => x.PrivateKey); }
|
||||
set { this.Store(x => x.PrivateKey, value); }
|
||||
}
|
||||
|
||||
public bool TrustAuthenticatedUsers {
|
||||
get { return Record.TrustAuthenticatedUsers; }
|
||||
set { Record.TrustAuthenticatedUsers = value; }
|
||||
get { return this.Retrieve(x => x.TrustAuthenticatedUsers); }
|
||||
set { this.Store(x => x.TrustAuthenticatedUsers, value); }
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.AntiSpam.Models {
|
||||
public class ReCaptchaSettingsPartRecord : ContentPartRecord {
|
||||
public virtual string PublicKey { get; set; }
|
||||
public virtual string PrivateKey { get; set; }
|
||||
public virtual bool TrustAuthenticatedUsers { get; set; }
|
||||
}
|
||||
}
|
@@ -109,7 +109,6 @@
|
||||
<Compile Include="Models\AkismetSettingsPart.cs" />
|
||||
<Compile Include="Models\CommentCheckContext.cs" />
|
||||
<Compile Include="Models\ReCaptchaSettingsPart.cs" />
|
||||
<Compile Include="Models\ReCaptchaSettingsPartRecord.cs" />
|
||||
<Compile Include="Models\TypePadSettingsPart.cs" />
|
||||
<Compile Include="Models\TypePadSettingsPartRecord.cs" />
|
||||
<Compile Include="Models\SpamFilterPart.cs" />
|
||||
|
@@ -1,4 +1,4 @@
|
||||
@model Orchard.AntiSpam.Models.ReCaptchaSettingsPartRecord
|
||||
@model Orchard.AntiSpam.Models.ReCaptchaSettingsPart
|
||||
|
||||
<fieldset>
|
||||
<legend>@T("ReCaptcha")</legend>
|
||||
|
@@ -85,6 +85,16 @@ namespace Upgrade.Controllers {
|
||||
|
||||
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_AntiSpam_AkismetSettingsPartRecord"), null);
|
||||
|
||||
// ReCaptchaSettingsPartRecord
|
||||
_upgradeService.ExecuteReader("SELECT * FROM " + _upgradeService.GetPrefixedTableName("Orchard_AntiSpam_ReCaptchaSettingsPartRecord"),
|
||||
(reader, connection) => {
|
||||
site.As<InfosetPart>().Set("ReCaptchaSettingsPart", "PublicKey", reader["PublicKey"].ToString());
|
||||
site.As<InfosetPart>().Set("ReCaptchaSettingsPart", "PrivateKey", reader["PrivateKey"].ToString());
|
||||
site.As<InfosetPart>().Set("ReCaptchaSettingsPart", "TrustAuthenticatedUsers", reader["TrustAuthenticatedUsers"].ToString());
|
||||
});
|
||||
|
||||
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_AntiSpam_ReCaptchaSettingsPartRecord"), null);
|
||||
|
||||
|
||||
_orchardServices.Notifier.Information(T("Site Settings migrated successfully"));
|
||||
|
||||
|
Reference in New Issue
Block a user