Skip to content

Commit

Permalink
Cookieconsent and terms and privacy tabs (#2369)
Browse files Browse the repository at this point in the history
* Two new default pages: terms (of use) and privacy (statement)

* Update tests

* Update to default schema to include new default pages

* Revert "Update to default schema to include new default pages"

This reverts commit d57da3e.

* Fix to sql

* Include new script in project file

* Change script

* Two new default pages: terms (of use) and privacy (statement)

* Fix to sql

* Implement settings in portal settings

* Fix default setting in template

* Implement cookie consent logic

* Change name of script

* Change name of sql script for terms and privacy tabs sql
  • Loading branch information
donker authored and ohine committed Oct 24, 2018
1 parent f99c03c commit d41de79
Show file tree
Hide file tree
Showing 28 changed files with 532 additions and 57 deletions.
10 changes: 8 additions & 2 deletions DNN Platform/Library/Data/DataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,8 @@ public virtual void UpdatePortalInfo(int portalId, int portalGroupId, string por
string processorPassword, string description, string keyWords,
string backgroundFile, int siteLogHistory, int splashTabId, int homeTabId,
int loginTabId,
int registerTabId, int userTabId, int searchTabId, int custom404TabId, int custom500TabId, string defaultLanguage,
int registerTabId, int userTabId, int searchTabId, int custom404TabId, int custom500TabId,
int termsTabId, int privacyTabId, string defaultLanguage,
string homeDirectory, int lastModifiedByUserID, string cultureCode)
{
ExecuteNonQuery("UpdatePortalInfo",
Expand Down Expand Up @@ -686,6 +687,8 @@ public virtual void UpdatePortalInfo(int portalId, int portalGroupId, string por
GetNull(searchTabId),
GetNull(custom404TabId),
GetNull(custom500TabId),
GetNull(termsTabId),
GetNull(privacyTabId),
GetNull(defaultLanguage),
homeDirectory,
lastModifiedByUserID,
Expand All @@ -701,7 +704,8 @@ public virtual void UpdatePortalSetting(int portalId, string settingName, string
public virtual void UpdatePortalSetup(int portalId, int administratorId, int administratorRoleId,
int registeredRoleId, int splashTabId, int homeTabId, int loginTabId,
int registerTabId,
int userTabId, int searchTabId, int custom404TabId, int custom500TabId, int adminTabId, string cultureCode)
int userTabId, int searchTabId, int custom404TabId, int custom500TabId,
int termsTabId, int privacyTabId, int adminTabId, string cultureCode)
{
ExecuteNonQuery("UpdatePortalSetup",
portalId,
Expand All @@ -716,6 +720,8 @@ public virtual void UpdatePortalSetup(int portalId, int administratorId, int adm
searchTabId,
custom404TabId,
custom500TabId,
termsTabId,
privacyTabId,
adminTabId,
cultureCode);
}
Expand Down
38 changes: 36 additions & 2 deletions DNN Platform/Library/Entities/Portals/PortalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,8 +1421,16 @@ private void ParsePortalSettings(XmlNode nodeSettings, int portalId)
UpdatePortalSetting(portalId, "EnableSkinWidgets", XmlUtils.GetNodeValue(nodeSettings, "enableskinwidgets", ""));
}

if (!String.IsNullOrEmpty(XmlUtils.GetNodeValue(nodeSettings, "showcookieconsent", "")))
{
UpdatePortalSetting(portalId, "ShowCookieConsent", XmlUtils.GetNodeValue(nodeSettings, "showcookieconsent", "False"));
}
if (!String.IsNullOrEmpty(XmlUtils.GetNodeValue(nodeSettings, "cookiemorelink", "")))
{
UpdatePortalSetting(portalId, "CookieMoreLink", XmlUtils.GetNodeValue(nodeSettings, "cookiemorelink", ""), true, currentCulture);
}

//Enable AutoSAve feature
//Enable Skin Widgets Setting
if (!String.IsNullOrEmpty(XmlUtils.GetNodeValue(nodeSettings, "enableautosave", "")))
{
UpdatePortalSetting(portalId, HtmlText_AutoSaveEnabled, XmlUtils.GetNodeValue(nodeSettings, "enableautosave", ""));
Expand Down Expand Up @@ -1550,6 +1558,8 @@ private void ParseRoleGroups(XPathNavigator nav, int portalID, int administrator
portal.SearchTabId,
portal.Custom404TabId,
portal.Custom500TabId,
portal.TermsTabId,
portal.PrivacyTabId,
portal.AdminTabId,
GetActivePortalLanguage(portalID));
}
Expand Down Expand Up @@ -1604,6 +1614,8 @@ private void ParseRoles(XPathNavigator nav, int portalID, int administratorId)
portal.SearchTabId,
portal.Custom404TabId,
portal.Custom500TabId,
portal.TermsTabId,
portal.PrivacyTabId,
portal.AdminTabId,
GetActivePortalLanguage(portalID));
}
Expand Down Expand Up @@ -1682,6 +1694,8 @@ private void ParseTab(XmlNode nodeTab, int portalId, bool isAdminTemplate, Porta
portal.SearchTabId,
portal.Custom404TabId,
portal.Custom500TabId,
portal.TermsTabId,
portal.PrivacyTabId,
portal.AdminTabId,
GetActivePortalLanguage(portalId));
EventLogController.Instance.AddLog(logType,
Expand Down Expand Up @@ -2009,6 +2023,8 @@ private void UpdatePortalInternal(PortalInfo portal, bool clearCache)
portal.SearchTabId,
portal.Custom404TabId,
portal.Custom500TabId,
portal.TermsTabId,
portal.PrivacyTabId,
portal.DefaultLanguage,
portal.HomeDirectory,
UserController.Instance.GetCurrentUserInfo().UserID,
Expand Down Expand Up @@ -2063,7 +2079,7 @@ private static void UpdatePortalSettingInternal(int portalID, string settingName
}

private void UpdatePortalSetup(int portalId, int administratorId, int administratorRoleId, int registeredRoleId, int splashTabId, int homeTabId, int loginTabId, int registerTabId,
int userTabId, int searchTabId, int custom404TabId, int custom500TabId, int adminTabId, string cultureCode)
int userTabId, int searchTabId, int custom404TabId, int custom500TabId, int termsTabId, int privacyTabId, int adminTabId, string cultureCode)
{
DataProvider.Instance().UpdatePortalSetup(portalId,
administratorId,
Expand All @@ -2077,6 +2093,8 @@ private void UpdatePortalSetup(int portalId, int administratorId, int administra
searchTabId,
custom404TabId,
custom500TabId,
termsTabId,
privacyTabId,
adminTabId,
cultureCode);
EventLogController.Instance.AddLog("PortalId", portalId.ToString(), GetCurrentPortalSettingsInternal(), UserController.Instance.GetCurrentUserInfo().UserID, EventLogController.EventLogType.PORTALINFO_UPDATED);
Expand Down Expand Up @@ -2606,6 +2624,22 @@ public void MapLocalizedSpecialPages(int portalId, string cultureCode)
targetPortal.Custom500TabId = tempTab.TabID;
}
}
if (defaultPortal.TermsTabId != Null.NullInteger)
{
tempTab = TabController.Instance.GetTabByCulture(defaultPortal.TermsTabId, portalId, targetLocale);
if (tempTab != null)
{
targetPortal.TermsTabId = tempTab.TabID;
}
}
if (defaultPortal.PrivacyTabId != Null.NullInteger)
{
tempTab = TabController.Instance.GetTabByCulture(defaultPortal.PrivacyTabId, portalId, targetLocale);
if (tempTab != null)
{
targetPortal.PrivacyTabId = tempTab.TabID;
}
}

UpdatePortalInternal(targetPortal, false);
}
Expand Down
22 changes: 22 additions & 0 deletions DNN Platform/Library/Entities/Portals/PortalInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,26 @@ public string HomeSystemDirectory {
[XmlElement("custom500tabid")]
public int Custom500TabId { get; set; }

/// <summary>
/// Tabid of the Terms of Use page
/// </summary>
/// <value>Tabid of the Terms of Use page</value>
/// <returns>Tabid of the Terms of Use page</returns>
/// <remarks>
/// </remarks>
[XmlElement("termstabid")]
public int TermsTabId { get; set; }

/// <summary>
/// Tabid of the Privacy Statement page
/// </summary>
/// <value>Tabid of the Privacy Statement page</value>
/// <returns>Tabid of the Privacy Statement page</returns>
/// <remarks>
/// </remarks>
[XmlElement("privacytabid")]
public int PrivacyTabId { get; set; }

/// <summary>
/// # of days that Site log history should be kept. 0 means unlimited
/// </summary>
Expand Down Expand Up @@ -837,6 +857,8 @@ public void Fill(IDataReader dr)
Custom500TabId = Null.SetNullInteger(dr["Custom500TabId"]);
}
}
TermsTabId = Null.SetNullInteger(dr["TermsTabId"]);
PrivacyTabId = Null.SetNullInteger(dr["PrivacyTabId"]);

DefaultLanguage = Null.SetNullString(dr["DefaultLanguage"]);
#pragma warning disable 612,618 //needed for upgrades and backwards compatibility
Expand Down
52 changes: 35 additions & 17 deletions DNN Platform/Library/Entities/Portals/PortalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,23 @@ private void BuildPortalSettings(int tabId, PortalInfo portal)

public int UserTabId { get; set; }

#endregion
public int TermsTabId { get; set; }

#region Read-Only Properties
public int PrivacyTabId { get; set; }

#endregion

/// -----------------------------------------------------------------------------
/// <summary>
/// Allows users to select their own UI culture.
/// When set to false (default) framework will allways same culture for both
/// CurrentCulture (content) and CurrentUICulture (interface)
/// </summary>
/// <remarks>Defaults to False</remarks>
/// -----------------------------------------------------------------------------
public bool AllowUserUICulture { get; internal set; }
#region Read-Only Properties

/// -----------------------------------------------------------------------------
/// <summary>
/// Allows users to select their own UI culture.
/// When set to false (default) framework will allways same culture for both
/// CurrentCulture (content) and CurrentUICulture (interface)
/// </summary>
/// <remarks>Defaults to False</remarks>
/// -----------------------------------------------------------------------------
public bool AllowUserUICulture { get; internal set; }

public int CdfVersion { get; internal set; }

Expand Down Expand Up @@ -338,12 +342,26 @@ private void BuildPortalSettings(int tabId, PortalInfo portal)
/// -----------------------------------------------------------------------------
public bool EnableSkinWidgets { get; internal set; }

/// -----------------------------------------------------------------------------
/// <summary>
/// Gets whether enable url language.
/// </summary>
/// <remarks>Defaults to True</remarks>
/// -----------------------------------------------------------------------------
/// -----------------------------------------------------------------------------
/// <summary>
/// Gets whether a cookie consent popup should be shown
/// </summary>
/// <remarks>Defaults to False</remarks>
/// -----------------------------------------------------------------------------
public bool ShowCookieConsent { get; internal set; }

/// <summary>
/// Link for the user to find out more about cookies. If not specified the link
/// shown will point to cookiesandyou.com
/// </summary>
public string CookieMoreLink { get; internal set; }

/// -----------------------------------------------------------------------------
/// <summary>
/// Gets whether enable url language.
/// </summary>
/// <remarks>Defaults to True</remarks>
/// -----------------------------------------------------------------------------
public bool EnableUrlLanguage { get; internal set; }

public int ErrorPage404 { get; internal set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ public virtual void LoadPortal(PortalInfo portal, PortalSettings portalSettings)
portalSettings.SearchTabId = portal.SearchTabId;
portalSettings.ErrorPage404 = portal.Custom404TabId;
portalSettings.ErrorPage500 = portal.Custom500TabId;
portalSettings.TermsTabId = portal.TermsTabId;
portalSettings.PrivacyTabId = portal.PrivacyTabId;
portalSettings.DefaultLanguage = Null.IsNull(portal.DefaultLanguage) ? Localization.SystemLocale : portal.DefaultLanguage;
portalSettings.HomeDirectory = Globals.ApplicationPath + "/" + portal.HomeDirectory + "/";
portalSettings.HomeDirectoryMapPath = portal.HomeDirectoryMapPath;
Expand Down Expand Up @@ -261,6 +263,8 @@ public virtual void LoadPortalSettings(PortalSettings portalSettings)
portalSettings.EnablePopUps = settings.GetValueOrDefault("EnablePopUps", true);
portalSettings.HideLoginControl = settings.GetValueOrDefault("HideLoginControl", false);
portalSettings.EnableSkinWidgets = settings.GetValueOrDefault("EnableSkinWidgets", true);
portalSettings.ShowCookieConsent = settings.GetValueOrDefault("ShowCookieConsent", false);
portalSettings.CookieMoreLink = settings.GetValueOrDefault("CookieMoreLink", Null.NullString);
portalSettings.EnableUrlLanguage = settings.GetValueOrDefault("EnableUrlLanguage", Host.Host.EnableUrlLanguage);
portalSettings.HideFoldersEnabled = settings.GetValueOrDefault("HideFoldersEnabled", true);
portalSettings.InlineEditorEnabled = settings.GetValueOrDefault("InlineEditorEnabled", true);
Expand Down
12 changes: 12 additions & 0 deletions DNN Platform/Library/Entities/Tabs/TabController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,18 @@ public static XmlNode SerializeTab(XmlDocument tabXml, Hashtable tabs, TabInfo t
newnode.InnerXml = "500tab";
tabNode.AppendChild(newnode);
}
else if (tab.TabID == portal.TermsTabId)
{
newnode = tabXml.CreateElement("tabtype");
newnode.InnerXml = "termstab";
tabNode.AppendChild(newnode);
}
else if (tab.TabID == portal.PrivacyTabId)
{
newnode = tabXml.CreateElement("tabtype");
newnode.InnerXml = "privacytab";
tabNode.AppendChild(newnode);
}
}
if (tabs != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public static void UpdatePortalInfo(PortalInfo portal)
portal.SearchTabId,
portal.Custom404TabId,
portal.Custom500TabId,
portal.TermsTabId,
portal.PrivacyTabId,
portal.DefaultLanguage,
portal.HomeDirectory,
portal.LastModifiedByUserID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private IDataReader GetPortalCallBack(int portalId, string culture)
"PaymentProcessor", "ProcessorUserId",
"ProcessorPassword", "SiteLogHistory", "Email", "DefaultLanguage", "TimezoneOffset", "AdminTabId", "HomeDirectory", "SplashTabId", "HomeTabId",
"LoginTabId", "RegisterTabId",
"UserTabId", "SearchTabId", "Custom404TabId", "Custom500TabId", "SuperTabId", "CreatedByUserID", "CreatedOnDate", "LastModifiedByUserID",
"UserTabId", "SearchTabId", "Custom404TabId", "Custom500TabId", "TermsTabId", "PrivacyTabId", "SuperTabId", "CreatedByUserID", "CreatedOnDate", "LastModifiedByUserID",
"LastModifiedOnDate", "CultureCode"
};

Expand All @@ -250,7 +250,7 @@ private IDataReader GetPortalCallBack(int portalId, string culture)
table.Rows.Add(portalId, null, "My Website", "Logo.png", "Copyright 2011 by DotNetNuke Corporation", null,
"2", "0", "2", "USD", "0", "0", "0", "0", "0", "1", "My Website", "DotNetNuke, DNN, Content, Management, CMS", null,
"1057AC7A-3C08-4849-A3A6-3D2AB4662020", null, null, null, "0", "admin@change.me", "en-US", "-8", "58", "Portals/0",
null, homePage.ToString("D"), null, null, "57", "56", "-1", "-1", "7", "-1", "2011-08-25 07:34:11", "-1", "2011-08-25 07:34:29", culture);
null, homePage.ToString("D"), null, null, "57", "56", "-1", "-1", "7", null, null, "-1", "2011-08-25 07:34:11", "-1", "2011-08-25 07:34:29", culture);

return table.CreateDataReader();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ private IDataReader GetPortalCallBack(int portalId, string culture)
"PortalID", "PortalGroupID", "PortalName", "LogoFile", "FooterText", "ExpiryDate", "UserRegistration", "BannerAdvertising", "AdministratorId", "Currency", "HostFee",
"HostSpace", "PageQuota", "UserQuota", "AdministratorRoleId", "RegisteredRoleId", "Description", "KeyWords", "BackgroundFile", "GUID", "PaymentProcessor", "ProcessorUserId",
"ProcessorPassword", "SiteLogHistory", "Email", "DefaultLanguage", "TimezoneOffset", "AdminTabId", "HomeDirectory", "SplashTabId", "HomeTabId", "LoginTabId", "RegisterTabId",
"UserTabId", "SearchTabId", "Custom404TabId", "Custom500TabId", "SuperTabId", "CreatedByUserID", "CreatedOnDate", "LastModifiedByUserID", "LastModifiedOnDate", "CultureCode"
"UserTabId", "SearchTabId", "Custom404TabId", "Custom500TabId", "TermsTabId", "PrivacyTabId", "SuperTabId", "CreatedByUserID", "CreatedOnDate", "LastModifiedByUserID", "LastModifiedOnDate", "CultureCode"
};

foreach (var col in cols)
Expand All @@ -294,7 +294,7 @@ private IDataReader GetPortalCallBack(int portalId, string culture)
table.Rows.Add(portalId, null, "My Website", "Logo.png", "Copyright 2011 by DotNetNuke Corporation", null,
"2", "0", "2", "USD", "0", "0", "0", "0", "0", "1", "My Website", "DotNetNuke, DNN, Content, Management, CMS", null,
"1057AC7A-3C08-4849-A3A6-3D2AB4662020", null, null, null, "0", "admin@change.me", "en-US", "-8", "58", "Portals/0",
null, homePage.ToString("D"), null, null, "57", "56", "-1", "-1", "7", "-1", "2011-08-25 07:34:11", "-1", "2011-08-25 07:34:29", culture);
null, homePage.ToString("D"), null, null, "57", "56", "-1", "-1", null, null, "7", "-1", "2011-08-25 07:34:11", "-1", "2011-08-25 07:34:29", culture);

return table.CreateDataReader();
}
Expand Down
Loading

0 comments on commit d41de79

Please sign in to comment.