Skip to content

Commit

Permalink
Merge pull request #1827 from 2sic/develop
Browse files Browse the repository at this point in the history
Releasing 10.06
  • Loading branch information
iJungleboy committed Sep 24, 2019
2 parents d0141ac + a14acc1 commit 2513822
Show file tree
Hide file tree
Showing 44 changed files with 120 additions and 9,919 deletions.
2 changes: 1 addition & 1 deletion 2Sexy Content Razor/Properties/AssemblyInfo.cs
Expand Up @@ -30,4 +30,4 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("10.05.00.*")]
[assembly: AssemblyVersion("10.06.00.*")]
4 changes: 4 additions & 0 deletions 2sxc Dnn/Environment/Dnn7/DnnFileSystem.cs
Expand Up @@ -65,6 +65,10 @@ private Folder DnnToAdam(AdamAppContext appContext, IFolderInfo f)
public List<File> GetFiles(int folderId, AdamAppContext appContext)
{
var fldObj = _folderManager.GetFolder(folderId);
// sometimes the folder doesn't exist for whatever reason
if (fldObj == null) return new List<File>();

// try to find the files
var firstList = _folderManager.GetFiles(fldObj);
var files = firstList?.Select(f => DnnToAdam(appContext, f)).ToList()
?? new List<File>();
Expand Down
2 changes: 1 addition & 1 deletion 2sxc Dnn/Environment/Dnn7/DnnRenderingHelpers.cs
Expand Up @@ -100,7 +100,7 @@ public void RegisterClientDependencies(Page page, bool js, bool css)
if (js)
{
RegisterJs(page, ver, root + "js/2sxc.api" + ext);
RegisterJs(page, ver, root + "dist/inpage/inpage" + ext);
RegisterJs(page, ver, root + "dist/inpage/inpage.min.js");// + ext);
}
}

Expand Down
4 changes: 2 additions & 2 deletions 2sxc.WebApi.Tests/2sxc.WebApi.Tests.csproj
Expand Up @@ -40,10 +40,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\eav-server\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
<HintPath>..\..\..\..\..\eav-server\packages\MSTest.TestFramework.2.0.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\eav-server\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
<HintPath>..\..\..\..\..\eav-server\packages\MSTest.TestFramework.2.0.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion 2sxc.WebApi.Tests/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net451" />
<package id="MSTest.TestFramework" version="1.3.2" targetFramework="net451" />
<package id="MSTest.TestFramework" version="2.0.0" targetFramework="net451" />
</packages>
8 changes: 4 additions & 4 deletions DnnPackageBuilder/2sic_2SexyContent.dnn
@@ -1,6 +1,6 @@
<dotnetnuke type="Package" version="5.0">
<packages>
<package name="2SexyContent" type="Module" version="10.05.00">
<package name="2SexyContent" type="Module" version="10.06.00">
<friendlyName> Content</friendlyName>
<description>2sxc is a DNN Extension to create attractive and designed content. It solves the common problem, allowing the web designer to create designed templates for different content elements, so that the user must only fill in fields and receive a perfectly designed and animated output.</description>
<iconFile>icon.png</iconFile>
Expand Down Expand Up @@ -39,7 +39,7 @@
<script type="UnInstall">
<path>SqlDataProvider</path>
<name>Uninstall.SqlDataProvider</name>
<version>10.05.00</version>
<version>10.06.00</version>
</script>
</scripts>
</component>
Expand Down Expand Up @@ -93,7 +93,7 @@
<attributes>
<businessControllerClass>ToSic.SexyContent.Environment.Dnn7.DnnBusinessController</businessControllerClass>
<desktopModuleID>[DESKTOPMODULEID]</desktopModuleID>
<upgradeVersionsList>01.00.00,08.11.00,08.12.00,09.00.00,09.00.01,09.00.02,09.01.00,09.01.02,09.01.03,09.02.00,09.03.00,09.03.01,09.03.02,09.03.03,09.04.00,09.04.01,09.04.02,09.04.03,09.05.00,09.05.01,09.05.02,09.06.00,09.06.01,09.07.00,09.08.00,09.09.00,09.10.00,09.11.00,09.11.01,09.12.00,09.13.00,09.14.00,09.20.00,09.21.00,09.22.00,09.23.00,09.30.00,09.31.00,09.32.00,09.33.00,09.35.00,09.40.00,09.40.01,09.41.00,09.42.00,09.43.00,09.43.01,10.00.00,10.01.00,10.02.00,10.03.00,10.04.00,10.05.00</upgradeVersionsList>
<upgradeVersionsList>01.00.00,08.11.00,08.12.00,09.00.00,09.00.01,09.00.02,09.01.00,09.01.02,09.01.03,09.02.00,09.03.00,09.03.01,09.03.02,09.03.03,09.04.00,09.04.01,09.04.02,09.04.03,09.05.00,09.05.01,09.05.02,09.06.00,09.06.01,09.07.00,09.08.00,09.09.00,09.10.00,09.11.00,09.11.01,09.12.00,09.13.00,09.14.00,09.20.00,09.21.00,09.22.00,09.23.00,09.30.00,09.31.00,09.32.00,09.33.00,09.35.00,09.40.00,09.40.01,09.41.00,09.42.00,09.43.00,09.43.01,10.00.00,10.01.00,10.02.00,10.03.00,10.04.00,10.05.00,10.06.00</upgradeVersionsList>
</attributes>
</eventMessage>
</component>
Expand Down Expand Up @@ -534,7 +534,7 @@
</components>
</package>

<package name="2SexyContent-App" type="Module" version="10.05.00">
<package name="2SexyContent-App" type="Module" version="10.06.00">
<friendlyName> App</friendlyName>
<description>2sxc App is an extension that allows to install and use a 2sxc app.</description>
<iconFile>icon-app.png</iconFile>
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ToSic")]
[assembly: AssemblyProduct("2SexyContent")]
[assembly: AssemblyCopyright("© 2sic 2018")]
[assembly: AssemblyCopyright("© 2sic 2019")]
[assembly: AssemblyTrademark("")]
[assembly: Guid("bd90b92e-79ec-4846-8998-b56277d5b2b4")]

Expand All @@ -29,7 +29,7 @@
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("10.05.00.*")]
[assembly: AssemblyVersion("10.06.00.*")]


[assembly: InternalsVisibleTo("ToSic.SexyContent.WebApi")]
Expand Down
6 changes: 4 additions & 2 deletions Sxc WebApi/AppApiControllerSelector.cs
Expand Up @@ -93,13 +93,15 @@ public HttpControllerDescriptor SelectController(HttpRequestMessage request)
edition + "api/");
var controllerPath = Path.Combine(controllerFolder + controllerTypeName + ".cs");

// note: this may look like something you could optimize/cache the result, but that's a bad idea
// because when the file changes, the type-object will be different, so please don't optimize :)
if (File.Exists(HostingEnvironment.MapPath(controllerPath)))
{
var assembly = BuildManager.GetCompiledAssembly(controllerPath);
var type = assembly.GetType(controllerTypeName, true, true);

// attach the folder it's running in as a property, in case the target needs this
_config.Properties.TryAdd(CodeCompiler.SharedCodeRootPathKeyInCache, controllerFolder);
// try to fix path resolution
request.Properties.Add(CodeCompiler.SharedCodeRootPathKeyInCache, controllerFolder);

return new HttpControllerDescriptor(_config, controllerTypeName, type);
}
Expand Down
11 changes: 6 additions & 5 deletions Sxc WebApi/EavApiProxies/EntitiesController.cs
Expand Up @@ -77,7 +77,7 @@ public dynamic GetManyForEditing([FromBody] List<ItemIdentifier> items, int appI

// 2018-09-26 2dm
// if we're giving items which already exist, then we must verify that edit/read is allowed.
// todo: also share this code bit with the UiController
// important, this code is shared/duplicated in the UiController.Load
if (list.Any(set => set.Entity != null))
if (!permCheck.EnsureAll(GrantSets.ReadSomething, out exception))
throw exception;
Expand All @@ -95,11 +95,12 @@ public dynamic GetManyForEditing([FromBody] List<ItemIdentifier> items, int appI
// log and do security check
Log.Add($"save many started with a#{appId}, i⋮{items.Count}, partOfPage:{partOfPage}");

var permCheck = new SaveHelpers.Security(SxcInstance, Log).DoPreSaveSecurityCheck(appId, items);

#region check if it's an update, and do more security checks then
// todo: also share this code bit with the UiController
var appRead = new AppRuntime(appId, Log);
#region check if it's an update, and do more security checks - shared with UiController.Save
// basic permission checks
var permCheck = new SaveHelpers.Security(SxcInstance, Log)
.DoPreSaveSecurityCheck(appId, items);

var foundItems = items.Where(i => i.EntityId != 0 && i.EntityGuid != Guid.Empty)
.Select(i => i.EntityGuid != Guid.Empty
? appRead.Entities.Get(i.EntityGuid) // prefer guid access if available
Expand Down
3 changes: 1 addition & 2 deletions Sxc WebApi/EavApiProxies/UiController.cs
@@ -1,11 +1,10 @@
using System.Web.Http.Controllers;
using DotNetNuke.Security;
using DotNetNuke.Web.Api;

namespace ToSic.SexyContent.WebApi.EavApiProxies
{
[SupportedModules("2sxc,2sxc-app")]
[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.Admin)] // while in dev-mode, only for super-users
// 2019-09-18 2dm enabled [DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.Admin)] // while in dev-mode, only for super-users
[ValidateAntiForgeryToken]
public partial class UiController : SxcApiControllerBase
{
Expand Down
6 changes: 5 additions & 1 deletion Sxc WebApi/EavApiProxies/UiController_Load.cs
@@ -1,6 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using DotNetNuke.Security;
using DotNetNuke.Web.Api;
using ToSic.Eav.Apps.Parts;
using ToSic.Eav.Data.Builder;
using ToSic.Eav.ImportExport.Json;
Expand All @@ -19,6 +21,7 @@ public partial class UiController
{

[HttpPost]
[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.View)]
public AllInOne Load([FromBody] List<ItemIdentifier> items, int appId)
{
// Security check
Expand Down Expand Up @@ -56,6 +59,7 @@ public AllInOne Load([FromBody] List<ItemIdentifier> items, int appId)

// since we're retrieving data - make sure we're allowed to
// this is to ensure that if public forms only have create permissions, they can't access existing data
// important, this code is shared/duplicated in the EntitiesController.GetManyForEditing
if (list.Any(set => set.Entity != null))
if (!permCheck.EnsureAll(GrantSets.ReadSomething, out exception))
throw exception;
Expand All @@ -74,7 +78,7 @@ public AllInOne Load([FromBody] List<ItemIdentifier> items, int appId)
// load input-field configurations
result.InputTypes = GetNecessaryInputTypes(result.ContentTypes/*types*/, typeRead);

// also deliver features
// also include UI features
result.Features = SystemController.FeatureListWithPermissionCheck(appId, permCheck).ToList();

// done - return
Expand Down
21 changes: 18 additions & 3 deletions Sxc WebApi/EavApiProxies/UiController_Save.cs
Expand Up @@ -2,18 +2,21 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using DotNetNuke.Security;
using DotNetNuke.Web.Api;
using ToSic.Eav.Apps;
using ToSic.Eav.Data;
using ToSic.Eav.ImportExport.Json;
using ToSic.Eav.Interfaces;
using ToSic.Eav.Security.Permissions;
using ToSic.Eav.WebApi.Formats;

namespace ToSic.SexyContent.WebApi.EavApiProxies
{
public partial class UiController
{
// todo: replace object with Dictionary<Guid, int> when ready
[HttpPost]
[DnnModuleAuthorize(AccessLevel = SecurityAccessLevel.View)]
public Dictionary<Guid, int> Save([FromBody] AllInOne package, int appId, bool partOfPage)
{
Log.Add($"save started with a#{appId}, i⋮{package.Items.Count}, partOfPage:{partOfPage}");
Expand Down Expand Up @@ -41,8 +44,20 @@ public partial class UiController
};
validator.PrepareForEntityChecks(appRead);

// permission checks
var permCheck = new SaveHelpers.Security(SxcInstance, Log).DoPreSaveSecurityCheck(appId, package.Items);
#region check if it's an update, and do more security checks then - shared with EntitiesController.Save
// basic permission checks
var permCheck = new SaveHelpers.Security(SxcInstance, Log)
.DoPreSaveSecurityCheck(appId, package.Items);

var foundItems = package.Items.Where(i => i.EntityId != 0 && i.EntityGuid != Guid.Empty)
.Select(i => i.EntityGuid != Guid.Empty
? appRead.Entities.Get(i.EntityGuid) // prefer guid access if available
: appRead.Entities.Get(i.EntityId) // otherwise id
);
if (foundItems.Any(i => i != null) && !permCheck.EnsureAll(GrantSets.UpdateSomething, out var exception))
throw exception;
#endregion


var items = package.Items.Select(i =>
{
Expand Down
4 changes: 2 additions & 2 deletions Sxc WebApi/Properties/AssemblyInfo.cs
Expand Up @@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Sxc WebApi")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -30,4 +30,4 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("10.05.00.*")]
[assembly: AssemblyVersion("10.06.00.*")]
3 changes: 1 addition & 2 deletions Sxc WebApi/SxcApiController.cs
Expand Up @@ -48,8 +48,7 @@ protected override void Initialize(HttpControllerContext controllerContext)
// must run this after creating AppAndDataHelpers
controllerContext.Request.Properties.Add(Constants.DnnContextKey, Dnn);

// Pick up the path given by the AppApiControllerSelector - for relative paths needed in the SharedCode section
if(controllerContext.Configuration.Properties.TryGetValue(CodeCompiler.SharedCodeRootPathKeyInCache, out var value))
if(controllerContext.Request.Properties.TryGetValue(CodeCompiler.SharedCodeRootPathKeyInCache, out var value))
SharedCodeVirtualRoot = value as string;
}
#endregion
Expand Down
4 changes: 2 additions & 2 deletions ToSic.Sxc.Tests/2sxc core tests (ToSic.Sxc.Tests).csproj
Expand Up @@ -39,10 +39,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\eav-server\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
<HintPath>..\..\..\..\..\eav-server\packages\MSTest.TestFramework.2.0.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\eav-server\packages\MSTest.TestFramework.1.3.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
<HintPath>..\..\..\..\..\eav-server\packages\MSTest.TestFramework.2.0.0\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
2 changes: 1 addition & 1 deletion ToSic.Sxc.Tests/packages.config
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net451" />
<package id="MSTest.TestFramework" version="1.3.2" targetFramework="net451" />
<package id="MSTest.TestFramework" version="2.0.0" targetFramework="net451" />
</packages>
2 changes: 1 addition & 1 deletion ToSic.Sxc/Interfaces/IDynamicEntity.cs
Expand Up @@ -17,6 +17,6 @@ public interface IDynamicEntity

dynamic GetPublished();


bool IsDemoItem { get; }
}
}
4 changes: 2 additions & 2 deletions ToSic.Sxc/Properties/AssemblyInfo.cs
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("2sic internet solutions GmbH")]
[assembly: AssemblyProduct("ToSic.Sxc")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,7 +32,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("10.05.00.*")]
[assembly: AssemblyVersion("10.06.00.*")]

[assembly: InternalsVisibleTo("ToSic.SexyContent")]
[assembly: InternalsVisibleTo("ToSic.SexyContent.WebApi")]
Expand Down
15 changes: 11 additions & 4 deletions ToSic.Sxc/SexyContent/DataSources/ModuleDataSource.cs
Expand Up @@ -83,10 +83,8 @@ private ContentGroup ContentGroup
Log.Add("need content-group, will construct as cannot use context");
if (!InstanceId.HasValue)
throw new Exception("Looking up ContentGroup failed because ModuleId is null.");
// 2018-03-05 2dm moved into the contentgroupmanager
//var tabId = ModuleController.Instance.GetTabModulesByModule(InstanceId.Value)[0].TabID;
var publish = Factory.Resolve<IEnvironmentFactory>().PagePublisher(Log);
var userMayEdit = HasSxcContext && SxcInstance.UserMayEdit;// Factory.Resolve<IPermissions>().UserMayEditContent(SxcInstance?.InstanceInfo);
var userMayEdit = HasSxcContext && SxcInstance.UserMayEdit;

var cgm = new ContentGroupManager(ZoneId, AppId,
HasSxcContext && userMayEdit, publish.IsEnabled(InstanceId.Value),
Expand Down Expand Up @@ -153,13 +151,20 @@ private IEnumerable<IEntity> GetStream(List<IEntity> contentList, IEntity conten
{
for (; i < contentEntities.Count; i++)
{
// new 2019-09-18 trying to mark demo-items for better detection in output #1792
var usingDemoItem = false;

// get the entity, if null: try to substitute with the demo item
var contentEntity = contentEntities[i];

// check if it "exists" in the in-stream. if not, then it's probably unpublished
// so try revert back to the demo-item (assuming it exists...)
if (contentEntity == null || !originals.Has(contentEntity.EntityId))
{
contentEntity = contentDemoEntity;
// new 2019-09-18 trying to mark demo-items for better detection in output #1792
usingDemoItem = true;
}

// now check again...
// ...we can't deliver entities that are not delivered by base (original stream), so continue
Expand Down Expand Up @@ -206,7 +211,9 @@ private IEnumerable<IEntity> GetStream(List<IEntity> contentList, IEntity conten
SortOrder = isListHeader ? -1 : i,
ContentGroupItemModified = itm.Modified,
Presentation = presentationEntity,
GroupId = ContentGroup.ContentGroupGuid
GroupId = ContentGroup.ContentGroupGuid,
// new 2019-09-18 trying to mark demo-items for better detection in output #1792
IsDemoItem = usingDemoItem
});
}
catch (Exception ex)
Expand Down
7 changes: 7 additions & 0 deletions ToSic.Sxc/SexyContent/DynamicEntity.cs
Expand Up @@ -135,6 +135,13 @@ public class ContentConfiguration

public dynamic GetPublished() => new DynamicEntity(Entity.GetPublished(), _dimensions, SxcInstance);

/// <summary>
/// Tell the system that it's a demo item, not one added by the user
/// 2019-09-18 trying to mark demo-items for better detection in output #1792
/// </summary>
/// <returns></returns>
public bool IsDemoItem => Entity is EntityInContentGroup entInCg && entInCg.IsDemoItem;

public IHtmlString Render() => ContentBlocks.Render.One(this);


Expand Down

0 comments on commit 2513822

Please sign in to comment.