protected void SiteSelector_OnSelectionChanged(object sender, EventArgs e) { // Create URL int siteId = ValidationHelper.GetInteger(siteSelector.Value, 0); SiteInfo si = SiteInfo.Provider.Get(siteId); if (si != null) { string domain = si.DomainName.TrimEnd('/'); string url = "~" + VirtualContext.CurrentURLPrefix + "/Admin/cmsadministration.aspx"; if (domain.Contains("/")) { // Resolve application path url = url.Substring(1); } url = URLHelper.GetAbsoluteUrl(url, domain, null, null); // Check if single sign-on is turned on if (SettingsKeyInfoProvider.GetBoolValue("CMSAutomaticallySignInUser")) { var user = UserInfo.Provider.Get(MembershipContext.AuthenticatedUser.UserID); url = AuthenticationHelper.GetUserAuthenticationUrl(user, url, si.DomainName); } PortalScriptHelper.RegisterAdminRedirectScript(Page, url); } }
/// <summary> /// Loads page, sets currently used task group and registers javascript. /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event arguments</param> protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { return; } stagingTaskGroupSelector.DisplayNameFormat = "{%" + TaskGroupInfo.TYPEINFO.CodeNameColumn + "%}"; btnCreateTaskGroup.Text = HTMLHelper.HTMLEncode(GetString("staging.btnCreateTaskGroup")); lblStagingTaskGroupSelector.AssociatedControlClientID = UniSelectorClientID; // Hide possibility to create task group in dialog plcCreateTaskGroup.Visible = UserCanManageTaskGroups(CMSActionContext.CurrentUser); // Hides link to staging, if user does not have permission lnkEditTaskGroup.Visible = UserCanAccessStagingUI(CMSActionContext.CurrentUser); // If too many objects are in UniSelector and dialog window is open, change user's task group stagingTaskGroupSelector.OnSelectionChanged += (s, ev) => { // Register script so in iframe under header, we will stay on the same page PortalScriptHelper.RegisterAdminRedirectScript(Page); TaskGroupInfoProvider.SetTaskGroupForUser(Convert.ToInt32(stagingTaskGroupSelector.Value), CMSActionContext.CurrentUser.UserID); }; }
/// <summary> /// PreRender event handler /// </summary> protected override void OnPreRender(EventArgs e) { // Keep latest application after logon PortalScriptHelper.RegisterApplicationStorageScript(Page); base.OnPreRender(e); }
/// <summary> /// Checks UI culture settings. /// </summary> private bool EnsureUICultures() { // Show selector only if there are more UI cultures than one var count = CultureInfoProvider.GetUICultures().Count; if (count > 1) { lnkUICultures.Visible = true; lnkUICultures.OnClientClick = ucUICultures.GetSelectionDialogScript(); string cultureName = ValidationHelper.GetString(ucUICultures.Value, String.Empty); if (cultureName != string.Empty) { MembershipContext.AuthenticatedUser.PreferredUICultureCode = cultureName; UserInfoProvider.SetUserInfo(MembershipContext.AuthenticatedUser); // Set selected UI culture and refresh all pages CultureHelper.SetPreferredUICultureCode(cultureName); PortalScriptHelper.RegisterAdminRedirectScript(Page); } return(true); } // Hide UI culture action in menu plcUICultures.Visible = false; return(false); }
/// <summary> /// OnClick event handler for cancel impersonation. /// </summary> protected void lnkCancelImpersonate_OnClick(object sender, EventArgs e) { AuthenticationHelper.CancelImpersonation(); if (RequestHelper.IsFormsAuthentication()) { PortalScriptHelper.RegisterAdminRedirectScript(Page); } else { URLHelper.Redirect(RequestContext.CurrentURL); } }
/// <summary> /// Checks user impersonation settings. /// </summary> private bool EnsureImpersonation() { var userIsImpersonated = MembershipContext.CurrentUserIsImpersonated(); // Show impersonate button for global admin only or impersonated user if (CookieHelper.AllowCookies && (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin) || userIsImpersonated)) { lnkUsers.Visible = true; lnkUsers.OnClientClick = ucUsers.GetSelectionDialogScript(); // Show all users except global administrators and public user, in CMSDesk show only site users ucUsers.WhereCondition = GetImpersonateWhereCondition().ToString(true); // Script for open uniselector modal dialog string impersonateScript = "function userImpersonateShowDialog () {US_SelectionDialog_" + ucUsers.ClientID + "()}"; ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ImpersonateContextMenu", ScriptHelper.GetScript(impersonateScript)); string userName = HTMLHelper.HTMLDecode(ValidationHelper.GetString(ucUsers.Value, String.Empty)); if (userName != String.Empty) { // Get selected user info UserInfo iui = UserInfoProvider.GetUserInfo(userName); if (!iui.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)) { // Indicates whether user will be able to continue in the administration interface bool keepAdimUI = iui.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Editor, SiteContext.CurrentSiteName); AuthenticationHelper.ImpersonateUser(iui, null, !keepAdimUI); if (keepAdimUI) { PortalScriptHelper.RegisterAdminRedirectScript(Page); } } } // Set visibility of Cancel impersonation item in menu plcCancelImpersonate.Visible = userIsImpersonated; // Hide impersonate action in menu if user is already impersonated plcImpersonate.Visible = !plcCancelImpersonate.Visible; return(true); } // Hide impersonate action in menu plcImpersonate.Visible = false; plcCancelImpersonate.Visible = false; return(false); }