PageRenderTime 56ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/DesktopModules/Admin/Portals/SiteSettings.ascx.cs

https://github.com/mailekah/AgapeConnect1
C# | 1381 lines | 1010 code | 197 blank | 174 comment | 110 complexity | b88ebe32937148c01c8e3372a3859365 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. #region Copyright
  2. //
  3. // DotNetNukeŽ - http://www.dotnetnuke.com
  4. // Copyright (c) 2002-2012
  5. // by DotNetNuke Corporation
  6. //
  7. // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  8. // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
  9. // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
  10. // to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in all copies or substantial portions
  13. // of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
  16. // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  18. // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  19. // DEALINGS IN THE SOFTWARE.
  20. #endregion
  21. #region Usings
  22. using System;
  23. using System.Collections;
  24. using System.Collections.Generic;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Text;
  28. using System.Text.RegularExpressions;
  29. using System.Web.UI.WebControls;
  30. using DotNetNuke.Common.Lists;
  31. using DotNetNuke.Common.Utilities;
  32. using DotNetNuke.Data;
  33. using DotNetNuke.Entities.Controllers;
  34. using DotNetNuke.Entities.Host;
  35. using DotNetNuke.Entities.Modules;
  36. using DotNetNuke.Entities.Portals;
  37. using DotNetNuke.Entities.Profile;
  38. using DotNetNuke.Entities.Tabs;
  39. using DotNetNuke.Entities.Users;
  40. using DotNetNuke.Framework;
  41. using DotNetNuke.Security.Membership;
  42. using DotNetNuke.Security.Roles;
  43. using DotNetNuke.Services.Exceptions;
  44. using DotNetNuke.Services.Installer;
  45. using DotNetNuke.Services.Localization;
  46. using DotNetNuke.Services.Log.EventLog;
  47. using DotNetNuke.UI.Internals;
  48. using DotNetNuke.UI.Skins;
  49. using DotNetNuke.UI.Skins.Controls;
  50. using DotNetNuke.UI.Utilities;
  51. using DotNetNuke.UI.WebControls;
  52. using DotNetNuke.Web.Client.ClientResourceManagement;
  53. using DotNetNuke.Web.UI.WebControls;
  54. using DotNetNuke.Web.UI.WebControls.Extensions;
  55. using Calendar = DotNetNuke.Common.Utilities.Calendar;
  56. using DataCache = DotNetNuke.Common.Utilities.DataCache;
  57. using Globals = DotNetNuke.Common.Globals;
  58. #endregion
  59. namespace DotNetNuke.Modules.Admin.Portals
  60. {
  61. using System.Globalization;
  62. using System.Web;
  63. using Web.Client;
  64. /// -----------------------------------------------------------------------------
  65. /// <summary>
  66. /// The SiteSettings PortalModuleBase is used to edit the main settings for a
  67. /// portal.
  68. /// </summary>
  69. /// <remarks>
  70. /// </remarks>
  71. /// <history>
  72. /// [cnurse] 9/8/2004 Updated to reflect design changes for Help, 508 support
  73. /// and localisation
  74. /// </history>
  75. /// -----------------------------------------------------------------------------
  76. public partial class SiteSettings : PortalModuleBase
  77. {
  78. #region Private Members
  79. private int _portalId = -1;
  80. private string SelectedCultureCode
  81. {
  82. get
  83. {
  84. return LocaleController.Instance.GetCurrentLocale(PortalId).Code;
  85. }
  86. }
  87. #endregion
  88. #region Public Properties
  89. protected string CustomRegistrationFields { get; set; }
  90. #endregion
  91. #region Private Methods
  92. private void BindAliases(PortalInfo portal)
  93. {
  94. var portalSettings = new PortalSettings(portal);
  95. var portalAliasController = new PortalAliasController();
  96. var aliases = portalAliasController.GetPortalAliasArrayByPortalID(portal.PortalID);
  97. var portalAliasMapping = portalSettings.PortalAliasMappingMode.ToString().ToUpper();
  98. if (String.IsNullOrEmpty(portalAliasMapping))
  99. {
  100. portalAliasMapping = "CANONICALURL";
  101. }
  102. portalAliasModeButtonList.Select(portalAliasMapping, false);
  103. BindDefaultAlias(aliases);
  104. //Auto Add Portal Alias
  105. if (new PortalController().GetPortals().Count > 1)
  106. {
  107. chkAutoAddPortalAlias.Enabled = false;
  108. chkAutoAddPortalAlias.Checked = false;
  109. }
  110. else
  111. {
  112. chkAutoAddPortalAlias.Checked = HostController.Instance.GetBoolean("AutoAddPortalAlias");
  113. }
  114. }
  115. private void BindDefaultAlias(ArrayList aliases)
  116. {
  117. defaultAliasDropDown.DataSource = aliases;
  118. defaultAliasDropDown.DataBind();
  119. var defaultAlias = PortalController.GetPortalSetting("DefaultPortalAlias", _portalId, "");
  120. if (defaultAliasDropDown.Items.FindByValue(defaultAlias) != null)
  121. {
  122. defaultAliasDropDown.Items.FindByValue(defaultAlias).Selected = true;
  123. }
  124. }
  125. private void BindDesktopModules()
  126. {
  127. var dicModules = DesktopModuleController.GetDesktopModules(Null.NullInteger);
  128. var dicPortalDesktopModules = DesktopModuleController.GetPortalDesktopModulesByPortalID(_portalId);
  129. foreach (var objPortalDesktopModule in dicPortalDesktopModules.Values)
  130. {
  131. dicModules.Remove(objPortalDesktopModule.DesktopModuleID);
  132. }
  133. ctlDesktopModules.AvailableDataSource = dicModules.Values;
  134. ctlDesktopModules.SelectedDataSource = dicPortalDesktopModules.Values;
  135. }
  136. private void BindDetails(PortalInfo portal)
  137. {
  138. if (portal != null)
  139. {
  140. txtPortalName.Text = portal.PortalName;
  141. txtDescription.Text = portal.Description;
  142. txtKeyWords.Text = portal.KeyWords;
  143. lblGUID.Text = portal.GUID.ToString().ToUpper();
  144. txtFooterText.Text = portal.FooterText;
  145. }
  146. }
  147. private void BindHostSettings(PortalInfo portal)
  148. {
  149. if (!Null.IsNull(portal.ExpiryDate))
  150. {
  151. datepickerExpiryDate.SelectedDate = portal.ExpiryDate;
  152. }
  153. txtHostFee.Text = portal.HostFee.ToString();
  154. txtHostSpace.Text = portal.HostSpace.ToString();
  155. txtPageQuota.Text = portal.PageQuota.ToString();
  156. txtUserQuota.Text = portal.UserQuota.ToString();
  157. if (portal.SiteLogHistory != Null.NullInteger)
  158. {
  159. txtSiteLogHistory.Text = portal.SiteLogHistory.ToString();
  160. }
  161. }
  162. private void BindMarketing(PortalInfo portal)
  163. {
  164. //Load DocTypes
  165. var searchEngines = new Dictionary<string, string>
  166. {
  167. { "Google", "http://www.google.com/addurl?q=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request))) },
  168. { "Yahoo", "http://siteexplorer.search.yahoo.com/submit" },
  169. { "Microsoft", "http://search.msn.com.sg/docs/submit.aspx" }
  170. };
  171. cboSearchEngine.DataSource = searchEngines;
  172. cboSearchEngine.DataBind();
  173. var portalAliasController = new PortalAliasController();
  174. var aliases = portalAliasController.GetPortalAliasArrayByPortalID(portal.PortalID);
  175. if (PortalController.IsChildPortal(portal, Globals.GetAbsoluteServerPath(Request)))
  176. {
  177. txtSiteMap.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/SiteMap.aspx?portalid=" + portal.PortalID;
  178. }
  179. else
  180. {
  181. if (aliases.Count > 0)
  182. {
  183. //Get the first Alias
  184. var objPortalAliasInfo = (PortalAliasInfo)aliases[0];
  185. txtSiteMap.Text = Globals.AddHTTP(objPortalAliasInfo.HTTPAlias) + @"/SiteMap.aspx";
  186. }
  187. else
  188. {
  189. txtSiteMap.Text = Globals.AddHTTP(Globals.GetDomainName(Request)) + @"/SiteMap.aspx";
  190. }
  191. }
  192. optBanners.SelectedIndex = portal.BannerAdvertising;
  193. if (UserInfo.IsSuperUser)
  194. {
  195. lblBanners.Visible = false;
  196. }
  197. else
  198. {
  199. optBanners.Enabled = portal.BannerAdvertising != 2;
  200. lblBanners.Visible = portal.BannerAdvertising == 2;
  201. }
  202. }
  203. private void BindMessaging(PortalInfo portal)
  204. {
  205. var throttlingIntervals = new Dictionary<int, int>
  206. {
  207. { 0, 0 }, { 1, 1 }, { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, { 7, 7 }, { 8, 8 }, { 9, 9 }, { 10, 10 }
  208. };
  209. cboMsgThrottlingInterval.DataSource = throttlingIntervals;
  210. cboMsgThrottlingInterval.DataBind(PortalController.GetPortalSettingAsInteger("MessagingThrottlingInterval", portal.PortalID, 0).ToString());
  211. var recipientLimits = new Dictionary<int, int>
  212. {
  213. { 1, 1 }, { 5, 5 }, { 10, 10 }, { 15, 15 }, { 25, 25 }, { 50, 50 }, { 75, 75 }, { 100, 100 }
  214. };
  215. cboMsgRecipientLimit.DataSource = recipientLimits;
  216. cboMsgRecipientLimit.DataBind(PortalController.GetPortalSettingAsInteger("MessagingRecipientLimit", portal.PortalID, 5).ToString());
  217. optMsgAllowAttachments.Select(PortalController.GetPortalSetting("MessagingAllowAttachments", portal.PortalID, "NO"), false);
  218. optMsgProfanityFilters.Select(PortalController.GetPortalSetting("MessagingProfanityFilters", portal.PortalID, "NO"), false);
  219. }
  220. private void BindPages(PortalInfo portal, string activeLanguage)
  221. {
  222. //Set up special page lists
  223. List<TabInfo> listTabs = TabController.GetPortalTabs(TabController.GetTabsBySortOrder(portal.PortalID, activeLanguage, true),
  224. Null.NullInteger,
  225. true,
  226. "<" + Localization.GetString("None_Specified") + ">",
  227. true,
  228. false,
  229. false,
  230. false,
  231. false);
  232. List<TabInfo> tabs = listTabs.Where(t => t.DisableLink == false).ToList();
  233. cboSplashTabId.DataSource = tabs;
  234. cboSplashTabId.DataBind(portal.SplashTabId.ToString());
  235. cboHomeTabId.DataSource = tabs;
  236. cboHomeTabId.DataBind(portal.HomeTabId.ToString());
  237. cboLoginTabId.DataSource = tabs;
  238. cboLoginTabId.DataBind(portal.LoginTabId.ToString());
  239. cboRegisterTabId.DataSource = tabs;
  240. cboRegisterTabId.DataBind(portal.RegisterTabId.ToString());
  241. cboSearchTabId.DataSource = tabs;
  242. cboSearchTabId.DataBind(portal.SearchTabId.ToString());
  243. listTabs = TabController.GetPortalTabs(portal.PortalID, Null.NullInteger, false, true);
  244. cboUserTabId.DataSource = listTabs;
  245. cboUserTabId.DataBind(portal.UserTabId.ToString());
  246. DisableInvalidLoginTabs();
  247. }
  248. private void DisableInvalidLoginTabs()
  249. {
  250. foreach (ListItem item in cboLoginTabId.Items)
  251. {
  252. var tabId = int.Parse(item.Value);
  253. if(tabId != Null.NullInteger && !Globals.ValidateLoginTabID(tabId))
  254. {
  255. item.Attributes.Add("disabled", "disabled");
  256. }
  257. }
  258. }
  259. private void BindPaymentProcessor(PortalInfo portal)
  260. {
  261. var listController = new ListController();
  262. currencyCombo.DataSource = listController.GetListEntryInfoItems("Currency", "");
  263. var currency = portal.Currency;
  264. if (String.IsNullOrEmpty(currency))
  265. {
  266. currency = "USD";
  267. }
  268. currencyCombo.DataBind(currency);
  269. processorCombo.DataSource = listController.GetListEntryInfoItems("Processor", "");
  270. processorCombo.DataBind();
  271. processorCombo.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", "");
  272. processorCombo.Select(Host.PaymentProcessor, true);
  273. // use sandbox?
  274. var usePayPalSandbox = Boolean.Parse(PortalController.GetPortalSetting("paypalsandbox", portal.PortalID, "false"));
  275. chkPayPalSandboxEnabled.Checked = usePayPalSandbox;
  276. if (usePayPalSandbox)
  277. {
  278. processorLink.NavigateUrl = "https://developer.paypal.com";
  279. }
  280. else
  281. {
  282. processorLink.NavigateUrl = Globals.AddHTTP(processorCombo.SelectedItem.Value);
  283. }
  284. txtUserId.Text = portal.ProcessorUserId;
  285. txtPassword.Attributes.Add("value", portal.ProcessorPassword);
  286. // return url after payment or on cancel
  287. string strPayPalReturnURL = PortalController.GetPortalSetting("paypalsubscriptionreturn", portal.PortalID, Null.NullString);
  288. txtPayPalReturnURL.Text = strPayPalReturnURL;
  289. string strPayPalCancelURL = PortalController.GetPortalSetting("paypalsubscriptioncancelreturn", portal.PortalID, Null.NullString);
  290. txtPayPalCancelURL.Text = strPayPalCancelURL;
  291. }
  292. private void BindPortal(int portalId, string activeLanguage)
  293. {
  294. //Ensure localization
  295. DataProvider.Instance().EnsureLocalizationExists(portalId, activeLanguage);
  296. var portalController = new PortalController();
  297. var portal = portalController.GetPortal(portalId, activeLanguage);
  298. BindDetails(portal);
  299. BindMarketing(portal);
  300. ctlLogo.FilePath = portal.LogoFile;
  301. ctlLogo.FileFilter = Globals.glbImageFileTypes;
  302. ctlBackground.FilePath = portal.BackgroundFile;
  303. ctlBackground.FileFilter = Globals.glbImageFileTypes;
  304. ctlFavIcon.FilePath = new FavIcon(portal.PortalID).GetSettingPath();
  305. chkSkinWidgestEnabled.Checked = PortalController.GetPortalSettingAsBoolean("EnableSkinWidgets", portalId, true);
  306. BindSkins(portal);
  307. BindPages(portal, activeLanguage);
  308. lblHomeDirectory.Text = portal.HomeDirectory;
  309. optUserRegistration.SelectedIndex = portal.UserRegistration;
  310. BindPaymentProcessor(portal);
  311. BindUsability(portal);
  312. BindMessaging(portal);
  313. var roleController = new RoleController();
  314. cboAdministratorId.DataSource = roleController.GetUserRoles(portalId, null, portal.AdministratorRoleName);
  315. cboAdministratorId.DataBind(portal.AdministratorId.ToString());
  316. //PortalSettings for portal being edited
  317. var portalSettings = new PortalSettings(portal);
  318. cboTimeZone.DataBind(portalSettings.TimeZone.Id);
  319. if (UserInfo.IsSuperUser)
  320. {
  321. BindAliases(portal);
  322. BindSSLSettings(portal);
  323. BindHostSettings(portal);
  324. }
  325. LoadStyleSheet(portal);
  326. ctlAudit.Entity = portal;
  327. var overrideDefaultSettings = Boolean.Parse(PortalController.GetPortalSetting(ClientResourceSettings.OverrideDefaultSettingsKey, portalId, "false"));
  328. chkOverrideDefaultSettings.Checked = overrideDefaultSettings;
  329. BindClientResourceManagementUi(portal.PortalID, overrideDefaultSettings);
  330. ManageMinificationUi();
  331. }
  332. private void BindClientResourceManagementUi(int portalId, bool overrideDefaultSettings)
  333. {
  334. EnableCompositeFilesRow.Visible = overrideDefaultSettings;
  335. CrmVersionRow.Visible = overrideDefaultSettings;
  336. MinifyCssRow.Visible = overrideDefaultSettings;
  337. MinifyJsRow.Visible = overrideDefaultSettings;
  338. DebugEnabledRow.Visible = HttpContext.Current.IsDebuggingEnabled;
  339. // set up host settings information
  340. var hostVersion = HostController.Instance.GetInteger(ClientResourceSettings.VersionKey, 1).ToString(CultureInfo.InvariantCulture);
  341. var hostEnableCompositeFiles = HostController.Instance.GetBoolean(ClientResourceSettings.EnableCompositeFilesKey, false);
  342. var hostEnableMinifyCss = HostController.Instance.GetBoolean(ClientResourceSettings.MinifyCssKey, false);
  343. var hostEnableMinifyJs = HostController.Instance.GetBoolean(ClientResourceSettings.MinifyJsKey, false);
  344. string yes = Localization.GetString("Yes.Text", Localization.SharedResourceFile);
  345. string no = Localization.GetString("No.Text", Localization.SharedResourceFile);
  346. CrmHostSettingsSummary.Text = string.Format(LocalizeString("CrmHostSettingsSummary"),
  347. hostVersion, // {0} = version
  348. hostEnableCompositeFiles ? yes : no, // {1} = enable composite files
  349. hostEnableMinifyCss ? yes : no, // {2} = minify css
  350. hostEnableMinifyJs ? yes : no); // {3} = minify js
  351. // set up UI for portal-specific options
  352. if (overrideDefaultSettings)
  353. {
  354. chkEnableCompositeFiles.Checked = Boolean.Parse(PortalController.GetPortalSetting(ClientResourceSettings.EnableCompositeFilesKey, portalId, "false"));
  355. chkMinifyCss.Checked = Boolean.Parse(PortalController.GetPortalSetting(ClientResourceSettings.MinifyCssKey, portalId, "false"));
  356. chkMinifyJs.Checked = Boolean.Parse(PortalController.GetPortalSetting(ClientResourceSettings.MinifyJsKey, portalId, "false"));
  357. var settingValue = PortalController.GetPortalSetting(ClientResourceSettings.VersionKey, portalId, "0");
  358. int version;
  359. if (int.TryParse(settingValue, out version))
  360. {
  361. if (version == 0)
  362. {
  363. version = 1;
  364. PortalController.UpdatePortalSetting(portalId, ClientResourceSettings.VersionKey, "1", true);
  365. }
  366. CrmVersionLabel.Text = version.ToString(CultureInfo.InvariantCulture);
  367. }
  368. }
  369. }
  370. private void BindSkins(PortalInfo portal)
  371. {
  372. var skins = SkinController.GetSkins(portal, SkinController.RootSkin, SkinScope.All)
  373. .ToDictionary(skin => skin.Key, skin => skin.Value);
  374. var containers = SkinController.GetSkins(portal, SkinController.RootContainer, SkinScope.All)
  375. .ToDictionary(skin => skin.Key, skin => skin.Value);
  376. portalSkinCombo.DataSource = skins;
  377. portalSkinCombo.DataBind(PortalController.GetPortalSetting("DefaultPortalSkin", portal.PortalID, Host.DefaultPortalSkin));
  378. portalContainerCombo.DataSource = containers;
  379. portalContainerCombo.DataBind(PortalController.GetPortalSetting("DefaultPortalContainer", portal.PortalID, Host.DefaultPortalContainer));
  380. editSkinCombo.DataSource = skins;
  381. editSkinCombo.DataBind(PortalController.GetPortalSetting("DefaultAdminSkin", portal.PortalID, Host.DefaultAdminSkin));
  382. editContainerCombo.DataSource = containers;
  383. editContainerCombo.DataBind(PortalController.GetPortalSetting("DefaultAdminContainer", portal.PortalID, Host.DefaultAdminContainer));
  384. if (ModuleContext.PortalSettings.UserInfo.IsSuperUser)
  385. {
  386. uploadSkinLink.NavigateUrl = Util.InstallURL(ModuleContext.TabId, "");
  387. if (PortalSettings.EnablePopUps)
  388. {
  389. uploadSkinLink.Attributes.Add("onclick", "return " + UrlUtils.PopUpUrl(uploadSkinLink.NavigateUrl, this, PortalSettings, true, false));
  390. }
  391. }
  392. else
  393. {
  394. uploadSkinLink.Visible = false;
  395. }
  396. }
  397. private void BindSSLSettings(PortalInfo portal)
  398. {
  399. chkSSLEnabled.Checked = PortalController.GetPortalSettingAsBoolean("SSLEnabled", portal.PortalID, false);
  400. chkSSLEnforced.Checked = PortalController.GetPortalSettingAsBoolean("SSLEnforced", portal.PortalID, false);
  401. txtSSLURL.Text = PortalController.GetPortalSetting("SSLURL", portal.PortalID, Null.NullString);
  402. txtSTDURL.Text = PortalController.GetPortalSetting("STDURL", portal.PortalID, Null.NullString);
  403. }
  404. private void BindUsability(PortalInfo portal)
  405. {
  406. //PortalSettings for portal being edited
  407. var portalSettings = new PortalSettings(portal);
  408. chkInlineEditor.Checked = portalSettings.InlineEditorEnabled;
  409. enablePopUpsCheckBox.Checked = portalSettings.EnablePopUps;
  410. chkHideSystemFolders.Checked = portalSettings.HideFoldersEnabled;
  411. var mode = (portalSettings.DefaultControlPanelMode == PortalSettings.Mode.Edit) ? "EDIT" : "VIEW";
  412. optControlPanelMode.Select(mode, false);
  413. optControlPanelVisibility.Select(PortalController.GetPortalSetting("ControlPanelVisibility", portal.PortalID, "MAX"), false);
  414. optControlPanelSecurity.Select(PortalController.GetPortalSetting("ControlPanelSecurity", portal.PortalID, "MODULE"), false);
  415. }
  416. private void BindUserAccountSettings(int portalId)
  417. {
  418. if (!Page.IsPostBack)
  419. {
  420. var settings = UserController.GetUserSettings(portalId);
  421. var providerConfig = new MembershipProviderConfig();
  422. basicRegistrationSettings.DataSource = settings;
  423. basicRegistrationSettings.DataBind();
  424. int setting = PortalController.GetPortalSettingAsInteger("Registration_RegistrationFormType", portalId, 0);
  425. registrationFormType.Select(setting.ToString(CultureInfo.InvariantCulture));
  426. standardRegistrationSettings.DataSource = settings;
  427. standardRegistrationSettings.DataBind();
  428. validationRegistrationSettings.DataSource = settings;
  429. validationRegistrationSettings.DataBind();
  430. var customRegistrationFields = PortalController.GetPortalSetting("Registration_RegistrationFields", portalId, String.Empty);
  431. CustomRegistrationFields = BuildCustomRegistrationFields(customRegistrationFields);
  432. passwordRegistrationSettings.DataSource = settings;
  433. passwordRegistrationSettings.DataBind();
  434. otherRegistrationSettings.DataSource = settings;
  435. otherRegistrationSettings.DataBind();
  436. PasswordFormatLabel.Text = MembershipProviderConfig.PasswordFormat.ToString();
  437. PasswordRetrievalEnabledLabel.Text = MembershipProviderConfig.PasswordRetrievalEnabled.ToString(CultureInfo.InvariantCulture);
  438. PasswordResetEnabledLabel.Text = MembershipProviderConfig.PasswordResetEnabled.ToString(CultureInfo.InvariantCulture);
  439. MinPasswordLengthLabel.Text = MembershipProviderConfig.MinPasswordLength.ToString(CultureInfo.InvariantCulture);
  440. MinNonAlphanumericCharactersLabel.Text = MembershipProviderConfig.MinNonAlphanumericCharacters.ToString(CultureInfo.InvariantCulture);
  441. RequiresQuestionAndAnswerLabel.Text = MembershipProviderConfig.RequiresQuestionAndAnswer.ToString(CultureInfo.InvariantCulture);
  442. PasswordStrengthRegularExpressionLabel.Text = MembershipProviderConfig.PasswordStrengthRegularExpression;
  443. MaxInvalidPasswordAttemptsLabel.Text = MembershipProviderConfig.MaxInvalidPasswordAttempts.ToString(CultureInfo.InvariantCulture);
  444. PasswordAttemptWindowLabel.Text = MembershipProviderConfig.PasswordAttemptWindow.ToString(CultureInfo.InvariantCulture);
  445. loginSettings.DataSource = settings;
  446. loginSettings.DataBind();
  447. userVisiblity.EnumType = "DotNetNuke.Entities.Users.UserVisibilityMode, DotNetNuke";
  448. profileSettings.DataSource = settings;
  449. profileSettings.DataBind();
  450. }
  451. else
  452. {
  453. CustomRegistrationFields = BuildCustomRegistrationFields(registrationFields.Text);
  454. }
  455. passwordSettings.EditMode = UserInfo.IsSuperUser ? PropertyEditorMode.Edit : PropertyEditorMode.View;
  456. passwordSettings.LocalResourceFile = LocalResourceFile;
  457. passwordSettings.DataSource = new PasswordConfig();
  458. passwordSettings.DataBind();
  459. }
  460. private string BuildCustomRegistrationFields(string customRegistrationFields)
  461. {
  462. if (!String.IsNullOrEmpty(customRegistrationFields))
  463. {
  464. var sb = new StringBuilder();
  465. sb.Append("[ ");
  466. int i = 0;
  467. foreach (var field in customRegistrationFields.Split(','))
  468. {
  469. if (i != 0) sb.Append(",");
  470. sb.Append("{ id: \"" + field + "\", name: \"" + field + "\"}");
  471. i++;
  472. }
  473. sb.Append(" ]");
  474. return sb.ToString();
  475. }
  476. return "null";
  477. }
  478. /// -----------------------------------------------------------------------------
  479. /// <summary>
  480. /// LoadStyleSheet loads the stylesheet
  481. /// </summary>
  482. /// <remarks>
  483. /// </remarks>
  484. /// <history>
  485. /// [cnurse] 9/8/2004 Created
  486. /// </history>
  487. /// -----------------------------------------------------------------------------
  488. private void LoadStyleSheet(PortalInfo portalInfo)
  489. {
  490. string uploadDirectory = "";
  491. if (portalInfo != null)
  492. {
  493. uploadDirectory = portalInfo.HomeDirectoryMapPath;
  494. }
  495. //read CSS file
  496. if (File.Exists(uploadDirectory + "portal.css"))
  497. {
  498. using (var text = File.OpenText(uploadDirectory + "portal.css"))
  499. {
  500. txtStyleSheet.Text = text.ReadToEnd();
  501. }
  502. }
  503. }
  504. #endregion
  505. #region Protected Methods
  506. /// -----------------------------------------------------------------------------
  507. /// <summary>
  508. /// FormatCurrency formats the currency.
  509. /// control.
  510. /// </summary>
  511. /// <returns>A formatted string</returns>
  512. /// <remarks>
  513. /// </remarks>
  514. /// <history>
  515. /// [cnurse] 9/8/2004 Modified
  516. /// </history>
  517. /// -----------------------------------------------------------------------------
  518. protected string FormatCurrency()
  519. {
  520. string retValue = "";
  521. try
  522. {
  523. retValue = Host.HostCurrency + " / " + Localization.GetString("Month");
  524. }
  525. catch (Exception exc)
  526. {
  527. Exceptions.ProcessModuleLoadException(this, exc);
  528. }
  529. return retValue;
  530. }
  531. /// -----------------------------------------------------------------------------
  532. /// <summary>
  533. /// FormatFee formats the fee.
  534. /// control.
  535. /// </summary>
  536. /// <returns>A formatted string</returns>
  537. /// <remarks>
  538. /// </remarks>
  539. /// <history>
  540. /// [cnurse] 9/8/2004 Modified
  541. /// </history>
  542. /// -----------------------------------------------------------------------------
  543. protected string FormatFee(object objHostFee)
  544. {
  545. var retValue = "";
  546. try
  547. {
  548. retValue = objHostFee != DBNull.Value ? ((float)objHostFee).ToString("#,##0.00") : "0";
  549. }
  550. catch (Exception exc)
  551. {
  552. Exceptions.ProcessModuleLoadException(this, exc);
  553. }
  554. return retValue;
  555. }
  556. /// -----------------------------------------------------------------------------
  557. /// <summary>
  558. /// IsSubscribed determines whether the portal has subscribed to the premium
  559. /// control.
  560. /// </summary>
  561. /// <returns>True if Subscribed, False if not</returns>
  562. /// <remarks>
  563. /// </remarks>
  564. /// <history>
  565. /// [cnurse] 9/8/2004 Modified
  566. /// </history>
  567. /// -----------------------------------------------------------------------------
  568. protected bool IsSubscribed(int portalModuleDefinitionId)
  569. {
  570. try
  571. {
  572. return Null.IsNull(portalModuleDefinitionId) == false;
  573. }
  574. catch (Exception exc)
  575. {
  576. Exceptions.ProcessModuleLoadException(this, exc);
  577. return false;
  578. }
  579. }
  580. /// -----------------------------------------------------------------------------
  581. /// <summary>
  582. /// IsSuperUser determines whether the cuurent user is a SuperUser
  583. /// control.
  584. /// </summary>
  585. /// <returns>True if SuperUser, False if not</returns>
  586. /// <remarks>
  587. /// </remarks>
  588. /// <history>
  589. /// [cnurse] 10/4/2004 Added
  590. /// </history>
  591. /// -----------------------------------------------------------------------------
  592. protected bool IsSuperUser()
  593. {
  594. return UserInfo.IsSuperUser;
  595. }
  596. protected string AddPortalAlias(string portalAlias, int portalID)
  597. {
  598. if (!String.IsNullOrEmpty(portalAlias))
  599. {
  600. if (portalAlias.IndexOf("://") != -1)
  601. {
  602. portalAlias = portalAlias.Remove(0, portalAlias.IndexOf("://") + 3);
  603. }
  604. var objPortalAliasController = new PortalAliasController();
  605. var objPortalAlias = objPortalAliasController.GetPortalAlias(portalAlias, portalID);
  606. if (objPortalAlias == null)
  607. {
  608. objPortalAlias = new PortalAliasInfo { PortalID = portalID, HTTPAlias = portalAlias };
  609. objPortalAliasController.AddPortalAlias(objPortalAlias);
  610. }
  611. }
  612. return portalAlias;
  613. }
  614. #endregion
  615. #region Event Handlers
  616. protected override void OnInit(EventArgs e)
  617. {
  618. base.OnInit(e);
  619. jQuery.RequestDnnPluginsRegistration();
  620. ServicesFramework.Instance.RequestAjaxAntiForgerySupport();
  621. chkPayPalSandboxEnabled.CheckedChanged += OnChkPayPalSandboxChanged;
  622. IncrementCrmVersionButton.Click += IncrementCrmVersion;
  623. chkOverrideDefaultSettings.CheckedChanged += OverrideDefaultSettingsChanged;
  624. ctlDesktopModules.LocalResourceFile = LocalResourceFile;
  625. chkEnableCompositeFiles.CheckedChanged += EnableCompositeFilesChanged;
  626. }
  627. private void EnableCompositeFilesChanged(object sender, EventArgs e)
  628. {
  629. ManageMinificationUi();
  630. }
  631. private void ManageMinificationUi()
  632. {
  633. var enableCompositeFiles = chkEnableCompositeFiles.Checked;
  634. if (!enableCompositeFiles)
  635. {
  636. chkMinifyCss.Checked = false;
  637. chkMinifyJs.Checked = false;
  638. }
  639. chkMinifyCss.Enabled = enableCompositeFiles;
  640. chkMinifyJs.Enabled = enableCompositeFiles;
  641. }
  642. private void OverrideDefaultSettingsChanged(object sender, EventArgs e)
  643. {
  644. BindClientResourceManagementUi(_portalId, chkOverrideDefaultSettings.Checked);
  645. }
  646. private void IncrementCrmVersion(object sender, EventArgs e)
  647. {
  648. PortalController.IncrementCrmVersion(_portalId);
  649. Response.Redirect(Request.RawUrl, true); // reload page
  650. }
  651. /// -----------------------------------------------------------------------------
  652. /// <summary>
  653. /// Page_Load runs when the control is loaded
  654. /// </summary>
  655. /// <remarks>
  656. /// </remarks>
  657. /// <history>
  658. /// [cnurse] 9/8/2004 Updated to reflect design changes for Help, 508 support
  659. /// and localisation
  660. /// </history>
  661. /// -----------------------------------------------------------------------------
  662. protected override void OnLoad(EventArgs e)
  663. {
  664. base.OnLoad(e);
  665. cmdDelete.Click += DeletePortal;
  666. cmdRestore.Click += OnRestoreClick;
  667. cmdSave.Click += OnSaveClick;
  668. cmdUpdate.Click += UpdatePortal;
  669. cmdVerification.Click += OnVerifyClick;
  670. ctlDesktopModules.AddAllButtonClick += OnAddAllModulesClick;
  671. ctlDesktopModules.AddButtonClick += OnAddModuleClick;
  672. ctlDesktopModules.RemoveAllButtonClick += OnRemoveAllModulesClick;
  673. ctlDesktopModules.RemoveButtonClick += OnRemoveModuleClick;
  674. portalAliases.AliasChanged += OnPortalAliasesChanged;
  675. try
  676. {
  677. if ((Request.QueryString["pid"] != null) && (Globals.IsHostTab(PortalSettings.ActiveTab.TabID) || UserInfo.IsSuperUser))
  678. {
  679. _portalId = Int32.Parse(Request.QueryString["pid"]);
  680. ctlLogo.ShowUpLoad = false;
  681. ctlBackground.ShowUpLoad = false;
  682. ctlFavIcon.ShowUpLoad = false;
  683. cancelHyperLink.Visible = true;
  684. cancelHyperLink.NavigateUrl = Globals.NavigateURL();
  685. }
  686. else
  687. {
  688. _portalId = PortalId;
  689. ctlLogo.ShowUpLoad = true;
  690. ctlBackground.ShowUpLoad = true;
  691. ctlFavIcon.ShowUpLoad = true;
  692. cancelHyperLink.Visible = false;
  693. }
  694. ////this needs to execute always to the client script code is registred in InvokePopupCal
  695. //cmdExpiryCalendar.NavigateUrl = Calendar.InvokePopupCal(txtExpiryDate);
  696. BindDesktopModules();
  697. //If this is the first visit to the page, populate the site data
  698. if (Page.IsPostBack == false)
  699. {
  700. BindPortal(_portalId, SelectedCultureCode);
  701. }
  702. BindUserAccountSettings(_portalId);
  703. if (UserInfo.IsSuperUser)
  704. {
  705. hostSections.Visible = true;
  706. cmdDelete.Visible = (_portalId != PortalId && !PortalController.IsMemberOfPortalGroup(_portalId));
  707. }
  708. else
  709. {
  710. hostSections.Visible = false;
  711. cmdDelete.Visible = false;
  712. }
  713. }
  714. catch (Exception exc)
  715. {
  716. Exceptions.ProcessModuleLoadException(this, exc);
  717. }
  718. }
  719. /// -----------------------------------------------------------------------------
  720. /// <summary>
  721. /// cmdDelete_Click runs when the Delete LinkButton is clicked.
  722. /// It deletes the current portal form the Database. It can only run in Host
  723. /// (SuperUser) mode
  724. /// </summary>
  725. /// <remarks>
  726. /// </remarks>
  727. /// <history>
  728. /// [cnurse] 9/9/2004 Modified
  729. /// [VMasanas] 9/12/2004 Move skin deassignment to DeletePortalInfo.
  730. /// [jmarino] 16/06/2011 Modify redirection after deletion of portal
  731. /// </history>
  732. /// -----------------------------------------------------------------------------
  733. protected void DeletePortal(object sender, EventArgs e)
  734. {
  735. try
  736. {
  737. var objPortalController = new PortalController();
  738. PortalInfo objPortalInfo = objPortalController.GetPortal(_portalId);
  739. if (objPortalInfo != null)
  740. {
  741. string strMessage = PortalController.DeletePortal(objPortalInfo, Globals.GetAbsoluteServerPath(Request));
  742. if (string.IsNullOrEmpty(strMessage))
  743. {
  744. var objEventLog = new EventLogController();
  745. objEventLog.AddLog("PortalName", objPortalInfo.PortalName, PortalSettings, UserId, EventLogController.EventLogType.PORTAL_DELETED);
  746. //Redirect to another site
  747. if (_portalId == PortalId)
  748. {
  749. if (!string.IsNullOrEmpty(Host.HostURL))
  750. {
  751. Response.Redirect(Globals.AddHTTP(Host.HostURL));
  752. }
  753. else
  754. {
  755. Response.End();
  756. }
  757. }
  758. else
  759. {
  760. if (ViewState["UrlReferrer"] != null)
  761. {
  762. Response.Redirect(Convert.ToString(ViewState["UrlReferrer"]), true);
  763. }
  764. else
  765. {
  766. Response.Redirect(Globals.NavigateURL(), true);
  767. }
  768. }
  769. }
  770. else
  771. {
  772. UI.Skins.Skin.AddModuleMessage(this, strMessage, ModuleMessage.ModuleMessageType.RedError);
  773. }
  774. }
  775. }
  776. catch (Exception exc)
  777. {
  778. Exceptions.ProcessModuleLoadException(this, exc);
  779. }
  780. }
  781. /// -----------------------------------------------------------------------------
  782. /// <summary>
  783. /// cmdRestore_Click runs when the Restore Default Stylesheet Linkbutton is clicked.
  784. /// It reloads the default stylesheet (copies from _default Portal to current Portal)
  785. /// </summary>
  786. /// <remarks>
  787. /// </remarks>
  788. /// <history>
  789. /// [cnurse] 9/9/2004 Modified
  790. /// </history>
  791. /// -----------------------------------------------------------------------------
  792. protected void OnRestoreClick(object sender, EventArgs e)
  793. {
  794. try
  795. {
  796. var portalController = new PortalController();
  797. PortalInfo portal = portalController.GetPortal(_portalId);
  798. if (portal != null)
  799. {
  800. if (File.Exists(portal.HomeDirectoryMapPath + "portal.css"))
  801. {
  802. //delete existing style sheet
  803. File.Delete(portal.HomeDirectoryMapPath + "portal.css");
  804. }
  805. //copy file from Host
  806. if (File.Exists(Globals.HostMapPath + "portal.css"))
  807. {
  808. File.Copy(Globals.HostMapPath + "portal.css", portal.HomeDirectoryMapPath + "portal.css");
  809. }
  810. }
  811. LoadStyleSheet(portal);
  812. }
  813. catch (Exception exc)
  814. {
  815. Exceptions.ProcessModuleLoadException(this, exc);
  816. }
  817. }
  818. /// -----------------------------------------------------------------------------
  819. /// <summary>
  820. /// cmdSave_Click runs when the Save Stylesheet Linkbutton is clicked. It saves
  821. /// the edited Stylesheet
  822. /// </summary>
  823. /// <remarks>
  824. /// </remarks>
  825. /// <history>
  826. /// [cnurse] 9/9/2004 Modified
  827. /// </history>
  828. /// -----------------------------------------------------------------------------
  829. protected void OnSaveClick(object sender, EventArgs e)
  830. {
  831. try
  832. {
  833. string strUploadDirectory = "";
  834. var objPortalController = new PortalController();
  835. PortalInfo objPortal = objPortalController.GetPortal(_portalId);
  836. if (objPortal != null)
  837. {
  838. strUploadDirectory = objPortal.HomeDirectoryMapPath;
  839. }
  840. //reset attributes
  841. if (File.Exists(strUploadDirectory + "portal.css"))
  842. {
  843. File.SetAttributes(strUploadDirectory + "portal.css", FileAttributes.Normal);
  844. }
  845. //write CSS file
  846. using (var writer = File.CreateText(strUploadDirectory + "portal.css"))
  847. {
  848. writer.WriteLine(txtStyleSheet.Text);
  849. }
  850. //Clear client resource cache
  851. var overrideSetting = PortalController.GetPortalSetting(ClientResourceSettings.OverrideDefaultSettingsKey, _portalId, "False");
  852. bool overridePortal;
  853. if (bool.TryParse(overrideSetting, out overridePortal))
  854. {
  855. if (overridePortal)
  856. {
  857. // increment this portal version only
  858. PortalController.IncrementCrmVersion(_portalId);
  859. }
  860. else
  861. {
  862. // increment host version, do not increment other portal versions though.
  863. HostController.Instance.IncrementCrmVersion(false);
  864. }
  865. }
  866. }
  867. catch (Exception exc) //Module failed to load
  868. {
  869. Exceptions.ProcessModuleLoadException(this, exc);
  870. }
  871. }
  872. /// -----------------------------------------------------------------------------
  873. /// <summary>
  874. /// cmdUpdate_Click runs when the Update LinkButton is clicked.
  875. /// It saves the current Site Settings
  876. /// </summary>
  877. /// <remarks>
  878. /// </remarks>
  879. /// <history>
  880. /// [cnurse] 9/9/2004 Modified
  881. /// [aprasad] 1/17/2011 New setting AutoAddPortalAlias
  882. /// </history>
  883. /// -----------------------------------------------------------------------------
  884. protected void UpdatePortal(object sender, EventArgs e)
  885. {
  886. if (Page.IsValid)
  887. {
  888. try
  889. {
  890. var portalController = new PortalController();
  891. PortalInfo existingPortal = portalController.GetPortal(_portalId);
  892. string logo = String.Format("FileID={0}", ctlLogo.FileID);
  893. string background = String.Format("FileID={0}", ctlBackground.FileID);
  894. //Refresh if Background or Logo file have changed
  895. bool refreshPage = (background == existingPortal.BackgroundFile || logo == existingPortal.LogoFile);
  896. float hostFee = existingPortal.HostFee;
  897. if (!String.IsNullOrEmpty(txtHostFee.Text))
  898. {
  899. hostFee = float.Parse(txtHostFee.Text);
  900. }
  901. int hostSpace = existingPortal.HostSpace;
  902. if (!String.IsNullOrEmpty(txtHostSpace.Text))
  903. {
  904. hostSpace = int.Parse(txtHostSpace.Text);
  905. }
  906. int pageQuota = existingPortal.PageQuota;
  907. if (!String.IsNullOrEmpty(txtPageQuota.Text))
  908. {
  909. pageQuota = int.Parse(txtPageQuota.Text);
  910. }
  911. int userQuota = existingPortal.UserQuota;
  912. if (!String.IsNullOrEmpty(txtUserQuota.Text))
  913. {
  914. userQuota = int.Parse(txtUserQuota.Text);
  915. }
  916. int siteLogHistory = existingPortal.SiteLogHistory;
  917. if (!String.IsNullOrEmpty(txtSiteLogHistory.Text))
  918. {
  919. siteLogHistory = int.Parse(txtSiteLogHistory.Text);
  920. }
  921. DateTime expiryDate = existingPortal.ExpiryDate;
  922. if (datepickerExpiryDate.SelectedDate.HasValue)
  923. {
  924. expiryDate = datepickerExpiryDate.SelectedDate.Value;
  925. }
  926. int intSplashTabId = Null.NullInteger;
  927. if (cboSplashTabId.SelectedItem != null)
  928. {
  929. intSplashTabId = int.Parse(cboSplashTabId.SelectedItem.Value);
  930. }
  931. int intHomeTabId = Null.NullInteger;
  932. if (cboHomeTabId.SelectedItem != null)
  933. {
  934. intHomeTabId = int.Parse(cboHomeTabId.SelectedItem.Value);
  935. }
  936. int intLoginTabId = Null.NullInteger;
  937. if (cboLoginTabId.SelectedItem != null)
  938. {
  939. intLoginTabId = int.Parse(cboLoginTabId.SelectedItem.Value);
  940. }
  941. int intRegisterTabId = Null.NullInteger;
  942. if (cboRegisterTabId.SelectedItem != null)
  943. {
  944. intRegisterTabId = int.Parse(cboRegisterTabId.SelectedItem.Value);
  945. }
  946. int intUserTabId = Null.NullInteger;
  947. if (cboUserTabId.SelectedItem != null)
  948. {
  949. intUserTabId = int.Parse(cboUserTabId.SelectedItem.Value);
  950. }
  951. int intSearchTabId = Null.NullInteger;
  952. if (cboSearchTabId.SelectedItem != null)
  953. {
  954. intSearchTabId = int.Parse(cboSearchTabId.SelectedItem.Value);
  955. }
  956. if (txtPassword.Attributes["value"] != null)
  957. {
  958. txtPassword.Attributes["value"] = txtPassword.Text;
  959. }
  960. var portal = new PortalInfo
  961. {
  962. PortalID = _portalId,
  963. PortalGroupID = existingPortal.PortalGroupID,
  964. PortalName = txtPortalName.Text,
  965. LogoFile = logo,
  966. FooterText = txtFooterText.Text,
  967. ExpiryDate = expiryDate,
  968. UserRegistration = optUserRegistration.SelectedIndex,
  969. BannerAdvertising = optBanners.SelectedIndex,
  970. Currency = currencyCombo.SelectedItem.Value,
  971. AdministratorId = Convert.ToInt32(cboAdministratorId.SelectedItem.Value),
  972. HostFee = hostFee,
  973. HostSpace = hostSpace,
  974. PageQuota = pageQuota,
  975. UserQuota = userQuota,
  976. PaymentProcessor =
  977. String.IsNullOrEmpty(processorCombo.SelectedValue)
  978. ? ""
  979. : processorCombo.SelectedItem.Text,
  980. ProcessorUserId = txtUserId.Text,
  981. ProcessorPassword = txtPassword.Text,
  982. Description = txtDescription.Text,
  983. KeyWords = txtKeyWords.Text,
  984. BackgroundFile = background,
  985. SiteLogHistory = siteLogHistory,
  986. SplashTabId = intSplashTabId,
  987. HomeTabId = intHomeTabId,
  988. LoginTabId = intLoginTabId,
  989. RegisterTabId = intRegisterTabId,
  990. UserTabId = intUserTabId,
  991. SearchTabId = intSearchTabId,
  992. DefaultLanguage = existingPortal.DefaultLanguage,
  993. HomeDirectory = lblHomeDirectory.Text,
  994. CultureCode = SelectedCultureCode
  995. };
  996. …

Large files files are truncated, but you can click here to view the full file