protected void Page_Load(object sender, EventArgs e) { // Event subscriptions // Titles and other page elements Page.Title = @"Swarmops - " + CurrentOrganization.NameShort + @" - " + CurrentPageTitle; this.ExternalScriptEasyUI.Controls = EasyUIControlsUsed.ToString(); this.IncludedScripts.Controls = IncludedControlsUsed.ToString(); this.LiteralSidebarInfo.Text = CurrentPageInfoBoxLiteral; // Set logo image. If there is no logo image, use text. if (CurrentOrganization.Identity == Organization.SandboxIdentity) { this.ImageLogo.ImageUrl = "~/Images/Other/swarmops-sandbox-logo--istockphoto.png"; this.ImageLogo.Visible = true; this.LabelOrganizationName.Visible = false; } else { Document logoLandscapeDoc = CurrentOrganization.LogoLandscape; if (logoLandscapeDoc == null) { this.ImageLogo.ImageUrl = "~/Images/Other/blank-logo-640x360.png"; } else { this.ImageLogo.ImageUrl = "~/Support/StreamUpload.aspx?DocId=" + logoLandscapeDoc.Identity.ToString(CultureInfo.InvariantCulture); } } // Check for SSL and force it // Special case for CloudFlare deployments - there is a case where somebody will get their connections de-SSLed at the server string cloudFlareVisitorScheme = Request.Headers["CF-Visitor"]; bool cloudFlareSsl = false; if (!string.IsNullOrEmpty(cloudFlareVisitorScheme)) { if (cloudFlareVisitorScheme.Contains("\"scheme\":\"https\"")) { cloudFlareSsl = true; } } // TODO: Same thing for Pound deployments // Rewrite if applicable if (Request.Url.ToString().StartsWith("http://") && !cloudFlareSsl && CurrentUser.Identity > 0) // only check client-side as many server sites de-SSL the connection before reaching the web server { if (!Request.Url.ToString().StartsWith("http://dev.swarmops.com/") && !Request.Url.ToString().StartsWith("http://sandbox.swarmops.com/") && !Request.Url.ToString().StartsWith("http://*****:*****@"$('div#divDashboardTodo').hide();"; } // Set up main menu SetupMenuItems(); this.ImageCultureIndicator.Style[HtmlTextWriterStyle.MarginTop] = "-3px"; this.ImageCultureIndicator.Style[HtmlTextWriterStyle.MarginRight] = "3px"; this.ImageCultureIndicator.Style[HtmlTextWriterStyle.Cursor] = "pointer"; this.ImageCultureIndicator.Style[HtmlTextWriterStyle.Height] = "25px"; SetupDropboxes(); // Check for message to display HttpCookie dashMessage = Request.Cookies["DashboardMessage"]; if (dashMessage != null && dashMessage.Value.Length > 0) { this.LiteralDocumentReadyHook.Text += string.Format("alertify.alert(SwarmopsJS.unescape('{0}'));", dashMessage.Value); DashboardMessage.Reset(); } else { this.LiteralDocumentReadyHook.Text = string.Empty; } // Enable support for RTL languages if (Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft) { this.LiteralBodyAttributes.Text = @"dir='rtl' class='right-to-left'"; } // If we're running as an open-something identity, remove the Preferences div if (CurrentUser.Identity < 0) { this.LiteralDocumentReadyHook.Text += @" $('#divUserPreferences').hide();"; } }
protected void Page_Load(object sender, EventArgs e) { // Event subscriptions // this.LanguageSelector.LanguageChanged += new EventHandler(LanguageSelector_LanguageChanged); // Titles and other page elements this.IconPage.ImageUrl = "/Images/PageIcons/" + CurrentPageIcon + "-40px.png"; this.LabelPageTitle.Text = CurrentPageTitle; Page.Title = "Swarmops - " + CurrentPageTitle; this.ExternalScriptEasyUI.Controls = EasyUIControlsUsed.ToString(); this.IncludedScripts.Controls = IncludedControlsUsed.ToString(); this.LiteralSidebarInfo.Text = CurrentPageInfoBoxLiteral; // Set logo image. If custom image is installed, use it instead. this.ImageLogo.ImageUrl = "~/Images/Logo-Stock.png"; if (File.Exists(Server.MapPath("~/Images/Logo-Custom.png"))) { this.ImageLogo.ImageUrl = "~/Images/Logo-Custom.png"; } // Check for SSL and force it // Special case for CloudFlare deployments - there is a case where somebody will get their connections de-SSLed at the server string cloudFlareVisitorScheme = Request.Headers["CF-Visitor"]; bool cloudFlareSsl = false; if (!string.IsNullOrEmpty(cloudFlareVisitorScheme)) { if (cloudFlareVisitorScheme.Contains("\"scheme\":\"https\"")) { cloudFlareSsl = true; } } // TODO: Same thing for Pound deployments // Rewrite if applicable if (Request.Url.ToString().StartsWith("http://") && !cloudFlareSsl) // only check client-side as many server sites de-SSL the connection before reaching the web server { if (!Request.Url.ToString().StartsWith("http://dev.swarmops.com/") && !Request.Url.ToString().StartsWith("http://sandbox.swarmops.com") && !Request.Url.ToString().StartsWith("http://localhost:") && !Request.Url.ToString().StartsWith("http://swarmops-")) { Response.Redirect(Request.Url.ToString().Replace("http:", "https:")); // Only force this if set to force it in database // TODO: Make admin init task } } Localize(); this.LabelCurrentUserName.Text = _currentUser.Name; this.LabelCurrentOrganizationName.Text = _currentOrganization.Name; this.LabelActionPlaceholder1.Text = "Action shortcut 1 (TODO)"; this.LabelActionPlaceholder2.Text = "Action shortcut 2 (TODO)"; this.LabelNoTodoItems.Text = "No Action Items (LOC)"; // Set up todo items DashboardTodos todos = DashboardTodos.ForPerson(_currentUser, _currentOrganization); this.RepeaterTodoItems.DataSource = todos; this.RepeaterTodoItems.DataBind(); this.LabelNoTodoItems.Visible = (todos.Count == 0); // Set up main menu // RadMenu mainMenu = FindControl("MainMenu") as RadMenu; Dictionary <string, bool> enableCache = new Dictionary <string, bool>(); if (Session["MainMenu-v4_Enabling"] != null && PermissionCacheTimestamp.AddSeconds(10) > DateTime.Now && Authorization.lastReload < PermissionCacheTimestamp) { enableCache = Session["MainMenu-v4_Enabling"] as Dictionary <string, bool>; } else { PermissionCacheTimestamp = DateTime.Now; } SetupMenuItems(); Authorization.flagReload = false; // SetupMenuItemsEnabling(authority, enableCache, menuItems); Session["MainMenu-v4_Enabling"] = enableCache; this.ImageCultureIndicator.Style[HtmlTextWriterStyle.MarginTop] = "-3px"; this.ImageCultureIndicator.Style[HtmlTextWriterStyle.MarginRight] = "3px"; this.ImageCultureIndicator.Style[HtmlTextWriterStyle.Cursor] = "pointer"; SetupDropboxes(); // Check for message to display HttpCookie dashMessage = Request.Cookies["DashboardMessage"]; if (dashMessage != null && dashMessage.Value.Length > 0) { this.LiteralDocumentReadyHook.Text = string.Format("alertify.alert(unescape('{0}'.replace(/\\+/g, '%20')));", dashMessage.Value); Response.SetCookie(new HttpCookie("DashboardMessage", string.Empty)); Response.Cookies["DashboardMessage"].Expires = DateTime.Now.AddYears(-10); } else { this.LiteralDocumentReadyHook.Text = string.Empty; } }