public void SetAppIdForInstance(IInstanceInfo instance, IAppEnvironment env, int?appId, Log parentLog) { Log.Add($"SetAppIdForInstance({instance.Id}, -, appid: {appId})"); // Reset temporary template ContentGroupManager.ClearPreviewTemplate(instance.Id); // ToDo: Should throw exception if a real ContentGroup exists var module = (instance as EnvironmentInstance <ModuleInfo>).Original; var zoneId = env.ZoneMapper.GetZoneId(module.OwnerPortalID); if (appId == 0 || !appId.HasValue) { DnnStuffToRefactor.UpdateInstanceSettingForAllLanguages(instance.Id, Settings.AppNameString, null, Log); } else { var appName = ((BaseCache)DataSource.GetCache(0, 0)).ZoneApps[zoneId].Apps[appId.Value]; DnnStuffToRefactor.UpdateInstanceSettingForAllLanguages(instance.Id, Settings.AppNameString, appName, Log); } // Change to 1. available template if app has been set if (appId.HasValue) { var app = App.LightWithoutData(new DnnTenant(null), zoneId, appId.Value, parentLog: Log); var templateGuid = app.TemplateManager.GetAllTemplates().FirstOrDefault(t => !t.IsHidden)?.Guid; if (templateGuid.HasValue) { ContentGroupManager.SetPreviewTemplate(instance.Id, templateGuid.Value); } } }
internal void PersistContentGroupAndBlankTemplateToModule(int moduleId, bool wasCreated, Guid guid) { // Remove the previewTemplateId (because it's not needed as soon Content is inserted) DeletePreviewTemplateId(moduleId); // Update contentGroup Guid for this module if (wasCreated) { DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(moduleId, Settings.ContentGroupGuidString, guid.ToString()); } }
public void SetContentGroupAndBlankTemplate(int instanceId, bool wasCreated, Guid guid) { // Remove the previewTemplateId (because it's not needed as soon Content is inserted) ClearPreviewTemplate(instanceId); // Update contentGroup Guid for this module if (wasCreated) { DnnStuffToRefactor.UpdateInstanceSettingForAllLanguages(instanceId, Settings.ContentGroupGuidString, guid.ToString()); } }
/// <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."); } DnnStuffToRefactor.UpdateInstanceSettingForAllLanguages(instanceId, Settings.PreviewTemplateIdString, previewTemplateGuid.ToString(), Log); }
/// <summary> /// Saves a temporary templateId to the module's settings /// This templateId will be used until a contentgroup exists /// </summary> /// <param name="moduleId"></param> /// <param name="previewTemplateGuid"></param> public void SetModulePreviewTemplateId(int moduleId, 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.GetModuleSettings(moduleId); // 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."); } //var dataSource = DataSource.GetInitialDataSource(_zoneId, _appId); //var previewTemplateGuid = dataSource.List[previewTemplateId].EntityGuid; //moduleController.UpdateModuleSetting(moduleId, PreviewTemplateIdString, previewTemplateGuid.ToString()); DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(moduleId, Settings.PreviewTemplateIdString, previewTemplateGuid.ToString()); }
public void ClearPreviewTemplate(int instanceId) { Log.Add($"ClearPreviewTemplate(iid: {instanceId})"); DnnStuffToRefactor.UpdateInstanceSettingForAllLanguages(instanceId, Settings.PreviewTemplateIdString, null, Log); }
public static void DeletePreviewTemplateId(int moduleId) { DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(moduleId, Settings.PreviewTemplateIdString, null); }
internal override void SetTemplateChooserState(bool state) => DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(ModuleId, Settings.SettingsShowTemplateChooser, state.ToString());
public void ClearPreviewTemplate(int instanceId) { DnnStuffToRefactor.UpdateInstanceSettingForAllLanguages(instanceId, Settings.PreviewTemplateIdString, null); }