Ejemplo n.º 1
0
        // *********************************************************************
        //  LoadValuesFromConfigurationXml
        //
        /// <summary>
        /// Loads the forums configuration values.
        /// </summary>
        /// <param name="node">XmlNode of the configuration section to parse.</param>
        /// 
        // ***********************************************************************/
        internal void LoadValuesFromConfigurationXml()
        {
            XmlNode node = GetConfigSection("CommunityServer/Core");

            XmlAttributeCollection attributeCollection = node.Attributes;

            // Get the default language
            //

            XmlAttribute att = attributeCollection["defaultLanguage"];
            if(att != null)
                defaultLanguage =att.Value;
            else
                defaultLanguage = "en-US";

            att = attributeCollection["filesPath"];
            if(att != null)
                filesPath = att.Value;
            else
                filesPath = "/";

            att = attributeCollection["applicationKeyOverride"];
            if(att != null)
                applicationKeyOverride = att.Value;

            att = attributeCollection["disableThreading"];
            if(att != null)
                disableBackgroundThreads = bool.Parse(att.Value);

            att = attributeCollection["disableIndexing"];
            if(att != null)
                disableIndexing = bool.Parse(att.Value);

            att = attributeCollection["cacheFactor"];
            if(att != null)
                cacheFactor = Int32.Parse(att.Value);
            else
                cacheFactor = 5;

            att = attributeCollection["disableEmail"];
            if(att != null)
                disableEmail = bool.Parse(att.Value);

            att = attributeCollection["smtpServerConnectionLimit"];
            if(att != null)
                smtpServerConnectionLimit = short.Parse(att.Value);
            else
                smtpServerConnectionLimit = -1;

            att = attributeCollection["enableLatestVersionCheck"];
            if(att != null)
                enableLatestVersionCheck = bool.Parse(att.Value);

            att = attributeCollection["backwardsCompatiblePasswords"];
            if(att != null)
                backwardsCompatiblePasswords = bool.Parse(att.Value);

            att = attributeCollection["textEditorType"];
            if(att != null)
                textEditorType = att.Value;
            else
                textEditorType =  "CommunityServer.Controls.DefaultTextEditor,CommunityServer.Controls";

            att = attributeCollection["applicationOverride"];
            if(att != null)
                applicationOverride = att.Value;
            else
                applicationOverride = null;

            att = attributeCollection["systemType"];
            if(att != null)
                systemType =  (SystemType)Enum.Parse(typeof(SystemType),attributeCollection["systemType"].Value);
            else
                systemType = SystemType.Self;

            att = attributeCollection["wwwStatus"];
            if(att != null)
                _wwwStatus = (WWWStatus)Enum.Parse(typeof(WWWStatus),attributeCollection["wwwStatus"].Value);

            // ��ȡĬ�ϸ������淽ʽ
            //
            att = attributeCollection["AttachmentSaveMode"];
            if(att != null)
            {
                try
                {
                    attachmentSaveMode = (FileSaveMode)Enum.Parse(typeof(FileSaveMode), attributeCollection["AttachmentSaveMode"].Value);
                }
                catch{}
            }

            // ��ȡĬ�ϸ������淽ʽ
            //
            att = attributeCollection["AvatarSaveMode"];
            if(att != null)
            {
                try
                {
                    avatarSaveMode = (FileSaveMode)Enum.Parse(typeof(FileSaveMode), attributeCollection["AvatarSaveMode"].Value);
                }
                catch{}
            }

            // ��ȡ��������·��
            //
            att = attributeCollection["AttachmentsPath"];
            if(att != null)
                attachmentsPath = att.Value;

            // ��ȡͷ�񱣴�·��
            //
            att = attributeCollection["AvatarsPath"];
            if(att != null)
                avatarsPath = att.Value;

            att = attributeCollection["requireSSL"];
            if(att != null)
                requireSSL = bool.Parse(att.Value);

            XmlAttribute roles = attributeCollection["defaultRoles"];
            if(roles != null)
            {
                _defaultRoles = roles.Value.Split(';');
            }

            // Read child nodes
            //
            foreach (XmlNode child in node.ChildNodes)
            {

                if (child.Name == "providers")
                    GetProviders(child, providers);

                if(child.Name == "appLocation")
                    GetAppLocation(child);

                if (child.Name == "extensionModules")
                    GetProviders(child, extensions);

                if(child.Name == "roleConfiguration")
                    GetRoleConfiguration(child);

            }

            //if we do not have an application, create the default one
            if(app == null)
            {
                app = AppLocation.Default();
            }

            if(roleConfiguration == null)
            {
                roleConfiguration = new RolesConfiguration();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// All configuration settings should "default" if possible.
        /// </summary>
        /// <returns></returns>
        public static AppLocation Default()
        {
            AppLocation app = new AppLocation();
            app.Add(new CSApplicationInternal("blogs/admin", "BlogAdmin", ApplicationType.Weblog));
            app.Add(new CSApplicationInternal("forums/admin", "ForumAdmin", ApplicationType.Forum));
            app.Add(new CSApplicationInternal("galleries/admin", "GalleryAdmin", ApplicationType.Gallery));

            app.Add(new CSApplicationInternal("blogs", "BlogPublic", ApplicationType.Weblog));
            app.Add(new CSApplicationInternal("forums", "ForumPublic", ApplicationType.Forum));
            app.Add(new CSApplicationInternal("galleries", "GalleryPublic", ApplicationType.Gallery));

            return app;
        }
Ejemplo n.º 3
0
 internal void GetAppLocation(XmlNode node)
 {
     app = AppLocation.Create(node);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates an instance of AppLocation  for the supplied XmlNode. 
        /// This node will generally be supplied during the ForumsConfiguration
        /// instantiation
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static AppLocation Create(XmlNode node)
        {
            AppLocation app = new AppLocation();

            //Look for AppLocation property values
            XmlAttributeCollection xac = node.Attributes;
            if(xac != null)
            {
                foreach(XmlAttribute att in xac)
                {
                    if(att.Name == "pattern")
                    {
                        app.Pattern = Globals.ApplicationPath + att.Value;
                    }
                    else if(att.Name == "defaultName")
                    {
                        app.DefaultName = att.Value;
                    }

                }

                //loop through the child nodes. For the moment, we will
                //only support add, but it might be worth while allowing applicatoins
                //to stack these settings
                foreach(XmlNode child in node.ChildNodes)
                {
                    if(child.Name == "add")
                    {
                        XmlAttributeCollection csAtt = child.Attributes;
                        if(csAtt != null)
                        {
                            string pattern = Globals.ApplicationPath + csAtt["pattern"].Value;
                            string name = csAtt["name"].Value;
                            ApplicationType appType = (ApplicationType) Enum.Parse(typeof(ApplicationType),csAtt["type"].Value,true);
                            app.Add(new CSApplicationInternal(pattern, name, appType));
                        }
                    }
                }

            }

            return app;
        }