Skip to content

Commit e79c397

Browse files
Resolves #950 make contact form comply with current German law
1 parent 8e1c3f4 commit e79c397

File tree

9 files changed

+76
-7
lines changed

9 files changed

+76
-7
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* #477 Implement option to specify the number of exported and imported pictures
2020
* #859 Make checkout attributes suitable for multi-stores
2121
* Product details: Select attribute and gift card values by query string parameters
22+
* #950 make contact form comply with current German law
2223

2324
### Improvements
2425
* Major improvements in Importer: better field mapping, higher performance, bug fixes etc.

src/Libraries/SmartStore.Core/Domain/Customers/CustomerSettings.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public CustomerSettings()
2424
NewsletterEnabled = true;
2525
OnlineCustomerMinutes = 20;
2626
StoreLastVisitedPage = true;
27+
DisplayPrivacyAgreementOnContactUs = false;
2728
}
2829

2930
/// <summary>
@@ -151,6 +152,11 @@ public CustomerSettings()
151152
/// </summary>
152153
public bool StoreLastVisitedPage { get; set; }
153154

155+
/// <summary>
156+
/// Gets or sets a value indicating whether to display a checkbox to the customer where he can agree to privacy terms
157+
/// </summary>
158+
public bool DisplayPrivacyAgreementOnContactUs { get; set; }
159+
154160
#region Form fields
155161

156162
/// <summary>

src/Libraries/SmartStore.Data/Migrations/201605201911421_ExportRevision.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,23 @@ public void MigrateLocaleResources(LocaleResourcesBuilder builder)
174174
"This function is not available for guests.",
175175
"Diese Funktion steht für Gäste nicht zur Verfügung.");
176176

177+
builder.AddOrUpdate("ContactUs.PrivacyAgreement",
178+
"Privacy consent",
179+
"Einwilligungserklärung Datenschutz");
180+
181+
builder.AddOrUpdate("ContactUs.PrivacyAgreement.MustBeAccepted",
182+
"Please agree to the storage of your data.",
183+
"Bitte stimmen Sie der Speicherung Ihrer Daten zu.");
184+
185+
builder.AddOrUpdate("ContactUs.PrivacyAgreement.DetailText",
186+
"Yes I've read the <a href=\"{0}\">privacy terms</a> and agree that my data given by me can be stored electronically. My data will thereby only be used to process my inquiry.",
187+
"Ja, ich habe die <a href=\"{0}\">Datenschutzerklärung</a> zur Kenntnis genommen und bin damit einverstanden, dass die von mir angegebenen Daten elektronisch erhoben und gespeichert werden. Meine Daten werden dabei nur zur Bearbeitung meiner Anfrage genutzt.");
188+
189+
builder.AddOrUpdate("Admin.Configuration.Settings.CustomerUser.DisplayPrivacyAgreementOnContactUs",
190+
"Get privacy consent for contact requests",
191+
"Einwilligungserklärung im Kontaktformular fordern",
192+
"Specifies whether a checkbox will be displayed on the contact page which requests the user to agree on storage of his data.",
193+
"Bestimmt ob im Kontaktformular eine Checkbox angezeigt wird, die den Benutzer auffordert der Speicherung seiner Daten zuzustimmen.");
177194

178195

179196
builder.Delete(

src/Presentation/SmartStore.Web/Administration/Models/Settings/CustomerUserSettingsModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ public partial class CustomerSettingsModel
8989
[SmartResourceDisplayName("Admin.Configuration.Settings.CustomerUser.StoreLastVisitedPage")]
9090
public bool StoreLastVisitedPage { get; set; }
9191

92+
[SmartResourceDisplayName("Admin.Configuration.Settings.CustomerUser.DisplayPrivacyAgreementOnContactUs")]
93+
public bool DisplayPrivacyAgreementOnContactUs { get; set; }
94+
9295
[SmartResourceDisplayName("Admin.Configuration.Settings.CustomerUser.GenderEnabled")]
9396
public bool GenderEnabled { get; set; }
9497

src/Presentation/SmartStore.Web/Administration/Views/Setting/CustomerUser.cshtml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,15 @@
259259
@Html.ValidationMessageFor(model => model.CustomerSettings.StoreLastVisitedPage)
260260
</td>
261261
</tr>
262+
<tr>
263+
<td class="adminTitle">
264+
@Html.SmartLabelFor(model => model.CustomerSettings.DisplayPrivacyAgreementOnContactUs)
265+
</td>
266+
<td class="adminData">
267+
@Html.SettingEditorFor(model => model.CustomerSettings.DisplayPrivacyAgreementOnContactUs)
268+
@Html.ValidationMessageFor(model => model.CustomerSettings.DisplayPrivacyAgreementOnContactUs)
269+
</td>
270+
</tr>
262271
</table>
263272
}
264273
@helper TabCustomerFormFields()

src/Presentation/SmartStore.Web/Controllers/HomeController.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using SmartStore.Core.Domain.Catalog;
77
using SmartStore.Core.Domain.Cms;
88
using SmartStore.Core.Domain.Common;
9+
using SmartStore.Core.Domain.Customers;
910
using SmartStore.Core.Domain.Messages;
1011
using SmartStore.Core.Infrastructure;
1112
using SmartStore.Core.Localization;
@@ -41,6 +42,7 @@ public partial class HomeController : PublicControllerBase
4142
private readonly Lazy<ISitemapGenerator> _sitemapGenerator;
4243
private readonly Lazy<CaptchaSettings> _captchaSettings;
4344
private readonly Lazy<CommonSettings> _commonSettings;
45+
private readonly Lazy<CustomerSettings> _customerSettings;
4446

4547
#endregion
4648

@@ -56,7 +58,8 @@ public HomeController(
5658
Lazy<IEmailAccountService> emailAccountService,
5759
Lazy<ISitemapGenerator> sitemapGenerator,
5860
Lazy<CaptchaSettings> captchaSettings,
59-
Lazy<CommonSettings> commonSettings)
61+
Lazy<CommonSettings> commonSettings,
62+
Lazy<CustomerSettings> customerSettings)
6063
{
6164
this._services = services;
6265
this._categoryService = categoryService;
@@ -68,6 +71,7 @@ public HomeController(
6871
this._sitemapGenerator = sitemapGenerator;
6972
this._captchaSettings = captchaSettings;
7073
this._commonSettings = commonSettings;
74+
this._customerSettings = customerSettings;
7175
}
7276

7377
#endregion
@@ -119,7 +123,9 @@ public ActionResult ContactUs()
119123
{
120124
Email = _services.WorkContext.CurrentCustomer.Email,
121125
FullName = _services.WorkContext.CurrentCustomer.GetFullName(),
122-
DisplayCaptcha = _captchaSettings.Value.Enabled && _captchaSettings.Value.ShowOnContactUsPage
126+
DisplayCaptcha = _captchaSettings.Value.Enabled && _captchaSettings.Value.ShowOnContactUsPage,
127+
DisplayPrivacyAgreement = _customerSettings.Value.DisplayPrivacyAgreementOnContactUs
128+
123129
};
124130

125131
return View(model);

src/Presentation/SmartStore.Web/Models/Common/ContactUsModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ namespace SmartStore.Web.Models.Common
1010
[Validator(typeof(ContactUsValidator))]
1111
public partial class ContactUsModel : ModelBase
1212
{
13+
[SmartResourceDisplayName("ContactUs.PrivacyAgreement")]
14+
public bool PrivacyAgreement { get; set; }
15+
16+
public bool DisplayPrivacyAgreement { get; set; }
17+
1318
[AllowHtml]
1419
[SmartResourceDisplayName("ContactUs.Email")]
1520
[DataType(DataType.EmailAddress)]

src/Presentation/SmartStore.Web/Validators/Common/ContactUsValidator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ public class ContactUsValidator : AbstractValidator<ContactUsModel>
88
{
99
public ContactUsValidator(ILocalizationService localizationService)
1010
{
11+
RuleFor(x => x.PrivacyAgreement)
12+
.Must(x => x == true)
13+
.WithMessage(localizationService.GetResource("ContactUs.PrivacyAgreement.MustBeAccepted"))
14+
.When(x => x.DisplayPrivacyAgreement == true);
15+
1116
RuleFor(x => x.Email).NotEmpty().WithMessage(localizationService.GetResource("ContactUs.Email.Required"));
1217
RuleFor(x => x.Email).EmailAddress().WithMessage(localizationService.GetResource("Common.WrongEmail"));
1318
RuleFor(x => x.FullName).NotEmpty().WithMessage(localizationService.GetResource("ContactUs.FullName.Required"));

src/Presentation/SmartStore.Web/Views/Home/ContactUs.cshtml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@
2424
{
2525
<fieldset>
2626

27-
@if (!ViewData.ModelState.IsValid)
28-
{
29-
@Html.ValidationSummary(true)
30-
}
31-
3227
<legend>@T("PageTitle.ContactUs")</legend>
3328

3429
<div class="control-group">
@@ -55,6 +50,28 @@
5550
</div>
5651
</div>
5752

53+
@if(Model.DisplayPrivacyAgreement)
54+
{
55+
@Html.HiddenFor(model => model.DisplayPrivacyAgreement)
56+
57+
<div class="control-group">
58+
@Html.LabelFor(model => model.PrivacyAgreement, new { @class = "control-label required", @for = "PrivacyAgreement" })
59+
<div class="controls">
60+
<div>
61+
<label class="checkbox">
62+
@Html.CheckBoxFor(model => model.PrivacyAgreement)
63+
@Html.Raw(T("ContactUs.PrivacyAgreement.DetailText").Text.FormatWith(
64+
Url.RouteUrl("Topic", new { SystemName = "PrivacyInfo" })
65+
))
66+
</label>
67+
</div>
68+
<div>
69+
@Html.ValidationMessageFor(model => model.PrivacyAgreement)
70+
</div>
71+
</div>
72+
</div>
73+
}
74+
5875
@if (Model.DisplayCaptcha)
5976
{
6077
<div class="control-group">

0 commit comments

Comments
 (0)