Skip to content

Commit 5b4a711

Browse files
committed
Fixes captcha not working, adds recaptcha support, fixes msbuild nuget reference preventing build in some environments.
1 parent d2d63b5 commit 5b4a711

6 files changed

+95
-71
lines changed

DotNetNuke.Modules.UserDefinedTable.xml

Lines changed: 54 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Form.ascx.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,32 @@ void BuildEditForm()
346346
editForm.Add(currentField);
347347
}
348348
}
349-
BuildCssForm(editForm);
349+
if (CaptchaNeeded())
350+
{
351+
_ctlCaptcha = new CaptchaControl
352+
{
353+
ID = "Captcha",
354+
CaptchaWidth = Unit.Pixel(130),
355+
CaptchaHeight = Unit.Pixel(40),
356+
ToolTip = Localization.GetString("CaptchaToolTip", LocalResourceFile),
357+
ErrorMessage = Localization.GetString("CaptchaError", LocalResourceFile)
358+
};
359+
currentField = new FormColumnInfo
360+
{
361+
Title = Localization.GetString("Captcha", LocalResourceFile),
362+
EditControl = _ctlCaptcha,
363+
Visible = true,
364+
IsUserDefinedField = false
365+
};
366+
editForm.Add(currentField);
367+
}
368+
369+
var enableFormTemplate = Settings.EnableFormTemplate;
370+
var formTemplate = Settings.FormTemplate;
371+
if (enableFormTemplate && !string.IsNullOrEmpty(formTemplate))
372+
BuildTemplateForm(editForm, formTemplate);
373+
else
374+
BuildCssForm(editForm);
350375
//Change captions of buttons in Form mode
351376
if (IsNewRow && Settings.ListOrForm.Contains("Form"))
352377
{
@@ -394,12 +419,14 @@ void Page_Load(object sender, EventArgs e)
394419
if (ModuleContext.PortalSettings.UserId == -1 && Settings.ForceCaptchaForAnonymous && Settings.PreferReCaptcha)
395420
{
396421
cmdUpdate.Attributes["disabled"] = "disabled";
422+
cmdUpdate.CssClass += " disabled";
397423

398424
DotNetNuke.Framework.CDefault page = (DotNetNuke.Framework.CDefault)this.Page;
399425
StringBuilder sb = new StringBuilder();
400426
sb.AppendLine(@"<script type=""text/javascript"">");
401427
sb.AppendLine("var onSubmit = function(token) {");
402428
sb.AppendLine("$('#" + cmdUpdate.ClientID + "').removeAttr('disabled');");
429+
sb.AppendLine("$('#" + cmdUpdate.ClientID + "').removeClass('disabled');");
403430
sb.AppendLine("};");
404431
sb.AppendLine("var onloadCallback = function() {");
405432
sb.AppendLine("grecaptcha.render('" + gRecaptcha.ClientID + "', {");

FormAndList.csproj

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
<Private>False</Private>
6868
</Reference>
6969
<Reference Include="DotNetNuke.Web, Version=9.0.0.1002, Culture=neutral, processorArchitecture=MSIL">
70+
<HintPath>..\..\bin\DotNetNuke.Web.dll</HintPath>
71+
<SpecificVersion>False</SpecificVersion>
72+
<Private>False</Private>
73+
</Reference>
7074
<Reference Include="DotNetNuke.Web.Client, Version=7.4.2.216, Culture=neutral, processorArchitecture=MSIL">
7175
<HintPath>packages\DotNetNuke.Web.Client.7.4.2.216\lib\net40\DotNetNuke.Web.Client.dll</HintPath>
7276
<SpecificVersion>False</SpecificVersion>
@@ -387,12 +391,12 @@
387391
<ItemGroup>
388392
<None Include="FormAndList.dnn" />
389393
</ItemGroup>
390-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
391-
Other similar extension points exist, see Microsoft.Common.targets.
392-
<Target Name="BeforeBuild">
393-
</Target>
394-
<Target Name="AfterBuild">
395-
</Target>
394+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
395+
Other similar extension points exist, see Microsoft.Common.targets.
396+
<Target Name="BeforeBuild">
397+
</Target>
398+
<Target Name="AfterBuild">
399+
</Target>
396400
-->
397401
<PropertyGroup>
398402
<Extension>zip</Extension>

Settings.ascx.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ public override void UpdateSettings()
6363
break;
6464
case 1:
6565
// DnnCaptcha
66+
mc.UpdateModuleSetting(ModuleId, SettingName.ForceCaptchaForAnonymous, true.ToString());
6667
mc.UpdateModuleSetting(ModuleId, SettingName.PreferReCaptcha, false.ToString());
6768
break;
6869
case 2:
6970
// ReCaptcha
71+
mc.UpdateModuleSetting(ModuleId, SettingName.ForceCaptchaForAnonymous, true.ToString());
7072
mc.UpdateModuleSetting(ModuleId, SettingName.PreferReCaptcha, true.ToString());
7173
break;
7274
default:

UpgradeLog.htm

28.1 KB
Binary file not shown.

form.ascx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div runat="server" id="divForm" class="dnnForm fnlForm dnnClear">
66

77
<div runat="server" ID="EditFormPlaceholder" />
8-
<asp:Panel ID="gRecaptcha" runat="server" />
8+
<asp:Panel ID="gRecaptcha" CssClass="recaptcha-container" runat="server" />
99
<ul class="dnnActions dnnClear">
1010
<li>
1111
<asp:LinkButton ID="cmdUpdate" Text="Update" runat="server" resourcekey="cmdUpdate" cssclass="dnnPrimaryAction reCaptchaSubmit" />

0 commit comments

Comments
 (0)