-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.ascx.cs
172 lines (151 loc) · 10 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
using System;
using DotNetNuke.Entities.Host;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Entities.Modules;
namespace Bitboxx.DNNModules.BBContact
{
/// -----------------------------------------------------------------------------
/// <summary>
/// The Settings class manages Module Settings
/// </summary>
/// -----------------------------------------------------------------------------
[DNNtc.PackageProperties("BBContact")]
[DNNtc.ModuleProperties("BBContact")]
[DNNtc.ModuleControlProperties("Settings", "Configure settings", DNNtc.ControlType.Edit, "", true, true)]
public partial class Settings : ModuleSettingsBase
{
#region Base Method Implementations
/// -----------------------------------------------------------------------------
/// <summary>
/// LoadSettings loads the settings from the Database and displays them
/// </summary>
/// -----------------------------------------------------------------------------
public override void LoadSettings()
{
try
{
if (!Page.IsPostBack)
{
if (Settings["SenderName"] != null)
txtSenderName.Text = (string) Settings["SenderName"];
if (Settings["SenderEmail"] != null)
txtSenderEmail.Text = (string) Settings["SenderEmail"];
else
txtSenderEmail.Text = Host.HostEmail;
if (Settings["RecipientEmail"] != null)
txtRecipientEmail.Text = (string)Settings["RecipientEmail"];
if (Settings["Interest"] != null)
txtInterests.Text = (string)Settings["Interest"];
if (Settings["Subject"] != null)
txtSubject.Text = (string) Settings["Subject"];
else
txtSubject.Text = "Contact form submission from [EMAIL]";
if (Settings["SendToUser"] != null)
chkFirstnameVisible.Checked = Convert.ToBoolean(Settings["SendToUser"]);
if (Settings["Bootstrap"] != null)
chkBootstrap.Checked = Convert.ToBoolean(Settings["Bootstrap"]);
if (Settings["Bodytext"] != null)
txtBodytext.Text = (string) Settings["Bodytext"];
else
txtBodytext.Text = "Contact form submission :\r\n\r\n" +
"Firstname : [FIRSTNAME]\r\n" +
"Lastname : [LASTNAME]\r\n" +
"Organization : [ORGANIZATION]\r\n" +
"Address : [ADDRESS]\r\n" +
"Phone : [PHONE]\r\n" +
"Fax : [FAX]\r\n" +
"Email : [EMAIL]\r\n" +
"Interest : [INTEREST]\r\n" +
"Product : [PRODUCT]\r\n" +
"Remarks : [REMARK]";
if (Settings["VisibleFirstname"] != null)
chkFirstnameVisible.Checked = Convert.ToBoolean(Settings["VisibleFirstname"]);
if (Settings["VisibleLastname"] != null)
chkLastnameVisible.Checked = Convert.ToBoolean(Settings["VisibleLastname"]);
if (Settings["VisibleOrganization"] != null)
chkOrganizationVisible.Checked = Convert.ToBoolean(Settings["VisibleOrganization"]);
if (Settings["VisibleAddress"] != null)
chkAddressVisible.Checked = Convert.ToBoolean(Settings["VisibleAddress"]);
if (Settings["VisiblePhone"] != null)
chkPhoneVisible.Checked = Convert.ToBoolean(Settings["VisiblePhone"]);
if (Settings["VisibleFax"] != null)
chkFaxVisible.Checked = Convert.ToBoolean(Settings["VisibleFax"]);
if (Settings["VisibleEmail"] != null)
chkEmailVisible.Checked = Convert.ToBoolean(Settings["VisibleEmail"]);
if (Settings["VisibleRemark"] != null)
chkRemarkVisible.Checked = Convert.ToBoolean(Settings["VisibleRemark"]);
if (Settings["VisibleInterest"] != null)
chkInterestVisible.Checked = Convert.ToBoolean(Settings["VisibleInterest"]);
if (Settings["VisibleProduct"] != null)
chkProductVisible.Checked = Convert.ToBoolean(Settings["VisibleProduct"]);
if (Settings["EnsureFirstname"] != null)
chkFirstnameMandatory.Checked = Convert.ToBoolean(Settings["EnsureFirstname"]);
if (Settings["EnsureLastname"] != null)
chkLastnameMandatory.Checked = Convert.ToBoolean(Settings["EnsureLastname"]);
if (Settings["EnsureOrganization"] != null)
chkOrganizationMandatory.Checked = Convert.ToBoolean(Settings["EnsureOrganization"]);
if (Settings["EnsureAddress"] != null)
chkAddressMandatory.Checked = Convert.ToBoolean(Settings["EnsureAddress"]);
if (Settings["EnsurePhone"] != null)
chkPhoneMandatory.Checked = Convert.ToBoolean(Settings["EnsurePhone"]);
if (Settings["EnsureFax"] != null)
chkFaxMandatory.Checked = Convert.ToBoolean(Settings["EnsureFax"]);
if (Settings["EnsureEmail"] != null)
chkEmailMandatory.Checked = Convert.ToBoolean(Settings["EnsureEmail"]);
if (Settings["EnsureRemark"] != null)
chkRemarkMandatory.Checked = Convert.ToBoolean(Settings["EnsureRemark"]);
if (Settings["EnsureInterest"] != null)
chkInterestMandatory.Checked = Convert.ToBoolean(Settings["EnsureInterest"]);
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
/// -----------------------------------------------------------------------------
/// <summary>
/// UpdateSettings saves the modified settings to the Database
/// </summary>
/// -----------------------------------------------------------------------------
public override void UpdateSettings()
{
try
{
ModuleController modules = new ModuleController();
modules.UpdateModuleSetting(this.ModuleId, "Bootstrap", chkBootstrap.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "SenderName", txtSenderName.Text.Trim());
modules.UpdateModuleSetting(this.ModuleId, "SenderEmail", txtSenderEmail.Text.Trim());
modules.UpdateModuleSetting(this.ModuleId, "RecipientEmail", txtRecipientEmail.Text.Trim());
modules.UpdateModuleSetting(this.ModuleId, "Subject", txtSubject.Text.Trim());
modules.UpdateModuleSetting(this.ModuleId, "SendToUser", chkSendToUser.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "Bodytext", txtBodytext.Text.Trim());
modules.UpdateModuleSetting(this.ModuleId, "Interest", txtInterests.Text.Trim());
modules.UpdateModuleSetting(this.ModuleId, "VisibleFirstname", chkFirstnameVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "VisibleLastname", chkLastnameVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "VisibleOrganization", chkOrganizationVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "VisibleAddress", chkAddressVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "VisiblePhone", chkPhoneVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "VisibleFax", chkFaxVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "VisibleEmail", chkEmailVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "VisibleRemark", chkRemarkVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "VisibleInterest", chkInterestVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "VisibleProduct", chkProductVisible.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "EnsureFirstname", chkFirstnameMandatory.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "EnsureLastname", chkLastnameMandatory.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "EnsureOrganization", chkOrganizationMandatory.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "EnsureAddress", chkAddressMandatory.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "EnsurePhone", chkPhoneMandatory.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "EnsureFax", chkFaxMandatory.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "EnsureEmail", chkEmailMandatory.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "EnsureRemark", chkRemarkMandatory.Checked.ToString());
modules.UpdateModuleSetting(this.ModuleId, "EnsureInterest", chkInterestMandatory.Checked.ToString());
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
#endregion
}
}