Exemplo n.º 1
0
        private void RemoveModuleControls(IEnumerable <string> controls)
        {
            logger.LogStep("08.--.--", "RemoveModuleControlls - Start", false);

            var desktopModuleNames = new[] { "2sxc", "2sxc-app" };

            // Remove settings and settingswrapper control
            foreach (var d in desktopModuleNames)
            {
                var dmi = DesktopModuleController.GetDesktopModuleByModuleName(d, -1);
                if (dmi != null)
                {
                    var mdi = dmi.ModuleDefinitions.FirstOrDefault();

                    if (mdi.Value != null)
                    {
                        foreach (var c in controls)
                        {
                            var settingsControl = ModuleControlController.GetModuleControlByControlKey(c, mdi.Value.ModuleDefID);
                            if (settingsControl != null)
                            {
                                ModuleControlController.DeleteModuleControl(settingsControl.ModuleControlID);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected override DesktopModuleInfo GetDesktopModule(PaFolder Folder)
        {
            DesktopModuleController objDesktopModules = new DesktopModuleController();
            DesktopModuleInfo       objDesktopModule  = objDesktopModules.GetDesktopModuleByModuleName(Folder.ModuleName);

            return(objDesktopModule);
        }
Exemplo n.º 3
0
        public string UpgradeModule(string Version)
        {
            switch (Version)
            {
            case "05.01.02":
                //remove the Code SubDirectory
                Config.RemoveCodeSubDirectory("HTML");

                //Once the web.config entry is done we can safely remove the HTML folder
                var arrPaths = new string[1];
                arrPaths[0] = "App_Code\\HTML\\";
                FileSystemUtils.DeleteFiles(arrPaths);
                break;

            case "06.00.00":
                DesktopModuleInfo desktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DNN_HTML", Null.NullInteger);
                desktopModule.Category = "Common";
                DesktopModuleController.SaveDesktopModule(desktopModule, false, false);
                break;

            case "06.02.00":
                AddNotificationTypes();
                break;
            }

            return(string.Empty);
        }
        public void CategorizeHccModule(string moduleName)
        {
            var  objDesktopModule   = DesktopModuleController.GetDesktopModuleByModuleName(moduleName, Null.NullInteger);
            var  vocabularyId       = -1;
            var  termController     = Util.GetTermController();
            Term moduleCategoryTerm = null;

            foreach (var term in termController.GetTermsByVocabulary("Module_Categories"))
            {
                vocabularyId = term.VocabularyId;
                if (term.Name == MODULE_CATEGORY)
                {
                    moduleCategoryTerm = term;
                    break;
                }
            }
            if (moduleCategoryTerm == null)
            {
                moduleCategoryTerm      = new Term(vocabularyId);
                moduleCategoryTerm.Name = MODULE_CATEGORY;
                termController.AddTerm(moduleCategoryTerm);
            }
            var contentItem        = Util.GetContentController().GetContentItem(objDesktopModule.ContentItemId);
            var contentItemTermIds = contentItem.Terms.Select(t => t.TermId).ToList();

            if (!contentItemTermIds.Contains(moduleCategoryTerm.TermId))
            {
                termController.AddTermToContent(moduleCategoryTerm, contentItem);
            }
        }
Exemplo n.º 5
0
        public bool HaveApi()
        {
            if (!this.haveChecked)
            {
                try
                {
                    if (DesktopModuleController.GetDesktopModuleByModuleName("PageLocalization", PortalSettings.Current.PortalId) != null)
                    {
                        var api     = Activator.CreateInstance("Apollo.LocalizationApi", "Apollo.DNN_Localization.LocalizeTab").Unwrap();
                        var apiType = api.GetType();
                        this.apiMember = apiType.GetMethod("getLocalizedTab", new[] { typeof(TabInfo) });
                    }
                }

                // ReSharper disable EmptyGeneralCatchClause
                catch

                // ReSharper restore EmptyGeneralCatchClause
                {
                }

                this.haveChecked = true;
            }

            return(this.apiMember != null);
        }
Exemplo n.º 6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Install method installs the UrlProvider component.
        /// </summary>
        /// -----------------------------------------------------------------------------
        public override void Install()
        {
            try
            {
                // Ensure DesktopModule Cache is cleared
                DataCache.RemoveCache(string.Format(DataCache.DesktopModuleCacheKey, Null.NullInteger));

                var desktopModule = DesktopModuleController.GetDesktopModuleByModuleName(this._desktopModuleName, Null.NullInteger);
                if (desktopModule != null)
                {
                    this._extensionUrlProvider.DesktopModuleId = desktopModule.DesktopModuleID;
                }

                // Attempt to get the Desktop Module
                this._installedExtensionUrlProvider = ExtensionUrlProviderController.GetProviders(Null.NullInteger)
                                                      .SingleOrDefault(p => p.ProviderType == this._extensionUrlProvider.ProviderType);

                if (this._installedExtensionUrlProvider != null)
                {
                    this._extensionUrlProvider.ExtensionUrlProviderId = this._installedExtensionUrlProvider.ExtensionUrlProviderId;
                }

                ExtensionUrlProviderController.SaveProvider(this._extensionUrlProvider);

                this.Completed = true;
                this.Log.AddInfo(string.Format(Util.URLPROVIDER_Registered, this._extensionUrlProvider.ProviderName));
            }
            catch (Exception ex)
            {
                this.Log.AddFailure(ex);
            }
        }
Exemplo n.º 7
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Install method installs the Module component
        /// </summary>
        /// -----------------------------------------------------------------------------
        public override void Install()
        {
            try
            {
                //Attempt to get the Desktop Module
                _installedDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName(_desktopModule.ModuleName, Package.InstallerInfo.PortalID);

                if (_installedDesktopModule != null)
                {
                    _desktopModule.DesktopModuleID = _installedDesktopModule.DesktopModuleID;
                    //save the module's category
                    _desktopModule.Category = _installedDesktopModule.Category;
                }

                //Clear ModuleControls and Module Definitions caches in case script has modifed the contents
                DataCache.RemoveCache(DataCache.ModuleDefinitionCacheKey);
                DataCache.RemoveCache(DataCache.ModuleControlsCacheKey);

                //Save DesktopModule and child objects to database
                _desktopModule.PackageID       = Package.PackageID;
                _desktopModule.DesktopModuleID = DesktopModuleController.SaveDesktopModule(_desktopModule, true, false);

                Completed = true;
                Log.AddInfo(string.Format(Util.MODULE_Registered, _desktopModule.ModuleName));
            }
            catch (Exception ex)
            {
                Log.AddFailure(ex);
            }
        }
        private static IEnumerable <KeyValuePair <int, string> > GetMonikersForList(string moduleList)
        {
            var portalId          = PortalSettings.Current.PortalId;
            var tabsController    = TabController.Instance;
            var modulesController = ModuleController.Instance;
            var resultIds         = new List <int>();

            var monikers = TabModulesController.Instance.GetTabModuleSettingsByName("Moniker");
            var modules  = modulesController.GetAllTabsModules(portalId, false).OfType <ModuleInfo>()
                           .Where(tabmodule => monikers.ContainsKey(tabmodule.TabModuleID)).ToArray();

            if (modules.Any())
            {
                foreach (var moduleName in (moduleList ?? "").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    var dtmRecord = DesktopModuleController.GetDesktopModuleByModuleName(moduleName, portalId);
                    if (dtmRecord != null)
                    {
                        var allowedTabs = modules.Where(m => m.DesktopModuleID == dtmRecord.DesktopModuleID)
                                          .Select(m => m.TabID).Distinct()
                                          .Where(tabId => TabPermissionController.CanViewPage(tabsController.GetTab(tabId, portalId)));

                        var allowedTabModules = modules.Where(tabModule => allowedTabs.Contains(tabModule.TabID) &&
                                                              ModulePermissionController.CanViewModule(modulesController.GetModule(tabModule.ModuleID, tabModule.TabID, false)));

                        resultIds.AddRange(allowedTabModules.Select(tabModule => tabModule.TabModuleID));
                    }
                }
            }

            return(monikers.Where(kpv => resultIds.Contains(kpv.Key)));
        }
        /// <summary>
        /// Logs a user's current activity (aka action) via the mechanics API.
        /// </summary>
        /// <param name="actionName"></param>
        /// <param name="userid"></param>
        /// <param name="portalid"></param>
        /// <param name="contentItemId"></param>
        /// <param name="context"></param>
        /// <param name="notes"></param>
        public int LogUserActivity(string actionName,
                                   int userid,
                                   int portalid,
                                   int contentItemId,
                                   string context,
                                   string notes)
        {
            var desktopModuleId = DesktopModuleController.GetDesktopModuleByModuleName(Constants.DESKTOPMODULE_NAME, portalid).DesktopModuleID;
            int ret             = -1;

            if (desktopModuleId > 0)
            {
                var smCtrl = MechanicsController.Instance;
                ScoringActionDefinition adef = smCtrl.GetScoringActionDefinition(actionName, DesktopModule.DesktopModuleID);
                if (adef == null)
                {
                    AddScoringDefinitions();
                }

                if (adef != null)
                {
                    ret = smCtrl.LogUserActivity(adef.ActionName, adef.DesktopModuleId, new UserScoreLog
                    {
                        ContentItemId      = contentItemId,
                        Context            = context,
                        Notes              = notes,
                        CreatedOnDate      = DateTime.Now,
                        ScoringActionDefId = adef.ScoringActionDefId,
                        PortalId           = portalid,
                        UserId             = userid
                    });
                }
            }
            return(ret);
        }
        /// <summary>
        /// Fill DropDownList with Portal Tabs
        /// </summary>
        private void FillYafInstances()
        {
            var objTabController = new TabController();

            var objTabs = TabController.GetPortalTabs(this.PortalSettings.PortalId, -1, true, true);

            var objDesktopModuleInfo =
                DesktopModuleController.GetDesktopModuleByModuleName("YetAnotherForumDotNet", this.PortalId);

            if (objDesktopModuleInfo == null)
            {
                return;
            }

            objTabs.Where(tab => tab != null && !tab.IsDeleted).ForEach(
                objTab =>
            {
                var objModules = new ModuleController();

                foreach (var pair in objModules.GetTabModules(objTab.TabID))
                {
                    var objModule = pair.Value;

                    if (objModule.IsDeleted ||
                        objModule.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID)
                    {
                        continue;
                    }

                    var strPath        = objTab.TabName;
                    var objTabSelected = objTab;

                    while (objTabSelected.ParentId != Null.NullInteger)
                    {
                        objTabSelected = objTabController.GetTab(
                            objTabSelected.ParentId,
                            objTab.PortalID,
                            false);
                        if (objTabSelected == null)
                        {
                            break;
                        }

                        strPath = $"{objTabSelected.TabName} -> {strPath}";
                    }

                    var objListItem = new ListItem
                    {
                        Value = $"{objModule.TabID}-{objModule.ModuleID}",
                        Text  = $"{strPath} -> {objModule.ModuleTitle}"
                    };

                    this.YafInstances.Items.Add(objListItem);
                }
            });
        }
        /// <summary>
        /// Fill DropDownList with Portal Tabs
        /// </summary>
        private void FillYafInstances()
        {
            var objTabController = new TabController();

            var objTabs = TabController.GetPortalTabs(this.PortalSettings.PortalId, -1, true, true);

            var objDesktopModuleInfo =
                DesktopModuleController.GetDesktopModuleByModuleName("YetAnotherForumDotNet", this.PortalId);

            if (objDesktopModuleInfo == null)
            {
                return;
            }

            foreach (var objTab in objTabs)
            {
                if (objTab == null || objTab.IsDeleted)
                {
                    continue;
                }

                var objModules = new ModuleController();

                foreach (var pair in objModules.GetTabModules(objTab.TabID))
                {
                    var objModule = pair.Value;

                    if (objModule.IsDeleted || objModule.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID)
                    {
                        continue;
                    }

                    var strPath        = objTab.TabName;
                    var objTabSelected = objTab;

                    while (objTabSelected.ParentId != Null.NullInteger)
                    {
                        objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, false);
                        if (objTabSelected == null)
                        {
                            break;
                        }

                        strPath = "{0} -> {1}".FormatWith(objTabSelected.TabName, strPath);
                    }

                    var objListItem = new ListItem
                    {
                        Value = "{0}-{1}".FormatWith(objModule.TabID, objModule.ModuleID),
                        Text  = "{0} -> {1}".FormatWith(strPath, objModule.ModuleTitle)
                    };

                    this.YafInstances.Items.Add(objListItem);
                }
            }
        }
Exemplo n.º 12
0
        public bool HaveApi()
        {
            if (!this.haveChecked)
            {
                this.found       = DesktopModuleController.GetDesktopModuleByModuleName("effority.Ealo.Tabs", PortalSettings.Current.PortalId) != null;
                this.haveChecked = true;
            }

            return(this.found);
        }
Exemplo n.º 13
0
        private static ArrayList GetModulesByDefinition(int portalId, string modulename)
        {
            var mc = new ModuleController();
            var dm = DesktopModuleController.GetDesktopModuleByModuleName(modulename, portalId);
            var md = ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(dm.DesktopModuleID).Values.First();

            ArrayList modules = mc.GetModulesByDefinition(portalId, md.FriendlyName);

            return(modules);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Fills the active forums list.
        /// </summary>
        private void FillActiveForumsList()
        {
            var objTabController = new TabController();

            var objDesktopModuleInfo =
                DesktopModuleController.GetDesktopModuleByModuleName("Active Forums", this.PortalId);

            if (objDesktopModuleInfo == null)
            {
                this.ActiveForumsPlaceHolder.Visible = false;
                return;
            }

            var tabs = TabController.GetPortalTabs(this.PortalSettings.PortalId, -1, true, true);

            tabs.Where(tab => !tab.IsDeleted).ForEach(
                tabInfo =>
            {
                var moduleController = new ModuleController();

                var tabModules = moduleController.GetTabModules(tabInfo.TabID).Select(pair => pair.Value).Where(
                    m => !m.IsDeleted && m.DesktopModuleID == objDesktopModuleInfo.DesktopModuleID);

                tabModules.ForEach(
                    moduleInfo =>
                {
                    var path        = tabInfo.TabName;
                    var tabSelected = tabInfo;

                    while (tabSelected.ParentId != Null.NullInteger)
                    {
                        tabSelected = objTabController.GetTab(tabSelected.ParentId, tabInfo.PortalID, false);
                        if (tabSelected == null)
                        {
                            break;
                        }

                        path = $"{tabSelected.TabName} -> {path}";
                    }

                    var objListItem = new ListItem
                    {
                        Value = moduleInfo.ModuleID.ToString(), Text = $"{path} -> {moduleInfo.ModuleTitle}"
                    };

                    this.ActiveForums.Items.Add(objListItem);
                });
            });

            if (this.ActiveForums.Items.Count == 0)
            {
                this.ActiveForumsPlaceHolder.Visible = false;
            }
        }
Exemplo n.º 15
0
        private static void GenerateAdminTab(string friendlyModuleName, int portalId)
        {
            var tabId = TabController.GetTabByTabPath(portalId, $"//Admin//{friendlyModuleName}", Null.NullString);

            if (tabId == Null.NullInteger)
            {
                var adminTabId = TabController.GetTabByTabPath(portalId, @"//Admin", Null.NullString);

                // create new page
                int parentTabId = adminTabId;
                var tabName     = friendlyModuleName;
                var tabPath     = Globals.GenerateTabPath(parentTabId, tabName);
                tabId = TabController.GetTabByTabPath(portalId, tabPath, Null.NullString);
                if (tabId == Null.NullInteger)
                {
                    //Create a new page
                    var newTab = new TabInfo
                    {
                        TabName       = tabName,
                        ParentId      = parentTabId,
                        PortalID      = portalId,
                        IsVisible     = true,
                        IconFile      = "~/Images/icon_search_16px.gif",
                        IconFileLarge = "~/Images/icon_search_32px.gif"
                    };
                    newTab.TabID = new TabController().AddTab(newTab, false);
                    tabId        = newTab.TabID;
                }
            }

            // create new module
            var moduleCtl = new ModuleController();

            if (moduleCtl.GetTabModules(tabId).Count == 0)
            {
                var dm = DesktopModuleController.GetDesktopModuleByModuleName(friendlyModuleName, portalId);
                var md = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(friendlyModuleName, dm.DesktopModuleID);

                var objModule = new ModuleInfo
                {
                    PortalID               = portalId,
                    TabID                  = tabId,
                    ModuleOrder            = Null.NullInteger,
                    ModuleTitle            = friendlyModuleName,
                    PaneName               = Globals.glbDefaultPane,
                    ModuleDefID            = md.ModuleDefID,
                    InheritViewPermissions = true,
                    AllTabs                = false,
                    IconFile               = "~/Images/icon_search_32px.gif"
                };
                moduleCtl.AddModule(objModule);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 绑定模块
        /// </summary>
        private void BindModules()
        {
            DesktopModuleInfo objDesktopModuleInfo = DesktopModuleController.GetDesktopModuleByModuleName("Playngo.ClientZone", PortalId);


            if ((objDesktopModuleInfo != null))
            {
                TabController objTabController = new TabController();
                ArrayList     objTabs          = objTabController.GetTabsByPortal(PortalId).ToArrayList();
                foreach (DotNetNuke.Entities.Tabs.TabInfo objTab in objTabs)
                {
                    if ((objTab != null))
                    {
                        if ((objTab.IsDeleted == false))
                        {
                            ModuleController objModules = new ModuleController();
                            foreach (KeyValuePair <int, ModuleInfo> pair in objModules.GetTabModules(objTab.TabID))
                            {
                                ModuleInfo objModule = pair.Value;
                                if ((objModule.IsDeleted == false))
                                {
                                    if ((objModule.DesktopModuleID == objDesktopModuleInfo.DesktopModuleID))
                                    {
                                        if (ModulePermissionController.CanEditModuleContent(objModule) & objModule.IsDeleted == false)
                                        {
                                            string  strPath        = objTab.TabName;
                                            TabInfo objTabSelected = objTab;
                                            while (objTabSelected.ParentId != Null.NullInteger)
                                            {
                                                objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, false);
                                                if ((objTabSelected == null))
                                                {
                                                    break; // TODO: might not be correct. Was : Exit While
                                                }
                                                strPath = objTabSelected.TabName + " -> " + strPath;
                                            }

                                            ListItem objListItem = new ListItem();

                                            objListItem.Value = objModule.TabID.ToString() + "-" + objModule.ModuleID.ToString();
                                            objListItem.Text  = strPath + " -> " + objModule.ModuleTitle;

                                            ddlModule.Items.Add(objListItem);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                WebHelper.SelectedListByValue(ddlModule, String.Format("{0}-{1}", Settings_TabID, Settings_ModuleID));
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 绑定模块列表
        /// </summary>
        private void BindModuleList()
        {
            DesktopModuleInfo objDesktopModuleInfo = DesktopModuleController.GetDesktopModuleByModuleName("DNNGo.LayerGallery", PortalId);

            ddlTabModule.Items.Clear();
            if ((objDesktopModuleInfo != null))
            {
                int           aPortalId        = Convert.ToInt32(ddlPortals.Items[ddlPortals.SelectedIndex].Value);
                TabController objTabController = new TabController();
                ArrayList     objTabs          = objTabController.GetTabsByPortal(aPortalId).ToArrayList();
                foreach (DotNetNuke.Entities.Tabs.TabInfo objTab in objTabs)
                {
                    if ((objTab != null))
                    {
                        if ((objTab.IsDeleted == false))
                        {
                            ModuleController objModules = new ModuleController();
                            foreach (KeyValuePair <int, ModuleInfo> pair in objModules.GetTabModules(objTab.TabID))
                            {
                                ModuleInfo objModule = pair.Value;
                                if ((objModule.IsDeleted == false))
                                {
                                    if ((objModule.DesktopModuleID == objDesktopModuleInfo.DesktopModuleID))
                                    {
                                        if (ModulePermissionController.CanEditModuleContent(objModule) & objModule.IsDeleted == false)
                                        {
                                            string  strPath        = objTab.TabName;
                                            TabInfo objTabSelected = objTab;
                                            while (objTabSelected.ParentId != Null.NullInteger)
                                            {
                                                objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, false);
                                                if ((objTabSelected == null))
                                                {
                                                    break; // TODO: might not be correct. Was : Exit While
                                                }
                                                strPath = objTabSelected.TabName + " -> " + strPath;
                                            }

                                            ListItem objListItem = new ListItem();

                                            objListItem.Value = objModule.TabID.ToString() + "-" + objModule.ModuleID.ToString();
                                            objListItem.Text  = strPath + " -> " + objModule.ModuleTitle;

                                            ddlTabModule.Items.Add(objListItem);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 18
0
        public static List <ListItem> GetModuleList(string ModuleName)
        {
            List <ListItem> lst                        = new List <ListItem>();
            PortalSettings  portalSettings             = PortalController.GetCurrentPortalSettings();
            List <TabInfo>  objTabs                    = TabController.GetPortalTabs(portalSettings.PortalId, -1, true, true);
            var             objTabController           = new TabController();
            var             objDesktopModuleController = new DesktopModuleController();
            var             objDesktopModuleInfo       = objDesktopModuleController.GetDesktopModuleByModuleName(ModuleName);

            if (objDesktopModuleInfo == null)
            {
                objDesktopModuleInfo = objDesktopModuleController.GetDesktopModuleByName(ModuleName);
                if (objDesktopModuleInfo == null)
                {
                    return(lst);
                }
            }
            foreach (TabInfo objTab in objTabs.Where(tab => !tab.IsDeleted))
            {
                ModuleController objModules = new ModuleController();
                foreach (KeyValuePair <int, ModuleInfo> pair in objModules.GetTabModules(objTab.TabID))
                {
                    ModuleInfo objModule = pair.Value;
                    if (objModule.IsDeleted)
                    {
                        continue;
                    }
                    if (objModule.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID)
                    {
                        continue;
                    }
                    string  strPath        = objTab.TabName;
                    TabInfo objTabSelected = objTab;
                    while (objTabSelected.ParentId != Null.NullInteger)
                    {
                        objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, false);
                        if (objTabSelected == null)
                        {
                            break;
                        }
                        strPath = string.Format("{0} -> {1}", objTabSelected.TabName, strPath);
                    }
                    var objListItem = new ListItem
                    {
                        Value = objModule.ModuleID.ToString(),
                        Text  = string.Format("{0} -> {1}", strPath, objModule.ModuleTitle)
                    };
                    lst.Add(objListItem);
                }
            }
            return(lst);
        }
Exemplo n.º 19
0
        ///<summary>
        /// Returns a scoring activity (aka action) via the mechanics API.
        ///</summary>
        /// <param name="actionName"></param>
        /// <param name="portalid"></param>
        public ScoringAction GetScoringAction(string actionName, int portalid)
        {
            var                     desktopModuleId = DesktopModuleController.GetDesktopModuleByModuleName(Constants.DESKTOPMODULE_NAME, portalid).DesktopModuleID;
            ScoringAction           ret             = null;
            var                     smCtrl          = MechanicsController.Instance;
            ScoringActionDefinition adef            = smCtrl.GetScoringActionDefinition(actionName, desktopModuleId);

            if (adef != null)
            {
                var ctlr = new DotNetNuke.Mechanics.Components.Controllers.Internal.InternalMechanicsController();
                ret = ctlr.GetScoringAction(adef.ScoringActionDefId, portalid);
            }
            return(ret);
        }
Exemplo n.º 20
0
        // this upgrade is for anything prior to 03.01.02 which is the re-branding release
        // that removes all references to Gooddogs Repository Module.
        public static string CustomUpgradeGRM3toDRM3()
        {
            string m_message = "";

            try {
                PortalSettings          _portalSettings          = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
                DesktopModuleController _desktopModuleController = new DesktopModuleController();

                if ((DesktopModuleController.GetDesktopModuleByModuleName("Gooddogs Repository", Null.NullInteger) == null))
                {
                    return("Gooddogs Repository Not installed - no upgrade required");
                }

                ModuleDefinitionController _moduleDefinitionControler = new ModuleDefinitionController();
                int OldRepositoryDefId = ModuleDefinitionController.GetModuleDefinitionByDefinitionName("Gooddogs Repository", DesktopModuleController.GetDesktopModuleByModuleName("Gooddogs Repository", Null.NullInteger).DesktopModuleID).ModuleDefID;
                int OldDashboardDefId  = ModuleDefinitionController.GetModuleDefinitionByDefinitionName("Gooddogs Dashboard", DesktopModuleController.GetDesktopModuleByModuleName("Gooddogs Dashboard", Null.NullInteger).DesktopModuleID).ModuleDefID;
                int NewRepositoryDefId = ModuleDefinitionController.GetModuleDefinitionByDefinitionName("Repository", DesktopModuleController.GetDesktopModuleByModuleName("Repository", Null.NullInteger).DesktopModuleID).ModuleDefID;
                int NewDashboardDefId  = ModuleDefinitionController.GetModuleDefinitionByDefinitionName("Repository Dashboard", DesktopModuleController.GetDesktopModuleByModuleName("Repository Dashboard", Null.NullInteger).DesktopModuleID).ModuleDefID;


                RepositoryController m_repositoryController = new RepositoryController();

                ModuleInfo       _moduleInfo       = null;
                ModuleController _moduleController = new ModuleController();

                // replace all Gooddogs Repository controls with the new Repository controls
                ArrayList _allModules = _moduleController.GetAllModules();

                foreach (ModuleInfo mi in _allModules)
                {
                    if (mi.ModuleDefID == OldRepositoryDefId)
                    {
                        m_repositoryController.ChangeRepositoryModuleDefId(mi.ModuleID, mi.ModuleDefID, NewRepositoryDefId);
                    }

                    if (mi.ModuleDefID == OldDashboardDefId)
                    {
                        m_repositoryController.ChangeRepositoryModuleDefId(mi.ModuleID, mi.ModuleDefID, NewDashboardDefId);
                    }
                }

                // we're all done .. so now we can remove the old Gooddogs Repository and Gooddogs Dashboard modules
                m_repositoryController.DeleteRepositoryModuleDefId(OldRepositoryDefId);
                m_repositoryController.DeleteRepositoryModuleDefId(OldDashboardDefId);
            } catch (Exception ex) {
                m_message += "EXCEPTION: " + ex.Message + " - " + ex.StackTrace.ToString();
            }
            m_message += "All Modules upgraded from GRM3 to DRM3";
            return(m_message);
        }
        /// <summary>
        /// Fill DropDownList with Portal Tabs
        /// </summary>
        private void FillYafInstances()
        {
            var objTabController = new TabController();

            var objTabs = TabController.GetPortalTabs(this.PortalSettings.PortalId, -1, true, true);

            var objDesktopModuleInfo =
                DesktopModuleController.GetDesktopModuleByModuleName("YetAnotherForumDotNet", this.PortalId);

            if (objDesktopModuleInfo == null)
            {
                return;
            }

            objTabs.Where(tab => tab is { IsDeleted: false }).ForEach(
        private static void RemoveLegacyModuleDefinitions(string moduleName, string currentModuleDefinitionName)
        {
            var mdc = new ModuleDefinitionController();

            var desktopModule = DesktopModuleController.GetDesktopModuleByModuleName(moduleName, Null.NullInteger);

            if (desktopModule == null)
            {
                return;
            }

            var desktopModuleId = desktopModule.DesktopModuleID;
            var modDefs         = ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId);

            var currentModDefId = 0;

            foreach (var modDefKeyPair in modDefs)
            {
                if (modDefKeyPair.Value.FriendlyName.Equals(currentModuleDefinitionName, StringComparison.InvariantCultureIgnoreCase))
                {
                    currentModDefId = modDefKeyPair.Value.ModuleDefID;
                }
            }

            foreach (var modDefKeyPair in modDefs)
            {
                var oldModDefId = modDefKeyPair.Value.ModuleDefID;
                if (oldModDefId != currentModDefId)
                {
                    foreach (ModuleInfo mod in ModuleController.Instance.GetAllModules())
                    {
                        if (mod.ModuleDefID == oldModDefId)
                        {
                            mod.ModuleDefID = currentModDefId;
                            ModuleController.Instance.UpdateModule(mod);
                        }
                    }

                    mdc.DeleteModuleDefinition(oldModDefId);
                }
            }

            modDefs = ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId);
            if (modDefs.Count == 0)
            {
                new DesktopModuleController().DeleteDesktopModule(desktopModuleId);
            }
        }
        /// <summary>Re-enables the configuration if it was previously enabled.</summary>
        /// <returns>A status message</returns>
        private static string UpgradeToVersion101()
        {
            var module = DesktopModuleController.GetDesktopModuleByModuleName("Engage: Application Insights", Null.NullInteger);
            var config = new ApplicationInsightsConfig(module);

            if (string.IsNullOrEmpty(config.InstrumentationKey))
            {
                return("Upgraded Engage: Application Insights to version 1.0.1, Application Insights was not enable and remains disabled");
            }

            config.EnableApplicationInsights(config.InstrumentationKey);
            new ApplicationInsightsJavaScript(module).EnableApplicationInsights(config.InstrumentationKey);
            new XmlMergeService(module).ApplyXmlMerge(new ModuleFileMapper(module).MapFilePath("EnableApplicationInsights.xml"));

            return("Upgraded to Engage: Application Insights to version 1.0.1, re-enabled Application Insights");
        }
Exemplo n.º 24
0
        private int GetModuleDefID(string ModuleName)
        {
            try
            {
                DesktopModuleInfo    desktopInfo = DesktopModuleController.GetDesktopModuleByModuleName(ModuleName, PortalController.GetCurrentPortalSettings().PortalId);
                ModuleDefinitionInfo modDefInfo  = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleName, desktopInfo.DesktopModuleID);

                return(modDefInfo.ModuleDefID);
            }
            catch
            {
                // WStrohl:
                // do nothing - an expected nullreference exception should happen here if the module is not going through the expected upgrade
                return(Null.NullInteger);
            }
        }
Exemplo n.º 25
0
        static ModuleDefinitionInfo GetModuleDefinition(XmlNode nodeModule)
        {
            ModuleDefinitionInfo objModuleDefinition = null;

            // Templates prior to v4.3.5 only have the <definition> node to define the Module Type
            // This <definition> node was populated with the DesktopModuleInfo.ModuleName property
            // Thus there is no mechanism to determine to which module definition the module belongs.
            //
            // Template from v4.3.5 on also have the <moduledefinition> element that is populated
            // with the ModuleDefinitionInfo.FriendlyName.  Therefore the module Instance identifies
            // which Module Definition it belongs to.

            //Get the DesktopModule defined by the <definition> element
            var objDesktopModule =
                DesktopModuleController.GetDesktopModuleByModuleName(
                    XmlUtils.GetNodeValue(nodeModule, "definition", ""), Null.NullInteger);

            if (objDesktopModule != null)
            {
                //Get the moduleDefinition from the <moduledefinition> element
                var friendlyName = XmlUtils.GetNodeValue(nodeModule, "moduledefinition", "");

                if (string.IsNullOrEmpty(friendlyName))
                {
                    //Module is pre 4.3.5 so get the first Module Definition (at least it won't throw an error then)
                    var moduleDefinitions =
                        ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(
                            objDesktopModule.DesktopModuleID).Values;
                    foreach (
                        var moduleDefinition in
                        moduleDefinitions)
                    {
                        objModuleDefinition = moduleDefinition;
                        break;
                    }
                }
                else
                {
                    //Module is 4.3.5 or later so get the Module Definition by its friendly name
                    objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(friendlyName,
                                                                                                       objDesktopModule.
                                                                                                       DesktopModuleID);
                }
            }

            return(objModuleDefinition);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Gets the web service URL.
        /// </summary>
        /// <returns>The url to the web service.</returns>
        public static string GetServiceUrl()
        {
            var url = new StringBuilder();

            if (HttpContext.Current != null)
            {
                url.Append(HttpContext.Current.Request.Url.Scheme);
                url.Append("://");
                url.Append(HttpContext.Current.Request.Url.Authority);
                url.Append(Framework.ModuleBase.ApplicationUrl);
                url.Append("/DesktopModules/");
                url.Append(DesktopModuleController.GetDesktopModuleByModuleName(DesktopModuleName, Globals.GetPortalSettings().PortalId).FolderName);
                url.Append("/SurveyService.asmx");
            }

            return(url.ToString());
        }
Exemplo n.º 27
0
        /// <summary>
        /// Gets the module definition ID.
        /// </summary>
        /// <returns>Returns the module definition ID</returns>
        private static int GetModuleDefinitionID()
        {
            var editorDesktopModule =
                DesktopModuleController.GetDesktopModuleByModuleName("CKEditor.EditorConfigManager", Null.NullInteger);

            if (editorDesktopModule == null)
            {
                return(-1);
            }

            // get module definition
            var editorModuleDefinition =
                ModuleDefinitionController.GetModuleDefinitionByFriendlyName(
                    "CKEditor Config Manager", editorDesktopModule.DesktopModuleID);

            return(editorModuleDefinition == null ? -1 : editorModuleDefinition.ModuleDefID);
        }
        private static IEnumerable <TabModule> GetTabModules(string moduleName)
        {
            var portalId      = PortalController.Instance.GetCurrentPortalSettings().PortalId;
            var desktopModule = DesktopModuleController.GetDesktopModuleByModuleName(moduleName, portalId);

            if (desktopModule != null)
            {
                var cacheKey = string.Format(DataCache.DesktopModuleCacheKey, portalId) + "_" +
                               desktopModule.DesktopModuleID;
                var args = new CacheItemArgs(cacheKey, DataCache.DesktopModuleCacheTimeOut,
                                             DataCache.DesktopModuleCachePriority, portalId, desktopModule);

                return(CBO.GetCachedObject <IList <TabModule> >(args, GetTabModulesCallback));
            }

            return(new List <TabModule>());
        }
Exemplo n.º 29
0
        private int GetTabIdByModuleName(string moduleName)
        {
            var portalId = CurrentPortalSettings.PortalId;
            var dModule  = DesktopModuleController.GetDesktopModuleByModuleName(moduleName, portalId);
            var modDef   = ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(dModule.DesktopModuleID);

            var moduleController = new ModuleController();
            var modules          = moduleController.GetModulesByDefinition(portalId, modDef.First().Value.FriendlyName);

            var currentCulture = HccRequestContext.Current.MainContentCulture;
            var module         = modules.OfType <ModuleInfo>().FirstOrDefault(m => m.CultureCode == currentCulture);

            if (module == null)
            {
                module = modules.OfType <ModuleInfo>().FirstOrDefault();
            }
            return(module.TabID);
        }
Exemplo n.º 30
0
        public override ConsoleResultModel Run()
        {
            try
            {
                var desktopModule = DesktopModuleController.GetDesktopModuleByModuleName(ModuleName, PortalId);
                if (desktopModule == null)
                {
                    return(new ConsoleErrorResultModel(string.Format(LocalizeString("Prompt_DesktopModuleNotFound"), ModuleName)));
                }

                KeyValuePair <HttpStatusCode, string> message;
                var addedModules = ModulesControllerLibrary.Instance.AddNewModule(
                    PortalSettings,
                    ModuleTitle,
                    desktopModule.DesktopModuleID,
                    PageId,
                    Pane,
                    0,
                    0,
                    null,
                    out message
                    );
                if (addedModules == null)
                {
                    return(new ConsoleErrorResultModel(message.Value));
                }
                if (addedModules.Count == 0)
                {
                    return(new ConsoleErrorResultModel(LocalizeString("Prompt_NoModulesAdded")));
                }
                var modules = addedModules.Select(newModule => ModuleInstanceModel.FromDnnModuleInfo(ModuleController.Instance.GetTabModule(newModule.TabModuleID))).ToList();

                return(new ConsoleResultModel(string.Format(LocalizeString("Prompt_ModuleAdded"), modules.Count, modules.Count == 1 ? string.Empty : "s"))
                {
                    Data = modules, Records = modules.Count
                });
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                return(new ConsoleErrorResultModel(LocalizeString("Prompt_AddModuleError")));
            }
        }