Example #1
0
        private JToken GetMetaData(string fieldname)
        {
            if (_fileMetaData == null)
            {
                if (ModuleDefinitionController.GetModuleDefinitionByFriendlyName("OpenFiles") == null)
                {
                    _fileMetaData = JObject.Parse("{}");
                }
                else if (FileInfo.ContentItemID <= 0)
                {
                    _fileMetaData = JObject.Parse("{}");
                }
                else
                {
                    var item = Util.GetContentController().GetContentItem(FileInfo.ContentItemID);
                    if (item != null && item.Content.IsJson())
                    {
                        _fileMetaData = JObject.Parse(item.Content);
                    }
                    else
                    {
                        _fileMetaData = JObject.Parse("{}");
                    }
                }
            }

            return(_fileMetaData?[fieldname]);
        }
Example #2
0
        public void Configuration(IAppBuilder app)
        {
            // Skip initialization if module is not defined
            var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(Globals.ModuleFriendlyName);

            if (Null.IsNull(moduleDefinition))
            {
                return;
            }

            Logger.Debug("Starting up DNN Dev Tools");

            // Wire up SignalR
            app.MapSignalR();

            // Configure Log4Net appender
            var root = ((log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository()).Root;

            root.Level = Level.All;
            var attachable = (IAppenderAttachable)root;
            var appender   = new Log4NetAppender();

            attachable.AddAppender(appender);

            // Start mail pickup folder watcher
            MailPickupFolderWatcher.Instance.Run();

            // Start event watcher
            DnnEventWatcher.Instance.Run();
        }
Example #3
0
        public static string GetImageUrl(IFileInfo file, Ratio requestedCropRatio)
        {
            if (file == null)
            {
                throw new NoNullAllowedException("FileInfo should not be null");
            }

            if (ModuleDefinitionController.GetModuleDefinitionByFriendlyName("OpenFiles") == null)
            {
                return(file.ToUrl());
            }
            var url = file.ToUrlWithoutLinkClick();

            if (url.Contains("LinkClick.aspx"))
            {
                return(url);
            }
            url = url.RemoveQueryParams();

            if (file.ContentItemID > 0)
            {
                var contentItem = Util.GetContentController().GetContentItem(file.ContentItemID);
                if (contentItem != null && !string.IsNullOrEmpty(contentItem.Content))
                {
                    JObject content = JObject.Parse(contentItem.Content);
                    var     crop    = content["crop"];
                    if (crop is JObject && crop["croppers"] != null)
                    {
                        foreach (var cropperobj in crop["croppers"].Children())
                        {
                            try
                            {
                                var cropper          = cropperobj.Children().First();
                                int left             = int.Parse(cropper["x"].ToString());
                                int top              = int.Parse(cropper["y"].ToString());
                                int w                = int.Parse(cropper["width"].ToString());
                                int h                = int.Parse(cropper["height"].ToString());
                                var definedCropRatio = new Ratio(w, h);

                                if (Math.Abs(definedCropRatio.AsFloat - requestedCropRatio.AsFloat) < 0.02) //allow 2% margin
                                {
                                    //crop first then resize (order defined by the processors definition order in the config file)
                                    return(url + string.Format("?crop={0},{1},{2},{3}&width={4}&height={5}", left, top, w, h, requestedCropRatio.Width, requestedCropRatio.Height));
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Logger.Warn(string.Format("Warning for page {0}. Error processing croppers in {1}. {2}", HttpContext.Current.Request.RawUrl, contentItem.Content, ex.Message));
                            }
                        }
                    }
                    else
                    {
                        //Log.Logger.Debug(string.Format("Warning for page {0}. Can't find croppers in {1}. ", HttpContext.Current.Request.RawUrl, contentItem.Content));
                    }
                }
            }

            return(url + string.Format("?width={0}&height={1}&mode=crop", requestedCropRatio.Width, requestedCropRatio.Height));
        }
        internal static void AddDesktopModuleToPage(DesktopModuleInfo desktopModule, TabInfo tab, ref bool addedNewModule)
        {
            if (tab.PortalID != Null.NullInteger)
            {
                AddDesktopModuleToPortal(tab.PortalID, desktopModule.DesktopModuleID, !desktopModule.IsAdmin, false);
            }

            var moduleDefinitions = ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModule.DesktopModuleID).Values;
            var tabModules        = ModuleController.Instance.GetTabModules(tab.TabID).Values;

            foreach (var moduleDefinition in moduleDefinitions)
            {
                if (tabModules.All(m => m.ModuleDefinition.ModuleDefID != moduleDefinition.ModuleDefID))
                {
                    Upgrade.AddModuleToPage(
                        tab,
                        moduleDefinition.ModuleDefID,
                        desktopModule.Page.Description,
                        desktopModule.Page.Icon,
                        true);

                    addedNewModule = true;
                }
            }
        }
Example #5
0
        /// <summary>
        /// LoadCacheProperties loads the Module Definitions Default Cache Time properties
        /// </summary>
        /// <history>
        ///     [cnurse]	4/21/2005   created
        /// </history>
        private void LoadCacheProperties(int ModuleDefId)
        {
            ModuleDefinitionController objModuleDefinitionController = new ModuleDefinitionController();
            ModuleDefinitionInfo       objModuleDefinition           = objModuleDefinitionController.GetModuleDefinition(ModuleDefId);

            txtCacheTime.Text = objModuleDefinition.DefaultCacheTime.ToString();
        }
Example #6
0
        internal static void AddModuleToPage(DesktopModuleInfo desktopModule, TabInfo tab)
        {
            try
            {
                if (tab.PortalID != Null.NullInteger)
                {
                    AddDesktopModuleToPortal(tab.PortalID, desktopModule.DesktopModuleID, !desktopModule.IsAdmin, false);
                }

                var moduleDefinitions = ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModule.DesktopModuleID).Values;
                var tabModules        = ModuleController.Instance.GetTabModules(tab.TabID).Values;
                foreach (var moduleDefinition in moduleDefinitions)
                {
                    if (tabModules.All(m => m.ModuleDefinition.ModuleDefID != moduleDefinition.ModuleDefID))
                    {
                        Upgrade.AddModuleToPage(
                            tab,
                            moduleDefinition.ModuleDefID,
                            desktopModule.FriendlyName,
                            "~/Icons/Sigma/Configuration_16X16_Standard.png",
                            true);
                    }
                }
            }
            catch (Exception e)
            {
                LogError(e);
                throw;
            }
        }
Example #7
0
    private void AddModuleToTab(TabInfo ti, DesktopModuleInfo dmi, string title = "", string paneName = "ContentPane", Dictionary <String, String> settings = null)
    {
        if (title == "")
        {
            title = dmi.ContentTitle;
        }
        PortalSettings    ps                = new PortalSettings();
        int               portalId          = ps.PortalId;
        DesktopModuleInfo desktopModuleInfo = null;

        foreach (KeyValuePair <int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(portalId))
        {
            DesktopModuleInfo mod = kvp.Value;
            if (mod != null)
            {
                if ((mod.FriendlyName == dmi.FriendlyName || mod.ModuleName == dmi.FriendlyName))
                {
                    desktopModuleInfo = mod;
                }
            }
        }

        if (desktopModuleInfo != null && ti != null)
        {
            foreach (ModuleDefinitionInfo moduleDefinitionInfo in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleInfo.DesktopModuleID).Values)
            {
                ModuleInfo moduleInfo = new ModuleInfo();
                moduleInfo.PortalID               = portalId;
                moduleInfo.TabID                  = ti.TabID;
                moduleInfo.ModuleOrder            = 1;
                moduleInfo.ModuleTitle            = title;
                moduleInfo.PaneName               = paneName;
                moduleInfo.ModuleDefID            = moduleDefinitionInfo.ModuleDefID;
                moduleInfo.CacheTime              = moduleDefinitionInfo.DefaultCacheTime;
                moduleInfo.InheritViewPermissions = true;
                moduleInfo.AllTabs                = false;
                ModuleController moduleController = new ModuleController();
                if (settings != null)
                {
                    foreach (KeyValuePair <String, String> kvp in settings)
                    {
                        if (kvp.Key.Contains("tabid"))
                        {
                            TabController tc = new TabController();
                            int           id = tc.GetTabByName(kvp.Value, portalId).TabID;
                            moduleInfo.ModuleSettings.Add(kvp.Key, id);
                            moduleController.UpdateModuleSetting(moduleInfo.ModuleID, kvp.Key, "" + id);
                        }
                        else
                        {
                            moduleInfo.ModuleSettings.Add(kvp.Key, kvp.Value);
                            moduleController.UpdateModuleSetting(moduleInfo.ModuleID, kvp.Key, kvp.Value);
                        }
                    }
                }
                int moduleId = moduleController.AddModule(moduleInfo);
            }
        }
    }
Example #8
0
        /// <summary>
        /// cmdDeleteDefinition_Click runs when the Delete Definition Button is clicked
        /// </summary>
        /// <history>
        ///     [cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdDeleteDefinition_Click(object sender, EventArgs e)
        {
            ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();

            objModuleDefinitions.DeleteModuleDefinition(int.Parse(cboDefinitions.SelectedItem.Value));

            LoadDefinitions();
        }
Example #9
0
        public void MustHaveHelpUrlFilledOutForHtmlModule()
        {
            var moduleDefId = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Text/HTML").ModuleDefID;
            var control     = ModuleControlController.GetModuleControlByControlKey("", moduleDefId);

            control.HelpURL = "http://hive.dotnetnuke.com/Default.aspx?tabid=283";
            ModuleControlController.UpdateModuleControl(control);
        }
        private void OnConfigureClick(object sender, EventArgs e)
        {
            var        objModuleControl    = ModuleControlController.GetModuleControl(ModuleControlId);
            var        objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
            var        objDesktopModule    = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, PortalId);
            ModuleInfo objModule           = ModuleController.Instance.GetModuleByDefinition(-1, "Extensions");

            Response.Redirect(Globals.NavigateURL(objModule.TabID, "Edit", "mid=" + objModule.ModuleID.ToString(), "PackageID=" + objDesktopModule.PackageID.ToString()) + "?popUp=true", true);
        }
Example #11
0
        private void OnPackageClick(object sender, EventArgs e)
        {
            var        objModuleControl    = ModuleControlController.GetModuleControl(this.ModuleControlId);
            var        objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
            var        objDesktopModule    = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, this.PortalId);
            ModuleInfo objModule           = ModuleController.Instance.GetModuleByDefinition(-1, "Extensions");

            this.Response.Redirect(this._navigationManager.NavigateURL(objModule.TabID, "PackageWriter", "rtab=" + this.TabId.ToString(), "packageId=" + objDesktopModule.PackageID.ToString(), "mid=" + objModule.ModuleID.ToString()) + "?popUp=true", true);
        }
        /// <summary>
        /// Gets a collection of <see cref="SearchItemInfo"/> instances, describing the job openings that can be viewed in the given Job Details module.
        /// </summary>
        /// <param name="modInfo">Information about the module instance for which jobs should be returned.</param>
        /// <returns>A collection of <see cref="SearchItemInfo"/> instances</returns>
        public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
        {
            if (modInfo == null)
            {
                throw new ArgumentNullException("modInfo", @"modInfo must not be null.");
            }

            var searchItems = new SearchItemInfoCollection();

            // only index the JobDetail module definition (since most of this information is only viewable there,
            // and because the Guid parameter on the SearchItemInfo ("jobid=" + jobid) gets put on the querystring to make it work all automagically).  BD
            if (ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleDefinition.JobDetail.ToString(), modInfo.DesktopModuleID).ModuleDefID == modInfo.ModuleDefID &&
                ModuleSettings.JobDetailEnableDnnSearch.GetValueAsBooleanFor(DesktopModuleName, modInfo, ModuleSettings.JobDetailEnableDnnSearch.DefaultValue))
            {
                int?jobGroupId = ModuleSettings.JobGroupId.GetValueAsInt32For(DesktopModuleName, modInfo, ModuleSettings.JobGroupId.DefaultValue);

                using (IDataReader jobs = DataProvider.Instance().GetJobs(jobGroupId, modInfo.PortalID))
                {
                    while (jobs.Read())
                    {
                        if (!(bool)jobs["IsFilled"])
                        {
                            string jobId             = ((int)jobs["JobId"]).ToString(CultureInfo.InvariantCulture);
                            string searchDescription = HtmlUtils.StripWhiteSpace(HtmlUtils.Clean((string)jobs["JobDescription"], false), true);
                            string searchItemTitle   = string.Format(
                                CultureInfo.CurrentCulture,
                                Utility.GetString("JobInLocation", LocalResourceFile, modInfo.PortalID),
                                (string)jobs["JobTitle"],
                                (string)jobs["LocationName"],
                                (string)jobs["StateName"]);

                            string searchedContent =
                                HtmlUtils.StripWhiteSpace(
                                    HtmlUtils.Clean(
                                        (string)jobs["JobTitle"] + " " + (string)jobs["JobDescription"] + " " + (string)jobs["RequiredQualifications"] +
                                        " " + (string)jobs["DesiredQualifications"],
                                        false),
                                    true);

                            searchItems.Add(
                                new SearchItemInfo(
                                    searchItemTitle,
                                    searchDescription,
                                    (int)jobs["RevisingUser"],
                                    (DateTime)jobs["RevisionDate"],
                                    modInfo.ModuleID,
                                    jobId,
                                    searchedContent,
                                    "jobid=" + jobId));
                        }
                    }
                }
            }

            return(searchItems);
        }
Example #13
0
        private void OnPackageClick(object sender, EventArgs e)
        {
            var objModuleControl        = ModuleControlController.GetModuleControl(ModuleControlId);
            var objModuleDefinition     = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
            var objDesktopModule        = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, PortalId);
            ModuleController objModules = new ModuleController();
            ModuleInfo       objModule  = objModules.GetModuleByDefinition(-1, "Extensions");

            Response.Redirect(Globals.NavigateURL(objModule.TabID, "PackageWriter", "rtab=" + TabId.ToString(), "packageId=" + objDesktopModule.PackageID.ToString(), "mid=" + objModule.ModuleID.ToString()) + "?popUp=true", true);
        }
Example #14
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);
        }
Example #15
0
        /// <summary>
        /// cmdAddDefinition_Click runs when the Add Definition Button is clicked
        /// </summary>
        /// <history>
        ///     [cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdAddDefinition_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtDefinition.Text))
            {
                ModuleDefinitionInfo objModuleDefinition = new ModuleDefinitionInfo();

                objModuleDefinition.DesktopModuleID = DesktopModuleId;
                objModuleDefinition.FriendlyName    = txtDefinition.Text;

                try
                {
                    objModuleDefinition.DefaultCacheTime = int.Parse(txtCacheTime.Text);
                    if (objModuleDefinition.DefaultCacheTime < 0)
                    {
                        UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("UpdateCache.ErrorMessage", this.LocalResourceFile), ModuleMessageType.RedError);
                        return;
                    }
                }
                catch
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("UpdateCache.ErrorMessage", this.LocalResourceFile), ModuleMessageType.RedError);
                    return;
                }

                ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();

                int ModuleDefId;
                try
                {
                    ModuleDefId = objModuleDefinitions.AddModuleDefinition(objModuleDefinition);
                }
                catch
                {
                    UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("AddDefinition.ErrorMessage", this.LocalResourceFile), ModuleMessageType.RedError);
                    return;
                }

                LoadDefinitions();

                if (ModuleDefId > -1)
                {
                    //Set the Combo
                    cboDefinitions.SelectedIndex = -1;
                    cboDefinitions.Items.FindByValue(ModuleDefId.ToString()).Selected = true;
                    LoadCacheProperties(ModuleDefId);
                    LoadControls(ModuleDefId);
                    //Clear the Text Box
                    txtDefinition.Text = "";
                }
            }
            else
            {
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("MissingDefinition.ErrorMessage", this.LocalResourceFile), ModuleMessageType.RedError);
            }
        }
Example #16
0
        public static int?GeModuleDefIdByFriendltName(string friendlyName)
        {
            if (string.IsNullOrEmpty(friendlyName))
            {
                return(null);
            }

            var moduleDefInfo = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(friendlyName);

            return(moduleDefInfo?.ModuleDefID);
        }
Example #17
0
        private void LoadReadMe()
        {
            var templatePath = this.Server.MapPath(this.ControlPath) + "Templates\\" + this.optLanguage.SelectedValue + "\\" + this.cboTemplate.SelectedItem.Value;

            if (File.Exists(templatePath + "\\readme.txt"))
            {
                var readMe = Null.NullString;
                using (TextReader tr = new StreamReader(templatePath + "\\readme.txt"))
                {
                    readMe = tr.ReadToEnd();
                    tr.Close();
                }

                this.lblDescription.Text = readMe.Replace("\n", "<br/>");
            }
            else
            {
                this.lblDescription.Text = string.Empty;
            }

            // Determine if Control Name is required
            var controlNameRequired = false;
            var controlName         = "<Not Required>";

            string[] fileList = Directory.GetFiles(templatePath);
            foreach (string filePath in fileList)
            {
                if (Path.GetFileName(filePath).ToLowerInvariant().IndexOf("template") > -1)
                {
                    controlNameRequired = true;
                    controlName         = "Edit";
                }
                else
                {
                    if (Path.GetFileName(filePath).EndsWith(".ascx"))
                    {
                        controlName = Path.GetFileNameWithoutExtension(filePath);
                    }
                }
            }

            this.txtControl.Text    = controlName;
            this.txtControl.Enabled = controlNameRequired;
            if (this.txtControl.Enabled)
            {
                if (!this.cboTemplate.SelectedItem.Value.ToLowerInvariant().StartsWith("module"))
                {
                    var objModuleControl    = ModuleControlController.GetModuleControl(this.ModuleControlId);
                    var objModuleDefinition = ModuleDefinitionController.GetModuleDefinitionByID(objModuleControl.ModuleDefID);
                    var objDesktopModule    = DesktopModuleController.GetDesktopModule(objModuleDefinition.DesktopModuleID, this.PortalId);
                    this.txtControl.Text = objDesktopModule.FriendlyName;
                }
            }
        }
Example #18
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);
            }
        }
Example #19
0
        public override RouteData GetRouteData(HttpContextBase httpContext, ModuleControlInfo moduleControl)
        {
            var assemblyName = moduleControl.ControlTitle;

            var    segments       = moduleControl.ControlSrc.Replace(".razorpages", "").Split('/');
            string routeNamespace = String.Empty;
            string routeModuleName;
            string routePageName;

            if (segments.Length == 3)
            {
                routeNamespace  = segments[0];
                routeModuleName = segments[1];
                routePageName   = segments[2];
            }
            else
            {
                routeModuleName = segments[0];
                routePageName   = segments[1];
            }

            var pageName   = (httpContext == null) ? routePageName : httpContext.Request.QueryString.GetValueOrDefault("action", routePageName);
            var moduleName = (httpContext == null) ? routeModuleName : httpContext.Request.QueryString.GetValueOrDefault("controller", routeModuleName);

            var routeData = new RouteData();

            routeData.Values.Add("module", moduleName);
            routeData.Values.Add("page", pageName);
            routeData.Values.Add("assembly", assemblyName);

            var moduleDef     = ModuleDefinitionController.GetModuleDefinitionByID(moduleControl.ModuleDefID);
            var desktopModule = DesktopModuleController.GetDesktopModule(moduleDef.DesktopModuleID, -1);

            routeData.Values.Add("page-path", $"~/DesktopModules/MVC/{desktopModule.FolderName}/Pages/{pageName}.cshtml");

            if (httpContext != null)
            {
                foreach (var param in httpContext.Request.QueryString.AllKeys)
                {
                    if (!ExcludedQueryStringParams.Split(',').ToList().Contains(param.ToLower()))
                    {
                        routeData.Values.Add(param, httpContext.Request.QueryString[param]);
                    }
                }
            }
            if (!String.IsNullOrEmpty(routeNamespace))
            {
                routeData.DataTokens.Add("namespaces", new string[] { routeNamespace });
            }

            return(routeData);
        }
Example #20
0
        private bool HaveContentLayoutModuleOnPage()
        {
            var moduleDefinition =
                ModuleDefinitionController.GetModuleDefinitions().Values
                .FirstOrDefault(m => m.DefinitionName == "Content Layout");

            if (moduleDefinition != null)
            {
                return(PortalSettings.ActiveTab.Modules.Cast <ModuleInfo>().Any(m => m.ModuleDefID == moduleDefinition.ModuleDefID));
            }

            return(false);
        }
        public string UpgradeModule(string Version)
        {
            try
            {
                switch (Version)
                {
                case "06.02.00":
                    var portalController = new PortalController();
                    var moduleController = new ModuleController();
                    var tabController    = new TabController();

                    var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Message Center");
                    if (moduleDefinition != null)
                    {
                        var portals = portalController.GetPortals();
                        foreach (PortalInfo portal in portals)
                        {
                            if (portal.UserTabId > Null.NullInteger)
                            {
                                //Find TabInfo
                                var tab = tabController.GetTab(portal.UserTabId, portal.PortalID, true);
                                if (tab != null)
                                {
                                    foreach (var module in moduleController.GetTabModules(portal.UserTabId).Values)
                                    {
                                        if (module.DesktopModule.FriendlyName == "Messaging")
                                        {
                                            //Delete the Module from the Modules list
                                            moduleController.DeleteTabModule(module.TabID, module.ModuleID, false);

                                            //Add new module to the page
                                            Upgrade.AddModuleToPage(tab, moduleDefinition.ModuleDefID, "Message Center", "", true);

                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    break;
                }
                return("Success");
            }
            catch (Exception exc)
            {
                Logger.Error(exc);

                return("Failed");
            }
        }
Example #22
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);
        }
Example #23
0
        public string UpgradeModule(string version)
        {
            try
            {
                switch (version)
                {
                case "07.01.00":
                    ModuleDefinitionInfo mDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Digital Asset Management");

                    // Add tab to Admin Menu
                    if (mDef != null)
                    {
                        var hostPage = Upgrade.AddHostPage(
                            "File Management",
                            "Manage assets.",
                            "~/Icons/Sigma/Files_16X16_Standard.png",
                            "~/Icons/Sigma/Files_32X32_Standard.png",
                            true);

                        // Add module to page
                        Upgrade.AddModuleToPage(hostPage, mDef.ModuleDefID, "File Management", "~/Icons/Sigma/Files_32X32_Standard.png", true);

                        Upgrade.AddAdminPages(
                            "File Management",
                            "Manage assets within the portal",
                            "~/Icons/Sigma/Files_16X16_Standard.png",
                            "~/Icons/Sigma/Files_32X32_Standard.png",
                            true,
                            mDef.ModuleDefID,
                            "File Management",
                            "~/Icons/Sigma/Files_16X16_Standard.png",
                            true);
                    }

                    // Remove Host File Manager page
                    Upgrade.RemoveHostPage("File Manager");

                    // Remove Admin File Manager Pages
                    Upgrade.RemoveAdminPages("//Admin//FileManager");

                    break;
                }

                return("Success");
            }
            catch (Exception)
            {
                return("Failed");
            }
        }
Example #24
0
        private void AddPictureToPage(int tabId, string imageUrl)
        {
            var moduleDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Text/HTML");
            var tab       = TabController.Instance.GetTab(tabId, 0);
            var objModule = new ModuleInfo();

            objModule.Initialize(0);
            objModule.PortalID    = 0;
            objModule.TabID       = tab.TabID;
            objModule.ModuleOrder = 0;
            objModule.ModuleTitle = tab.Title;
            objModule.PaneName    = "ContentPane";
            objModule.ModuleDefID = moduleDef.ModuleDefID; // Text/HTML
            objModule.CacheTime   = 1200;
            ModuleController.Instance.InitialModulePermission(objModule, objModule.TabID, 0);
            objModule.CultureCode = Null.NullString;
            objModule.AllTabs     = false;
            objModule.Alignment   = "";
            var moduleId = ModuleController.Instance.AddModule(objModule);


            //creating the content object, and adding the content to the module
            var htmlTextController      = new HtmlTextController();
            var workflowStateController = new WorkflowStateController();

            int workflowId = htmlTextController.GetWorkflow(moduleId, tabId, 0).Value;

            HtmlTextInfo htmlContent = htmlTextController.GetTopHtmlText(moduleId, false, workflowId);

            if (htmlContent == null)
            {
                htmlContent             = new HtmlTextInfo();
                htmlContent.ItemID      = -1;
                htmlContent.StateID     = workflowStateController.GetFirstWorkflowStateID(workflowId);
                htmlContent.WorkflowID  = workflowId;
                htmlContent.ModuleID    = moduleId;
                htmlContent.IsPublished = true;
                htmlContent.Approved    = true;
                htmlContent.IsActive    = true;
            }

            htmlContent.Content = $"<img src='/Portals/0/{imageUrl}' />";

            int draftStateId        = workflowStateController.GetFirstWorkflowStateID(workflowId);
            int nextWorkflowStateId = workflowStateController.GetNextWorkflowStateID(workflowId, htmlContent.StateID);
            int publishedStateId    = workflowStateController.GetLastWorkflowStateID(workflowId);

            htmlTextController.UpdateHtmlText(htmlContent, htmlTextController.GetMaximumVersionHistory(0));
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ExportModule implements the IPortable ExportModule Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be exported</param>
        /// -----------------------------------------------------------------------------
        //public string ExportModule(int ModuleID)
        //{
        //string strXML = "";

        //List<OpenBlocksInfo> colOpenBlockss = GetOpenBlockss(ModuleID);
        //if (colOpenBlockss.Count != 0)
        //{
        //    strXML += "<OpenBlockss>";

        //    foreach (OpenBlocksInfo objOpenBlocks in colOpenBlockss)
        //    {
        //        strXML += "<OpenBlocks>";
        //        strXML += "<content>" + DotNetNuke.Common.Utilities.XmlUtils.XMLEncode(objOpenBlocks.Content) + "</content>";
        //        strXML += "</OpenBlocks>";
        //    }
        //    strXML += "</OpenBlockss>";
        //}

        //return strXML;

        //	throw new System.NotImplementedException("The method or operation is not implemented.");
        //}

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be imported</param>
        /// <param name="Content">The content to be imported</param>
        /// <param name="Version">The version of the module to be imported</param>
        /// <param name="UserId">The Id of the user performing the import</param>
        /// -----------------------------------------------------------------------------
        //public void ImportModule(int ModuleID, string Content, string Version, int UserID)
        //{
        //XmlNode xmlOpenBlockss = DotNetNuke.Common.Globals.GetContent(Content, "OpenBlockss");
        //foreach (XmlNode xmlOpenBlocks in xmlOpenBlockss.SelectNodes("OpenBlocks"))
        //{
        //    OpenBlocksInfo objOpenBlocks = new OpenBlocksInfo();
        //    objOpenBlocks.ModuleId = ModuleID;
        //    objOpenBlocks.Content = xmlOpenBlocks.SelectSingleNode("content").InnerText;
        //    objOpenBlocks.CreatedByUser = UserID;
        //    AddOpenBlocks(objOpenBlocks);
        //}

        //	throw new System.NotImplementedException("The method or operation is not implemented.");
        //}

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSearchItems implements the ISearchable Interface
        /// </summary>
        /// <param name="ModInfo">The ModuleInfo for the module to be Indexed</param>
        /// -----------------------------------------------------------------------------
        //public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
        //{
        //SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection();

        //List<OpenBlocksInfo> colOpenBlockss = GetOpenBlockss(ModInfo.ModuleID);

        //foreach (OpenBlocksInfo objOpenBlocks in colOpenBlockss)
        //{
        //    SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objOpenBlocks.Content, objOpenBlocks.CreatedByUser, objOpenBlocks.CreatedDate, ModInfo.ModuleID, objOpenBlocks.ItemId.ToString(), objOpenBlocks.Content, "ItemId=" + objOpenBlocks.ItemId.ToString());
        //    SearchItemCollection.Add(SearchItem);
        //}

        //return SearchItemCollection;

        //	throw new System.NotImplementedException("The method or operation is not implemented.");
        //}

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// UpgradeModule implements the IUpgradeable Interface
        /// </summary>
        /// <param name="Version">The current version of the module</param>
        /// -----------------------------------------------------------------------------
        public string UpgradeModule(string Version)
        {
            string result = "";

            try
            {
                switch (Version)
                {
                case "00.00.01":


                    ModuleDefinitionInfo mDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("OpenTemplateStudio");

                    //Add tab to Admin Menu
                    if (mDef != null)
                    {
                        var hostPage = Upgrade.AddHostPage("Template Studio",
                                                           "Open Template Studio",
                                                           "~/DesktopModules/OpenBlocks/Files_16X16_Standard.png",
                                                           "~/Icons/Sigma/Files_32X32_Standard.png",
                                                           true);

                        //Add module to page
                        Upgrade.AddModuleToPage(hostPage, mDef.ModuleDefID, "Open Template Studio", "~/Icons/Sigma/Files_32X32_Standard.png", true);

                        /*
                         * Upgrade.AddAdminPages("File Management",
                         *                   "Manage assets within the portal",
                         *                   "~/Icons/Sigma/Files_16X16_Standard.png",
                         *                   "~/Icons/Sigma/Files_32X32_Standard.png",
                         *                   true,
                         *                   mDef.ModuleDefID,
                         *                   "File Management",
                         *                   "~/Icons/Sigma/Files_16X16_Standard.png",
                         *                   true);
                         */
                        result = hostPage == null ? "host page null" : "host page created";
                    }

                    break;
                }
                return("Success : " + result);
            }
            catch (Exception)
            {
                return("Failed");
            }
        }
        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);
            }
        }
Example #27
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ExportModule implements the IPortable ExportModule Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be exported</param>
        /// -----------------------------------------------------------------------------
        //public string ExportModule(int ModuleID)
        //{
        //string strXML = "";

        //List<OpenBlocksInfo> colOpenBlockss = GetOpenBlockss(ModuleID);
        //if (colOpenBlockss.Count != 0)
        //{
        //    strXML += "<OpenBlockss>";

        //    foreach (OpenBlocksInfo objOpenBlocks in colOpenBlockss)
        //    {
        //        strXML += "<OpenBlocks>";
        //        strXML += "<content>" + DotNetNuke.Common.Utilities.XmlUtils.XMLEncode(objOpenBlocks.Content) + "</content>";
        //        strXML += "</OpenBlocks>";
        //    }
        //    strXML += "</OpenBlockss>";
        //}

        //return strXML;

        //	throw new System.NotImplementedException("The method or operation is not implemented.");
        //}

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be imported</param>
        /// <param name="Content">The content to be imported</param>
        /// <param name="Version">The version of the module to be imported</param>
        /// <param name="UserId">The Id of the user performing the import</param>
        /// -----------------------------------------------------------------------------
        //public void ImportModule(int ModuleID, string Content, string Version, int UserID)
        //{
        //XmlNode xmlOpenBlockss = DotNetNuke.Common.Globals.GetContent(Content, "OpenBlockss");
        //foreach (XmlNode xmlOpenBlocks in xmlOpenBlockss.SelectNodes("OpenBlocks"))
        //{
        //    OpenBlocksInfo objOpenBlocks = new OpenBlocksInfo();
        //    objOpenBlocks.ModuleId = ModuleID;
        //    objOpenBlocks.Content = xmlOpenBlocks.SelectSingleNode("content").InnerText;
        //    objOpenBlocks.CreatedByUser = UserID;
        //    AddOpenBlocks(objOpenBlocks);
        //}

        //	throw new System.NotImplementedException("The method or operation is not implemented.");
        //}

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSearchItems implements the ISearchable Interface
        /// </summary>
        /// <param name="ModInfo">The ModuleInfo for the module to be Indexed</param>
        /// -----------------------------------------------------------------------------
        //public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
        //{
        //SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection();

        //List<OpenBlocksInfo> colOpenBlockss = GetOpenBlockss(ModInfo.ModuleID);

        //foreach (OpenBlocksInfo objOpenBlocks in colOpenBlockss)
        //{
        //    SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objOpenBlocks.Content, objOpenBlocks.CreatedByUser, objOpenBlocks.CreatedDate, ModInfo.ModuleID, objOpenBlocks.ItemId.ToString(), objOpenBlocks.Content, "ItemId=" + objOpenBlocks.ItemId.ToString());
        //    SearchItemCollection.Add(SearchItem);
        //}

        //return SearchItemCollection;

        //	throw new System.NotImplementedException("The method or operation is not implemented.");
        //}

        /// -----------------------------------------------------------------------------
        /// <summary>
        /// UpgradeModule implements the IUpgradeable Interface
        /// </summary>
        /// <param name="Version">The current version of the module</param>
        /// -----------------------------------------------------------------------------
        public string UpgradeModule(string Version)
        {
            string result = "";

            try
            {
                switch (Version)
                {
                case "00.00.01":
                    ModuleDefinitionInfo mDef = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("OpenBlocks");

                    //Add tab to Admin Menu
                    if (mDef != null)
                    {
                        /*
                         * var hostPage = Upgrade.AddHostPage("Open Blocks",
                         *                              "Open Blocks",
                         *                              "~/Icons/Sigma/Software_16X16_Standard.png",
                         *                              "~/Icons/Sigma/Software_32X32_Standard.png",
                         *                              true);
                         *
                         * //Add module to page
                         * Upgrade.AddModuleToPage(hostPage, mDef.ModuleDefID, "Open Blocks", "~/Icons/Sigma/Software_32X32_Standard.png", true);
                         */

                        AddAdminPages("Blocks",
                                      "Manage resuable blocks of content",
                                      "~/Icons/Sigma/Software_16X16_Standard.png",
                                      "~/Icons/Sigma/Software_32X32_Standard.png",
                                      true,
                                      mDef.ModuleDefID,
                                      "Open Blocks",
                                      "~/Icons/Sigma/Software_16X16_Standard.png",
                                      true);

                        //result = hostPage == null ? "hostpage null" : "hostpage created";
                    }


                    break;
                }
                return("Success " + result);
            }
            catch (Exception)
            {
                return("Failed");
            }
        }
Example #28
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);
            }
        }
Example #29
0
 public static void SoftDeleteModule(int PortalId, string ModuleFriendlyName)
 {
     try
     {
         using (VanjaroRepo vrepo = new VanjaroRepo())
         {
             ModuleDefinitionInfo moduleDefinitionInfo = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleFriendlyName);
             System.Collections.Generic.List <ModuleSettings> moduleInfo = vrepo.Fetch <ModuleSettings>("Select T.PortalID,Tabm.TabID,Tabm.ModuleID,Tabm.PaneName,Tabm.IsDeleted from TabModules Tabm inner join Tabs T On Tabm.TabID = t.TabID Where PortalID=@0 AND ModuleTitle= @1", PortalId, ModuleFriendlyName);
             foreach (ModuleSettings ModuleSettings in moduleInfo)
             {
                 ModuleController.Instance.DeleteTabModule(ModuleSettings.TabID, ModuleSettings.ModuleID, true);
             }
         }
     }
     catch (Exception) { }
 }
Example #30
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);
        }