Ejemplo n.º 1
0
    protected void SiteSelector_OnSelectionChanged(object sender, EventArgs e)
    {
        // Create URL
        int      siteId = ValidationHelper.GetInteger(siteSelector.Value, 0);
        SiteInfo si     = SiteInfoProvider.GetSiteInfo(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"))
            {
                url = AuthenticationHelper.GetUserAuthenticationUrl(MembershipContext.AuthenticatedUser, url);
            }

            UIContextHelper.RegisterAdminRedirectScript(Page, url);
        }
    }
Ejemplo n.º 2
0
    /// <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);

                UIContextHelper.RegisterAdminRedirectScript(Page);
            }

            return(true);
        }

        // Hide UI culture action in menu
        plcUICultures.Visible = false;
        return(false);
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Checks UI culture settings.
    /// </summary>
    private bool EnsureUICultures()
    {
        DataSet ds = CultureInfoProvider.GetUICultures(topN: 0, columns: "COUNT (CultureID)");

        // Show selector only if there are more UI cultures than one
        if (!DataHelper.DataSourceIsEmpty(ds) && (ValidationHelper.GetInteger(ds.Tables[0].Rows[0][0], 0) > 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);

                UIContextHelper.RegisterAdminRedirectScript(Page);
            }

            return(true);
        }

        // Hide UI culture action in menu
        plcUICultures.Visible = false;
        return(false);
    }
Ejemplo n.º 4
0
    /// <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
            UIContextHelper.RegisterAdminRedirectScript(Page);
            TaskGroupInfoProvider.SetTaskGroupForUser(Convert.ToInt32(stagingTaskGroupSelector.Value), CMSActionContext.CurrentUser.UserID);
        };
    }
Ejemplo n.º 5
0
    /// <summary>
    /// OnClick event handler for cancel impersonation.
    /// </summary>
    protected void lnkCancelImpersonate_OnClick(object sender, EventArgs e)
    {
        string originalUserName = ValidationHelper.GetString(SessionHelper.GetValue("OriginalUserName"), "");

        if (RequestHelper.IsFormsAuthentication())
        {
            UserInfo ui = UserInfoProvider.GetUserInfo(originalUserName);

            AuthenticationHelper.SetCurrentUser(null);
            AuthenticationHelper.AuthenticateUser(ui.UserName, false, false);

            EventLogProvider.LogEvent(EventType.INFORMATION, "Administration", "Impersonate", "User " + ui.UserName + " has returned to his account.");

            UIContextHelper.RegisterAdminRedirectScript(Page);
        }
        else
        {
            SessionHelper.SetValue("ImpersonateUserName", null);
            SessionHelper.SetValue("OriginalUserName", null);

            MembershipContext.AuthenticatedUser.Generalized.Invalidate(false);

            // Log event
            EventLogProvider.LogEvent(EventType.INFORMATION, "Administration", "Impersonate", "User " + originalUserName + " has returned to his account.", RequestContext.CurrentURL, 0, null, 0, null, null, SiteContext.CurrentSiteID);

            URLHelper.Redirect(RequestContext.CurrentURL);
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Checks user impersonation settings.
    /// </summary>
    private bool EnsureImpersonation()
    {
        string originalUserName = ValidationHelper.GetString(SessionHelper.GetValue(RequestHelper.IsFormsAuthentication() ? "OriginalUserName" : "ImpersonateUserName"), "");

        // Show impersonate button for global admin only or impersonated user
        if (MembershipContext.AuthenticatedUser.IsGlobalAdministrator || !String.IsNullOrEmpty(originalUserName))
        {
            lnkUsers.Visible       = true;
            lnkUsers.OnClientClick = ucUsers.GetSelectionDialogScript();

            // Show all users except global administrators and public user, in CMSDesk show only site users
            ucUsers.WhereCondition = "UserID IN (SELECT UserID FROM CMS_UserSite WHERE " + (IsCMSDesk ? "(SiteID = " + SiteContext.CurrentSiteID + ") AND" : "") + " (UserIsGlobalAdministrator = 0)) AND (UserID != " + MembershipContext.AuthenticatedUser.UserID + ") AND (UserName != N'public')";

            // 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 = HttpUtility.UrlDecode(ValidationHelper.GetString(ucUsers.Value, String.Empty));
            if (userName != String.Empty)
            {
                // Get selected user info
                UserInfo iui = UserInfoProvider.GetUserInfo(userName);
                if (!iui.IsGlobalAdministrator)
                {
                    // 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)
                    {
                        UIContextHelper.RegisterAdminRedirectScript(Page);
                    }
                }
            }

            // Set visibility of Cancel impersonation item in menu
            if (!String.IsNullOrEmpty(originalUserName))
            {
                plcCancelImpersonate.Visible = true;
                lnkCancelImpersonate.Text    = GetString("users.cancelimpersonation");
            }
            else
            {
                plcCancelImpersonate.Visible = false;
            }
            return(true);
        }

        // Hide impersonate action in menu
        plcImpersonate.Visible = false;
        return(false);
    }