/// -----------------------------------------------------------------------------
        /// <summary>
        /// The Install method installs the Module component
        /// </summary>
        /// <history>
        ///     [cnurse]	01/15/2008  created
        /// </history>
        /// -----------------------------------------------------------------------------
        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);
            }
        }
Example #2
0
        public override void UpdatePackage()
        {
            bool        bUpdateSupportedFeatures = Null.NullBoolean;
            PackageInfo _Package = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == PackageID);

            //Update module settings
            if (desktopModuleForm.IsValid)
            {
                var desktopModule = desktopModuleForm.DataSource as DesktopModuleInfo;
                if (desktopModule != null && _Package != null)
                {
                    desktopModule.Shareable    = (ModuleSharing)Enum.Parse(typeof(ModuleSharing), Shareable.ComboBox.SelectedValue.ToString());
                    desktopModule.FriendlyName = _Package.FriendlyName;
                    desktopModule.Version      = Globals.FormatVersion(_Package.Version);
                    if (string.IsNullOrEmpty(desktopModule.BusinessControllerClass))
                    {
                        desktopModule.SupportedFeatures = 0;
                        //If there is no BusinessControllerClass, then there is no any implementation
                    }
                    else
                    {
                        DesktopModuleController controller = new DesktopModuleController();
                        controller.UpdateModuleInterfaces(ref desktopModule);
                    }
                    DesktopModuleController.SaveDesktopModule(desktopModule, false, true);
                }
            }
        }
Example #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":
                this.AddNotificationTypes();
                break;
            }

            return(string.Empty);
        }
Example #4
0
        public bool SavePackageSettings(PackageSettingsDto packageSettings, out string errorMessage)
        {
            errorMessage = string.Empty;

            try
            {
                var desktopModule = DesktopModuleController.GetDesktopModuleByPackageID(packageSettings.PackageId);

                if (desktopModule == null)
                {
                    return(false);
                }

                var isHostUser = UserController.Instance.GetCurrentUserInfo().IsSuperUser;

                this.UpdatePermissions(desktopModule, packageSettings);

                if (isHostUser)
                {
                    this.UpdateModuleProperties(desktopModule, packageSettings.Settings);
                    this.UpdateModuleProperties(desktopModule, packageSettings.EditorActions);

                    DesktopModuleController.SaveDesktopModule(desktopModule, false, true);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                errorMessage = ex.Message;
                return(false);
            }
        }
Example #5
0
 public static void ProcessLegacyModules()
 {
     foreach (DesktopModuleInfo desktopModule in DesktopModuleController.GetDesktopModules(Null.NullInteger).Values)
     {
         if (desktopModule.PackageID == Null.NullInteger)
         {
             string         moduleFolder = Path.Combine(CommonLibrary.Common.Globals.ApplicationMapPath, Path.Combine("DesktopModules", desktopModule.FolderName));
             XPathNavigator rootNav      = null;
             try
             {
                 string   hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions";
                 string[] files       = Directory.GetFiles(moduleFolder, "*.dnn.config");
                 if (files.Length > 0)
                 {
                     XPathDocument doc = new XPathDocument(new FileStream(files[0], FileMode.Open, FileAccess.Read));
                     rootNav = doc.CreateNavigator().SelectSingleNode("CommonLibrary");
                 }
                 PackageInfo package = new PackageInfo(new InstallerInfo());
                 package.Name         = desktopModule.ModuleName;
                 package.FriendlyName = desktopModule.FriendlyName;
                 package.Description  = desktopModule.Description;
                 package.Version      = new Version(1, 0, 0);
                 if (!string.IsNullOrEmpty(desktopModule.Version))
                 {
                     package.Version = new Version(desktopModule.Version);
                 }
                 if (hostModules.Contains(desktopModule.ModuleName))
                 {
                     package.IsSystemPackage = true;
                     desktopModule.IsAdmin   = true;
                 }
                 else
                 {
                     desktopModule.IsAdmin = false;
                 }
                 package.PackageType = "Module";
                 ParsePackageName(package);
                 if (files.Length > 0)
                 {
                     ModulePackageWriter modulewriter = new ModulePackageWriter(desktopModule, rootNav, package);
                     package.Manifest = modulewriter.WriteManifest(true);
                 }
                 else
                 {
                     package.Manifest = "";
                 }
                 PackageController.SavePackage(package);
                 desktopModule.PackageID = package.PackageID;
                 DesktopModuleController.SaveDesktopModule(desktopModule, false, false);
             }
             catch (Exception ex)
             {
                 ex.ToString();
             }
         }
     }
 }
Example #6
0
        /// <summary>Called when a module is upgraded.</summary>
        /// <param name="version">The version.</param>
        /// <returns>Success if all goes well, otherwise, Failed</returns>
        public string UpgradeModule(string version)
        {
            try
            {
                switch (version)
                {
                case "07.04.00":
                    const string ResourceFile    = ModuleFolder + "/App_LocalResources/ProviderConfiguration.ascx.resx";
                    string       pageName        = Localization.GetString("HTMLEditorPageName", ResourceFile);
                    string       pageDescription = Localization.GetString("HTMLEditorPageDescription", ResourceFile);

                    // Create HTML Editor Config Page (or get existing one)
                    TabInfo editorPage = Upgrade.AddHostPage(pageName, pageDescription, ModuleFolder + "/images/HtmlEditorManager_Standard_16x16.png", ModuleFolder + "/images/HtmlEditorManager_Standard_32x32.png", false);

                    // Find the RadEditor control and remove it
                    Upgrade.RemoveModule("RadEditor Manager", editorPage.TabName, editorPage.ParentId, false);

                    // Add Module To Page
                    int moduleDefId = this.GetModuleDefinitionID("DotNetNuke.HtmlEditorManager", "Html Editor Management");
                    Upgrade.AddModuleToPage(editorPage, moduleDefId, pageName, ModuleFolder + "/images/HtmlEditorManager_Standard_32x32.png", true);

                    foreach (var item in DesktopModuleController.GetDesktopModules(Null.NullInteger))
                    {
                        DesktopModuleInfo moduleInfo = item.Value;

                        if (moduleInfo.ModuleName == "DotNetNuke.HtmlEditorManager")
                        {
                            moduleInfo.Category = "Host";
                            DesktopModuleController.SaveDesktopModule(moduleInfo, false, false);
                        }
                    }

                    break;

                case "09.01.01":
                    if (RadEditorProviderInstalled())
                    {
                        UpdateRadCfgFiles();
                    }
                    if (TelerikAssemblyExists())
                    {
                        UpdateWebConfigFile();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                var xlc = new ExceptionLogController();
                xlc.AddLog(ex);

                return("Failed");
            }

            return("Success");
        }
 public override void Rollback()
 {
     if (InstalledDesktopModule == null)
     {
         DeleteModule();
     }
     else
     {
         DesktopModuleController.SaveDesktopModule(InstalledDesktopModule, true, false);
     }
 }
Example #8
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// The Rollback method undoes the installation of the component in the event
 /// that one of the other components fails
 /// </summary>
 /// -----------------------------------------------------------------------------
 public override void Rollback()
 {
     //If Temp Module exists then we need to update the DataStore with this
     if (_installedDesktopModule == null)
     {
         //No Temp Module - Delete newly added module
         DeleteModule();
     }
     else
     {
         //Temp Module - Rollback to Temp
         DesktopModuleController.SaveDesktopModule(_installedDesktopModule, true, false);
     }
 }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Version"></param>
        /// <returns></returns>
        /// <remarks>This is not localizing Page Name or description.</remarks>
        public string UpgradeModule(string Version)
        {
            try
            {
                switch (Version)
                {
                case "06.00.00":
                    string resourceFile    = ModuleFolder + "/App_LocalResources/ProviderConfig.ascx.resx";
                    string pageName        = Localization.GetString("HTMLEditorPageName", resourceFile);
                    string pageDescription = Localization.GetString("HTMLEditorPageDescription", resourceFile);

                    //Create Rad Editor Config Page (or get existing one)
                    TabInfo newPage = Upgrade.AddHostPage(pageName, pageDescription, ModuleFolder + "/images/radeditor_config_small.png", ModuleFolder + "/images/radeditor_config_large.png", true);

                    //Add Module To Page
                    int moduleDefId = GetModuleDefinitionID();
                    Upgrade.AddModuleToPage(newPage, moduleDefId, pageName, ModuleFolder + "/images/radeditor_config_large.png", true);

                    foreach (var item in DesktopModuleController.GetDesktopModules(Null.NullInteger))
                    {
                        DesktopModuleInfo moduleInfo = item.Value;

                        if (moduleInfo.ModuleName == "DotNetNuke.RadEditorProvider")
                        {
                            moduleInfo.Category = "Host";
                            DesktopModuleController.SaveDesktopModule(moduleInfo, false, false);
                        }
                    }
                    break;

                case "07.00.06":
                    UpdateConfigOfLinksType();
                    break;

                case "07.03.00":
                    UpdateConfigFilesName();
                    UpdateToolsFilesName();
                    break;
                }
            }
            catch (Exception ex)
            {
                ExceptionLogController xlc = new ExceptionLogController();
                xlc.AddLog(ex);

                return("Failed");
            }

            return("Success");
        }
 public override void Install()
 {
     try
     {
         InstalledDesktopModule = DesktopModuleController.GetDesktopModuleByModuleName(DesktopModule.ModuleName, Package.InstallerInfo.PortalID);
         if (InstalledDesktopModule != null)
         {
             DesktopModule.DesktopModuleID = InstalledDesktopModule.DesktopModuleID;
         }
         DataCache.RemoveCache(DataCache.ModuleDefinitionCacheKey);
         DataCache.RemoveCache(DataCache.ModuleControlsCacheKey);
         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);
     }
 }
Example #11
0
        public string UpgradeModule(string Version)
        {
            try
            {
                switch (Version)
                {
                case "01.00.00":
                    ModuleDefinitionInfo moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName("Taxonomy Manager");

                    if (moduleDefinition != null)
                    {
                        //Add Module to Admin Page for all Portals
                        Upgrade.AddAdminPages("Taxonomy",
                                              "Manage the Taxonomy for your Site",
                                              "~/images/icon_tag_16px.gif",
                                              "~/images/icon_tag_32px.gif",
                                              true,
                                              moduleDefinition.ModuleDefID,
                                              "Taxonomy Manager",
                                              "~/images/icon_tag_32px.gif",
                                              true);
                    }
                    break;

                case "06.00.00":
                    DesktopModuleInfo desktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DotNetNuke.Taxonomy", Null.NullInteger);
                    desktopModule.Category = "Admin";
                    DesktopModuleController.SaveDesktopModule(desktopModule, false, false);
                    break;
                }
                return("Success");
            }
            catch (Exception exc)
            {
                Logger.Error(exc);

                return("Failed");
            }
        }
Example #12
0
        public string UpgradeModule(string Version)
        {
            try
            {
                switch (Version)
                {
                case "01.00.00":
                    break;

                case "06.00.00":
                    DesktopModuleInfo desktopModule = DesktopModuleController.GetDesktopModuleByModuleName("DotNetNuke.Taxonomy", Null.NullInteger);
                    desktopModule.Category = "Admin";
                    DesktopModuleController.SaveDesktopModule(desktopModule, false, false);
                    break;
                }
                return("Success");
            }
            catch (Exception exc)
            {
                Logger.Error(exc);

                return("Failed");
            }
        }
Example #13
0
        /// <summary>
        /// </summary>
        /// <remarks>
        /// </remarks>
        private bool CreateModuleDefinition()
        {
            try
            {
                if (PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == GetClassName()) == null)
                {
                    var controlName = Null.NullString;

                    //Create module folder
                    CreateModuleFolder();

                    //Create module control
                    controlName = CreateModuleControl();
                    if (controlName != "")
                    {
                        //Create package
                        var objPackage = new PackageInfo();
                        objPackage.Name         = GetClassName();
                        objPackage.FriendlyName = txtModule.Text;
                        objPackage.Description  = txtDescription.Text;
                        objPackage.Version      = new Version(1, 0, 0);
                        objPackage.PackageType  = "Module";
                        objPackage.License      = "";
                        objPackage.Owner        = txtOwner.Text;
                        objPackage.Organization = txtOwner.Text;
                        objPackage.FolderName   = "DesktopModules/" + GetFolderName();
                        objPackage.License      = "The license for this package is not currently included within the installation file, please check with the vendor for full license details.";
                        objPackage.ReleaseNotes = "This package has no Release Notes.";
                        PackageController.Instance.SaveExtensionPackage(objPackage);

                        //Create desktopmodule
                        var objDesktopModule = new DesktopModuleInfo();
                        objDesktopModule.DesktopModuleID         = Null.NullInteger;
                        objDesktopModule.ModuleName              = GetClassName();
                        objDesktopModule.FolderName              = GetFolderName();
                        objDesktopModule.FriendlyName            = txtModule.Text;
                        objDesktopModule.Description             = txtDescription.Text;
                        objDesktopModule.IsPremium               = false;
                        objDesktopModule.IsAdmin                 = false;
                        objDesktopModule.Version                 = "01.00.00";
                        objDesktopModule.BusinessControllerClass = "";
                        objDesktopModule.CompatibleVersions      = "";
                        objDesktopModule.AdminPage               = "";
                        objDesktopModule.HostPage                = "";
                        objDesktopModule.Dependencies            = "";
                        objDesktopModule.Permissions             = "";
                        objDesktopModule.PackageID               = objPackage.PackageID;
                        objDesktopModule.DesktopModuleID         = DesktopModuleController.SaveDesktopModule(objDesktopModule, false, true);
                        objDesktopModule = DesktopModuleController.GetDesktopModule(objDesktopModule.DesktopModuleID, Null.NullInteger);

                        //Add OwnerName to the DesktopModule taxonomy and associate it with this module
                        var vocabularyId      = -1;
                        var termId            = -1;
                        var objTermController = DotNetNuke.Entities.Content.Common.Util.GetTermController();
                        var objTerms          = objTermController.GetTermsByVocabulary("Module_Categories");
                        foreach (Term term in objTerms)
                        {
                            vocabularyId = term.VocabularyId;
                            if (term.Name == txtOwner.Text)
                            {
                                termId = term.TermId;
                            }
                        }
                        if (termId == -1)
                        {
                            termId = objTermController.AddTerm(new Term(vocabularyId)
                            {
                                Name = txtOwner.Text
                            });
                        }
                        var objTerm = objTermController.GetTerm(termId);
                        var objContentController = DotNetNuke.Entities.Content.Common.Util.GetContentController();
                        var objContent           = objContentController.GetContentItem(objDesktopModule.ContentItemId);
                        objTermController.AddTermToContent(objTerm, objContent);

                        //Add desktopmodule to all portals
                        DesktopModuleController.AddDesktopModuleToPortals(objDesktopModule.DesktopModuleID);

                        //Create module definition
                        var objModuleDefinition = new ModuleDefinitionInfo();
                        objModuleDefinition.ModuleDefID     = Null.NullInteger;
                        objModuleDefinition.DesktopModuleID = objDesktopModule.DesktopModuleID;
                        // need core enhancement to have a unique DefinitionName
                        objModuleDefinition.FriendlyName = GetClassName();
                        //objModuleDefinition.FriendlyName = txtModule.Text;
                        //objModuleDefinition.DefinitionName = GetClassName();
                        objModuleDefinition.DefaultCacheTime = 0;
                        objModuleDefinition.ModuleDefID      = ModuleDefinitionController.SaveModuleDefinition(objModuleDefinition, false, true);

                        //Create modulecontrol
                        var objModuleControl = new ModuleControlInfo();
                        objModuleControl.ModuleControlID          = Null.NullInteger;
                        objModuleControl.ModuleDefID              = objModuleDefinition.ModuleDefID;
                        objModuleControl.ControlKey               = "";
                        objModuleControl.ControlSrc               = "DesktopModules/" + GetFolderName() + "/" + controlName;
                        objModuleControl.ControlTitle             = "";
                        objModuleControl.ControlType              = SecurityAccessLevel.View;
                        objModuleControl.HelpURL                  = "";
                        objModuleControl.IconFile                 = "";
                        objModuleControl.ViewOrder                = 0;
                        objModuleControl.SupportsPartialRendering = false;
                        objModuleControl.SupportsPopUps           = false;
                        ModuleControlController.AddModuleControl(objModuleControl);

                        //Update current module to reference new moduledefinition
                        var objModule = ModuleController.Instance.GetModule(ModuleId, TabId, false);
                        objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
                        objModule.ModuleTitle = txtModule.Text;

                        //HACK - need core enhancement to be able to update ModuleDefID
                        DotNetNuke.Data.DataProvider.Instance().ExecuteSQL("Update dbo.Modules set ModuleDefID = " + objModule.ModuleDefID.ToString() + " where ModuleID = " + ModuleId.ToString());

                        ModuleController.Instance.UpdateModule(objModule);

                        return(true);
                    }
                    else
                    {
                        DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("TemplateProblem.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                        return(false);
                    }
                }
                else
                {
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("AlreadyExists.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.YellowWarning);
                    return(false);
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, exc.ToString(), ModuleMessage.ModuleMessageType.RedError);
                return(false);
            }
        }
Example #14
0
        /// <summary>
        /// </summary>
        /// <remarks>
        /// Loads the cboSource control list with locations of controls.
        /// </remarks>
        /// <history>
        /// </history>
        private ModuleDefinitionInfo ImportControl(string controlSrc)
        {
            ModuleDefinitionInfo moduleDefinition = null;

            try
            {
                string folder        = PathUtils.Instance.RemoveTrailingSlash(GetSourceFolder());
                string friendlyName  = txtName.Text;
                string name          = GetClassName();
                string moduleControl = "DesktopModules/" + folder + "/" + controlSrc;

                var packageInfo = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == name || p.FriendlyName == friendlyName);
                if (packageInfo != null)
                {
                    UI.Skins.Skin.AddModuleMessage(this, String.Format(Localization.GetString("NonuniqueNameModule", LocalResourceFile), packageInfo.FriendlyName), ModuleMessage.ModuleMessageType.RedError);
                }
                else
                {
                    var package = new PackageInfo
                    {
                        Name         = name,
                        FriendlyName = friendlyName,
                        Description  = txtDescription.Text,
                        Version      = new Version(1, 0, 0),
                        PackageType  = "Module",
                        License      = Util.PACKAGE_NoLicense
                    };

                    //Save Package
                    PackageController.Instance.SaveExtensionPackage(package);

                    var objDesktopModule = new DesktopModuleInfo
                    {
                        DesktopModuleID         = Null.NullInteger,
                        ModuleName              = name,
                        FolderName              = folder,
                        FriendlyName            = friendlyName,
                        Description             = txtDescription.Text,
                        IsPremium               = false,
                        IsAdmin                 = false,
                        Version                 = "01.00.00",
                        BusinessControllerClass = "",
                        CompatibleVersions      = "",
                        Dependencies            = "",
                        Permissions             = "",
                        PackageID               = package.PackageID
                    };

                    objDesktopModule.DesktopModuleID = DesktopModuleController.SaveDesktopModule(objDesktopModule, false, true);

                    //Add module to all portals
                    DesktopModuleController.AddDesktopModuleToPortals(objDesktopModule.DesktopModuleID);

                    //Save module definition
                    moduleDefinition = new ModuleDefinitionInfo();

                    moduleDefinition.ModuleDefID      = Null.NullInteger;
                    moduleDefinition.DesktopModuleID  = objDesktopModule.DesktopModuleID;
                    moduleDefinition.FriendlyName     = friendlyName;
                    moduleDefinition.DefaultCacheTime = 0;

                    moduleDefinition.ModuleDefID = ModuleDefinitionController.SaveModuleDefinition(moduleDefinition, false, true);

                    //Save module control
                    var objModuleControl = new ModuleControlInfo();

                    objModuleControl.ModuleControlID          = Null.NullInteger;
                    objModuleControl.ModuleDefID              = moduleDefinition.ModuleDefID;
                    objModuleControl.ControlKey               = "";
                    objModuleControl.ControlSrc               = moduleControl;
                    objModuleControl.ControlTitle             = "";
                    objModuleControl.ControlType              = SecurityAccessLevel.View;
                    objModuleControl.HelpURL                  = "";
                    objModuleControl.IconFile                 = "";
                    objModuleControl.ViewOrder                = 0;
                    objModuleControl.SupportsPartialRendering = false;

                    ModuleControlController.AddModuleControl(objModuleControl);
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("ImportControl.ErrorMessage", LocalResourceFile), ModuleMessage.ModuleMessageType.RedError);
            }
            return(moduleDefinition);
        }
        private int CreateModuleFromControl(CreateModuleDto createModuleDto, out string newPageUrl, out string errorMessage)
        {
            newPageUrl   = string.Empty;
            errorMessage = string.Empty;
            if (string.IsNullOrEmpty(createModuleDto.FileName))
            {
                errorMessage = "NoControl";
                return(Null.NullInteger);
            }

            try
            {
                var folder        = PathUtils.Instance.RemoveTrailingSlash(GetSourceFolder(createModuleDto));
                var friendlyName  = createModuleDto.ModuleName;
                var name          = createModuleDto.ModuleName;
                var moduleControl = "DesktopModules/" + folder + "/" + createModuleDto.FileName;

                var packageInfo = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p =>
                                                                                 p.Name.Equals(createModuleDto.ModuleName, StringComparison.OrdinalIgnoreCase) ||
                                                                                 p.FriendlyName.Equals(createModuleDto.ModuleName, StringComparison.OrdinalIgnoreCase));
                if (packageInfo != null)
                {
                    errorMessage = "NonuniqueName";
                    return(Null.NullInteger);
                }

                var package = new PackageInfo
                {
                    Name         = name,
                    FriendlyName = friendlyName,
                    Description  = createModuleDto.Description,
                    Version      = new Version(1, 0, 0),
                    PackageType  = "Module",
                    License      = Util.PACKAGE_NoLicense
                };

                //Save Package
                PackageController.Instance.SaveExtensionPackage(package);

                var objDesktopModule = new DesktopModuleInfo
                {
                    DesktopModuleID         = Null.NullInteger,
                    ModuleName              = name,
                    FolderName              = folder,
                    FriendlyName            = friendlyName,
                    Description             = createModuleDto.Description,
                    IsPremium               = false,
                    IsAdmin                 = false,
                    Version                 = "01.00.00",
                    BusinessControllerClass = "",
                    CompatibleVersions      = "",
                    Dependencies            = "",
                    Permissions             = "",
                    PackageID               = package.PackageID
                };

                objDesktopModule.DesktopModuleID = DesktopModuleController.SaveDesktopModule(objDesktopModule, false, true);

                //Add module to all portals
                DesktopModuleController.AddDesktopModuleToPortals(objDesktopModule.DesktopModuleID);

                //Save module definition
                var moduleDefinition = new ModuleDefinitionInfo();

                moduleDefinition.ModuleDefID      = Null.NullInteger;
                moduleDefinition.DesktopModuleID  = objDesktopModule.DesktopModuleID;
                moduleDefinition.FriendlyName     = friendlyName;
                moduleDefinition.DefaultCacheTime = 0;

                moduleDefinition.ModuleDefID = ModuleDefinitionController.SaveModuleDefinition(moduleDefinition, false, true);

                //Save module control
                var objModuleControl = new ModuleControlInfo();

                objModuleControl.ModuleControlID          = Null.NullInteger;
                objModuleControl.ModuleDefID              = moduleDefinition.ModuleDefID;
                objModuleControl.ControlKey               = "";
                objModuleControl.ControlSrc               = moduleControl;
                objModuleControl.ControlTitle             = "";
                objModuleControl.ControlType              = SecurityAccessLevel.View;
                objModuleControl.HelpURL                  = "";
                objModuleControl.IconFile                 = "";
                objModuleControl.ViewOrder                = 0;
                objModuleControl.SupportsPartialRendering = false;

                ModuleControlController.AddModuleControl(objModuleControl);

                if (createModuleDto.AddPage)
                {
                    newPageUrl = CreateNewPage(moduleDefinition);
                }

                return(package.PackageID);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                errorMessage = "CreateModuleFailed";
                return(Null.NullInteger);
            }
        }
Example #16
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// wizNewExtension_NextButtonClick when the next Button is clicked.  It provides
        ///	a mechanism for cancelling the page change if certain conditions aren't met.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	08/25/2008	created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void wizNewExtension_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            switch (e.CurrentStepIndex)
            {
            case 0:
                if (extensionForm.IsValid)
                {
                    var         newPackage = extensionForm.DataSource as PackageInfo;
                    PackageInfo tmpPackage = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.Name == newPackage.Name);
                    if (tmpPackage == null)
                    {
                        switch (Mode)
                        {
                        case "All":
                            newPackage.PackageType = cboExtensionType.SelectedValue;
                            break;

                        default:
                            newPackage.PackageType = Mode;
                            break;
                        }
                        PackageController.Instance.SaveExtensionPackage(newPackage);
                        PackageID = newPackage.PackageID;
                        Locale           locale;
                        LanguagePackInfo languagePack;
                        switch (newPackage.PackageType)
                        {
                        case "Auth_System":
                            //Create a new Auth System
                            var authSystem = new AuthenticationInfo
                            {
                                AuthenticationType = newPackage.Name,
                                IsEnabled          = Null.NullBoolean,
                                PackageID          = newPackage.PackageID
                            };
                            AuthenticationController.AddAuthentication(authSystem);
                            break;

                        case "Container":
                        case "Skin":
                            var skinPackage = new SkinPackageInfo
                            {
                                SkinName  = newPackage.Name,
                                PackageID = newPackage.PackageID,
                                SkinType  = newPackage.PackageType
                            };
                            SkinController.AddSkinPackage(skinPackage);
                            break;

                        case "CoreLanguagePack":
                            locale       = LocaleController.Instance.GetLocale(PortalController.Instance.GetCurrentPortalSettings().DefaultLanguage);
                            languagePack = new LanguagePackInfo
                            {
                                PackageID          = newPackage.PackageID,
                                LanguageID         = locale.LanguageId,
                                DependentPackageID = -2
                            };
                            LanguagePackController.SaveLanguagePack(languagePack);
                            break;

                        case "ExtensionLanguagePack":
                            locale       = LocaleController.Instance.GetLocale(PortalController.Instance.GetCurrentPortalSettings().DefaultLanguage);
                            languagePack = new LanguagePackInfo
                            {
                                PackageID          = newPackage.PackageID,
                                LanguageID         = locale.LanguageId,
                                DependentPackageID = Null.NullInteger
                            };
                            LanguagePackController.SaveLanguagePack(languagePack);
                            break;

                        case "Module":
                            //Create a new DesktopModule
                            var desktopModule = new DesktopModuleInfo
                            {
                                PackageID         = newPackage.PackageID,
                                ModuleName        = newPackage.Name,
                                FriendlyName      = newPackage.FriendlyName,
                                FolderName        = newPackage.Name,
                                Description       = newPackage.Description,
                                Version           = newPackage.Version.ToString(3),
                                SupportedFeatures = 0
                            };
                            int desktopModuleId = DesktopModuleController.SaveDesktopModule(desktopModule, false, true);
                            if (desktopModuleId > Null.NullInteger)
                            {
                                DesktopModuleController.AddDesktopModuleToPortals(desktopModuleId);
                            }
                            break;

                        case "SkinObject":
                            var skinControl = new SkinControlInfo {
                                PackageID = newPackage.PackageID, ControlKey = newPackage.Name
                            };
                            SkinControlController.SaveSkinControl(skinControl);
                            break;
                        }
                    }
                    else
                    {
                        e.Cancel         = true;
                        lblError.Text    = string.Format(Localization.GetString("DuplicateName", LocalResourceFile), newPackage.Name);
                        lblError.Visible = true;
                    }
                }
                if (PackageEditor != null && PackageID > Null.NullInteger)
                {
                    BindPackageEditor();
                }
                break;

            case 1:
                if (PackageEditor != null)
                {
                    PackageEditor.UpdatePackage();
                }
                break;

            case 2:
                if (ownerForm.IsValid)
                {
                    PackageController.Instance.SaveExtensionPackage(ownerForm.DataSource as PackageInfo);
                }
                Response.Redirect(Globals.NavigateURL(), true);
                break;
            }
        }
Example #17
0
        public static int AddPackage(PackageInfo package, bool includeDetail)
        {
            int packageID = provider.AddPackage(package.PortalID,
                                                package.Name,
                                                package.FriendlyName,
                                                package.Description,
                                                package.PackageType,
                                                package.Version.ToString(3),
                                                package.License,
                                                package.Manifest,
                                                package.Owner,
                                                package.Organization,
                                                package.Url,
                                                package.Email,
                                                package.ReleaseNotes,
                                                package.IsSystemPackage,
                                                UserController.GetCurrentUserInfo().UserID,
                                                package.FolderName,
                                                package.IconFile);
            var objEventLog = new EventLogController();

            objEventLog.AddLog(package, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PACKAGE_CREATED);
            if (includeDetail)
            {
                Locale           locale;
                LanguagePackInfo languagePack;
                switch (package.PackageType)
                {
                case "Auth_System":
                    //Create a new Auth System
                    var authSystem = new AuthenticationInfo();
                    authSystem.AuthenticationType = package.Name;
                    authSystem.IsEnabled          = Null.NullBoolean;
                    authSystem.PackageID          = packageID;
                    AuthenticationController.AddAuthentication(authSystem);
                    break;

                case "Container":
                case "Skin":
                    var skinPackage = new SkinPackageInfo();
                    skinPackage.SkinName  = package.Name;
                    skinPackage.PackageID = packageID;
                    skinPackage.SkinType  = package.PackageType;
                    SkinController.AddSkinPackage(skinPackage);
                    break;

                case "CoreLanguagePack":
                    locale                          = LocaleController.Instance.GetLocale(PortalController.GetCurrentPortalSettings().DefaultLanguage);
                    languagePack                    = new LanguagePackInfo();
                    languagePack.PackageID          = packageID;
                    languagePack.LanguageID         = locale.LanguageId;
                    languagePack.DependentPackageID = -2;
                    LanguagePackController.SaveLanguagePack(languagePack);
                    break;

                case "ExtensionLanguagePack":
                    locale                          = LocaleController.Instance.GetLocale(PortalController.GetCurrentPortalSettings().DefaultLanguage);
                    languagePack                    = new LanguagePackInfo();
                    languagePack.PackageID          = packageID;
                    languagePack.LanguageID         = locale.LanguageId;
                    languagePack.DependentPackageID = Null.NullInteger;
                    LanguagePackController.SaveLanguagePack(languagePack);
                    break;

                case "Module":
                    //Create a new DesktopModule
                    var desktopModule = new DesktopModuleInfo();
                    desktopModule.PackageID         = packageID;
                    desktopModule.ModuleName        = package.Name;
                    desktopModule.FriendlyName      = package.FriendlyName;
                    desktopModule.FolderName        = package.Name;
                    desktopModule.Description       = package.Description;
                    desktopModule.Version           = package.Version.ToString(3);
                    desktopModule.SupportedFeatures = 0;
                    int desktopModuleId = DesktopModuleController.SaveDesktopModule(desktopModule, false, true);
                    if (desktopModuleId > Null.NullInteger)
                    {
                        DesktopModuleController.AddDesktopModuleToPortals(desktopModuleId);
                    }
                    break;

                case "SkinObject":
                    var skinControl = new SkinControlInfo();
                    skinControl.PackageID  = packageID;
                    skinControl.ControlKey = package.Name;
                    SkinControlController.SaveSkinControl(skinControl);
                    break;
                }
            }

            DataCache.ClearPackagesCache(package.PortalID);
            return(packageID);
        }
Example #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="Version"></param>
        /// <returns></returns>
        /// <remarks>This is not localizing Page Name or description.</remarks>
        public string UpgradeModule(string Version)
        {
            try
            {
                var pageName        = Localization.GetString("HTMLEditorPageName", ResourceFile);
                var pageDescription = Localization.GetString("HTMLEditorPageDescription", ResourceFile);

                switch (Version)
                {
                case "06.00.00":

                    //Create Rad Editor Config Page (or get existing one)
                    TabInfo newPage = Upgrade.AddHostPage(pageName, pageDescription, ModuleFolder + "/images/radeditor_config_small.png", ModuleFolder + "/images/radeditor_config_large.png", true);

                    //Add Module To Page
                    int moduleDefId = GetModuleDefinitionID();
                    Upgrade.AddModuleToPage(newPage, moduleDefId, pageName, ModuleFolder + "/images/radeditor_config_large.png", true);

                    foreach (var item in DesktopModuleController.GetDesktopModules(Null.NullInteger))
                    {
                        DesktopModuleInfo moduleInfo = item.Value;

                        if (moduleInfo.ModuleName == "DotNetNuke.RadEditorProvider")
                        {
                            moduleInfo.Category = "Host";
                            DesktopModuleController.SaveDesktopModule(moduleInfo, false, false);
                        }
                    }
                    break;

                case "07.00.06":
                    UpdateConfigOfLinksType();
                    break;

                case "07.03.00":
                    UpdateConfigFilesName();
                    UpdateToolsFilesName();
                    break;

                case "07.04.00":
                    // Find the RadEditor page.  It should already exist and this will return it's reference.
                    var editorPage = Upgrade.AddHostPage(pageName, pageDescription, ModuleFolder + "/images/HtmlEditorManager_Standard_16x16.png", ModuleFolder + "/images/HtmlEditorManager_Standard_32x32.png", true);

                    // If the Html Editor Manager is installed, then remove the old RadEditor Manager
                    var htmlEditorManager = DesktopModuleController.GetDesktopModuleByModuleName("DotNetNuke.HtmlEditorManager", Null.NullInteger);
                    if (htmlEditorManager != null)
                    {
                        Upgrade.RemoveModule("RadEditor Manager", editorPage.TabName, editorPage.ParentId, false);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                ExceptionLogController xlc = new ExceptionLogController();
                xlc.AddLog(ex);

                return("Failed");
            }

            return("Success");
        }
Example #19
0
        /// <summary>
        /// Process legacy module version 3 .dnn install file
        /// </summary>
        /// <param name="desktopModule"></param>
        public static void ProcessLegacyModule(DesktopModuleInfo desktopModule)
        {
            //Get the Module folder
            string moduleFolder = Path.Combine(Globals.ApplicationMapPath, Path.Combine("DesktopModules", desktopModule.FolderName));

            //Find legacy manifest
            XPathNavigator rootNav = null;

            try
            {
                string   hostModules = "Portals, SQL, HostSettings, Scheduler, SearchAdmin, Lists, SkinDesigner, Extensions";
                string[] files       = Directory.GetFiles(moduleFolder, "*.dnn.config");
                if (files.Length > 0)
                {
                    //Create an XPathDocument from the Xml
                    var doc = new XPathDocument(new FileStream(files[0], FileMode.Open, FileAccess.Read));
                    rootNav = doc.CreateNavigator().SelectSingleNode("dotnetnuke");
                }

                //Module is not affiliated with a Package
                var package = new PackageInfo(new InstallerInfo());
                package.Name = desktopModule.ModuleName;

                package.FriendlyName = desktopModule.FriendlyName;
                package.Description  = desktopModule.Description;
                package.Version      = new Version(1, 0, 0);
                if (!string.IsNullOrEmpty(desktopModule.Version))
                {
                    package.Version = new Version(desktopModule.Version);
                }
                if (hostModules.Contains(desktopModule.ModuleName))
                {
                    //Host Module so make this a system package
                    package.IsSystemPackage = true;
                    desktopModule.IsAdmin   = true;
                }
                else
                {
                    desktopModule.IsAdmin = false;
                }
                package.PackageType = "Module";

                //See if the Module is using a "Namespace" for its name
                ParsePackageName(package);

                if (files.Length > 0)
                {
                    var modulewriter = new ModulePackageWriter(desktopModule, rootNav, package);
                    package.Manifest = modulewriter.WriteManifest(true);
                }
                else
                {
                    package.Manifest = ""; //module has no manifest
                }

                //Save Package
                PackageController.Instance.SaveExtensionPackage(package);

                //Update Desktop Module with new PackageID
                desktopModule.PackageID = package.PackageID;

                //Save DesktopModule
                DesktopModuleController.SaveDesktopModule(desktopModule, false, false);
            }
            catch (Exception exc)
            {
                Logger.Error(exc);
            }
        }
        public bool SavePackageSettings(PackageSettingsDto packageSettings, out string errorMessage)
        {
            errorMessage = string.Empty;

            try
            {
                var desktopModule = DesktopModuleController.GetDesktopModuleByPackageID(packageSettings.PackageId);
                var isHostUser    = UserController.Instance.GetCurrentUserInfo().IsSuperUser;

                UpdatePermissions(desktopModule, packageSettings);

                if (isHostUser)
                {
                    foreach (var settingName in packageSettings.EditorActions.Keys)
                    {
                        var settingValue = packageSettings.EditorActions[settingName];

                        switch (settingName.ToLowerInvariant())
                        {
                        case "foldername":
                            desktopModule.FolderName = settingValue;
                            break;

                        case "category":
                            desktopModule.Category = settingValue;
                            break;

                        case "businesscontroller":
                            desktopModule.BusinessControllerClass = settingValue;
                            break;

                        case "dependencies":
                            desktopModule.Dependencies = settingValue;
                            break;

                        case "hostpermissions":
                            desktopModule.Permissions = settingValue;
                            break;

                        case "premiummodule":
                            desktopModule.IsPremium = Convert.ToBoolean(settingValue);
                            break;

                        case "shareable":
                            desktopModule.Shareable = (ModuleSharing)Convert.ToInt32(settingValue);
                            break;

                        case "assignportal":
                            AssignPortals(desktopModule, JsonConvert.DeserializeObject <IList <ListItemDto> >(settingValue));
                            break;

                        case "unassignportal":
                            UnassignPortals(desktopModule, JsonConvert.DeserializeObject <IList <ListItemDto> >(settingValue));
                            break;

                        case "savedefinition":
                            var definition = JsonConvert.DeserializeObject <ModuleDefinitionDto>(settingValue);
                            SaveModuleDefinition(definition);
                            break;

                        case "deletedefinition":
                            DeleteModuleDefinition(Convert.ToInt32(settingValue));
                            break;

                        case "savemodulecontrol":
                            var moduleControl = JsonConvert.DeserializeObject <ModuleControlDto>(settingValue);
                            SaveModuleControl(moduleControl);
                            break;

                        case "deletemodulecontrol":
                            DeleteModuleControl(Convert.ToInt32(settingValue));
                            break;
                        }
                    }

                    DesktopModuleController.SaveDesktopModule(desktopModule, false, true);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                errorMessage = ex.Message;
                return(false);
            }
        }