Beispiel #1
0
        internal static void SetAppIdForModule(ModuleInfo module, IEnvironment <PortalSettings> env, int?appId, Log parentLog)
        {
            // Reset temporary template
            ContentGroupManager.DeletePreviewTemplateId(module.ModuleID);

            // ToDo: Should throw exception if a real ContentGroup exists

            var zoneId = /*new Environment.DnnEnvironment(parentLog)*/ env.ZoneMapper.GetZoneId(module.OwnerPortalID);// ZoneHelpers.GetZoneId(module.OwnerPortalID);

            if (appId == 0 || !appId.HasValue)
            {
                DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(module.ModuleID, Settings.AppNameString, null);
            }
            else
            {
                var appName = ((BaseCache)DataSource.GetCache(0, 0)).ZoneApps[zoneId].Apps[appId.Value];
                DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(module.ModuleID, Settings.AppNameString, appName);
            }

            // Change to 1. available template if app has been set
            if (appId.HasValue)
            {
                var app          = new App(zoneId, appId.Value, PortalSettings.Current);
                var templateGuid = app.TemplateManager.GetAllTemplates().FirstOrDefault(t => !t.IsHidden)?.Guid;// .GetFirstTemplateGuid(module.ModuleID, module.TabID, app.ContentGroupManager);
                if (templateGuid.HasValue)
                {
                    app.ContentGroupManager.SetModulePreviewTemplateId(module.ModuleID, templateGuid.Value);
                }
            }
        }
Beispiel #2
0
        public static void SetAppIdForModule(ModuleInfo module, int?appId)
        {
            //var moduleController = new ModuleController();

            // Reset temporary template
            ContentGroupManager.DeletePreviewTemplateId(module.ModuleID);

            // ToDo: Should throw exception if a real ContentGroup exists

            var zoneId = ZoneHelpers.GetZoneID(module.OwnerPortalID);

            if (appId == 0 || !appId.HasValue)
            {
                //moduleController.DeleteModuleSetting(module.ModuleID, AppNameString);
                DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(module.ModuleID, Settings.AppNameString, null);
            }
            else
            {
                var appName = ((BaseCache)DataSource.GetCache(0, 0)).ZoneApps[zoneId.Value].Apps[appId.Value];
                //moduleController.UpdateModuleSetting(module.ModuleID, AppNameString, appName);
                DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(module.ModuleID, Settings.AppNameString, appName);
            }

            // Change to 1. available template if app has been set
            if (appId.HasValue)
            {
                //var sexyForNewApp = new SxcInstance(zoneId.Value, appId.Value);// 2016-03-26 2dm this used to have a third parameter false = don't enable caching, which hasn't been respected for a while; removed it
                var app       = new App(zoneId.Value, appId.Value, PortalSettings.Current);
                var templates = app.TemplateManager.GetAvailableTemplatesForSelector(module.ModuleID, app.ContentGroupManager).ToList();
                if (templates.Any())
                {
                    app.ContentGroupManager.SetModulePreviewTemplateId(module.ModuleID, templates.First().Guid /* .TemplateId */);
                }
            }
        }
Beispiel #3
0
        public static void SetAppIdForModule(ModuleInfo module, int?appId)
        {
            // Reset temporary template
            ContentGroupManager.DeletePreviewTemplateId(module.ModuleID);

            // ToDo: Should throw exception if a real ContentGroup exists

            var zoneId = ZoneHelpers.GetZoneID(module.OwnerPortalID);

            if (appId == 0 || !appId.HasValue)
            {
                DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(module.ModuleID, Settings.AppNameString, null);
            }
            else
            {
                var appName = ((BaseCache)DataSource.GetCache(0, 0)).ZoneApps[zoneId.Value].Apps[appId.Value];
                DnnStuffToRefactor.UpdateModuleSettingForAllLanguages(module.ModuleID, Settings.AppNameString, appName);
            }

            // Change to 1. available template if app has been set
            if (appId.HasValue)
            {
                var app       = new App(zoneId.Value, appId.Value, PortalSettings.Current);
                var templates = app.TemplateManager.GetAvailableTemplatesForSelector(module.ModuleID, app.ContentGroupManager).ToList();
                if (templates.Any())
                {
                    app.ContentGroupManager.SetModulePreviewTemplateId(module.ModuleID, templates.First().Guid /* .TemplateId */);
                }
            }
        }
Beispiel #4
0
        //public class AppResponse
        //{
        //    public int AppId;
        //    public bool IsStored;
        //    public bool IsDefaultApp;
        //}

        public static int?GetAppIdFromModule(ModuleInfo module, int zoneId)
        {
            if (module.DesktopModule.ModuleName == "2sxc")
            {
                return(GetDefaultAppId(zoneId));// : new int?();
            }
            var appName = DnnStuffToRefactor.TryToGetReliableSetting(module, Settings.AppNameString);

            if (appName != null)
            {
                return(GetAppIdFromName(zoneId, appName));
            }

            return(null);
        }