public void SetAppId(IContainer instance, /*IAppEnvironment env,*/ int?appId, ILog parentLog) { Log.Add($"SetAppIdForInstance({instance.Id}, -, appid: {appId})"); // Reset temporary template ClearPreview(instance.Id); // ToDo: Should throw exception if a real BlockConfiguration exists var module = (instance as Container <ModuleInfo>).UnwrappedContents; var zoneId = _environment.ZoneMapper.GetZoneId(module.OwnerPortalID); if (appId == Constants.AppIdEmpty || !appId.HasValue) { DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instance.Id, Settings.AppNameString, null, Log); } else { var appName = State.Zones[zoneId].Apps[appId.Value]; DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instance.Id, Settings.AppNameString, appName, Log); } // Change to 1. available template if app has been set if (appId.HasValue) { var appIdentity = new AppIdentity(zoneId, appId.Value); var cms = new CmsRuntime(appIdentity, Log, true, _environment.PagePublishing.IsEnabled(instance.Id)); var templateGuid = cms.Views.GetAll().FirstOrDefault(t => !t.IsHidden)?.Guid; if (templateGuid.HasValue) { SetPreview(instance.Id, templateGuid.Value); } } }
public void SetContentGroup(int instanceId, bool blockExists, Guid guid) { Log.Add($"SetContentGroup(iid: {instanceId}, {nameof(blockExists)}: {blockExists}, guid: {guid})"); // Remove Preview because it's not needed as soon Content is inserted ClearPreview(instanceId); // Update blockConfiguration Guid for this module if (blockExists) { DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instanceId, Settings.FieldContentGroup, guid.ToString(), Log); } }
public void SetContentGroup(int instanceId, bool wasCreated, Guid guid) { Log.Add($"SetContentGroup(iid: {instanceId}, wasCreated: {wasCreated}, guid: {guid})"); // Remove the previewTemplateId (because it's not needed as soon Content is inserted) ClearPreviewTemplate(instanceId); // Update blockConfiguration Guid for this module if (wasCreated) { DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instanceId, Settings.ContentGroupGuidString, guid.ToString(), Log); } }
/// <summary> /// Saves a temporary templateId to the module's settings /// This templateId will be used until a ContentGroup exists /// </summary> public void SetPreview(int instanceId, Guid previewView) { var moduleController = new ModuleController(); var settings = moduleController.GetModule(instanceId).ModuleSettings; // Do not allow saving the temporary template id if a ContentGroup exists for this module if (settings[Settings.FieldContentGroup] != null) { throw new Exception("Preview template id cannot be set for a module that already has content."); } DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instanceId, Settings.FieldPreviewTemplate, previewView.ToString(), Log); }
/// <summary> /// Saves a temporary templateId to the module's settings /// This templateId will be used until a contentgroup exists /// </summary> public void SetPreviewTemplate(int instanceId, Guid previewTemplateGuid) { // todo: 2rm - I believe you are accidentally using uncached module settings access - pls check and probably change // todo: note: this is done ca. 3x in this class var moduleController = new ModuleController(); var settings = moduleController.GetModule(instanceId).ModuleSettings;// older, deprecated api: .GetModuleSettings(instanceId); // Do not allow saving the temporary template id if a contentgroup exists for this module if (settings[Settings.ContentGroupGuidString] != null) { throw new Exception("Preview template id cannot be set for a module that already has content."); } DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instanceId, Settings.PreviewTemplateIdString, previewTemplateGuid.ToString(), Log); }
protected void ClearPreview(int instanceId) { Log.Add($"ClearPreviewTemplate(iid: {instanceId})"); DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instanceId, Settings.FieldPreviewTemplate, null, Log); }
public void ClearPreviewTemplate(int instanceId) { Log.Add($"ClearPreviewTemplate(iid: {instanceId})"); DnnTenantSettings.UpdateInstanceSettingForAllLanguages(instanceId, Settings.PreviewTemplateIdString, null, Log); }