Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UserProfileHelper == null)
            {
                UserProfileHelper = new ProfileHelper(SecurityContext.CurrentAccount.ID.ToString());
            }
            UserInfo         = UserProfileHelper.UserInfo;
            ShowSocialLogins = UserInfo.IsMe();

            EnableOauth = CoreContext.Configuration.Standalone ||
                          CoreContext.TenantManager.GetTenantQuota(TenantProvider.CurrentTenantID).Oauth;

            TariffPageLink = TenantExtra.GetTariffPageLink();

            IsAdmin = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsAdmin() ||
                      WebItemSecurity.IsProductAdministrator(WebItemManager.PeopleProductID, SecurityContext.CurrentAccount.ID);

            IsVisitor = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor();

            if (!IsAdmin && (UserInfo.Status != EmployeeStatus.Active))
            {
                Response.Redirect(CommonLinkUtility.GetFullAbsolutePath("~/Products/People/"), true);
            }

            Role = GetRole();

            Actions = new AllowedActions(UserInfo);

            LdapFields = ASC.ActiveDirectory.Base.Settings.LdapSettings.GetImportedFields;

            HappyBirthday = CheckHappyBirthday();

            ContactPhones.DataSource = UserProfileHelper.Phones;
            ContactPhones.DataBind();

            ContactEmails.DataSource = UserProfileHelper.Emails;
            ContactEmails.DataBind();

            ContactMessengers.DataSource = UserProfileHelper.Messengers;
            ContactMessengers.DataBind();

            ContactSoccontacts.DataSource = UserProfileHelper.Contacts;
            ContactSoccontacts.DataBind();

            _deleteProfileContainer.Options.IsPopup = true;

            Page.RegisterStyle("~/UserControls/Users/UserProfile/css/userprofilecontrol_style.less")
            .RegisterBodyScripts(VirtualPathUtility.ToAbsolute("~/UserControls/Users/UserProfile/js/userprofilecontrol.js"));

            if (Actions.AllowEdit)
            {
                _editControlsHolder.Controls.Add(LoadControl(PwdTool.Location));
            }
            if (Actions.AllowEdit || (UserInfo.IsOwner() && IsAdmin))
            {
                var control = (UserEmailChange)LoadControl(UserEmailChange.Location);
                control.UserInfo = UserInfo;
                control.RegisterStylesAndScripts = false;
                userEmailChange.Controls.Add(control);
            }

            if (ShowSocialLogins && AccountLinkControl.IsNotEmpty)
            {
                var accountLink = (AccountLinkControl)LoadControl(AccountLinkControl.Location);
                accountLink.ClientCallback = "loginCallback";
                accountLink.SettingsView   = true;
                _accountPlaceholder.Controls.Add(accountLink);
            }

            var emailControl = (UserEmailControl)LoadControl(UserEmailControl.Location);

            emailControl.User   = UserInfo;
            emailControl.Viewer = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            _phEmailControlsHolder.Controls.Add(emailControl);

            var photoControl = (LoadPhotoControl)LoadControl(LoadPhotoControl.Location);

            photoControl.User = UserInfo;
            loadPhotoWindow.Controls.Add(photoControl);

            if (UserInfo.IsMe() && SetupInfo.EnabledCultures.Count > 1)
            {
                _phLanguage.Controls.Add(LoadControl(UserLanguage.Location));
            }

            if ((UserInfo.IsLDAP() && !String.IsNullOrEmpty(UserInfo.MobilePhone)) ||
                !String.IsNullOrEmpty(UserInfo.MobilePhone) ||
                UserInfo.IsMe())
            {
                ShowPrimaryMobile = true;
                if (Actions.AllowEdit && (!UserInfo.IsLDAP() || UserInfo.IsLDAP() && !LdapFields.Contains(LdapMapping.MobilePhoneAttribute)))
                {
                    var changeMobile = (ChangeMobileNumber)LoadControl(ChangeMobileNumber.Location);
                    changeMobile.User = UserInfo;
                    ChangeMobileHolder.Controls.Add(changeMobile);
                }
            }

            if (TfaAppAuthSettings.IsVisibleSettings && TfaAppAuthSettings.Enable && TfaAppUserSettings.EnableForUser(UserInfo.ID) && (UserInfo.IsMe() || IsAdmin))
            {
                ShowTfaAppSettings = true;

                if (UserInfo.IsMe() || IsAdmin)
                {
                    var resetApp = (ResetAppDialog)LoadControl(ResetAppDialog.Location);
                    resetApp.User = UserInfo;
                    _backupCodesPlaceholder.Controls.Add(resetApp);
                }
                if (UserInfo.IsMe())
                {
                    var showBackup = (ShowBackupCodesDialog)LoadControl(ShowBackupCodesDialog.Location);
                    showBackup.User = UserInfo;
                    _backupCodesPlaceholder.Controls.Add(showBackup);
                }
            }

            if (UserInfo.BirthDate.HasValue)
            {
                switch (HappyBirthday)
                {
                case 0:
                    BirthDayText = Resource.DrnToday;
                    break;

                case 1:
                    BirthDayText = Resource.DrnTomorrow;
                    break;

                case 2:
                    BirthDayText = Resource.In + " " + DateTimeExtension.Yet(2);
                    break;

                case 3:
                    BirthDayText = Resource.In + " " + DateTimeExtension.Yet(3);
                    break;

                default:
                    BirthDayText = String.Empty;
                    break;
                }
            }

            if (UserInfo.Status != EmployeeStatus.Terminated)
            {
                Groups = CoreContext.UserManager.GetUserGroups(UserInfo.ID).ToList();
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UserProfileHelper == null)
            {
                UserProfileHelper = new ProfileHelper(SecurityContext.CurrentAccount.ID.ToString());
            }
            UserInfo         = UserProfileHelper.UserInfo;
            ShowSocialLogins = UserInfo.IsMe();

            IsAdmin   = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsAdmin();
            IsVisitor = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor();

            if (!IsAdmin && (UserInfo.Status != EmployeeStatus.Active))
            {
                Response.Redirect(CommonLinkUtility.GetFullAbsolutePath("~/products/people/"), true);
            }

            AjaxPro.Utility.RegisterTypeForAjax(GetType());
            Actions = new AllowedActions(UserInfo);

            HappyBirthday = CheckHappyBirthday();

            ContactPhones.DataSource = UserProfileHelper.Phones;
            ContactPhones.DataBind();

            ContactEmails.DataSource = UserProfileHelper.Emails;
            ContactEmails.DataBind();

            ContactMessengers.DataSource = UserProfileHelper.Messengers;
            ContactMessengers.DataBind();

            ContactSoccontacts.DataSource = UserProfileHelper.Contacts;
            ContactSoccontacts.DataBind();

            _deleteProfileContainer.Options.IsPopup = true;

            Page.RegisterStyleControl(VirtualPathUtility.ToAbsolute("~/usercontrols/users/userprofile/css/userprofilecontrol_style.less"));
            Page.RegisterBodyScripts(VirtualPathUtility.ToAbsolute("~/usercontrols/users/userprofile/js/userprofilecontrol.js"));

            if (Actions.AllowEdit)
            {
                _editControlsHolder.Controls.Add(LoadControl(PwdTool.Location));
            }
            if (Actions.AllowEdit || (UserInfo.IsOwner() && IsAdmin))
            {
                var control = (UserEmailChange)LoadControl(UserEmailChange.Location);
                control.UserInfo = UserInfo;
                userEmailChange.Controls.Add(control);
            }

            if (!MobileDetector.IsMobile)
            {
                var thumbnailEditorControl = (ThumbnailEditor)LoadControl(ThumbnailEditor.Location);
                thumbnailEditorControl.Title            = Resource.TitleThumbnailPhoto;
                thumbnailEditorControl.BehaviorID       = "UserPhotoThumbnail";
                thumbnailEditorControl.JcropMinSize     = UserPhotoManager.SmallFotoSize;
                thumbnailEditorControl.JcropAspectRatio = 1;
                thumbnailEditorControl.SaveFunctionType = typeof(SavePhotoThumbnails);
                _editControlsHolder.Controls.Add(thumbnailEditorControl);
            }

            if (ShowSocialLogins && AccountLinkControl.IsNotEmpty)
            {
                var accountLink = (AccountLinkControl)LoadControl(AccountLinkControl.Location);
                accountLink.ClientCallback = "loginCallback";
                accountLink.SettingsView   = true;
                _accountPlaceholder.Controls.Add(accountLink);
            }

            var emailControl = (UserEmailControl)LoadControl(UserEmailControl.Location);

            emailControl.User   = UserInfo;
            emailControl.Viewer = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            _phEmailControlsHolder.Controls.Add(emailControl);

            var photoControl = (LoadPhotoControl)LoadControl(LoadPhotoControl.Location);

            loadPhotoWindow.Controls.Add(photoControl);

            if (UserInfo.IsMe())
            {
                _phLanguage.Controls.Add(LoadControl(UserLanguage.Location));
            }

            if (StudioSmsNotificationSettings.IsVisibleSettings && (Actions.AllowEdit && !String.IsNullOrEmpty(UserInfo.MobilePhone) || UserInfo.IsMe()))
            {
                ShowPrimaryMobile = true;
                var changeMobile = (ChangeMobileNumber)LoadControl(ChangeMobileNumber.Location);
                changeMobile.User = UserInfo;
                ChangeMobileHolder.Controls.Add(changeMobile);
            }

            if (UserInfo.BirthDate.HasValue)
            {
                switch (HappyBirthday)
                {
                case 0:
                    BirthDayText = Resource.DrnToday;
                    break;

                case 1:
                    BirthDayText = Resource.DrnTomorrow;
                    break;

                case 2:
                    BirthDayText = Resource.In + " " + DateTimeExtension.Yet(2);
                    break;

                case 3:
                    BirthDayText = Resource.In + " " + DateTimeExtension.Yet(3);
                    break;

                default:
                    BirthDayText = String.Empty;
                    break;
                }
            }

            if (UserInfo.Status != EmployeeStatus.Terminated)
            {
                List <GroupInfo> Groups = CoreContext.UserManager.GetUserGroups(UserInfo.ID).ToList();
                if (!Groups.Any())
                {
                    DepartmentsRepeater.Visible = false;
                }
                else
                {
                    Groups.Sort((group1, group2) => String.Compare(group1.Name, group2.Name, StringComparison.Ordinal));
                }

                DepartmentsRepeater.DataSource = Groups;
                DepartmentsRepeater.DataBind();
            }
        }