示例#1
0
    /// <summary>
    /// Load UI cultures for the dropdown list.
    /// </summary>
    private void LoadCultures()
    {
        CMSDropDownList drpCulture = (CMSDropDownList)Login1.FindControl("drpCulture");

        if (drpCulture != null)
        {
            DataSet  ds         = CultureInfoProvider.GetUICultures();
            DataView dvCultures = ds.Tables[0].DefaultView;
            dvCultures.Sort = "CultureName ASC";

            drpCulture.DataValueField = "CultureCode";
            drpCulture.DataTextField  = "CultureName";
            drpCulture.DataSource     = dvCultures;
            drpCulture.DataBind();

            // Add default value
            drpCulture.Items.Insert(0, new ListItem(GetString("LogonForm.DefaultCulture"), ""));

            LocalizedLabel lblCulture = (LocalizedLabel)Login1.FindControl("lblCulture");
            if (lblCulture != null)
            {
                lblCulture.AssociatedControlID = drpCulture.ID;
                lblCulture.Text    = ResHelper.GetString("general.select");
                lblCulture.Display = false;
            }
        }
    }
示例#2
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);
    }
示例#3
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);

                PortalScriptHelper.RegisterAdminRedirectScript(Page);
            }

            return(true);
        }

        // Hide UI culture action in menu
        plcUICultures.Visible = false;
        return(false);
    }
    /// <summary>
    /// Gets all the UI cultures and fill them in the drop-down list.
    /// </summary>
    private void GetAvailableCultures()
    {
        // Get available UI cultures from the system
        DataSet uiCultures = CultureInfoProvider.GetUICultures();

        if (!DataHelper.DataSourceIsEmpty(uiCultures))
        {
            ddlAvailableCultures.DataSource     = uiCultures;
            ddlAvailableCultures.DataTextField  = "CultureName";
            ddlAvailableCultures.DataValueField = "CultureID";
            ddlAvailableCultures.DataBind();
        }
        else
        {
            pnlCultures.Visible = false;
        }
    }
示例#5
0
    /// <summary>
    /// Loads data of edited user from DB into TextBoxes.
    /// </summary>
    protected void LoadData()
    {
        // Fill lstUICulture (loop over and localize them first)
        DataSet uiCultures = CultureInfoProvider.GetUICultures().OrderBy("CultureName");

        LocalizeCultureNames(uiCultures);
        lstUICulture.DataSource     = uiCultures.Tables[0].DefaultView;
        lstUICulture.DataTextField  = "CultureName";
        lstUICulture.DataValueField = "CultureID";
        lstUICulture.DataBind();

        lstUICulture.Items.Insert(0, GetString("Administration-User_Edit.Default"));
        lstUICulture.Items[0].Value = "0";

        if (ui != null)
        {
            // Get user info properties
            txtEmail.Text      = ui.Email;
            txtFirstName.Text  = ui.FirstName;
            txtFullName.Text   = ui.FullName;
            txtLastName.Text   = ui.LastName;
            txtMiddleName.Text = ui.MiddleName;
            ucUserName.Value   = ui.UserName;

            CheckBoxEnabled.Checked = ui.Enabled;
            chkIsExternal.Checked   = ui.IsExternal;
            chkIsDomain.Checked     = ui.UserIsDomain;
            chkIsHidden.Checked     = ui.UserIsHidden;
            chkIsMFRequired.Checked = ui.UserMFRequired;

            // Privilege drop down check
            if (!CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
            {
                // Disable for global admins
                if (ui.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
                {
                    drpPrivilege.Enabled = false;
                }
                else
                // Only global admin can manage other admins.
                if (ui.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))
                {
                    // Allow manage only for user himself
                    if (ui.UserID != CurrentUser.UserID)
                    {
                        drpPrivilege.Enabled = false;
                    }
                    else
                    {
                        drpPrivilege.ExcludedValues = ((int)UserPrivilegeLevelEnum.GlobalAdmin).ToString();
                    }
                }
                else
                {
                    drpPrivilege.ExcludedValues = (int)UserPrivilegeLevelEnum.GlobalAdmin + ";" + (int)UserPrivilegeLevelEnum.Admin;
                }
            }

            if (ui.IsGlobalAdministrator)
            {
                drpPrivilege.Value = ui.UserGlobalAccessDisabled ? (int)UserPrivilegeLevelEnum.Admin : (int)UserPrivilegeLevelEnum.GlobalAdmin;
            }
            else if (ui.IsEditorInternal)
            {
                drpPrivilege.Value = (int)UserPrivilegeLevelEnum.Editor;
            }

            password = ui.GetValue("UserPassword").ToString();

            // Disable username textbox for public user
            if (ui.IsPublic())
            {
                ucUserName.Enabled = false;
            }

            myCulture   = ui.PreferredCultureCode;
            myUICulture = ui.PreferredUICultureCode;

            lblInvalidLogonAttemptsNumber.Text = string.Format(GetString("general.attempts"), ui.UserInvalidLogOnAttempts);
            if (ui.UserInvalidLogOnAttempts > 0)
            {
                lblInvalidLogonAttemptsNumber.Style.Add(HtmlTextWriterStyle.Color, "Red");
            }
            else
            {
                btnResetLogonAttempts.Enabled = (ui.UserAccountLockReason == UserAccountLockCode.FromEnum(UserAccountLockEnum.MaximumInvalidLogonAttemptsReached));
            }

            LoadPasswordExpiration(ui);

            txtUserStartingPath.Text = ui.UserStartingAliasPath;
        }

        // Set content culture
        cultureSelector.Value = myCulture;

        if (!string.IsNullOrEmpty(myUICulture))
        {
            // Set UI culture
            try
            {
                CultureInfo ciUI = CultureInfoProvider.GetCultureInfo(myUICulture);
                lstUICulture.SelectedIndex = lstUICulture.Items.IndexOf(lstUICulture.Items.FindByValue(ciUI.CultureID.ToString()));
            }
            catch
            {
                lstUICulture.SelectedIndex = lstUICulture.Items.IndexOf(lstUICulture.Items.FindByValue("0"));
            }
        }
        else
        {
            lstUICulture.SelectedIndex = lstUICulture.Items.IndexOf(lstUICulture.Items.FindByValue("0"));
        }

        if (ui != null)
        {
            // If new user
            lblCreatedInfo.Text   = ui.UserCreated.ToString();
            lblLastLogonTime.Text = ui.LastLogon.ToString();

            LoadUserLogon(ui);

            if (ui.UserCreated == DateTimeHelper.ZERO_TIME)
            {
                lblCreatedInfo.Text = GetString("general.na");
            }

            if (ui.LastLogon == DateTimeHelper.ZERO_TIME)
            {
                lblLastLogonTime.Text = GetString("general.na");
            }
        }
    }