Example #1
0
        private static UserMaker CreateSingleOnPage(Page page, out bool allreadyexists)
        {
            var       key    = "created-user-maker";
            UserMaker finded = null;

            if (HttpContext.Current != null)
            {
                finded = HttpContext.Current.Items[key] as UserMaker;
            }

            allreadyexists = finded != null;

            return(finded ?? (UserMaker)(HttpContext.Current.Items[key] = page.LoadControl(Location)));
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _emailChangerContainer.Options.IsPopup  = true;
            _deleteProfileContainer.Options.IsPopup = true;
            _changePhoneContainer.Options.IsPopup   = true;
            _isAdmin = CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, ASC.Core.Users.Constants.GroupAdmin.ID);

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "userprofile_style", "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + WebSkin.GetUserSkin().GetAbsoluteWebPath("usercontrols/users/userprofile/css/<theme_folder>/userprofilecontrol_style.css") + "\">", false);
            Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "userprofile_script", WebPath.GetPath("usercontrols/users/userprofile/js/userprofilecontrol.js"));
            AjaxPro.Utility.RegisterTypeForAjax(this.GetType());

            _self           = SecurityContext.CurrentAccount.ID.Equals(UserInfo.ID);
            _allowDelete    = SecurityContext.CheckPermissions(ASC.Core.Users.Constants.Action_AddRemoveUser);
            _allowChangePwd = SecurityContext.CheckPermissions(new UserSecurityProvider(SecurityContext.CurrentAccount.ID), ASC.Core.Users.Constants.Action_EditUser);
            _allowEdit      = _allowDelete;

            var isOwner = UserInfo.IsOwner();

            if (_self || isOwner)
            {
                _allowDelete = false;
            }

            if (MyStaffMode)
            {
                _allowEditSelf = (SecurityContext.CheckPermissions(new UserSecurityProvider(SecurityContext.CurrentAccount.ID), ASC.Core.Users.Constants.Action_EditUser) && !SecurityContext.DemoMode);
            }
            else if (!MyStaffMode && isOwner && !_self)
            {
                _allowDelete    = false;
                _allowChangePwd = false;
                _allowEdit      = false;
            }

            if (UserInfo.ActivationStatus == EmployeeActivationStatus.Pending)
            {
                _allowChangePwd = false;
            }


            if (_allowChangePwd || (_self && MyStaffMode))
            {
                _editControlsHolder.Controls.Add(LoadControl(PwdTool.Location));
            }


            if (_allowEdit || _allowEditSelf)
            {
                UserMaker.AddOnlyOne(Page, _editControlsHolder);
            }

            if (!ASC.Web.Core.Mobile.MobileDetector.IsRequestMatchesMobile(Context))
            {
                ThumbnailEditor thumbnailEditorControl = (ThumbnailEditor)LoadControl(ThumbnailEditor.Location);
                thumbnailEditorControl.Title            = Resources.Resource.TitleThumbnailPhoto;
                thumbnailEditorControl.BehaviorID       = "UserPhotoThumbnail";
                thumbnailEditorControl.JcropMinSize     = UserPhotoManager.SmallFotoSize;
                thumbnailEditorControl.JcropAspectRatio = 1;
                thumbnailEditorControl.SaveFunctionType = typeof(SavePhotoThumbnails);
                _editControlsHolder.Controls.Add(thumbnailEditorControl);
            }

            List <Dictionary <String, String> > contacts = new List <Dictionary <String, String> >();

            for (Int32 i = 0, n = UserInfo.Contacts.Count; i < n; i += 2)
            {
                if (i + 1 < UserInfo.Contacts.Count)
                {
                    contacts.Add(GetSocialContact(UserInfo.Contacts[i], UserInfo.Contacts[i + 1]));
                }
            }
            SocialContacts.DataSource = contacts;
            SocialContacts.DataBind();


            if (MyStaffMode && SetupInfo.ThirdPartyAuthEnabled)
            {
                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);
        }