Beispiel #1
0
	protected void OutputSitenameOptions()
	{
        SiteXmlBuilder siteXml = new SiteXmlBuilder(_basePage);
        XmlNode sites = siteXml.GenerateAllSitesXml(_basePage.TheSiteList);
		XmlNodeList nodes = sites.SelectNodes("//SITE-LIST/SITE/NAME");
		foreach (XmlNode namenode in nodes)
		{
			Response.Write(string.Format("<option value=\"{0}\">{0}</option>", namenode.InnerText));
		}
		//Site[] sites = _basePage.TheSiteList.GetSites();
		//foreach (Site site in sites)
		//{
		//    Response.Write(string.Format("<option value=\"{0}\">{0}</option>", site.SiteName));
		//}
	}
Beispiel #2
0
        /// <summary>
        /// Create an Xml representation of the site list that the given user is an editor for
        /// </summary>
        /// <param name="userID">User to get groups for</param>
        /// <param name="isSuperUser">Whether the user is a superuser or not</param>
        /// <param name="context">The context it's called in</param>
        /// <returns>XmlElement pointing to the sites the user is editor of.</returns>
        public static XmlElement GetSitesUserIsEditorOfXML(int userID, bool isSuperUser, IInputContext context)
        {
            /*
             * <EDITOR-SITE-LIST>
             *  <SITE-LIST>
                    <SITE ID="17">
                        <NAME>1xtra</NAME>
                        <DESCRIPTION>1xtra messageboard</DESCRIPTION>
                        <SHORTNAME>1xtra</SHORTNAME>
                    </SITE>
                    <SITE ID="3">
                        <NAME>360</NAME>
                        <DESCRIPTION>360</DESCRIPTION>
                        <SHORTNAME>360</SHORTNAME>
                    </SITE>
             *  </SITE-LIST>
             * </EDITOR-SITE-LIST>
             */

            XmlDocument editorGroupsDoc = new XmlDocument();
            XmlElement root = editorGroupsDoc.CreateElement("EDITOR-SITE-LIST");

            if (isSuperUser)
            {
                SiteXmlBuilder siteXml = new SiteXmlBuilder(context);
                root.AppendChild(ImportNode(editorGroupsDoc, siteXml.GenerateAllSitesXml(context.TheSiteList).FirstChild));
            }
            else
            {
				XmlElement siteList = editorGroupsDoc.CreateElement("SITE-LIST");
               
                var siteIds = UserGroups.GetObject().GetSitesUserIsMemberOf(userID, "editor");


                foreach (int siteID in siteIds)
				{
						XmlElement siteXml = editorGroupsDoc.CreateElement("SITE");

						ISite site = context.TheSiteList.GetSite(siteID);

						siteXml.SetAttribute("ID", siteID.ToString());

						AddTextElement(siteXml, "NAME", site.SiteName);
						AddTextElement(siteXml, "DESCRIPTION", site.Description);
						AddTextElement(siteXml, "SHORTNAME", site.ShortName);
						AddTextElement(siteXml, "SSOSERVICE", site.SSOService);

						siteList.AppendChild(siteXml);

				}
                root.AppendChild(siteList);
            }
            return root;
        }