protected void Page_Load(object sender, EventArgs e) { var sort = "pattern"; if (Request.QueryString["sort"] == "destination") { sort = "destination"; } if (Request.QueryString["sort"] == "date") { sort = "date"; } sortLinks.Controls.Add(new LiteralControl((sort == "destination" || sort == "date") ? "<li><a href=\"shorturls.aspx\">Short URL</a></li>" : "<li>Short URL</li>")); sortLinks.Controls.Add(new LiteralControl((sort == "destination") ? "<li>Where it redirects to</li>" : "<li><a href=\"shorturls.aspx?sort=destination\">Where it redirects to</a></li>")); sortLinks.Controls.Add(new LiteralControl((sort == "date") ? "<li>Most recent first</li>" : "<li><a href=\"shorturls.aspx?sort=date\">Most recent first</a></li>")); var editConfig = XElement.Load(Server.MapPath(@".\edit\web.config")); var allowed = editConfig.Descendants("authorization").Descendants("allow").Attributes("roles").Select(attr => attr.Value).ToList(); var permissions = new LogonIdentityGroupMembershipChecker(); editTable.Visible = (allowed.Count > 0 && permissions.UserIsInGroup(allowed)); add.Visible = editTable.Visible; viewTable.Visible = !editTable.Visible; var table = editTable.Visible ? editTable : viewTable; using (var reader = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["RedirectsReader"].ConnectionString, "usp_Redirect_SelectByType", new SqlParameter("@type", 1), new SqlParameter("@sort", sort))) { table.DataSource = reader; table.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { var skinnable = Master as BaseMasterPage; if (skinnable != null) { skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile)); } var sort = "pattern"; if (Request.QueryString["sort"] == "destination") sort = "destination"; if (Request.QueryString["sort"] == "date") sort = "date"; sortLinks.Controls.Add(new LiteralControl((sort == "destination" || sort == "date") ? "<li><a href=\"moved.aspx\">Moved from</a></li>" : "<li>Moved from</li>")); sortLinks.Controls.Add(new LiteralControl((sort == "destination") ? "<li>Moved to</li>" : "<li><a href=\"moved.aspx?sort=destination\">Moved to</a></li>")); sortLinks.Controls.Add(new LiteralControl((sort == "date") ? "<li>Most recent first</li>" : "<li><a href=\"moved.aspx?sort=date\">Most recent first</a></li>")); var editConfig = XElement.Load(Server.MapPath(@".\edit\web.config")); var allowed = editConfig.Descendants("authorization").Descendants("allow").Attributes("roles").Select(attr => attr.Value).ToList(); var permissions = new LogonIdentityGroupMembershipChecker(); editTable.Visible = (allowed.Count > 0 && permissions.UserIsInGroup(allowed)); add.Visible = editTable.Visible; viewTable.Visible = !editTable.Visible; var table = editTable.Visible ? editTable : viewTable; using (var reader = SqlHelper.ExecuteReader(ConfigurationManager.ConnectionStrings["RedirectsReader"].ConnectionString, "usp_Redirect_SelectByType", new SqlParameter("@type", 2), new SqlParameter("@sort", sort))) { table.DataSource = reader; table.DataBind(); } }
/// <summary> /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. /// </summary> protected override void CreateChildControls() { // Ensure controls are visible by default this.Visible = true; // Look for various reasons why controls may need to be hidden // Hide based on master page var viewSelector = new WebFormsViewSelector(); if (Desktop != null && Desktop.Value != viewSelector.CurrentViewIs(Page.MasterPageFile, EsccWebsiteView.Desktop)) { HideContents(); return; } if (Plain != null && Plain.Value != viewSelector.CurrentViewIs(Page.MasterPageFile, EsccWebsiteView.Plain)) { HideContents(); return; } if (FullScreen != null && FullScreen.Value != viewSelector.CurrentViewIs(Page.MasterPageFile, EsccWebsiteView.FullScreen)) { HideContents(); return; } // Hide based on user var libraryContext = new LibraryCatalogueContext(HttpContext.Current.Request.UserAgent); if (LibraryCatalogue != null && LibraryCatalogue.Value != libraryContext.RequestIsFromLibraryCatalogueMachine()) { HideContents(); return; } if (!String.IsNullOrEmpty(Groups)) { var settings = new ActiveDirectorySettingsFromConfiguration(); var permissions = new LogonIdentityGroupMembershipChecker(settings.DefaultDomain, new ActiveDirectoryMemoryCache()); if (!permissions.UserIsInGroup(Groups.SplitAndTrim(';'))) { HideContents(); return; } } // Hide based on location if (!String.IsNullOrEmpty(this.UrlMatch) && !Regex.IsMatch(HttpContext.Current.Request.Url.ToString(), this.UrlMatch, RegexOptions.IgnoreCase)) { HideContents(); return; } var context = new HostingEnvironmentContext(HttpContext.Current.Request.Url); if (Public != null && Public.Value != context.IsPublicUrl) { HideContents(); return; } // Hide based on date if (this.After.HasValue && DateTime.Now.ToUkDateTime() <= this.After) { HideContents(); return; } if (this.Before.HasValue && DateTime.Now.ToUkDateTime() >= this.Before) { HideContents(); return; } }