public bool UserCanViewPage(int moduleId) { if (CurrentPage == null) { return(false); } if (!CurrentPage.ContainsModule(moduleId)) { return(false); } if (WebUser.IsInRoles(CurrentPage.AuthorizedRoles)) { return(true); } return(false); }
private void RenderRss(int moduleId) { /* * * For more info on RSS 2.0 * http://www.feedvalidator.org/docs/rss2.html * * Fields not implemented yet: * <blogChannel:blogRoll>http://radio.weblogs.com/0001015/userland/scriptingNewsLeftLinks.opml</blogChannel:blogRoll> * <blogChannel:mySubscriptions>http://radio.weblogs.com/0001015/gems/mySubscriptions.opml</blogChannel:mySubscriptions> * <blogChannel:blink>http://diveintomark.org/</blogChannel:blink> * <lastBuildDate>Mon, 30 Sep 2002 11:00:00 GMT</lastBuildDate> * <docs>http://backend.userland.com/rss</docs> * */ Response.Cache.SetExpires(DateTime.Now.AddMinutes(30)); Response.Cache.SetCacheability(HttpCacheability.Public); //Response.Cache.VaryByParams["g"] = true; Response.ContentType = "application/xml"; moduleSettings = ModuleSettings.GetModuleSettings(moduleId); addSignature = WebUtils.ParseBoolFromHashtable( moduleSettings, "RSSAddSignature", false); ShowPostAuthorSetting = WebUtils.ParseBoolFromHashtable( moduleSettings, "ShowPostAuthorSetting", ShowPostAuthorSetting); addCommentsLink = WebUtils.ParseBoolFromHashtable( moduleSettings, "RSSAddCommentsLink", false); feedIsDisabled = WebUtils.ParseBoolFromHashtable( moduleSettings, "BlogDisableFeedSetting", feedIsDisabled); useExcerptInFeed = WebUtils.ParseBoolFromHashtable( moduleSettings, "UseExcerptInFeedSetting", useExcerptInFeed); excerptLength = WebUtils.ParseInt32FromHashtable( moduleSettings, "BlogExcerptLengthSetting", excerptLength); if (moduleSettings.Contains("BlogExcerptSuffixSetting")) { ExcerptSuffix = moduleSettings["BlogExcerptSuffixSetting"].ToString(); } if (moduleSettings.Contains("BlogMoreLinkText")) { MoreLinkText = moduleSettings["BlogMoreLinkText"].ToString(); } Response.ContentEncoding = Encoding.UTF8; using (XmlTextWriter xmlTextWriter = new XmlTextWriter(Response.OutputStream, Encoding.UTF8)) { xmlTextWriter.Formatting = Formatting.Indented; xmlTextWriter.WriteStartDocument(); ////////////////// // style for RSS Feed viewed in browsers if (ConfigurationManager.AppSettings["RSSCSS"] != null) { string rssCss = ConfigurationManager.AppSettings["RSSCSS"].ToString(); xmlTextWriter.WriteWhitespace(" "); xmlTextWriter.WriteRaw(String.Format("<?xml-stylesheet type=\"text/css\" href=\"{0}{1}\" ?>", cssBaseUrl, rssCss)); } if (ConfigurationManager.AppSettings["RSSXsl"] != null) { string rssXsl = ConfigurationManager.AppSettings["RSSXsl"].ToString(); xmlTextWriter.WriteWhitespace(" "); xmlTextWriter.WriteRaw(String.Format("<?xml-stylesheet type=\"text/xsl\" href=\"{0}{1}\" ?>", cssBaseUrl, rssXsl)); } /////////////////////////// xmlTextWriter.WriteComment(String.Format("RSS generated by Cynthia Blog Module V 1.0 on {0}", DateTime.Now.ToLongDateString())); xmlTextWriter.WriteStartElement("rss"); xmlTextWriter.WriteStartAttribute("version", ""); xmlTextWriter.WriteString("2.0"); xmlTextWriter.WriteEndAttribute(); xmlTextWriter.WriteStartElement("channel"); /* * RSS 2.0 * Required elements for channel are title link and description */ xmlTextWriter.WriteStartElement("title"); xmlTextWriter.WriteString(module.ModuleTitle); xmlTextWriter.WriteEndElement(); // this assumes a valid pageid passed in url string blogUrl = SiteUtils.GetCurrentPageUrl(); xmlTextWriter.WriteStartElement("link"); xmlTextWriter.WriteString(blogUrl); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteStartElement("description"); xmlTextWriter.WriteString(moduleSettings["BlogDescriptionSetting"].ToString()); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteStartElement("copyright"); xmlTextWriter.WriteString(moduleSettings["BlogCopyrightSetting"].ToString()); xmlTextWriter.WriteEndElement(); // begin optional RSS 2.0 fields //ttl = time to live in minutes, how long a channel can be cached before refreshing from the source xmlTextWriter.WriteStartElement("ttl"); xmlTextWriter.WriteString(moduleSettings["BlogRSSCacheTimeSetting"].ToString()); xmlTextWriter.WriteEndElement(); //protection from scrapers wnating to add you to the spam list string authorEmail = moduleSettings["BlogAuthorEmailSetting"].ToString().Replace("@", "@nospam"); xmlTextWriter.WriteStartElement("managingEditor"); xmlTextWriter.WriteString(authorEmail); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteStartElement("generator"); xmlTextWriter.WriteString("Cynthia Blog Module V 1.0"); xmlTextWriter.WriteEndElement(); // check if the user has page view permission if ( (!feedIsDisabled) && (currentPage.ContainsModule(moduleId)) && ((bypassPageSecurity) || (WebUser.IsInRoles(currentPage.AuthorizedRoles))) ) { RenderItems(xmlTextWriter); } else { //beginning of blog entry xmlTextWriter.WriteStartElement("item"); xmlTextWriter.WriteStartElement("title"); xmlTextWriter.WriteString("this feed is not available"); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteStartElement("link"); xmlTextWriter.WriteString(navigationSiteRoot); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteStartElement("pubDate"); xmlTextWriter.WriteString(DateTime.UtcNow.ToString("r")); xmlTextWriter.WriteEndElement(); xmlTextWriter.WriteStartElement("guid"); xmlTextWriter.WriteString(navigationSiteRoot); xmlTextWriter.WriteEndElement(); //end blog entry xmlTextWriter.WriteEndElement(); } //end of document xmlTextWriter.WriteEndElement(); } }