/// -----------------------------------------------------------------------------
        /// <summary>
        /// SaveModuleDefinition saves the Module Definition to the database
        /// </summary>
        /// <param name="moduleDefinition">The Module Definition to save</param>
        /// <param name="saveChildren">A flag that determines whether the child objects are also saved</param>
        /// <param name="clearCache">A flag that determines whether to clear the host cache</param>
        /// <history>
        ///     [cnurse]	01/14/2008   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static int SaveModuleDefinition(ModuleDefinitionInfo moduleDefinition, bool saveChildren, bool clearCache)
        {
            int moduleDefinitionID = moduleDefinition.ModuleDefID;

            if (moduleDefinitionID == Null.NullInteger)
            {
                //Add new Module Definition
                moduleDefinitionID = dataProvider.AddModuleDefinition(moduleDefinition.DesktopModuleID,
                                                                      moduleDefinition.FriendlyName,
                                                                      moduleDefinition.DefinitionName,
                                                                      moduleDefinition.DefaultCacheTime,
                                                                      UserController.GetCurrentUserInfo().UserID);
            }
            else
            {
                //Upgrade Module Definition
                dataProvider.UpdateModuleDefinition(moduleDefinition.ModuleDefID, moduleDefinition.FriendlyName, moduleDefinition.DefinitionName, moduleDefinition.DefaultCacheTime, UserController.GetCurrentUserInfo().UserID);
            }
            if (saveChildren)
            {
                foreach (KeyValuePair <string, PermissionInfo> kvp in moduleDefinition.Permissions)
                {
                    kvp.Value.ModuleDefID = moduleDefinitionID;

                    //check if permission exists
                    var       permissionController = new PermissionController();
                    ArrayList permissions          = permissionController.GetPermissionByCodeAndKey(kvp.Value.PermissionCode, kvp.Value.PermissionKey);
                    if (permissions != null && permissions.Count == 1)
                    {
                        var permission = (PermissionInfo)permissions[0];
                        kvp.Value.PermissionID = permission.PermissionID;
                        permissionController.UpdatePermission(kvp.Value);
                    }
                    else
                    {
                        permissionController.AddPermission(kvp.Value);
                    }
                }
                foreach (KeyValuePair <string, ModuleControlInfo> kvp in moduleDefinition.ModuleControls)
                {
                    kvp.Value.ModuleDefID = moduleDefinitionID;

                    //check if definition exists
                    ModuleControlInfo moduleControl = ModuleControlController.GetModuleControlByControlKey(kvp.Value.ControlKey, kvp.Value.ModuleDefID);
                    if (moduleControl != null)
                    {
                        kvp.Value.ModuleControlID = moduleControl.ModuleControlID;
                    }
                    ModuleControlController.SaveModuleControl(kvp.Value, clearCache);
                }
            }
            if (clearCache)
            {
                DataCache.ClearHostCache(true);
            }
            return(moduleDefinitionID);
        }
        protected void btnAddModule_Click(object sender, EventArgs e)
        {
            string DesktopModuleFriendlyName = "DNNDal2";
            ModuleDefinitionInfo moduleDefinitionInfo = new ModuleDefinitionInfo();
            ModuleInfo moduleInfo = new ModuleInfo();
            moduleInfo.PortalID = 0;
            moduleInfo.TabID = 150;
            moduleInfo.PaneName = "TopPane";
            moduleInfo.ModuleDefID = 160;
            moduleInfo.CacheTime = moduleDefinitionInfo.DefaultCacheTime;//Default Cache Time is 0
            moduleInfo.InheritViewPermissions = true;  //Inherit View Permissions from Tab
            moduleInfo.AllTabs = false;
            moduleInfo.Alignment = "Top";

            ModuleController moduleController = new ModuleController();
            int moduleId = moduleController.AddModule(moduleInfo);
        }
 public int AddModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     return(SaveModuleDefinition(objModuleDefinition, false, true));
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetModuleDefinitionByID gets a Module Definition by its ID
        /// </summary>
		/// <param name="objModuleDefinition">The object of the Module Definition</param>
        /// <history>
        /// 	[cnurse]	01/14/2008   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public void DeleteModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
        {
            DeleteModuleDefinition(objModuleDefinition.ModuleDefID);
        }
 public void UpdateModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     SaveModuleDefinition(objModuleDefinition, false, true);
 }
		/// <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.GetPackages().FirstOrDefault(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();
                    package.Name = name;
                    package.FriendlyName = friendlyName;
                    package.Description = txtDescription.Text;
                    package.Version = new Version(1, 0, 0);
                    package.PackageType = "Module";
                    package.License = Util.PACKAGE_NoLicense;

                    //Save Package
                    PackageController.SavePackage(package);

                    var objDesktopModules = new DesktopModuleController();
                    var objDesktopModule = new DesktopModuleInfo();

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

#pragma warning disable 612,618
                    objDesktopModule.DesktopModuleID = objDesktopModules.AddDesktopModule(objDesktopModule);
#pragma warning restore 612,618

                    //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;
		}
        protected void grdControls_DeleteCommand(object source, DataGridCommandEventArgs e)
        {
            int controlID = Int32.Parse(e.CommandArgument.ToString());
            ModuleControlController.DeleteModuleControl(controlID);

            //Force Module Definition to refresh
            _ModuleDefinition = null;
            BindDefinition();
        }
        protected void cmdAddDefinition_Click(object sender, EventArgs e)
        {
            IsAddDefinitionMode = true;
            ModuleDefinitionID = Null.NullInteger;
            _ModuleDefinition = null;

            ////empty definition form's content
            definitionsEditor.Items.ForEach(i =>
                                                {
                                                    i.Value = null;
                                                });

            BindDefinition();
        }
        private static void ProcessControls(XPathNavigator controlNav, string moduleFolder, ModuleDefinitionInfo definition)
        {
            var moduleControl = new ModuleControlInfo();

            moduleControl.ControlKey = Util.ReadElement(controlNav, "key");
            moduleControl.ControlTitle = Util.ReadElement(controlNav, "title");

            //Write controlSrc
            string controlSrc = Util.ReadElement(controlNav, "src");
            if (!(controlSrc.ToLower().StartsWith("desktopmodules") || !controlSrc.ToLower().EndsWith(".ascx")))
            {
				//this code allows a developer to reference an ASCX file in a different folder than the module folder ( good for ASCX files shared between modules where you want only a single copy )
                //or it allows the developer to use webcontrols rather than usercontrols

                controlSrc = Path.Combine("DesktopModules", Path.Combine(moduleFolder, controlSrc));
            }
            controlSrc = controlSrc.Replace('\\', '/');
            moduleControl.ControlSrc = controlSrc;

            moduleControl.IconFile = Util.ReadElement(controlNav, "iconfile");

            string controlType = Util.ReadElement(controlNav, "type");
            if (!string.IsNullOrEmpty(controlType))
            {
                try
                {
                    moduleControl.ControlType = (SecurityAccessLevel) TypeDescriptor.GetConverter(typeof (SecurityAccessLevel)).ConvertFromString(controlType);
                }
                catch (Exception exc)
                {
                    Logger.Error(exc);

                    throw new Exception(Util.EXCEPTION_Type);
                }
            }
            string viewOrder = Util.ReadElement(controlNav, "vieworder");
            if (!string.IsNullOrEmpty(viewOrder))
            {
                moduleControl.ViewOrder = int.Parse(viewOrder);
            }
            moduleControl.HelpURL = Util.ReadElement(controlNav, "helpurl");
            string supportsPartialRendering = Util.ReadElement(controlNav, "supportspartialrendering");
            if (!string.IsNullOrEmpty(supportsPartialRendering))
            {
                moduleControl.SupportsPartialRendering = bool.Parse(supportsPartialRendering);
            }
            string supportsPopUps = Util.ReadElement(controlNav, "supportspopups");
            if (!string.IsNullOrEmpty(supportsPopUps))
            {
                moduleControl.SupportsPartialRendering = bool.Parse(supportsPopUps);
            }

            definition.ModuleControls[moduleControl.ControlKey] = moduleControl;
        }
Exemple #10
0
        /// <summary>
        /// AddModuleDefinition adds a new Core Module Definition to the system
        /// </summary>
        /// <remarks>
        ///	This overload allows the caller to determine whether the module has a controller
        /// class
        /// </remarks>
        ///	<param name="DesktopModuleName">The Friendly Name of the Module to Add</param>
        ///	<param name="Description">Description of the Module</param>
        ///	<param name="ModuleDefinitionName">The Module Definition Name</param>
        ///	<param name="Premium">A flag representing whether the module is a Premium module</param>
        ///	<param name="Admin">A flag representing whether the module is an Admin module</param>
        ///	<param name="Controller">The Controller Class string</param>
        ///	<param name="Version">The Module Version</param>
        ///	<returns>The Module Definition Id of the new Module</returns>
        /// <history>
        /// 	[cnurse]	10/14/2004	documented
        ///     [cnurse]    11/11/2004  removed addition of Module Control (now in AddMOduleControl)
        /// </history>
        private static int AddModuleDefinition(string DesktopModuleName, string Description, string ModuleDefinitionName, bool Premium, bool Admin, string Controller, string Version)
        {
            DesktopModuleController objDesktopModules = new DesktopModuleController();

            // check if desktop module exists
            DesktopModuleInfo objDesktopModule = objDesktopModules.GetDesktopModuleByName(DesktopModuleName);
            if (objDesktopModule == null)
            {
                objDesktopModule = new DesktopModuleInfo();

                objDesktopModule.DesktopModuleID = Null.NullInteger;
                objDesktopModule.FriendlyName = DesktopModuleName;
                objDesktopModule.FolderName = DesktopModuleName;
                objDesktopModule.ModuleName = DesktopModuleName;
                objDesktopModule.Description = Description;
                objDesktopModule.Version = Version;
                objDesktopModule.IsPremium = Premium;
                objDesktopModule.IsAdmin = Admin;
                objDesktopModule.BusinessControllerClass = Controller;

                objDesktopModule.DesktopModuleID = objDesktopModules.AddDesktopModule(objDesktopModule);
            }

            ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();

            // check if module definition exists
            ModuleDefinitionInfo objModuleDefinition = objModuleDefinitions.GetModuleDefinitionByName(objDesktopModule.DesktopModuleID, ModuleDefinitionName);
            if (objModuleDefinition == null)
            {
                objModuleDefinition = new ModuleDefinitionInfo();

                objModuleDefinition.ModuleDefID = Null.NullInteger;
                objModuleDefinition.DesktopModuleID = objDesktopModule.DesktopModuleID;
                objModuleDefinition.FriendlyName = ModuleDefinitionName;

                objModuleDefinition.ModuleDefID = objModuleDefinitions.AddModuleDefinition(objModuleDefinition);
            }

            return objModuleDefinition.ModuleDefID;
        }
        /// <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 );
            }
        }
        /// <remarks>
        /// Loads the cboSource control list with locations of controls.
        /// </remarks>
        private void InstallManifest( string strManifest )
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load( strManifest );

                XmlNode dnnRoot = doc.DocumentElement;
                foreach( XmlElement FolderElement in dnnRoot.SelectNodes( "folders/folder" ) )
                {
                    DesktopModuleController objDesktopModules = new DesktopModuleController();
                    DesktopModuleInfo objDesktopModule = new DesktopModuleInfo();

                    objDesktopModule.DesktopModuleID = Null.NullInteger;
                    objDesktopModule.ModuleName = XmlUtils.GetNodeValue( FolderElement, "modulename", "" );
                    objDesktopModule.FolderName = XmlUtils.GetNodeValue( FolderElement, "foldername", "" );
                    objDesktopModule.FriendlyName = XmlUtils.GetNodeValue( FolderElement, "friendlyname", "" );
                    if( objDesktopModule.FolderName == "" )
                    {
                        objDesktopModule.FolderName = objDesktopModule.ModuleName;
                    }
                    objDesktopModule.Description = XmlUtils.GetNodeValue( FolderElement, "description", "" );
                    objDesktopModule.IsPremium = false;
                    objDesktopModule.IsAdmin = false;
                    objDesktopModule.Version = XmlUtils.GetNodeValue( FolderElement, "version", "" );
                    objDesktopModule.BusinessControllerClass = XmlUtils.GetNodeValue( FolderElement, "businesscontrollerclass", "" );
                    objDesktopModule.CompatibleVersions = XmlUtils.GetNodeValue( FolderElement, "compatibleversions", "" );
                    objDesktopModule.DesktopModuleID = objDesktopModules.AddDesktopModule( objDesktopModule );

                    foreach( XmlElement ModuleElement in FolderElement.SelectNodes( "modules/module" ) )
                    {
                        ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();
                        ModuleDefinitionInfo objModuleDefinition = new ModuleDefinitionInfo();

                        objModuleDefinition.ModuleDefID = Null.NullInteger;
                        objModuleDefinition.DesktopModuleID = objDesktopModule.DesktopModuleID;
                        objModuleDefinition.FriendlyName = XmlUtils.GetNodeValue( ModuleElement, "friendlyname", "" );
                        objModuleDefinition.DefaultCacheTime = XmlUtils.GetNodeValueInt( ModuleElement, "cachetime", 0 );

                        objModuleDefinition.ModuleDefID = objModuleDefinitions.AddModuleDefinition( objModuleDefinition );

                        foreach( XmlElement ControlElement in ModuleElement.SelectNodes( "controls/control" ) )
                        {
                            ModuleControlController objModuleControls = new ModuleControlController();
                            ModuleControlInfo objModuleControl = new ModuleControlInfo();

                            objModuleControl.ModuleControlID = Null.NullInteger;
                            objModuleControl.ModuleDefID = objModuleDefinition.ModuleDefID;
                            objModuleControl.ControlKey = XmlUtils.GetNodeValue( ControlElement, "key", "" );
                            objModuleControl.ControlSrc = XmlUtils.GetNodeValue( ControlElement, "src", "" );
                            objModuleControl.ControlTitle = XmlUtils.GetNodeValue( ControlElement, "title", "" );
                            switch( XmlUtils.GetNodeValue( ControlElement, "type", "" ) )
                            {
                                case "Anonymous":

                                    objModuleControl.ControlType = SecurityAccessLevel.Anonymous;
                                    break;
                                case "View":

                                    objModuleControl.ControlType = SecurityAccessLevel.View;
                                    break;
                                case "Edit":

                                    objModuleControl.ControlType = SecurityAccessLevel.Edit;
                                    break;
                                case "Admin":

                                    objModuleControl.ControlType = SecurityAccessLevel.Admin;
                                    break;
                                case "Host":

                                    objModuleControl.ControlType = SecurityAccessLevel.Host;
                                    break;
                            }
                            objModuleControl.HelpURL = XmlUtils.GetNodeValue( ControlElement, "helpurl", "" );
                            objModuleControl.IconFile = XmlUtils.GetNodeValue( ControlElement, "iconfile", "" );
                            objModuleControl.ViewOrder = XmlUtils.GetNodeValueInt( ControlElement, "vieworder", 0 );

                            objModuleControls.AddModuleControl( objModuleControl );
                        }
                    }
                    // update interfaces
                    UpdateModuleInterfaces( objDesktopModule.BusinessControllerClass );
                }

                Response.Redirect( Globals.NavigateURL(), true );
            }
            catch
            {
                // can not open manifest
                UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "InstallManifest.ErrorMessage", this.LocalResourceFile ), ModuleMessageType.RedError );
            }
        }
Exemple #13
0
 public void UpdateModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     DataProvider.Instance().UpdateModuleDefinition(objModuleDefinition.ModuleDefID, objModuleDefinition.FriendlyName, objModuleDefinition.DefaultCacheTime);
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Reads a Module Definitions from an XmlReader
        /// </summary>
        /// <param name="reader">The XmlReader to use</param>
        /// <history>
        /// 	[cnurse]	01/17/2008   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void ReadModuleDefinitions(XmlReader reader)
        {
            reader.ReadStartElement("moduleDefinitions");
            do
            {
                reader.ReadStartElement("moduleDefinition");

				//Create new ModuleDefinition object
                var moduleDefinition = new ModuleDefinitionInfo();

				//Load it from the Xml
                moduleDefinition.ReadXml(reader);

				//Add to the collection
                ModuleDefinitions.Add(moduleDefinition.FriendlyName, moduleDefinition);
            } while (reader.ReadToNextSibling("moduleDefinition"));
		}
        private void ProcessModules(XPathNavigator moduleNav, string moduleFolder)
        {
            var definition = new ModuleDefinitionInfo();

            definition.FriendlyName = Util.ReadElement(moduleNav, "friendlyname");
            string cacheTime = Util.ReadElement(moduleNav, "cachetime");
            if (!string.IsNullOrEmpty(cacheTime))
            {
                definition.DefaultCacheTime = int.Parse(cacheTime);
            }
			
            //Process legacy controls Node
            foreach (XPathNavigator controlNav in moduleNav.Select("controls/control"))
            {
                ProcessControls(controlNav, moduleFolder, definition);
            }
            DesktopModule.ModuleDefinitions[definition.FriendlyName] = definition;
        }
Exemple #16
0
 public int AddModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     return(DataProvider.Instance().AddModuleDefinition(objModuleDefinition.DesktopModuleID, objModuleDefinition.FriendlyName, objModuleDefinition.DefaultCacheTime));
 }
 protected void cboDefinitions_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!IsAddDefinitionMode)
     {
         ModuleDefinitionID = int.Parse(cboDefinitions.SelectedValue);
         //Force Module Definition to refresh
         _ModuleDefinition = null;
         BindDefinition();
     }
 }
        protected void cmdDeleteDefinition_Click(object sender, EventArgs e)
        {
            var objModuleDefinitions = new ModuleDefinitionController();
            objModuleDefinitions.DeleteModuleDefinition(ModuleDefinitionID);

            //Force Definitions list to refresh by rebinding DesktopModule
            ModuleDefinitionID = Null.NullInteger;
            _ModuleDefinition = null;
            _DesktopModule = null;

            //empty definition form's content
            definitionsEditor.Items.ForEach(i =>
                                                {
                                                    i.Value = null;
                                                });
            BindDesktopModule(true);
        }
 protected void cmdAddDefinition_Click(object sender, EventArgs e)
 {
     IsAddDefinitionMode = true;
     ModuleDefinitionID = Null.NullInteger;
     _ModuleDefinition = null;
     BindDefinition();
 }
        private void BindDefinition()
        {
            if (IsAddDefinitionMode)
            {
                var definition = new ModuleDefinitionInfo {DesktopModuleID = DesktopModule.DesktopModuleID, ModuleDefID = Null.NullInteger};
                definitionsEditor.DataSource = definition;
                definitionsEditor.DataBind();

                cmdDeleteDefinition.Visible = false;
                cmdUpdateDefinition.Text = Localization.GetString("cmdCreateDefinition", LocalResourceFile);
                pnlDefinition.Visible = true;
                pnlControls.Visible = false;
                definitionSelectRow.Visible = false;
            }
            else
            {
                if (ModuleDefinition != null && ModuleDefinition.DesktopModuleID == DesktopModule.DesktopModuleID)
                {
                    definitionsEditor.DataSource = ModuleDefinition;
                    definitionsEditor.DataBind();

                    cmdDeleteDefinition.Visible = true;
                    cmdUpdateDefinition.Text = Localization.GetString("cmdUpdateDefinition", LocalResourceFile);

                    if (!Page.IsPostBack)
                    {
                        Localization.LocalizeDataGrid(ref grdControls, LocalResourceFile);
                    }
                    grdControls.DataSource = ModuleDefinition.ModuleControls.Values;
                    grdControls.DataBind();

                    pnlDefinition.Visible = true;
                    pnlControls.Visible = true;
                    definitionSelectRow.Visible = true;

                    cmdAddControl.NavigateUrl = ModuleContext.EditUrl("ModuleControlID", "-1", "EditControl", "packageId=" + PackageID, "moduledefid=" + ModuleDefinition.ModuleDefID);
                }
                else
                {
                    pnlDefinition.Visible = false;
                }
            }
        }
        protected void cmdDeleteDefinition_Click(object sender, EventArgs e)
        {
            var objModuleDefinitions = new ModuleDefinitionController();
            objModuleDefinitions.DeleteModuleDefinition(ModuleDefinitionID);

            //Force Definitions list to refresh by rebinding DesktopModule
            ModuleDefinitionID = Null.NullInteger;
            _ModuleDefinition = null;
            _DesktopModule = null;
            BindDesktopModule(true);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// SaveModuleDefinition saves the Module Definition to the database
        /// </summary>
        /// <param name="moduleDefinition">The Module Definition to save</param>
        /// <param name="saveChildren">A flag that determines whether the child objects are also saved</param>
        /// <param name="clearCache">A flag that determines whether to clear the host cache</param>
        /// <history>
        /// 	[cnurse]	01/14/2008   Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public static int SaveModuleDefinition(ModuleDefinitionInfo moduleDefinition, bool saveChildren, bool clearCache)
        {
            int moduleDefinitionID = moduleDefinition.ModuleDefID;
            if (moduleDefinitionID == Null.NullInteger)
            {
				//Add new Module Definition
                moduleDefinitionID = dataProvider.AddModuleDefinition(moduleDefinition.DesktopModuleID,
                                                                      moduleDefinition.FriendlyName,
                                                                      moduleDefinition.DefinitionName,
                                                                      moduleDefinition.DefaultCacheTime,
                                                                      UserController.Instance.GetCurrentUserInfo().UserID);
            }
            else
            {
				//Upgrade Module Definition
                dataProvider.UpdateModuleDefinition(moduleDefinition.ModuleDefID, moduleDefinition.FriendlyName, moduleDefinition.DefinitionName, moduleDefinition.DefaultCacheTime, UserController.Instance.GetCurrentUserInfo().UserID);
            }
            if (saveChildren)
            {
                foreach (KeyValuePair<string, PermissionInfo> kvp in moduleDefinition.Permissions)
                {
                    kvp.Value.ModuleDefID = moduleDefinitionID;

                    //check if permission exists
                    var permissionController = new PermissionController();
                    ArrayList permissions = permissionController.GetPermissionByCodeAndKey(kvp.Value.PermissionCode, kvp.Value.PermissionKey);
                    if (permissions != null && permissions.Count == 1)
                    {
                        var permission = (PermissionInfo) permissions[0];
                        kvp.Value.PermissionID = permission.PermissionID;
                        permissionController.UpdatePermission(kvp.Value);
                    }
                    else
                    {
                        permissionController.AddPermission(kvp.Value);
                    }
                }
                foreach (KeyValuePair<string, ModuleControlInfo> kvp in moduleDefinition.ModuleControls)
                {
                    kvp.Value.ModuleDefID = moduleDefinitionID;

                    //check if definition exists
                    ModuleControlInfo moduleControl = ModuleControlController.GetModuleControlByControlKey(kvp.Value.ControlKey, kvp.Value.ModuleDefID);
                    if (moduleControl != null)
                    {
                        kvp.Value.ModuleControlID = moduleControl.ModuleControlID;
                    }
                    ModuleControlController.SaveModuleControl(kvp.Value, clearCache);
                }
            }
            if (clearCache)
            {
                DataCache.ClearHostCache(true);
            }
            return moduleDefinitionID;
        }
 public int AddModuleDefinition( ModuleDefinitionInfo objModuleDefinition )
 {
     return DataProvider.Instance().AddModuleDefinition( objModuleDefinition.DesktopModuleID, objModuleDefinition.FriendlyName, objModuleDefinition.DefaultCacheTime );
 }
 public int AddModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     return SaveModuleDefinition(objModuleDefinition, false, true);
 }
 public void UpdateModuleDefinition( ModuleDefinitionInfo objModuleDefinition )
 {
     DataProvider.Instance().UpdateModuleDefinition( objModuleDefinition.ModuleDefID, objModuleDefinition.FriendlyName, objModuleDefinition.DefaultCacheTime );
 }
        /// <summary>
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        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 objDesktopModules = new DesktopModuleController();
                        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.Dependencies = "";
                        objDesktopModule.Permissions = "";
                        objDesktopModule.PackageID = objPackage.PackageID;
                        objDesktopModule.DesktopModuleID = objDesktopModules.AddDesktopModule(objDesktopModule);
                        objDesktopModule = objDesktopModules.GetDesktopModule(objDesktopModule.DesktopModuleID);

                        //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 objModules = new ModuleController();
                        var objModule = objModules.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());

                        objModules.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;
            }
        }
        public override PaFolderCollection ReadDnn()
        {
            //This is a very long subroutine and should probably be broken down
            //into a couple of smaller routines.  That would make it easier to
            //maintain.
            InstallerInfo.Log.StartJob(DNN_Reading);

            //Determine if XML conforms to designated schema
            ArrayList DnnErrors = ValidateDnn();
            if (DnnErrors.Count == 0)
            {
                InstallerInfo.Log.AddInfo(DNN_ValidSkinObject);

                PaFolderCollection Folders = new PaFolderCollection();

                XmlDocument doc = new XmlDocument();
                MemoryStream buffer = new MemoryStream(InstallerInfo.DnnFile.Buffer, false);
                doc.Load(buffer);
                InstallerInfo.Log.AddInfo(XML_Loaded);

                XmlNode dnnRoot = doc.DocumentElement;

                int TempModuleDefinitionID = 0;

                XmlElement FolderElement;
                foreach (XmlElement tempLoopVar_FolderElement in dnnRoot.SelectNodes("folders/folder"))
                {
                    FolderElement = tempLoopVar_FolderElement;
                    //We will process each folder individually.  So we don't need to keep
                    //as much in memory.

                    //As we loop through each folder, we will save the data
                    PaFolder Folder = new PaFolder();

                    //The folder/name node is a required node.  If empty, this will throw
                    //an exception.
                    try
                    {
                        Folder.Name = FolderElement.SelectSingleNode("name").InnerText.Trim();
                    }
                    catch (Exception)
                    {
                        throw (new Exception(EXCEPTION_FolderName));
                    }

                    // in V2 the FriendlyName/FolderName/ModuleName attributes were not supported in the *.dnn file,
                    // so set them to the Folder Name
                    Folder.FriendlyName = Folder.Name;
                    Folder.FolderName = Folder.Name;
                    Folder.ModuleName = Folder.Name;

                    XmlElement resourcefileElement = (XmlElement)FolderElement.SelectSingleNode("resourcefile");
                    if (resourcefileElement != null)
                    {
                        if (resourcefileElement.InnerText.Trim() != "")
                        {
                            Folder.ResourceFile = resourcefileElement.InnerText.Trim();
                            PaFile paRF = (PaFile)InstallerInfo.FileTable[Folder.ResourceFile.ToLower()];
                            if (paRF == null)
                            {
                                InstallerInfo.Log.AddFailure(EXCEPTION_MissingResource + Folder.ResourceFile);
                            }
                            else
                            {
                                paRF.Path = Folder.ResourceFile;
                            }
                        }
                    }

                    // loading files
                    InstallerInfo.Log.AddInfo(FILES_Loading);
                    XmlElement file;
                    foreach (XmlElement tempLoopVar_file in FolderElement.SelectNodes("files/file"))
                    {
                        file = tempLoopVar_file;
                        //The file/name node is a required node.  If empty, this will throw
                        //an exception.
                        string name;
                        try
                        {
                            name = file.SelectSingleNode("name").InnerText.Trim();
                        }
                        catch (Exception)
                        {
                            throw (new Exception(EXCEPTION_FileName));
                        }
                        PaFile paf = (PaFile)InstallerInfo.FileTable[name.ToLower()];
                        if (paf == null)
                        {
                            InstallerInfo.Log.AddFailure(FILE_NotFound + name);
                        }
                        else
                        {
                            //A file path may or may not exist
                            XmlElement pathElement = (XmlElement)file.SelectSingleNode("path");
                            if (!(pathElement == null))
                            {
                                string filepath = pathElement.InnerText.Trim();
                                InstallerInfo.Log.AddInfo(string.Format(FILE_Found, filepath, name));
                                paf.Path = filepath;
                            }
                            Folder.Files.Add(paf);
                        }
                    }

                    // add dnn file to collection ( if it does not exist already )
                    if (Folder.Files.Contains(InstallerInfo.DnnFile) == false)
                    {
                        Folder.Files.Add(InstallerInfo.DnnFile);
                    }

                    InstallerInfo.Log.AddInfo(MODULES_Loading);
                    XmlElement DNNModule;
                    foreach (XmlElement tempLoopVar_DNNModule in FolderElement.SelectNodes("modules/module"))
                    {
                        DNNModule = tempLoopVar_DNNModule;

                        ModuleDefinitionInfo ModuleDef = new ModuleDefinitionInfo();

                        ModuleDef.TempModuleID = TempModuleDefinitionID;
                        //We need to ensure that admin order is null for "User" modules

                        TempModuleDefinitionID++;

                        Folder.Modules.Add(ModuleDef);

                        InstallerInfo.Log.AddInfo(string.Format(MODULES_ControlInfo, ModuleDef.FriendlyName));
                        XmlElement ModuleControl;
                        foreach (XmlElement tempLoopVar_ModuleControl in DNNModule.SelectNodes("controls/control"))
                        {
                            ModuleControl = tempLoopVar_ModuleControl;
                            ModuleControlInfo ModuleControlDef = new ModuleControlInfo();

                            XmlElement keyElement = (XmlElement)ModuleControl.SelectSingleNode("key");
                            if (keyElement != null)
                            {
                                ModuleControlDef.ControlKey = keyElement.InnerText.Trim();
                            }

                            XmlElement titleElement = (XmlElement)ModuleControl.SelectSingleNode("title");
                            if (titleElement != null)
                            {
                                ModuleControlDef.ControlTitle = titleElement.InnerText.Trim();
                            }

                            try
                            {
                                ModuleControlDef.ControlSrc = Path.Combine("DesktopModules", Path.Combine(Folder.Name, ModuleControl.SelectSingleNode("src").InnerText.Trim()).Replace('\\', '/')).Replace(@"\", "/");
                            }
                            catch (Exception)
                            {
                                throw (new Exception(EXCEPTION_Src));
                            }

                            XmlElement iconFileElement = (XmlElement)ModuleControl.SelectSingleNode("iconfile");
                            if (iconFileElement != null)
                            {
                                ModuleControlDef.IconFile = iconFileElement.InnerText.Trim();
                            }

                            try
                            {
                                ModuleControlDef.ControlType = (SecurityAccessLevel)TypeDescriptor.GetConverter(typeof(SecurityAccessLevel)).ConvertFromString(ModuleControl.SelectSingleNode("type").InnerText.Trim());
                                //ModuleControlDef.ControlType = CType(ModuleControl.SelectSingleNode("type").InnerText.Trim, SecurityAccessLevel)
                            }
                            catch (Exception)
                            {
                                throw (new Exception(EXCEPTION_Type));
                            }

                            XmlElement orderElement = (XmlElement)ModuleControl.SelectSingleNode("vieworder");
                            if (orderElement != null)
                            {
                                ModuleControlDef.ViewOrder = Convert.ToInt32(orderElement.InnerText.Trim());
                            }
                            else
                            {
                                ModuleControlDef.ViewOrder = Null.NullInteger;
                            }

                            //This is a temporary relationship since the ModuleDef has not been saved to the db
                            //it does not have a valid ModuleDefID.  Once it is saved then we can update the
                            //ModuleControlDef with the correct value.
                            ModuleControlDef.ModuleDefID = ModuleDef.TempModuleID;

                            Folder.Controls.Add(ModuleControlDef);
                        }
                    }

                    Folders.Add(Folder);
                }

                if (!InstallerInfo.Log.Valid)
                {
                    throw (new Exception(EXCEPTION_LoadFailed));
                }
                InstallerInfo.Log.EndJob(DNN_Success);

                return Folders;
            }
            else
            {
                string err;
                foreach (string tempLoopVar_err in DnnErrors)
                {
                    err = tempLoopVar_err;
                    InstallerInfo.Log.AddFailure(err);
                }
                throw (new Exception(EXCEPTION_Format));
            }
        }
 public void UpdateModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     SaveModuleDefinition(objModuleDefinition, false, true);
 }
Exemple #29
0
        public int AddModuleToPage(TabInfo t, ModuleType type)
        {
            string DesktopModuleFriendlyName="";
            string ModuleDefFriendlyName="";

            ModuleDefinitionInfo moduleDefinitionInfo = new ModuleDefinitionInfo();
            ModuleInfo moduleInfo = new ModuleInfo();
            moduleInfo.PortalID = t.PortalID;
            moduleInfo.TabID = t.TabID;
            moduleInfo.ModuleOrder = 1;
            moduleInfo.ModuleTitle = "";
            moduleInfo.DisplayPrint = false;
            moduleInfo.IsShareable = true;
            moduleInfo.IsShareableViewOnly = true;

            switch (type)
            {
                case ModuleType.DisplayPlugg:
                    moduleInfo.PaneName = "RowTwo_Grid8_Pane";
                    DesktopModuleFriendlyName = "DisplayPlugg";
                    ModuleDefFriendlyName = "DisplayPlugg";
                    break;
                case ModuleType.DisplayCourse:
                    moduleInfo.PaneName = "RowTwo_Grid8_Pane";
                    DesktopModuleFriendlyName = "DisplayCourse";
                    ModuleDefFriendlyName = "DisplayCourse";
                    break;
                case ModuleType.CourseMenu:
                    moduleInfo.PaneName = "RowTwo_Grid4_Pane";
                    DesktopModuleFriendlyName = "CourseMenu";
                    ModuleDefFriendlyName = "CourseMenu";
                    break;
                case ModuleType.Rating:
                    moduleInfo.PaneName = "RowTwo_Grid4_Pane";
                    DesktopModuleFriendlyName = "DNNCentric RnC";
                    ModuleDefFriendlyName = "DNNCentric.RatingAndComments";
                    break;
                case ModuleType.Comments:
                    moduleInfo.PaneName = "RowTwo_Grid8_Pane";
                    DesktopModuleFriendlyName = "DNNCentric RnC";
                    ModuleDefFriendlyName = "DNNCentric.RatingAndComments";
                    break;
                case ModuleType.DisplayPluggeTitle:
                    moduleInfo.PaneName = "RowTwo_Grid4_Pane";
                    DesktopModuleFriendlyName = "DisplayPluggeTitle";
                    ModuleDefFriendlyName = "DisplayPluggeTitle";
                    break;

               }

            DesktopModuleInfo myModule = null;
            foreach (KeyValuePair<int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(t.PortalID))
            {
                DesktopModuleInfo mod = kvp.Value;
                if (mod != null)
                    if (mod.FriendlyName == DesktopModuleFriendlyName)
                    {
                        myModule = mod;
                        break;
                    }
            }

            int moduleId=0;
            if (myModule != null)
            {
                var mc = new ModuleDefinitionController();
                var mInfo = new ModuleDefinitionInfo();
                mInfo = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleDefFriendlyName,
                    myModule.DesktopModuleID);
                moduleInfo.ModuleDefID = mInfo.ModuleDefID;
                moduleInfo.CacheTime = moduleDefinitionInfo.DefaultCacheTime;//Default Cache Time is 0
                moduleInfo.InheritViewPermissions = true;  //Inherit View Permissions from Tab
                moduleInfo.AllTabs = false;
                moduleInfo.Alignment = "Top";

                ModuleController moduleController = new ModuleController();
                moduleId = moduleController.AddModule(moduleInfo);
            }

            DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(t.TabID);
            DotNetNuke.Common.Utilities.DataCache.ClearTabsCache(t.PortalID);
            DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(t.PortalID, false);

            //Add settings for RnC
            ModuleController m = new ModuleController();
            if (type == ModuleType.Rating)
            {
                AddModuleSettingsRnCCommon(moduleId);
                m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID);
                m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyRatings");
                m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "357");
            }
            if (type == ModuleType.Comments)
            {
                AddModuleSettingsRnCCommon(moduleId);
                m.UpdateModuleSetting(moduleId, "PRC_settingCommentObject", "tabid:" + t.TabID);
                m.UpdateModuleSetting(moduleId, "PRC_settingShow", "OnlyComments");
                m.UpdateModuleSetting(moduleId, "PRC_settingRncWidth", "744");
            }

            if (type == ModuleType.Rating || type == ModuleType.Comments)
            {
                RnCController c = new RnCController();
                DCC_PRC_CommentObject myCO = new DCC_PRC_CommentObject();
                myCO.CommentObject = "tabid:" + t.TabID;
                myCO.CommentObjectViewCount = 0;
                myCO.PortalID = t.PortalID;
                c.CreateCommentObject(myCO);
            }
            return moduleId;
        }
Exemple #30
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// GetModuleDefinitionByID gets a Module Definition by its ID.
 /// </summary>
 /// <param name="objModuleDefinition">The object of the Module Definition.</param>
 /// -----------------------------------------------------------------------------
 public void DeleteModuleDefinition(ModuleDefinitionInfo objModuleDefinition)
 {
     this.DeleteModuleDefinition(objModuleDefinition.ModuleDefID);
 }
        protected void cboDefinitions_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!IsAddDefinitionMode)
            {
                ModuleDefinitionID = int.Parse(cboDefinitions.SelectedValue);
                //Force Module Definition to refresh
                _ModuleDefinition = null;

                //empty definition form's content
                definitionsEditor.Items.ForEach(i =>
                                                    {
                                                        i.Value = null;
                                                    });
                BindDefinition();
            }
        }
Exemple #32
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// AddModuleDefinition adds a new Core Module Definition to the system
        /// </summary>
        /// <remarks>
        ///	This overload allows the caller to determine whether the module has a controller
        /// class
        /// </remarks>
        ///	<param name="desktopModuleName">The Friendly Name of the Module to Add</param>
        ///	<param name="description">Description of the Module</param>
        ///	<param name="moduleDefinitionName">The Module Definition Name</param>
        /// <param name="businessControllerClass">Business Control Class.</param>
        /// <param name="isPortable">Whether the module is enable for portals.</param>
        ///	<param name="premium">A flag representing whether the module is a Premium module</param>
        ///	<param name="admin">A flag representing whether the module is an Admin module</param>
        ///	<returns>The Module Definition Id of the new Module</returns>
        /// <history>
        /// 	[cnurse]	10/14/2004	documented
        ///     [cnurse]    11/11/2004  removed addition of Module Control (now in AddMOduleControl)
        /// </history>
        /// -----------------------------------------------------------------------------
        private static int AddModuleDefinition(string desktopModuleName, string description, string moduleDefinitionName, string businessControllerClass, bool isPortable, bool premium, bool admin)
        {
            DnnInstallLogger.InstallLogInfo(Localization.Localization.GetString("LogStart", Localization.Localization.GlobalResourceFile) + "AddModuleDefinition:" + desktopModuleName);
            // check if desktop module exists
            var desktopModule = DesktopModuleController.GetDesktopModuleByModuleName(desktopModuleName, Null.NullInteger);
            if (desktopModule == null)
            {
                var package = new PackageInfo
                                  {
                                      Description = description,
                                      FriendlyName = desktopModuleName,
                                      Name = string.Concat("DotNetNuke.", desktopModuleName),
                                      PackageType = "Module",
                                      Owner = "DNN",
                                      Organization = "DNN Corp.",
                                      Url = "http://www.dnnsoftware.com",
                                      Email = "*****@*****.**"
                                  };
                if (desktopModuleName == "Extensions" || desktopModuleName == "Skin Designer" || desktopModuleName == "Dashboard")
                {
                    package.IsSystemPackage = true;
                }
                package.Version = new Version(1, 0, 0);

                PackageController.Instance.SaveExtensionPackage(package);

                string moduleName = desktopModuleName.Replace(" ", "");
                desktopModule = new DesktopModuleInfo
                                    {
                                        DesktopModuleID = Null.NullInteger,
                                        PackageID = package.PackageID,
                                        FriendlyName = desktopModuleName,
                                        FolderName = "Admin/" + moduleName,
                                        ModuleName = moduleName,
                                        Description = description,
                                        Version = "01.00.00",
                                        BusinessControllerClass = businessControllerClass,
                                        IsPortable = isPortable,
                                        SupportedFeatures = 0
                                    };
                if ((isPortable))
                {
                    desktopModule.SupportedFeatures = 1;
                }
                desktopModule.IsPremium = premium;
                desktopModule.IsAdmin = admin;

                desktopModule.DesktopModuleID = DesktopModuleController.SaveDesktopModule(desktopModule, false, false);

                if (!premium)
                {
                    DesktopModuleController.AddDesktopModuleToPortals(desktopModule.DesktopModuleID);
                }
            }

            // check if module definition exists
            var moduleDefinition = ModuleDefinitionController.GetModuleDefinitionByFriendlyName(moduleDefinitionName, desktopModule.DesktopModuleID);
            if (moduleDefinition == null)
            {
                moduleDefinition = new ModuleDefinitionInfo { ModuleDefID = Null.NullInteger, DesktopModuleID = desktopModule.DesktopModuleID, FriendlyName = moduleDefinitionName };

                moduleDefinition.ModuleDefID = ModuleDefinitionController.SaveModuleDefinition(moduleDefinition, false, false);
            }
            return moduleDefinition.ModuleDefID;
        }
        protected virtual ModuleDefinitionInfo GetModuleFromNode(int TempModuleDefinitionID, PaFolder Folder, XmlElement DNNModule)
        {
            ModuleDefinitionInfo ModuleDef = new ModuleDefinitionInfo();

            XmlElement friendlyNameElement = (XmlElement)DNNModule.SelectSingleNode("friendlyname");
            if (friendlyNameElement != null)
            {
                ModuleDef.FriendlyName = friendlyNameElement.InnerText.Trim();
            }

            ModuleDef.TempModuleID = TempModuleDefinitionID;
            //We need to ensure that admin order is null for "User" modules

            InstallerInfo.Log.AddInfo(string.Format(MODULES_ControlInfo, ModuleDef.FriendlyName));

            XmlElement ModuleControl;
            foreach (XmlElement tempLoopVar_ModuleControl in DNNModule.SelectNodes("controls/control"))
            {
                ModuleControl = tempLoopVar_ModuleControl;

                Folder.Controls.Add(GetModuleControlFromNode(Folder.Name, ModuleDef.TempModuleID, ModuleControl));
            }

            return ModuleDef;
        }