Skip to content
This repository has been archived by the owner on Oct 6, 2019. It is now read-only.

Cookieconsent #100

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,18 @@ private void SerializePortalSettings(XmlWriter writer, PortalInfo portal, bool i
writer.WriteElementString("addcompatiblehttpheader", setting);
}

settingsDictionary.TryGetValue("ShowCookieConsent", out setting);
if (!string.IsNullOrEmpty(setting))
{
writer.WriteElementString("showcookieconsent", setting);
}

settingsDictionary.TryGetValue("CookieMoreLink", out setting);
if (!string.IsNullOrEmpty(setting))
{
writer.WriteElementString("cookiemorelink", setting);
}

//End Portal Settings
writer.WriteEndElement();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<Compile Include="Services\Dto\UpdateLanguageRequest.cs" />
<Compile Include="Services\Dto\UpdateLanguageSettingsRequest.cs" />
<Compile Include="Services\Dto\UpdateIgnoreWordsRequest.cs" />
<Compile Include="Services\Dto\UpdatePrivacySettings.cs" />
<Compile Include="Services\Dto\UpdateOtherSettingsRequest.cs" />
<Compile Include="Services\Dto\UpdateListEntryOrdersRequest.cs" />
<Compile Include="Services\Dto\UpdateProfilePropertyOrdersRequest.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public class UpdateDefaultPagesSettingsRequest

public int Custom500TabId { get; set; }

public int TermsTabId { get; set; }

public int PrivacyTabId { get; set; }

public string PageHeadText { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@ namespace Dnn.PersonaBar.SiteSettings.Services.Dto
{
public class UpdateOtherSettingsRequest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this class be removed completely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hesitated. Because we may (within the next few weeks) discover settings that should find their way here. Can we continue with this PR and decide this in the run-up to the 9.3 release?

{
public bool CheckUpgrade { get; set; }

public bool DnnImprovementProgram { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#region Copyright
//
// DotNetNuke� - http://www.dotnetnuke.com
// Copyright (c) 2002-2018
// by DotNetNuke Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
// to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions
// of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#endregion
#region Usings

using Newtonsoft.Json;

#endregion

namespace Dnn.PersonaBar.SiteSettings.Services.Dto
{
public class UpdatePrivacySettingsRequest
{
public int? PortalId { get; set; }

public string CultureCode { get; set; }

public bool ShowCookieConsent { get; set; }

public string CookieMoreLink { get; set; }

public bool CheckUpgrade { get; set; }

public bool DnnImprovementProgram { get; set; }

public bool DisplayCopyright { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#endregion
#region Usings

using Newtonsoft.Json;

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@
// DEALINGS IN THE SOFTWARE.
#endregion

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Web;
using System.Web.Http;
using System.Text.RegularExpressions;
using Dnn.PersonaBar.Library;
using Dnn.PersonaBar.Library.Attributes;
using Dnn.PersonaBar.SiteSettings.Services.Dto;
Expand All @@ -59,6 +45,20 @@
using DotNetNuke.UI.Internals;
using DotNetNuke.UI.Skins;
using DotNetNuke.Web.Api;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Threading;
using System.Web;
using System.Web.Http;
using FileInfo = System.IO.FileInfo;

namespace Dnn.PersonaBar.SiteSettings.Services
Expand Down Expand Up @@ -334,6 +334,10 @@ public HttpResponseMessage GetDefaultPagesSettings(int? portalId, string culture
Custom404TabName = TabSanitizer(portal.Custom404TabId, pid)?.TabName,
Custom500TabId = TabSanitizer(portal.Custom500TabId, pid)?.TabID,
Custom500TabName = TabSanitizer(portal.Custom500TabId, pid)?.TabName,
TermsTabId = TabSanitizer(portal.TermsTabId, pid)?.TabID,
TermsTabName = TabSanitizer(portal.TermsTabId, pid)?.TabName,
PrivacyTabId = TabSanitizer(portal.PrivacyTabId, pid)?.TabID,
PrivacyTabName = TabSanitizer(portal.PrivacyTabId, pid)?.TabName,
portalSettings.PageHeadText
}
});
Expand Down Expand Up @@ -381,6 +385,8 @@ public HttpResponseMessage UpdateDefaultPagesSettings(UpdateDefaultPagesSettings
portalInfo.SearchTabId = ValidateTabId(request.SearchTabId, pid);
portalInfo.Custom404TabId = ValidateTabId(request.Custom404TabId, pid);
portalInfo.Custom500TabId = ValidateTabId(request.Custom500TabId, pid);
portalInfo.TermsTabId = ValidateTabId(request.TermsTabId, pid);
portalInfo.PrivacyTabId = ValidateTabId(request.PrivacyTabId, pid);

PortalController.Instance.UpdatePortalInfo(portalInfo);
PortalController.UpdatePortalSetting(pid, "PageHeadText", string.IsNullOrEmpty(request.PageHeadText) ? "false" : request.PageHeadText);
Expand Down Expand Up @@ -1436,7 +1442,7 @@ public HttpResponseMessage UpdateListEntry(UpdateListEntryRequest request)
{
listController.AddListEntry(entry);
}

return Request.CreateResponse(HttpStatusCode.OK, new { Success = true });
}
catch (Exception exc)
Expand Down Expand Up @@ -1468,7 +1474,7 @@ public HttpResponseMessage DeleteListEntry([FromUri]int entryId, [FromUri] int?

var listController = new ListController();
listController.DeleteListEntryByID(entryId, true);

return Request.CreateResponse(HttpStatusCode.OK, new { Success = true });
}
catch (Exception exc)
Expand Down Expand Up @@ -1503,7 +1509,11 @@ public HttpResponseMessage UpdateListEntryOrders(UpdateListEntryOrdersRequest re
if (request.Entries[i].EntryId.HasValue)
{
var entry = listController.GetListEntryInfo(request.Entries[i].EntryId.Value);
if (entry.SortOrder == i + 1) continue;
if (entry.SortOrder == i + 1)
{
continue;
}

if (entry.SortOrder > i + 1)
{
var j = entry.SortOrder - i - 1;
Expand Down Expand Up @@ -1535,6 +1545,83 @@ public HttpResponseMessage UpdateListEntryOrders(UpdateListEntryOrdersRequest re
}
}

/// GET: api/SiteSettings/GetPrivacySettings
/// <summary>
/// Gets messaging settings
/// </summary>
/// <param name="portalId"></param>
/// <returns>privacy settings</returns>
[HttpGet]
[DnnAuthorize(StaticRoles = Constants.AdminsRoleName)]
public HttpResponseMessage GetPrivacySettings(int? portalId)
{
try
{
var pid = portalId ?? PortalId;
if (!UserInfo.IsSuperUser && PortalId != pid)
{
return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, AuthFailureMessage);
}

var portal = PortalController.Instance.GetPortal(pid);
var portalSettings = new PortalSettings(portal);

return Request.CreateResponse(HttpStatusCode.OK, new
{
Settings = new
{
PortalId = portal.PortalID,
portal.CultureCode,
portalSettings.ShowCookieConsent,
portalSettings.CookieMoreLink,
CheckUpgrade = HostController.Instance.GetBoolean("CheckUpgrade", true),
DnnImprovementProgram = HostController.Instance.GetBoolean("DnnImprovementProgram", true),
DisplayCopyright = HostController.Instance.GetBoolean("Copyright", true)
}
});
}
catch (Exception exc)
{
Logger.Error(exc);
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
}
}

/// POST: api/SiteSettings/UpdatePrivacySettings
/// <summary>
/// Updates privacy settings
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]
[DnnAuthorize(StaticRoles = Constants.AdminsRoleName)]
public HttpResponseMessage UpdatePrivacySettings(UpdatePrivacySettingsRequest request)
{
try
{
var pid = request.PortalId ?? PortalId;
if (!UserInfo.IsSuperUser && PortalId != pid)
{
return Request.CreateErrorResponse(HttpStatusCode.Unauthorized, AuthFailureMessage);
}

PortalController.UpdatePortalSetting(pid, "ShowCookieConsent", request.ShowCookieConsent.ToString(), false);
PortalController.UpdatePortalSetting(pid, "CookieMoreLink", request.CookieMoreLink, false, request.CultureCode);
HostController.Instance.Update("CheckUpgrade", request.CheckUpgrade ? "Y" : "N", false);
HostController.Instance.Update("DnnImprovementProgram", request.DnnImprovementProgram ? "Y" : "N", false);
HostController.Instance.Update("Copyright", request.DisplayCopyright ? "Y" : "N", false);
DataCache.ClearCache();

return Request.CreateResponse(HttpStatusCode.OK, new { Success = true });
}
catch (Exception exc)
{
Logger.Error(exc);
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
}
}

#endregion

#region Search Settings API
Expand Down Expand Up @@ -3014,8 +3101,6 @@ public HttpResponseMessage GetOtherSettings()
{
Settings = new
{
CheckUpgrade = HostController.Instance.GetBoolean("CheckUpgrade", true),
DnnImprovementProgram = HostController.Instance.GetBoolean("DnnImprovementProgram", true)
}
});
}
Expand All @@ -3039,8 +3124,6 @@ public HttpResponseMessage UpdateOtherSettings(UpdateOtherSettingsRequest reques
{
try
{
HostController.Instance.Update("CheckUpgrade", request.CheckUpgrade ? "Y" : "N", false);
HostController.Instance.Update("DnnImprovementProgram", request.DnnImprovementProgram ? "Y" : "N", false);
DataCache.ClearCache();
return Request.CreateResponse(HttpStatusCode.OK, new { Success = true });
}
Expand Down Expand Up @@ -3182,7 +3265,7 @@ private bool ValidateProperty(ProfilePropertyDefinition definition, out HttpResp
if (!propertyNameRegex.Match(definition.PropertyName).Success)
{
isValid = false;
httpPropertyValidationError = Request.CreateErrorResponse(HttpStatusCode.BadRequest,
httpPropertyValidationError = Request.CreateErrorResponse(HttpStatusCode.BadRequest,
string.Format(Localization.GetString("NoSpecialCharacterName.Text", Components.Constants.Constants.LocalResourcesFile)));
}

Expand All @@ -3196,7 +3279,7 @@ private bool ValidateProperty(ProfilePropertyDefinition definition, out HttpResp
break;
}

if(isValid == false)
if (isValid == false)
{
httpPropertyValidationError = Request.CreateErrorResponse(HttpStatusCode.BadRequest,
string.Format(Localization.GetString("RequiredTextBox", Components.Constants.Constants.LocalResourcesFile)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,52 @@ const siteBehaviorActions = {
});
};
},
getPrivacySettings(portalId, callback) {
return (dispatch) => {
ApplicationService.getPrivacySettings(portalId, data => {
dispatch({
type: ActionTypes.RETRIEVED_SITESETTINGS_PRIVACY_SETTINGS,
data: {
settings: data.Settings,
privacySettingsClientModified: false
}
});
if (callback) {
callback(data);
}
});
};
},
updatePrivacySettings(payload, callback, failureCallback) {
return (dispatch) => {
ApplicationService.updatePrivacySettings(payload, data => {
dispatch({
type: ActionTypes.UPDATED_SITESETTINGS_PRIVACY_SETTINGS,
data: {
privacySettingsClientModified: false
}
});
if (callback) {
callback(data);
}
}, data => {
if (failureCallback) {
failureCallback(data);
}
});
};
},
privacySettingsClientModified(parameter) {
return (dispatch) => {
dispatch({
type: ActionTypes.SITESETTINGS_PRIVACY_SETTINGS_CLIENT_MODIFIED,
data: {
settings: parameter,
privacySettingsClientModified: true
}
});
};
},
getOtherSettings(callback) {
return (dispatch) => {
ApplicationService.getOtherSettings(data => {
Expand Down
Loading