-
Notifications
You must be signed in to change notification settings - Fork 20
/
Settings.ascx.cs
81 lines (79 loc) · 4.04 KB
/
Settings.ascx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using System;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Modules.UserDefinedTable.Components;
using System.Web.UI.WebControls;
namespace DotNetNuke.Modules.UserDefinedTable
{
/// -----------------------------------------------------------------------------
/// <summary>
/// Module Settings
/// </summary>
/// -----------------------------------------------------------------------------
public partial class Settings : ModuleSettingsBase
{
public override void LoadSettings()
{
txtUserRecordQuota.Text = Settings[SettingName.UserRecordQuota].AsString();
chkEditOwnData.Checked = Convert.ToBoolean(Settings[SettingName.EditOnlyOwnItems]);
chkInputFiltering.Checked = Convert.ToBoolean(Settings[SettingName.ForceInputFiltering]);
chkDisplayColumns.Checked =
Convert.ToBoolean(!Settings[SettingName.ShowAllColumnsForAdmins].AsBoolean(true));
chkPrivateColumns.Checked =
Convert.ToBoolean(!Settings[SettingName.EditPrivateColumnsForAdmins].AsBoolean(true));
chkHideSystemColumns.Checked = Convert.ToBoolean(!Settings[SettingName.ShowSystemColumns].AsBoolean());
ddlCaptcha.Items.Add(new ListItem(LocalizeString("No"), "No"));
ddlCaptcha.Items.Add(new ListItem(LocalizeString("DnnCaptcha"), "DnnCaptcha"));
ddlCaptcha.Items.Add(new ListItem(LocalizeString("ReCaptcha"), "ReCaptcha"));
if (!Convert.ToBoolean(Settings[SettingName.ForceCaptchaForAnonymous]))
{
ddlCaptcha.SelectedIndex = 0;
}
else
{
if (Convert.ToBoolean(Settings[SettingName.PreferReCaptcha]))
{
ddlCaptcha.SelectedIndex = 2;
}
else
{
ddlCaptcha.SelectedIndex = 1;
}
}
txtSiteKey.Text = Settings[SettingName.ReCaptchaSiteKey].AsString();
txtSecretKey.Text = Settings[SettingName.ReCaptchaSecretKey].AsString();
}
public override void UpdateSettings()
{
var mc = new ModuleController();
mc.UpdateModuleSetting(ModuleId, SettingName.UserRecordQuota, txtUserRecordQuota.Text);
mc.UpdateModuleSetting(ModuleId, SettingName.EditOnlyOwnItems, chkEditOwnData.Checked.ToString());
mc.UpdateModuleSetting(ModuleId, SettingName.ForceInputFiltering, chkInputFiltering.Checked.ToString());
mc.UpdateModuleSetting(ModuleId, SettingName.ShowAllColumnsForAdmins,
(!(chkDisplayColumns.Checked)).ToString());
mc.UpdateModuleSetting(ModuleId, SettingName.EditPrivateColumnsForAdmins,
(!(chkPrivateColumns.Checked)).ToString());
mc.UpdateModuleSetting(ModuleId, SettingName.ShowSystemColumns, (!(chkHideSystemColumns.Checked)).ToString());
switch (ddlCaptcha.SelectedIndex)
{
case 0:
// No
mc.UpdateModuleSetting(ModuleId, SettingName.ForceCaptchaForAnonymous, false.ToString());
break;
case 1:
// DnnCaptcha
mc.UpdateModuleSetting(ModuleId, SettingName.ForceCaptchaForAnonymous, true.ToString());
mc.UpdateModuleSetting(ModuleId, SettingName.PreferReCaptcha, false.ToString());
break;
case 2:
// ReCaptcha
mc.UpdateModuleSetting(ModuleId, SettingName.ForceCaptchaForAnonymous, true.ToString());
mc.UpdateModuleSetting(ModuleId, SettingName.PreferReCaptcha, true.ToString());
break;
default:
break;
}
mc.UpdateModuleSetting(ModuleId, SettingName.ReCaptchaSiteKey, txtSiteKey.Text);
mc.UpdateModuleSetting(ModuleId, SettingName.ReCaptchaSecretKey, txtSecretKey.Text);
}
}
}