protected override void RegisterModules(PaFolder Folder, ArrayList Modules, ArrayList Controls)
        {
            InstallerInfo.Log.AddInfo(REGISTER_Controls);

            ModuleControlController objModuleControls = new ModuleControlController();

            ModuleControlInfo objModuleControl;
            foreach (ModuleControlInfo tempLoopVar_objModuleControl in Controls)
            {
                objModuleControl = tempLoopVar_objModuleControl;
                // Skins Objects have a null ModuleDefID
                objModuleControl.ModuleDefID = Null.NullInteger;

                // check if control exists
                ModuleControlInfo objModuleControl2 = objModuleControls.GetModuleControlByKeyAndSrc(Null.NullInteger, objModuleControl.ControlKey, objModuleControl.ControlSrc);
                if (objModuleControl2 == null)
                {
                    // add new control
                    objModuleControls.AddModuleControl(objModuleControl);
                }
                else
                {
                    // update existing control
                    objModuleControl.ModuleControlID = objModuleControl2.ModuleControlID;
                    objModuleControls.UpdateModuleControl(objModuleControl);
                }
            }

            InstallerInfo.Log.EndJob(REGISTER_End);
        }
예제 #2
0
        /// <Summary>Page_Load runs when the control is loaded.</Summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            string FriendlyName = "";

            ModuleController objModules = new ModuleController();
            ModuleInfo objModule = objModules.GetModule( ModuleId, TabId, false );
            if( objModule != null )
            {
                FriendlyName = objModule.FriendlyName;
            }

            int ModuleControlId = Null.NullInteger;

            if( !( Request.QueryString["ctlid"] == null ) )
            {
                ModuleControlId = int.Parse( Request.QueryString["ctlid"] );
            }

            ModuleControlController objModuleControls = new ModuleControlController();
            ModuleControlInfo objModuleControl = objModuleControls.GetModuleControl( ModuleControlId );
            if( objModuleControl != null )
            {
                string FileName = Path.GetFileName( objModuleControl.ControlSrc );
                string localResourceFile = objModuleControl.ControlSrc.Replace( FileName, Localization.LocalResourceDirectory + "/" + FileName );
                if( Localization.GetString( ModuleActionType.HelpText, localResourceFile ) != "" )
                {
                    lblHelp.Text = Localization.GetString( ModuleActionType.HelpText, localResourceFile );
                }
                _key = objModuleControl.ControlKey;

                string helpUrl = Globals.GetOnLineHelp( objModuleControl.HelpURL, ModuleConfiguration );
                if( !Null.IsNull( helpUrl ) )
                {
                    cmdHelp.NavigateUrl = Globals.FormatHelpUrl( helpUrl, PortalSettings, FriendlyName );
                    cmdHelp.Visible = true;
                }
                else
                {
                    cmdHelp.Visible = false;
                }
            }

            if( Page.IsPostBack == false )
            {
                if( Request.UrlReferrer != null )
                {
                    ViewState["UrlReferrer"] = Convert.ToString( Request.UrlReferrer );
                }
                else
                {
                    ViewState["UrlReferrer"] = "";
                }
            }
        }
예제 #3
0
        private string getModulePath(int moduleid, int tabid, string controlKey)
        {
            string path = String.Empty;
            try
            {
                ModuleController mc = new ModuleController();
                ModuleControlController mcc = new ModuleControlController();

                ModuleInfo mi = mc.GetModule(moduleid, tabid);
                if (mi != null)
                {
                    var mControl = ModuleControlController.GetModuleControlByControlKey(controlKey, mi.ModuleDefID);
                    if (mControl != null)
                        path = "~/" + mControl.ControlSrc;
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
            return path;
        }
예제 #4
0
        /// <summary>
        /// BindData fetches the data from the database and updates the controls
        /// </summary>
        /// <history>
        /// 	[cnurse]	9/27/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        private void BindData()
        {
            lblVersion.Text = Globals.glbAppVersion;
            switch( Convert.ToString( Globals.HostSettings["CheckUpgrade"] ) )
            {
                case "":
                    chkUpgrade.Checked = true;
                    break;

                case "Y":

                    chkUpgrade.Checked = true;
                    break;
                case "N":

                    chkUpgrade.Checked = false;
                    break;
            }
            if( chkUpgrade.Checked )
            {                
                hypUpgrade.ImageUrl = string.Format( "{0}/update.aspx?version={1}", Globals.glbUpgradeUrl, lblVersion.Text.Replace( ".", "" ) );
                hypUpgrade.NavigateUrl = string.Format( "{0}/redirect.aspx?version={1}", Globals.glbUpgradeUrl, lblVersion.Text.Replace( ".", "" ) );

            }
            else
            {
                hypUpgrade.Visible = false;
            }
            lblDataProvider.Text = ProviderConfiguration.GetProviderConfiguration( "data" ).DefaultProvider;
            lblFramework.Text = Environment.Version.ToString();
            lblIdentity.Text = WindowsIdentity.GetCurrent().Name;
            lblHostName.Text = Dns.GetHostName();

            PortalController objPortals = new PortalController();
            cboHostPortal.DataSource = objPortals.GetPortals();
            cboHostPortal.DataBind();
            if( Convert.ToString( Globals.HostSettings["HostPortalId"] ) != "" )
            {
                if( cboHostPortal.Items.FindByValue( Convert.ToString( Globals.HostSettings["HostPortalId"] ) ) != null )
                {
                    cboHostPortal.Items.FindByValue( Convert.ToString( Globals.HostSettings["HostPortalId"] ) ).Selected = true;
                }
            }
            txtHostTitle.Text = Convert.ToString( Globals.HostSettings["HostTitle"] );
            txtHostURL.Text = Convert.ToString( Globals.HostSettings["HostURL"] );
            txtHostEmail.Text = Convert.ToString( Globals.HostSettings["HostEmail"] );

            //SkinController objSkins = new SkinController();
            SkinInfo objSkin;

            ctlHostSkin.Width = "252px";
            ctlHostSkin.SkinRoot = SkinInfo.RootSkin;
            objSkin = SkinController.GetSkin( SkinInfo.RootSkin, Null.NullInteger, SkinType.Portal );
            if( objSkin != null )
            {
                if( Null.IsNull( objSkin.PortalId )  )
                {
                    ctlHostSkin.SkinSrc = objSkin.SkinSrc;
                }
            }
            ctlHostContainer.Width = "252px";
            ctlHostContainer.SkinRoot = SkinInfo.RootContainer;
            objSkin = SkinController.GetSkin( SkinInfo.RootContainer, Null.NullInteger, SkinType.Portal );
            if( objSkin != null )
            {
                if( Null.IsNull( objSkin.PortalId )  )
                {
                    ctlHostContainer.SkinSrc = objSkin.SkinSrc;
                }
            }

            ctlAdminSkin.Width = "252px";
            ctlAdminSkin.SkinRoot = SkinInfo.RootSkin;
            objSkin = SkinController.GetSkin( SkinInfo.RootSkin, Null.NullInteger, SkinType.Admin );
            if( objSkin != null )
            {
                if( Null.IsNull( objSkin.PortalId )  )
                {
                    ctlAdminSkin.SkinSrc = objSkin.SkinSrc;
                }
            }
            ctlAdminContainer.Width = "252px";
            ctlAdminContainer.SkinRoot = SkinInfo.RootContainer;
            objSkin = SkinController.GetSkin( SkinInfo.RootContainer, Null.NullInteger, SkinType.Admin );
            if( objSkin != null )
            {
                if( Null.IsNull( objSkin.PortalId )  )
                {
                    ctlAdminContainer.SkinSrc = objSkin.SkinSrc;
                }
            }
            ModuleControlController objModuleControls = new ModuleControlController();
            ArrayList arrModuleControls = objModuleControls.GetModuleControls( Null.NullInteger );
            int intModuleControl;
            for( intModuleControl = 0; intModuleControl <= arrModuleControls.Count - 1; intModuleControl++ )
            {
                ModuleControlInfo objModuleControl = (ModuleControlInfo)arrModuleControls[intModuleControl];
                if( objModuleControl.ControlType == SecurityAccessLevel.ControlPanel )
                {
                    cboControlPanel.Items.Add( new ListItem( objModuleControl.ControlKey.Replace( "CONTROLPANEL:", "" ), objModuleControl.ControlSrc ) );
                }
            }
            if( Convert.ToString( Globals.HostSettings["ControlPanel"] ) != "" )
            {
                if( cboControlPanel.Items.FindByValue( Convert.ToString( Globals.HostSettings["ControlPanel"] ) ) != null )
                {
                    cboControlPanel.Items.FindByValue( Convert.ToString( Globals.HostSettings["ControlPanel"] ) ).Selected = true;
                }
            }
            else
            {
                if( cboControlPanel.Items.FindByValue( Globals.glbDefaultControlPanel ) != null )
                {
                    cboControlPanel.Items.FindByValue( Globals.glbDefaultControlPanel ).Selected = true;
                }
            }

            ListController ctlList = new ListController();
            ListEntryInfoCollection colProcessor = ctlList.GetListEntryInfoCollection( "Processor", "" );

            cboProcessor.DataSource = colProcessor;
            cboProcessor.DataBind();
            cboProcessor.Items.Insert( 0, new ListItem( "<" + Localization.GetString( "None_Specified" ) + ">", "" ) );

            if( cboProcessor.Items.FindByText( Globals.HostSettings["PaymentProcessor"].ToString() ) != null )
            {
                cboProcessor.Items.FindByText( Globals.HostSettings["PaymentProcessor"].ToString() ).Selected = true;
            }
            txtUserId.Text = Convert.ToString( Globals.HostSettings["ProcessorUserId"] );
            txtPassword.Attributes.Add( "value", Convert.ToString( Globals.HostSettings["ProcessorPassword"] ) );

            txtHostFee.Text = Convert.ToString( Globals.HostSettings["HostFee"] );

            ListEntryInfoCollection colCurrency = ctlList.GetListEntryInfoCollection( "Currency", "" );

            cboHostCurrency.DataSource = colCurrency;
            cboHostCurrency.DataBind();
            if( cboHostCurrency.Items.FindByValue( Convert.ToString( Globals.HostSettings["HostCurrency"] ) ) != null )
            {
                cboHostCurrency.Items.FindByValue( Globals.HostSettings["HostCurrency"].ToString() ).Selected = true;
            }
            else
            {
                cboHostCurrency.Items.FindByValue( "USD" ).Selected = true;
            }
            
            if( cboSchedulerMode.Items.FindByValue( Convert.ToString( Globals.HostSettings["SchedulerMode"] ) ) != null )
            {
                cboSchedulerMode.Items.FindByValue( Globals.HostSettings["SchedulerMode"].ToString() ).Selected = true;
            }
            else
            {
                cboSchedulerMode.Items.FindByValue( "1" ).Selected = true;
            }

            txtHostSpace.Text = Convert.ToString( Globals.HostSettings["HostSpace"] );
            txtPageQuota.Text = Convert.ToString(Globals.HostSettings["PageQuota"]);
            txtUserQuota.Text = Convert.ToString(Globals.HostSettings["UserQuota"]);

            if( Convert.ToString( Globals.HostSettings["SiteLogStorage"] ) == "" )
            {
                optSiteLogStorage.Items.FindByValue( "D" ).Selected = true;
            }
            else
            {
                optSiteLogStorage.Items.FindByValue( Convert.ToString( Globals.HostSettings["SiteLogStorage"] ) ).Selected = true;
            }
            if( Convert.ToString( Globals.HostSettings["SiteLogBuffer"] ) == "" )
            {
                txtSiteLogBuffer.Text = "1";
            }
            else
            {
                txtSiteLogBuffer.Text = Convert.ToString( Globals.HostSettings["SiteLogBuffer"] );
            }
            txtSiteLogHistory.Text = Convert.ToString( Globals.HostSettings["SiteLogHistory"] );

            if (Convert.ToString(Globals.HostSettings["PageStatePersister"]) == "")
            {
                cboPageState.Items.FindByValue("P").Selected = true;
            }
            else
            {
                cboPageState.Items.FindByValue(Convert.ToString(Globals.HostSettings["PageStatePersister"])).Selected = true;
            }

            if( Convert.ToString( Globals.HostSettings["ModuleCaching"] ) == "" )
            {
                cboCacheMethod.Items.FindByValue( "M" ).Selected = true;
            }
            else
            {
                cboCacheMethod.Items.FindByValue( Convert.ToString( Globals.HostSettings["ModuleCaching"] ) ).Selected = true;
            }

            if (cboPerformance.Items.FindByValue(Convert.ToString(Globals.HostSettings["PerformanceSetting"])) != null)
            {
                cboPerformance.Items.FindByValue(Globals.HostSettings["PerformanceSetting"].ToString()).Selected = true;
            }
            else
            {
                cboPerformance.Items.FindByValue("3").Selected = true;
            }
            if (cboCacheability.Items.FindByValue(Convert.ToString(Globals.HostSettings["AuthenticatedCacheability"])) != null)
            {
                cboCacheability.Items.FindByValue(Globals.HostSettings["AuthenticatedCacheability"].ToString()).Selected = true;
            }
            else
            {
                cboCacheability.Items.FindByValue("4").Selected = true;
            }
            if (cboCompression.Items.FindByValue(Convert.ToString(Globals.HostSettings["HttpCompression"])) != null)
            {
                cboCompression.Items.FindByValue(Globals.HostSettings["HttpCompression"].ToString()).Selected = true;
            }
            else
            {
                cboCompression.Items.FindByValue("0").Selected = true;
            }
            if (cboLevel.Items.FindByValue(Convert.ToString(Globals.HostSettings["HttpCompressionLevel"])) != null)
            {
                cboLevel.Items.FindByValue(Globals.HostSettings["HttpCompressionLevel"].ToString()).Selected = true;
            }
            else
            {
                cboLevel.Items.FindByValue("0").Selected = true;
            }
            if (Convert.ToString(Globals.HostSettings["WhitespaceFilter"]) == "Y")
            {
                chkWhitespace.Checked = true;
            }
            else
            {
                chkWhitespace.Checked = false;
            }



            string filePath = Globals.ApplicationMapPath + "\\Compression.config";
            if (File.Exists(filePath))
            {
                FileStream fileReader = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                XPathDocument doc = new XPathDocument(fileReader);
                foreach (XPathNavigator nav in doc.CreateNavigator().Select("compression/excludedMimeTypes/mimeType"))
                {
                    txtExcludedMimeTypes.Text += nav.Value.ToLower() + Environment.NewLine;
                }
                foreach (XPathNavigator nav in doc.CreateNavigator().Select("compression/excludedPaths/path"))
                {
                    txtExcludedPaths.Text += nav.Value.ToLower() + Environment.NewLine;
                }
                txtWhitespaceFilter.Text = doc.CreateNavigator().SelectSingleNode("compression/whitespace").Value;
            }



            txtDemoPeriod.Text = Convert.ToString( Globals.HostSettings["DemoPeriod"] );
            if( Convert.ToString( Globals.HostSettings["DemoSignup"] ) == "Y" )
            {
                chkDemoSignup.Checked = true;
            }
            else
            {
                chkDemoSignup.Checked = false;
            }
            if( Globals.GetHashValue( Globals.HostSettings["Copyright"], "Y" ) == "Y" )
            {
                chkCopyright.Checked = true;
            }
            else
            {
                chkCopyright.Checked = false;
            }
            if( Globals.HostSettings.ContainsKey( "DisableUsersOnline" ) )
            {
                if( Globals.HostSettings["DisableUsersOnline"].ToString() == "Y" )
                {
                    chkUsersOnline.Checked = true;
                }
                else
                {
                    chkUsersOnline.Checked = false;
                }
            }
            else
            {
                chkUsersOnline.Checked = false;
            }
            txtUsersOnlineTime.Text = Convert.ToString( Globals.HostSettings["UsersOnlineTime"] );
            txtAutoAccountUnlock.Text = Convert.ToString( Globals.HostSettings["AutoAccountUnlockDuration"] );
            txtProxyServer.Text = Convert.ToString( Globals.HostSettings["ProxyServer"] );
            txtProxyPort.Text = Convert.ToString( Globals.HostSettings["ProxyPort"] );
            txtProxyUsername.Text = Convert.ToString( Globals.HostSettings["ProxyUsername"] );
            txtProxyPassword.Attributes.Add( "value", Convert.ToString( Globals.HostSettings["ProxyPassword"] ) );
            txtSMTPServer.Text = Convert.ToString( Globals.HostSettings["SMTPServer"] );
            if( Convert.ToString( Globals.HostSettings["SMTPAuthentication"] ) != "" )
            {
                optSMTPAuthentication.Items.FindByValue( Globals.HostSettings["SMTPAuthentication"].ToString() ).Selected = true;
            }
            else
            {
                optSMTPAuthentication.Items.FindByValue( "0" ).Selected = true;
            }

            if (Convert.ToString(Globals.HostSettings["SMTPEnableSSL"]) == "Y")
            {
                chkSMTPEnableSSL.Checked = true;
            }
            else
            {
                chkSMTPEnableSSL.Checked = false;
            }

            txtSMTPUsername.Text = Convert.ToString( Globals.HostSettings["SMTPUsername"] );
            txtSMTPPassword.Attributes.Add( "value", Convert.ToString( Globals.HostSettings["SMTPPassword"] ) );
            txtFileExtensions.Text = Convert.ToString( Globals.HostSettings["FileExtensions"] );

            if( Globals.HostSettings.ContainsKey( "UseCustomErrorMessages" ) )
            {
                if( Globals.HostSettings["UseCustomErrorMessages"].ToString() == "Y" )
                {
                    chkUseCustomErrorMessages.Checked = true;
                }
                else
                {
                    chkUseCustomErrorMessages.Checked = false;
                }
            }
            else
            {
                chkUseCustomErrorMessages.Checked = false;
            }

            if( Globals.HostSettings.ContainsKey( "UseFriendlyUrls" ) )
            {
                if( Globals.HostSettings["UseFriendlyUrls"].ToString() == "Y" )
                {
                    chkUseFriendlyUrls.Checked = true;
                }
                else
                {
                    chkUseFriendlyUrls.Checked = false;
                }
            }
            else
            {
                chkUseFriendlyUrls.Checked = false;
            }
            rowFriendlyUrls.Visible = chkUseFriendlyUrls.Checked;

            if( Globals.HostSettings.ContainsKey( "EventLogBuffer" ) )
            {
                if( Globals.HostSettings["EventLogBuffer"].ToString() == "Y" )
                {
                    chkLogBuffer.Checked = true;
                }
                else
                {
                    chkLogBuffer.Checked = false;
                }
            }
            else
            {
                chkLogBuffer.Checked = false;
            }

            if( Convert.ToString( Globals.HostSettings["SkinUpload"] ) != "" )
            {
                optSkinUpload.Items.FindByValue( Globals.HostSettings["SkinUpload"].ToString() ).Selected = true;
            }
            else
            {
                optSkinUpload.Items.FindByValue( "G" ).Selected = true;
            }

            txtHelpURL.Text = Convert.ToString( Globals.HostSettings["HelpURL"] );
            if( Globals.HostSettings.ContainsKey( "EnableModuleOnLineHelp" ) )
            {
                if( Globals.HostSettings["EnableModuleOnLineHelp"].ToString() == "Y" )
                {
                    chkEnableHelp.Checked = true;
                }
                else
                {
                    chkEnableHelp.Checked = false;
                }
            }
            else
            {
                chkEnableHelp.Checked = true;
            }

            if (Globals.HostSettings.ContainsKey("EnableFileAutoSync"))
            {
                if (Globals.HostSettings["EnableFileAutoSync"].ToString() == "Y")
                {
                    chkAutoSync.Checked = true;
                }
                else
                {
                    chkAutoSync.Checked = false;
                }
            }
            else
            {
                chkAutoSync.Checked = false;
            }


            ViewState["SelectedSchedulerMode"] = cboSchedulerMode.SelectedItem.Value;
            ViewState["SelectedLogBufferEnabled"] = chkLogBuffer.Checked;
            ViewState["SelectedUsersOnlineEnabled"] = chkUsersOnline.Checked;

            // Get the name of the data provider
            ProviderConfiguration objProviderConfiguration = ProviderConfiguration.GetProviderConfiguration( "data" );

            // get list of script files
            string strProviderPath = PortalSettings.GetProviderPath();
            ArrayList arrScriptFiles = new ArrayList();
            string[] arrFiles = Directory.GetFiles( strProviderPath, "*." + objProviderConfiguration.DefaultProvider );
            foreach( string strFile in arrFiles )
            {                                
                arrScriptFiles.Add( Path.GetFileNameWithoutExtension( strFile ) );
            }
            arrScriptFiles.Sort();

            cboUpgrade.DataSource = arrScriptFiles;
            cboUpgrade.DataBind();

            ModuleInfo FileManagerModule = ( new ModuleController() ).GetModuleByDefinition( Null.NullInteger, "File Manager" );

            string[] additionalParameters = new string[3];

            additionalParameters[0] = "mid=" + FileManagerModule.ModuleID;
            additionalParameters[1] = "ftype=" + UploadType.Skin;
            additionalParameters[2] = "rtab=" + this.TabId;
            lnkUploadSkin.NavigateUrl = Globals.NavigateURL( FileManagerModule.TabID, "Edit", additionalParameters );

            additionalParameters[1] = "ftype=" + UploadType.Container;
            lnkUploadContainer.NavigateUrl = Globals.NavigateURL( FileManagerModule.TabID, "Edit", additionalParameters );
        }
예제 #5
0
        /// <summary>
        /// Creates the DNN manifest.
        /// </summary>
        /// <param name="objDesktopModule">The obj desktop module.</param>
        private void CreateDnnManifest(DesktopModuleInfo objDesktopModule)
        {
            string filename = "";
            _Name = objDesktopModule.ModuleName;

            //Create Manifest Document
            XmlDocument xmlManifest = new XmlDocument();

            //Root Element
            XmlNode nodeRoot = xmlManifest.CreateElement("dotnetnuke");
            nodeRoot.Attributes.Append(XmlUtils.CreateAttribute(xmlManifest, "version", "3.0"));
            nodeRoot.Attributes.Append(XmlUtils.CreateAttribute(xmlManifest, "type", "Module"));

            //Folders Element
            XmlNode nodeFolders = xmlManifest.CreateElement("folders");
            nodeRoot.AppendChild(nodeFolders);

            //Folder Element
            XmlNode nodeFolder = xmlManifest.CreateElement("folder");
            nodeFolders.AppendChild(nodeFolder);

            //Desktop Module Info
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "name", _Name));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "friendlyname", objDesktopModule.FriendlyName));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "foldername", objDesktopModule.FolderName));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "modulename", _Name));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "description", objDesktopModule.Description));
            if (objDesktopModule.Version == Null.NullString)
            {
                objDesktopModule.Version = "01.00.00";
            }
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "version", objDesktopModule.Version));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "businesscontrollerclass", objDesktopModule.BusinessControllerClass));

            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "version", objDesktopModule.Version));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "businesscontrollerclass", objDesktopModule.BusinessControllerClass));
            if (objDesktopModule.CompatibleVersions != "")
            {
                nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "compatibleversions", objDesktopModule.CompatibleVersions));
            }

            if (SupportsProbingPrivatePath)
            {
                nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "supportsprobingprivatepath", SupportsProbingPrivatePath.ToString()));
            }

            //Add Source files
            if (IncludeSource)
            {
                nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "resourcefile", ResourceFileName));
            }          

            //Modules Element
            XmlNode nodeModules = xmlManifest.CreateElement("modules");
            nodeFolder.AppendChild(nodeModules);

            //Get the Module Definitions for this Module
            ModuleDefinitionController objModuleDefinitionController = new ModuleDefinitionController();
            ArrayList arrModuleDefinitions = objModuleDefinitionController.GetModuleDefinitions(objDesktopModule.DesktopModuleID);

            //Iterate through Module Definitions
            foreach (ModuleDefinitionInfo objModuleInfo in arrModuleDefinitions)
            {
                XmlNode nodeModule = xmlManifest.CreateElement("module");

                //Add module definition properties
                nodeModule.AppendChild(XmlUtils.CreateElement(xmlManifest, "friendlyname", objModuleInfo.FriendlyName));

                //Add Cache properties
                nodeModule.AppendChild(XmlUtils.CreateElement(xmlManifest, "cachetime", objModuleInfo.DefaultCacheTime.ToString()));

                //Get the Module Controls for this Module Definition
                ModuleControlController objModuleControlController = new ModuleControlController();
                ArrayList arrModuleControls = objModuleControlController.GetModuleControls(objModuleInfo.ModuleDefID);

                //Controls Element
                XmlNode nodeControls = xmlManifest.CreateElement("controls");
                nodeModule.AppendChild(nodeControls);

                //Iterate through Module Controls
                foreach (ModuleControlInfo objModuleControl in arrModuleControls)
                {
                    XmlNode nodeControl = xmlManifest.CreateElement("control");

                    //Add module control properties
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "key", objModuleControl.ControlKey, false);
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "title", objModuleControl.ControlTitle, false);

                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "src", objModuleControl.ControlSrc, true);
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "iconfile", objModuleControl.IconFile, false);
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "type", objModuleControl.ControlType.ToString(), true);
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "helpurl", objModuleControl.HelpURL, false);

                    //Add control Node to controls
                    nodeControls.AppendChild(nodeControl);

                    //Determine the filename for the Manifest file (It should be saved with the other Module files)
                    if (filename == "")
                    {
                        filename = Folder + "\\" + objDesktopModule.ModuleName + ".dnn";
                    }
                }

                //Add module Node to modules
                nodeModules.AppendChild(nodeModule);
            }

            //Files Element
            XmlNode nodeFiles = xmlManifest.CreateElement("files");
            nodeFolder.AppendChild(nodeFiles);

            //Add the files
            foreach (PaFileInfo file in _Files)
            {
                XmlNode nodeFile = xmlManifest.CreateElement("file");

                //Add file properties
                XmlUtils.AppendElement(ref xmlManifest, nodeFile, "path", file.Path, false);
                XmlUtils.AppendElement(ref xmlManifest, nodeFile, "name", file.Name, false);

                //Add file Node to files
                nodeFiles.AppendChild(nodeFile);
            }

            //Add Root element to document
            xmlManifest.AppendChild(nodeRoot);

            //Save Manifest file
            xmlManifest.Save(filename);

        }
        protected void Page_Init( Object sender, EventArgs e )
        {
            ModuleController objModules = new ModuleController();
            ModuleControlController objModuleControlController = new ModuleControlController();

            // get ModuleId
            if( ( Request.QueryString["ModuleId"] != null ) )
            {
                moduleId = int.Parse( Request.QueryString["ModuleId"] );
            }

            // get module
            ModuleInfo objModule = objModules.GetModule( moduleId, TabId, false );
            if( objModule != null )
            {
                tabModuleId = objModule.TabModuleID;

                //get Settings Control(s)
                ArrayList arrModuleControls = objModuleControlController.GetModuleControlsByKey( "Settings", objModule.ModuleDefID );

                if( arrModuleControls.Count > 0 )
                {
                    ModuleControlInfo objModuleControlInfo = (ModuleControlInfo)arrModuleControls[0];
                    string src = "~/" + objModuleControlInfo.ControlSrc;
                    ctlSpecific = (ModuleSettingsBase)LoadControl( src );
                    ctlSpecific.ID = src.Substring( src.LastIndexOf( "/" ) + 1 );
                    ctlSpecific.ModuleId = moduleId;
                    ctlSpecific.TabModuleId = tabModuleId;
                    dshSpecific.Text = Localization.LocalizeControlTitle( objModuleControlInfo.ControlTitle, objModuleControlInfo.ControlSrc, "settings" );
                    pnlSpecific.Controls.Add( ctlSpecific );

                    if( Localization.GetString( ModuleActionType.HelpText, ctlSpecific.LocalResourceFile ) != "" )
                    {
                        rowspecifichelp.Visible = true;
                        imgSpecificHelp.AlternateText = Localization.GetString( ModuleActionType.ModuleHelp, Localization.GlobalResourceFile );
                        lnkSpecificHelp.Text = Localization.GetString( ModuleActionType.ModuleHelp, Localization.GlobalResourceFile );
                        lnkSpecificHelp.NavigateUrl = Globals.NavigateURL( TabId, "Help", "ctlid=" + objModuleControlInfo.ModuleControlID, "moduleid=" + moduleId );
                    }
                    else
                    {
                        rowspecifichelp.Visible = false;
                    }
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Creates the DNN manifest.
        /// </summary>
        /// <param name="objDesktopModule">The obj desktop module.</param>
        private void CreateDnnManifest(DesktopModuleInfo objDesktopModule)
        {
            string filename = "";

            _Name = objDesktopModule.ModuleName;

            //Create Manifest Document
            XmlDocument xmlManifest = new XmlDocument();

            //Root Element
            XmlNode nodeRoot = xmlManifest.CreateElement("dotnetnuke");

            nodeRoot.Attributes.Append(XmlUtils.CreateAttribute(xmlManifest, "version", "3.0"));
            nodeRoot.Attributes.Append(XmlUtils.CreateAttribute(xmlManifest, "type", "Module"));

            //Folders Element
            XmlNode nodeFolders = xmlManifest.CreateElement("folders");

            nodeRoot.AppendChild(nodeFolders);

            //Folder Element
            XmlNode nodeFolder = xmlManifest.CreateElement("folder");

            nodeFolders.AppendChild(nodeFolder);

            //Desktop Module Info
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "name", _Name));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "friendlyname", objDesktopModule.FriendlyName));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "foldername", objDesktopModule.FolderName));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "modulename", _Name));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "description", objDesktopModule.Description));
            if (objDesktopModule.Version == Null.NullString)
            {
                objDesktopModule.Version = "01.00.00";
            }
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "version", objDesktopModule.Version));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "businesscontrollerclass", objDesktopModule.BusinessControllerClass));

            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "version", objDesktopModule.Version));
            nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "businesscontrollerclass", objDesktopModule.BusinessControllerClass));
            if (objDesktopModule.CompatibleVersions != "")
            {
                nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "compatibleversions", objDesktopModule.CompatibleVersions));
            }

            if (SupportsProbingPrivatePath)
            {
                nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "supportsprobingprivatepath", SupportsProbingPrivatePath.ToString()));
            }

            //Add Source files
            if (IncludeSource)
            {
                nodeFolder.AppendChild(XmlUtils.CreateElement(xmlManifest, "resourcefile", ResourceFileName));
            }

            //Modules Element
            XmlNode nodeModules = xmlManifest.CreateElement("modules");

            nodeFolder.AppendChild(nodeModules);

            //Get the Module Definitions for this Module
            ModuleDefinitionController objModuleDefinitionController = new ModuleDefinitionController();
            ArrayList arrModuleDefinitions = objModuleDefinitionController.GetModuleDefinitions(objDesktopModule.DesktopModuleID);

            //Iterate through Module Definitions
            foreach (ModuleDefinitionInfo objModuleInfo in arrModuleDefinitions)
            {
                XmlNode nodeModule = xmlManifest.CreateElement("module");

                //Add module definition properties
                nodeModule.AppendChild(XmlUtils.CreateElement(xmlManifest, "friendlyname", objModuleInfo.FriendlyName));

                //Add Cache properties
                nodeModule.AppendChild(XmlUtils.CreateElement(xmlManifest, "cachetime", objModuleInfo.DefaultCacheTime.ToString()));

                //Get the Module Controls for this Module Definition
                ModuleControlController objModuleControlController = new ModuleControlController();
                ArrayList arrModuleControls = objModuleControlController.GetModuleControls(objModuleInfo.ModuleDefID);

                //Controls Element
                XmlNode nodeControls = xmlManifest.CreateElement("controls");
                nodeModule.AppendChild(nodeControls);

                //Iterate through Module Controls
                foreach (ModuleControlInfo objModuleControl in arrModuleControls)
                {
                    XmlNode nodeControl = xmlManifest.CreateElement("control");

                    //Add module control properties
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "key", objModuleControl.ControlKey, false);
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "title", objModuleControl.ControlTitle, false);

                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "src", objModuleControl.ControlSrc, true);
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "iconfile", objModuleControl.IconFile, false);
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "type", objModuleControl.ControlType.ToString(), true);
                    XmlUtils.AppendElement(ref xmlManifest, nodeControl, "helpurl", objModuleControl.HelpURL, false);

                    //Add control Node to controls
                    nodeControls.AppendChild(nodeControl);

                    //Determine the filename for the Manifest file (It should be saved with the other Module files)
                    if (filename == "")
                    {
                        filename = Folder + "\\" + objDesktopModule.ModuleName + ".dnn";
                    }
                }

                //Add module Node to modules
                nodeModules.AppendChild(nodeModule);
            }

            //Files Element
            XmlNode nodeFiles = xmlManifest.CreateElement("files");

            nodeFolder.AppendChild(nodeFiles);

            //Add the files
            foreach (PaFileInfo file in _Files)
            {
                XmlNode nodeFile = xmlManifest.CreateElement("file");

                //Add file properties
                XmlUtils.AppendElement(ref xmlManifest, nodeFile, "path", file.Path, false);
                XmlUtils.AppendElement(ref xmlManifest, nodeFile, "name", file.Name, false);

                //Add file Node to files
                nodeFiles.AppendChild(nodeFile);
            }

            //Add Root element to document
            xmlManifest.AppendChild(nodeRoot);

            //Save Manifest file
            xmlManifest.Save(filename);
        }
예제 #8
0
        /// <summary>
        /// RemoveCoreModule removes a Core Module from the system
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="DesktopModuleName">The Friendly Name of the Module to Remove</param>
        ///	<param name="ParentTabName">The Name of the parent Tab/Page for this module</param>
        ///	<param name="TabName">The Name to tab that contains the Module</param>
        ///	<param name="TabRemove">A flag to determine whether to remove the Tab if it has no
        ///	other modules</param>
        private static void RemoveCoreModule(string DesktopModuleName, string ParentTabName, string TabName, bool TabRemove)
        {
            TabController objTabs = new TabController();
            ModuleController objModules = new ModuleController();
            int intIndex;
            int intModuleDefId = 0;
            int intDesktopModuleId;

            //Find and remove the Module from the Tab
            switch (ParentTabName)
            {
                case "Host":
                    //TODO - when we have a need to remove a Host Module
                    break;
                case "Admin":
                    PortalController objPortals = new PortalController();

                    ArrayList arrPortals = objPortals.GetPortals();                  

                    //Iterate through the Portals to remove the Module from the Tab
                    for (int intPortal = 0; intPortal < arrPortals.Count; intPortal++)
                    {
                        PortalInfo objPortal = (PortalInfo)(arrPortals[intPortal]);

                        int ParentId = objPortal.AdminTabId;
                        TabInfo objTab = objTabs.GetTabByName(TabName, objPortal.PortalID, ParentId);
                        int intCount = 0;

                        //Get the Modules on the Tab
                        foreach (KeyValuePair<int, ModuleInfo> kvp in objModules.GetTabModules(objTab.TabID))
                        {
                            ModuleInfo objModule = kvp.Value;
                            if (objModule.FriendlyName == DesktopModuleName)
                            {
                                //Delete the Module from the Modules list
                                objModules.DeleteModule(objModule.ModuleID);
                                intModuleDefId = objModule.ModuleDefID;
                            }
                            else
                            {
                                intCount += 1;
                            }
                        }

                        //If Tab has no modules optionally remove tab
                        if (intCount == 0 & TabRemove)
                        {
                            objTabs.DeleteTab(objTab.TabID, objTab.PortalID);
                        }
                    }
                    break;
            }

            //Delete all the Module Controls for this Definition
            ModuleControlController objModuleControls = new ModuleControlController();
            ArrayList arrModuleControls = objModuleControls.GetModuleControls(intModuleDefId);
            for (intIndex = 0; intIndex <= arrModuleControls.Count - 1; intIndex++)
            {
                ModuleControlInfo objModuleControl = (ModuleControlInfo)arrModuleControls[intIndex];
                objModuleControls.DeleteModuleControl(objModuleControl.ModuleControlID);
            }

            //Get the Module Definition
            ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();
            ModuleDefinitionInfo objModuleDefinition;
            objModuleDefinition = objModuleDefinitions.GetModuleDefinition(intModuleDefId);
            intDesktopModuleId = objModuleDefinition.DesktopModuleID;

            //Delete the Module Definition
            objModuleDefinitions.DeleteModuleDefinition(intModuleDefId);

            //Delete the Desktop Module Control
            DesktopModuleController objDesktopModules = new DesktopModuleController();
            objDesktopModules.DeleteDesktopModule(intDesktopModuleId);
        }
예제 #9
0
        /// <summary>
        /// AddModuleControl adds a new Module Control to the system
        /// </summary>
        /// <remarks>
        /// </remarks>
        ///	<param name="ModuleDefId">The Module Definition Id</param>
        ///	<param name="ControlKey">The key for this control in the Definition</param>
        ///	<param name="ControlTitle">The title of this control</param>
        ///	<param name="ControlSrc">Te source of ths control</param>
        ///	<param name="IconFile">The icon file</param>
        ///	<param name="ControlType">The type of control</param>
        ///	<param name="ViewOrder">The vieworder for this module</param>
        ///	<param name="HelpURL">The Help Url</param>
        private static void AddModuleControl(int ModuleDefId, string ControlKey, string ControlTitle, string ControlSrc, string IconFile, SecurityAccessLevel ControlType, int ViewOrder, string HelpURL)
        {
            ModuleControlController objModuleControls = new ModuleControlController();

            // check if module control exists
            ModuleControlInfo objModuleControl = objModuleControls.GetModuleControlByKeyAndSrc(ModuleDefId, ControlKey, ControlSrc);
            if (objModuleControl == null)
            {
                objModuleControl = new ModuleControlInfo();

                objModuleControl.ModuleControlID = Null.NullInteger;
                objModuleControl.ModuleDefID = ModuleDefId;
                objModuleControl.ControlKey = ControlKey;
                objModuleControl.ControlTitle = ControlTitle;
                objModuleControl.ControlSrc = ControlSrc;
                objModuleControl.ControlType = ControlType;
                objModuleControl.ViewOrder = ViewOrder;
                objModuleControl.IconFile = IconFile;
                objModuleControl.HelpURL = HelpURL;

                objModuleControls.AddModuleControl(objModuleControl);
            }
        }
예제 #10
0
        /// <summary>
        /// SkinFileProcessor class constructor.
        /// </summary>
        /// <param name="SkinPath">File path to the portals upload directory.</param>
        /// <param name="SkinRoot">Specifies type of skin (Skins or Containers)</param>
        /// <param name="SkinName">Name of folder in which skin will reside (Zip file name)</param>
        /// <remarks>
        /// The constructor primes the file processor with path information and
        /// control data that should only be retrieved once.  It checks for the
        /// existentce of a skin level attribute file and read it in, if found.
        /// It also sorts through the complete list of controls and creates
        /// a hashtable which contains only the skin objects and their source paths.
        /// These are recognized by their ControlKey's which are formatted like
        /// tokens ("[TOKEN]").  The hashtable is required for speed as it will be
        /// processed for each token found in the source file by the Control Parser.
        /// </remarks>
        public SkinFileProcessor( string SkinPath, string SkinRoot, string SkinName )
        {
            this.Message += SkinController.FormatMessage( INITIALIZE_PROCESSOR, SkinRoot + " :: " + SkinName, 0, false );

            // Save path information for future use
            m_SkinRoot = SkinRoot;
            m_SkinPath = SkinPath;
            m_SkinName = SkinName;

            // Check for and read skin package level attribute information file
            string FileName = this.SkinPath + this.SkinRoot + "\\" + this.SkinName + "\\" + SkinRoot.Substring( 0, SkinRoot.Length - 1 ) + ".xml";
            if( File.Exists( FileName ) )
            {
                try
                {
                    this.SkinAttributes.Load( FileName );
                    this.Message += SkinController.FormatMessage( PACKAGE_LOAD, Path.GetFileName( FileName ), 2, false );
                }
                catch( Exception ex )
                {
                    // could not load XML file
                    this.Message += SkinController.FormatMessage( string.Format( PACKAGE_LOAD_ERROR, ex.Message ), Path.GetFileName( FileName ), 2, true );
                }
            }

            // Retrieve a list of available controls
            ModuleControlController objModuleControls = new ModuleControlController();
            ArrayList arrModuleControls = objModuleControls.GetModuleControls( Null.NullInteger );

            // Look at every control
            string Token;
            int i;
            ModuleControlInfo objModuleControl;
            for( i = 0; i <= arrModuleControls.Count - 1; i++ )
            {
                objModuleControl = (ModuleControlInfo)arrModuleControls[i];
                // If the control is a skin object, save the key and source in the hash table
                if( objModuleControl.ControlType == SecurityAccessLevel.SkinObject )
                {
                    Token = objModuleControl.ControlKey.ToUpper();

                    // If the control is already in the hash table
                    if( m_ControlList.ContainsKey( Token ) )
                    {
                        // Record an error message and skip it
                        this.Message += SkinController.FormatMessage( string.Format( DUPLICATE_ERROR, objModuleControl.ControlKey.ToString().ToUpper() ), string.Format( DUPLICATE_DETAIL, ( (string)m_ControlList[Token] ), objModuleControl.ControlSrc.ToString() ), 2, true );
                    }
                    else
                    {
                        // Add it
                        this.Message += SkinController.FormatMessage( string.Format( LOAD_SKIN_TOKEN, objModuleControl.ControlKey.ToString().ToUpper() ), objModuleControl.ControlSrc.ToString(), 2, false );
                        m_ControlList.Add( Token, objModuleControl.ControlSrc );
                    }
                }
            }

            // Instantiate the control parser with the list of skin objects
            m_ControlFactory = new ControlParser( m_ControlList );
        }
        /// <summary>
        /// cmdUpdate_Click runs when the Update Button is clicked
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdUpdate_Click( object sender, EventArgs e )
        {
            try
            {
                if( Page.IsValid )
                {
                    ModuleControlInfo objModuleControl = new ModuleControlInfo();

                    objModuleControl.ModuleControlID = ModuleControlId;
                    objModuleControl.ModuleDefID = ModuleDefId;
                    if( !String.IsNullOrEmpty(txtKey.Text) )
                    {
                        objModuleControl.ControlKey = txtKey.Text;
                    }
                    else
                    {
                        objModuleControl.ControlKey = Null.NullString;
                    }
                    if( !String.IsNullOrEmpty(txtTitle.Text) )
                    {
                        objModuleControl.ControlTitle = txtTitle.Text;
                    }
                    else
                    {
                        objModuleControl.ControlTitle = Null.NullString;
                    }
                    objModuleControl.ControlSrc = cboSource.SelectedItem.Text;
                    objModuleControl.ControlType = (SecurityAccessLevel)Enum.Parse(typeof(SecurityAccessLevel), cboType.SelectedItem.Value);
                    if( !String.IsNullOrEmpty(txtViewOrder.Text) )
                    {
                        objModuleControl.ViewOrder = int.Parse( txtViewOrder.Text );
                    }
                    else
                    {
                        objModuleControl.ViewOrder = Null.NullInteger;
                    }
                    if( cboIcon.SelectedIndex > 0 )
                    {
                        objModuleControl.IconFile = cboIcon.SelectedItem.Text;
                    }
                    else
                    {
                        objModuleControl.IconFile = Null.NullString;
                    }

                    if( !String.IsNullOrEmpty(txtHelpURL.Text) )
                    {
                        objModuleControl.HelpURL = txtHelpURL.Text;
                    }
                    else
                    {
                        objModuleControl.HelpURL = Null.NullString;
                    }

                    ModuleControlController objModuleControls = new ModuleControlController();

                    if( Null.IsNull( ModuleControlId ) )
                    {
                        try
                        {
                            objModuleControls.AddModuleControl( objModuleControl );
                        }
                        catch
                        {
                            UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "AddControl.ErrorMessage", this.LocalResourceFile ), ModuleMessageType.RedError );
                            return;
                        }
                    }
                    else
                    {
                        objModuleControls.UpdateModuleControl( objModuleControl );
                    }

                    if( DesktopModuleId == - 1 )
                    {
                        DesktopModuleId = - 2;
                    }
                    Response.Redirect( EditUrl( "desktopmoduleid", DesktopModuleId.ToString() ), true );
                }
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
        /// <summary>
        /// cmdDelete_Click runs when the Delete Button is clicked
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void cmdDelete_Click( object sender, EventArgs e )
        {
            try
            {
                ModuleControlController objModuleControls = new ModuleControlController();

                if( ! Null.IsNull( ModuleControlId ) )
                {
                    objModuleControls.DeleteModuleControl( ModuleControlId );
                }

                if( DesktopModuleId == - 1 )
                {
                    DesktopModuleId = - 2;
                }
                Response.Redirect( EditUrl( "desktopmoduleid", DesktopModuleId.ToString() ), true );
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
        /// <summary>
        /// Page_Load runs when the control is loaded.
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        protected void Page_Load( Object sender, EventArgs e )
        {
            try
            {
                if( ( Request.QueryString["desktopmoduleid"] != null ) )
                {
                    DesktopModuleId = int.Parse( Request.QueryString["desktopmoduleid"] );
                    if( DesktopModuleId == - 2 )
                    {
                        DesktopModuleId = Null.NullInteger;
                    }
                }
                else
                {
                    DesktopModuleId = Null.NullInteger;
                }

                if( ( Request.QueryString["moduledefid"] != null ) )
                {
                    ModuleDefId = int.Parse( Request.QueryString["moduledefid"] );
                }
                else
                {
                    ModuleDefId = Null.NullInteger;
                }

                if( ( Request.QueryString["modulecontrolid"] != null ) )
                {
                    ModuleControlId = int.Parse( Request.QueryString["modulecontrolid"] );
                }
                else
                {
                    ModuleControlId = Null.NullInteger;
                }

                if( Page.IsPostBack == false )
                {
                    DesktopModuleController objDesktopModules = new DesktopModuleController();
                    DesktopModuleInfo objDesktopModule;

                    objDesktopModule = objDesktopModules.GetDesktopModule( DesktopModuleId );
                    if( objDesktopModule != null )
                    {
                        txtModule.Text = objDesktopModule.FriendlyName;
                    }
                    else
                    {
                        txtModule.Text = Localization.GetString( "SkinObjects" );
                        txtTitle.Enabled = false;
                        cboType.Enabled = false;
                        txtViewOrder.Enabled = false;
                        cboIcon.Enabled = false;
                    }

                    ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();
                    ModuleDefinitionInfo objModuleDefinition;

                    objModuleDefinition = objModuleDefinitions.GetModuleDefinition( ModuleDefId );
                    if( objModuleDefinition != null )
                    {
                        txtDefinition.Text = objModuleDefinition.FriendlyName;
                    }

                    ClientAPI.AddButtonConfirm( cmdDelete, Localization.GetString( "DeleteItem" ) );

                    ModuleControlController objModuleControls = new ModuleControlController();
                    ModuleControlInfo objModuleControl;

                    objModuleControl = objModuleControls.GetModuleControl( ModuleControlId );

                    // Added to populate cboSource with desktop module or skin controls
                    // Issue #586
                    BindControlList( "DesktopModules", true );
                    BindControlList( "Admin/Skins", false );
                    if( objDesktopModule == null ) // Add Container Controls
                    {
                        BindControlList( "Admin/Containers", false );
                    }

                    if( ! Null.IsNull( ModuleControlId ) )
                    {
                        if( objModuleControl != null )
                        {
                            txtKey.Text = objModuleControl.ControlKey;
                            txtTitle.Text = objModuleControl.ControlTitle;
                            if( cboSource.Items.FindByValue( objModuleControl.ControlSrc.ToString().ToLower() ) != null )
                            {
                                cboSource.Items.FindByValue( objModuleControl.ControlSrc.ToString().ToLower() ).Selected = true;
                                LoadIcons();
                            }
                            if( cboType.Items.FindByValue( Convert.ToInt32( objModuleControl.ControlType ).ToString() ) != null )
                            {
                                cboType.Items.FindByValue( Convert.ToInt32( objModuleControl.ControlType ).ToString() ).Selected = true;
                            }
                            if( ! Null.IsNull( objModuleControl.ViewOrder ) )
                            {
                                txtViewOrder.Text = objModuleControl.ViewOrder.ToString();
                            }
                            if( cboIcon.Items.FindByValue( objModuleControl.IconFile.ToLower() ) != null )
                            {
                                cboIcon.Items.FindByValue( objModuleControl.IconFile.ToLower() ).Selected = true;
                            }
                            if( ! Null.IsNull( objModuleControl.HelpURL ) )
                            {
                                txtHelpURL.Text = objModuleControl.HelpURL;
                            }
                        }
                    }
                }
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
        /// <summary>
        /// LoadDefinitions fetches the control data from the database
        /// </summary>
        /// <param name="ModuleDefId">The Module definition Id</param>
        /// <history>
        /// 	[cnurse]	9/28/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        private void LoadControls( int ModuleDefId )
        {
            ModuleControlController objModuleControls = new ModuleControlController();
            ArrayList arrModuleControls = objModuleControls.GetModuleControls( ModuleDefId );

            if( DesktopModuleId == - 2 )
            {
                int intIndex;
                for( intIndex = arrModuleControls.Count - 1; intIndex >= 0; intIndex-- )
                {
                    ModuleControlInfo objModuleControl = (ModuleControlInfo)arrModuleControls[intIndex];
                    if( objModuleControl.ControlType != SecurityAccessLevel.SkinObject )
                    {
                        arrModuleControls.RemoveAt( intIndex );
                    }
                }
            }

            grdControls.DataSource = arrModuleControls;
            grdControls.DataBind();

            cmdAddControl.Visible = true;
            grdControls.Visible = true;
        }
        /// <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 );
            }
        }
예제 #16
0
        private void Page_Init( object sender, EventArgs e )
        {
            ModuleController objModules = new ModuleController();
            ModuleInfo objModule;
            Control ctlPane;
            bool blnLayoutMode = Globals.IsLayoutMode();

            bool bSuccess = true;

            // iterate page controls

            foreach (Control ctlControl in this.Controls)
            {
                
                // load the skin panes
                if (ctlControl is HtmlControl)
                {
                    HtmlControl objHtmlControl = (HtmlControl)ctlControl;
                    if (objHtmlControl.ID != null)
                    {
                        switch (objHtmlControl.TagName.ToUpper())
                        {
                            case "TD":
                                // content pane
                                if (ctlControl.ID != "ControlPanel")
                                {
                                    PortalSettings.ActiveTab.Panes.Add(ctlControl.ID);
                                }
                                break;

                            case "DIV":
                                // content pane
                                if (ctlControl.ID != "ControlPanel")
                                {
                                    PortalSettings.ActiveTab.Panes.Add(ctlControl.ID);
                                }
                                break;

                            case "SPAN":
                                // content pane
                                if (ctlControl.ID != "ControlPanel")
                                {
                                    PortalSettings.ActiveTab.Panes.Add(ctlControl.ID);
                                }
                                break;

                            case "P":

                                // content pane
                                if (ctlControl.ID != "ControlPanel")
                                {
                                    PortalSettings.ActiveTab.Panes.Add(ctlControl.ID);
                                }
                                break;
                        }
                    }
                }
            }

            //if querystring dnnprintmode=true, controlpanel will not be shown
            if (Request.QueryString["dnnprintmode"] != "true")
            {
                // ControlPanel processing
                if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName.ToString()) || PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString()))
                {
                    UserControl objControlPanel = null;
                    if (Convert.ToString(PortalSettings.HostSettings["ControlPanel"]) != "")
                    {
                        // load custom control panel
                        objControlPanel = (UserControl)LoadControl("~/" + Convert.ToString(PortalSettings.HostSettings["ControlPanel"]));
                    }
                    if (objControlPanel == null)
                    {
                        // load default control panel
                        objControlPanel = (UserControl)LoadControl("~/" + Globals.glbDefaultControlPanel);
                    }
                    // inject ControlPanel control into skin
                    ctlPane = this.FindControl("ControlPanel");
                    if (ctlPane == null)
                    {
                        HtmlForm objForm = (HtmlForm)this.Parent.FindControl("Form");
                        objForm.Controls.AddAt(0, objControlPanel);
                    }
                    else
                    {
                        ctlPane.Controls.Add(objControlPanel);
                    }
                }
            }

            if (!Globals.IsAdminControl()) // master module
            {
                if (PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AuthorizedRoles))
                {
                    // check portal expiry date
                    bool blnExpired = false;
                    if (PortalSettings.ExpiryDate != Null.NullDate)
                    {
                        if (Convert.ToDateTime(PortalSettings.ExpiryDate) < DateTime.Now && PortalSettings.ActiveTab.ParentId != PortalSettings.AdminTabId && PortalSettings.ActiveTab.ParentId != PortalSettings.SuperTabId)
                        {
                            blnExpired = true;
                        }
                    }
                    if (!blnExpired)
                    {
                        if ((PortalSettings.ActiveTab.StartDate < DateTime.Now && PortalSettings.ActiveTab.EndDate > DateTime.Now) || blnLayoutMode)
                        {
                            // process panes
                            if (blnLayoutMode)
                            {
                                foreach (string strPane in PortalSettings.ActiveTab.Panes)
                                {                                    
                                    ctlPane = this.FindControl(strPane);
                                    ctlPane.Visible = true;

                                    // display pane border
                                    if (ctlPane is HtmlContainerControl)
                                    {
                                        ((HtmlContainerControl)ctlPane).Style["border-top"] = "1px #CCCCCC dotted";
                                        ((HtmlContainerControl)ctlPane).Style["border-bottom"] = "1px #CCCCCC dotted";
                                        ((HtmlContainerControl)ctlPane).Style["border-right"] = "1px #CCCCCC dotted";
                                        ((HtmlContainerControl)ctlPane).Style["border-left"] = "1px #CCCCCC dotted";
                                    }

                                    // display pane name
                                    Label ctlLabel = new Label();
                                    ctlLabel.Text = "<center>" + strPane + "</center><br>";
                                    ctlLabel.CssClass = "SubHead";
                                    ctlPane.Controls.AddAt(0, ctlLabel);
                                }
                            }

                            // dynamically populate the panes with modules
                            if (PortalSettings.ActiveTab.Modules.Count > 0)
                            {
                                // loop through each entry in the configuration system for this tab
                                foreach (ModuleInfo tempLoopVar_objModule in PortalSettings.ActiveTab.Modules)
                                {
                                    objModule = tempLoopVar_objModule;

                                    // if user is allowed to view module and module is not deleted
                                    if (PortalSecurity.IsInRoles(objModule.AuthorizedViewRoles) && objModule.IsDeleted == false)
                                    {
                                        // if current date is within module display schedule or user is admin
                                        if ((objModule.StartDate < DateTime.Now && objModule.EndDate > DateTime.Now) || blnLayoutMode)
                                        {
                                            // modules which are displayed on all tabs should not be displayed on the Admin or Super tabs
                                            if (objModule.AllTabs == false || PortalSettings.ActiveTab.IsAdminTab == false)
                                            {
                                                Control parent = this.FindControl(objModule.PaneName);

                                                if (parent == null)
                                                {
                                                    // the pane specified in the database does not exist for this skin
                                                    // insert the module into the default pane instead
                                                    parent = this.FindControl(Globals.glbDefaultPane);
                                                }

                                                if (parent != null)
                                                {
                                                    // try to localize admin modules
                                                    if (PortalSettings.ActiveTab.IsAdminTab)
                                                    {
                                                        objModule.ModuleTitle = Localization.LocalizeControlTitle(objModule.ModuleTitle, objModule.ControlSrc, "");
                                                    }

                                                    //try to inject the module into the skin
                                                    try
                                                    {
                                                        InjectModule(parent, objModule, PortalSettings);
                                                    }
                                                    catch (Exception)
                                                    {
                                                        bSuccess = false;
                                                    }
                                                }
                                                else // no ContentPane in skin
                                                {
                                                    ModuleLoadException lex;
                                                    lex = new ModuleLoadException(PANE_LOAD_ERROR);
                                                    Controls.Add(new ErrorContainer(PortalSettings, MODULELOAD_ERROR, lex).Container);
                                                    Exceptions.LogException(lex);
                                                    Information.Err().Clear();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Skin.AddPageMessage(this, "", TABACCESS_ERROR, ModuleMessageType.YellowWarning);
                        }
                    }
                    else
                    {
                        Skin.AddPageMessage(this, "", string.Format(CONTRACTEXPIRED_ERROR, PortalSettings.PortalName, Globals.GetMediumDate(PortalSettings.ExpiryDate.ToString()), PortalSettings.Email), ModuleMessageType.RedError);
                    }
                }
                else
                {
                    Response.Redirect(Globals.AccessDeniedURL(TABACCESS_ERROR), true);
                }
            }
            else // slave module
            {
                int ModuleId = -1;
                string Key = "";
                ModuleInfo slaveModule = null;

                // get ModuleId
                if (Request.QueryString["mid"] != null)
                {
                    ModuleId = Int32.Parse(Request.QueryString["mid"]);
                }

                // get ControlKey
                if (Request.QueryString["ctl"] != null)
                {
                    Key = Request.QueryString["ctl"];
                }

                // initialize moduleid for modulesettings
                if (Request.QueryString["moduleid"] != null & (Key.ToLower() == "module" | Key.ToLower() == "help"))
                {
                    ModuleId = Int32.Parse(Request.QueryString["moduleid"]);
                }

                if (ModuleId != -1)
                {
                    // get master module security settings
                    objModule = objModules.GetModule(ModuleId, PortalSettings.ActiveTab.TabID, false);
                    if (objModule != null)
                    {
                        //Clone the Master Module as we do not want to modify the cached module
                        slaveModule = objModule.Clone();
                        if (slaveModule.InheritViewPermissions)
                        {
                            slaveModule.AuthorizedViewRoles = PortalSettings.ActiveTab.AuthorizedRoles;
                        }
                    }
                }

                if (slaveModule == null)
                {
                    // initialize object not related to a module
                    slaveModule = new ModuleInfo();
                    slaveModule.ModuleID = ModuleId;
                    slaveModule.ModuleDefID = -1;
                    slaveModule.TabID = PortalSettings.ActiveTab.TabID;
                    slaveModule.AuthorizedEditRoles = "";
                    slaveModule.AuthorizedViewRoles = "";
                    ModulePermissionController objModulePermissionController = new ModulePermissionController();
                    slaveModule.ModulePermissions = objModulePermissionController.GetModulePermissionsCollectionByModuleID(slaveModule.ModuleID, slaveModule.TabID);
                }

                // initialize moduledefid for modulesettings
                if (Request.QueryString["moduleid"] != null & (Key.ToLower() == "module" | Key.ToLower() == "help"))
                {
                    slaveModule.ModuleDefID = -1;
                }

                // override slave module settings
                if (Request.QueryString["dnnprintmode"] != "true")
                {
                    slaveModule.ModuleTitle = "";
                }
                slaveModule.Header = "";
                slaveModule.Footer = "";
                slaveModule.StartDate = DateTime.MinValue;
                slaveModule.EndDate = DateTime.MaxValue;
                slaveModule.PaneName = Globals.glbDefaultPane;
                slaveModule.Visibility = VisibilityState.None;
                slaveModule.Color = "";
                if (Request.QueryString["dnnprintmode"] != "true")
                {
                    slaveModule.Alignment = "center";
                }
                slaveModule.Border = "";
                slaveModule.DisplayTitle = true;
                slaveModule.DisplayPrint = false;
                slaveModule.DisplaySyndicate = false;

                // get portal container for slave module
                if (PortalSettings.PortalContainer != null)
                {
                    slaveModule.ContainerSrc = PortalSettings.PortalContainer.SkinSrc;
                }
                if (string.IsNullOrEmpty(slaveModule.ContainerSrc))
                {
                    slaveModule.ContainerSrc = "[G]" + SkinInfo.RootContainer + Globals.glbDefaultContainerFolder + Globals.glbDefaultContainer;
                }
                slaveModule.ContainerSrc = SkinController.FormatSkinSrc(slaveModule.ContainerSrc, PortalSettings);
                slaveModule.ContainerPath = SkinController.FormatSkinPath(slaveModule.ContainerSrc);

                // get the pane
                Control parent = this.FindControl(slaveModule.PaneName);

                // load the controls
                ModuleControlController objModuleControls = new ModuleControlController();

                ArrayList arrModuleControls = objModuleControls.GetModuleControlsByKey(Key, slaveModule.ModuleDefID);

                for (int intCounter = 0; intCounter < arrModuleControls.Count; intCounter++)
                {
                    ModuleControlInfo objModuleControl = (ModuleControlInfo)(arrModuleControls[intCounter]);

                    // initialize control values
                    slaveModule.ModuleControlId = objModuleControl.ModuleControlID;
                    slaveModule.ControlSrc = objModuleControl.ControlSrc;
                    slaveModule.ControlType = objModuleControl.ControlType;
                    slaveModule.IconFile = objModuleControl.IconFile;
                    slaveModule.HelpUrl = objModuleControl.HelpURL;

                    if (!(Null.IsNull(objModuleControl.ControlTitle)))
                    {
                        // try to localize control title
                        slaveModule.ModuleTitle = Localization.LocalizeControlTitle(objModuleControl.ControlTitle, slaveModule.ControlSrc, Key);
                    }

                    // verify that the current user has access to this control
                    bool blnAuthorized = true;
                    if (slaveModule.ControlType == SecurityAccessLevel.Anonymous) // anonymous
                    {
                    }
                    else if (slaveModule.ControlType == SecurityAccessLevel.View) // view
                    {
                        if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) == false & PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString()) == false)
                        {
                            if (!(PortalSecurity.IsInRoles(slaveModule.AuthorizedViewRoles)))
                            {
                                blnAuthorized = false;
                            }
                        }
                    }
                    else if (slaveModule.ControlType == SecurityAccessLevel.Edit) // edit
                    {
                        if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) == false & PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString()) == false)
                        {
                            if (!(PortalSecurity.IsInRoles(slaveModule.AuthorizedViewRoles)))
                            {
                                blnAuthorized = false;
                            }
                            else
                            {
                                if (!(PortalSecurity.HasEditPermissions(slaveModule.ModulePermissions)))
                                {
                                    blnAuthorized = false;
                                }
                            }
                        }
                    }
                    else if (slaveModule.ControlType == SecurityAccessLevel.Admin) // admin
                    {
                        if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) == false & PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString()) == false)
                        {
                            blnAuthorized = false;
                        }
                    }
                    else if (slaveModule.ControlType == SecurityAccessLevel.Host) // host
                    {
                        UserInfo objUserInfo = UserController.GetCurrentUserInfo();
                        if (!objUserInfo.IsSuperUser)
                        {
                            blnAuthorized = false;
                        }
                    }

                    if (blnAuthorized)
                    {
                        //try to inject the module into the skin
                        try
                        {
                            InjectModule(parent, slaveModule, PortalSettings);
                        }
                        catch (Exception)
                        {
                            bSuccess = false;
                        }
                    }
                    else
                    {
                        Response.Redirect(Globals.AccessDeniedURL(MODULEACCESS_ERROR), true);
                    }

                }

            }

            if (!blnLayoutMode)
            {
                CollapseUnusedPanes();
            }

            if (Request.QueryString["error"] != null)
            {
                Skin.AddPageMessage(this, CRITICAL_ERROR, Server.HtmlEncode(Request.QueryString["error"]), ModuleMessageType.RedError);
            }

            if (!(PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName) | PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString())))
            {
                // only display the warning to non-administrators (adminsitrators will see the errors)
                if (!bSuccess)
                {
                    Skin.AddPageMessage(this, MODULELOAD_WARNING, string.Format(MODULELOAD_WARNINGTEXT, PortalSettings.Email), ModuleMessageType.YellowWarning);
                }
            }
        }