public EmployeeWraperFull(UserInfo userInfo, ApiContext context)
            : base(userInfo)
        {
            UserName = userInfo.UserName;
            IsVisitor = userInfo.IsVisitor();
            FirstName = userInfo.FirstName;
            LastName = userInfo.LastName;
            Birthday = (ApiDateTime)userInfo.BirthDate;

            if (userInfo.Sex.HasValue)
                Sex = userInfo.Sex.Value ? "male" : "female";

            Status = userInfo.Status;
            ActivationStatus = userInfo.ActivationStatus;
            Terminated = (ApiDateTime)userInfo.TerminatedDate;

            if (!string.IsNullOrEmpty(userInfo.Department))
                Department = userInfo.Department;

            WorkFrom = (ApiDateTime)userInfo.WorkFromDate;
            Email = userInfo.Email;

            if (!string.IsNullOrEmpty(userInfo.Location))
                Location = userInfo.Location;

            if (!string.IsNullOrEmpty(userInfo.Notes))
                Notes = userInfo.Notes;

            if (!string.IsNullOrEmpty(userInfo.MobilePhone))
                MobilePhone = userInfo.MobilePhone;

            MobilePhoneActivationStatus = userInfo.MobilePhoneActivationStatus;

            if (!string.IsNullOrEmpty(userInfo.CultureName))
                CultureName = userInfo.CultureName;

            FillConacts(userInfo);

            var groups = Core.CoreContext.UserManager.GetUserGroups(userInfo.ID).Select(x => new GroupWrapperSummary(x)).ToList();

            if (groups.Any())
                Groups = groups;

            try
            {
                if (CheckContext(context, "avatarSmall"))
                    AvatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID);

                if (CheckContext(context, "avatarMedium"))
                    AvatarMedium = UserPhotoManager.GetMediumPhotoURL(userInfo.ID);

                if (CheckContext(context, "avatar"))
                    Avatar = UserPhotoManager.GetBigPhotoURL(userInfo.ID);
            }
            catch (Exception)
            {
            }

            try
            {
                IsOnline = false;
                IsAdmin = userInfo.IsAdmin();

                if (CheckContext(context, "listAdminModules"))
                {
                    var listAdminModules = userInfo.GetListAdminModules();

                    if (listAdminModules.Any())
                        ListAdminModules = listAdminModules;
                }

                IsOwner = userInfo.IsOwner();
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
 private static object PrepareUserInfo(UserInfo userInfo)
 {
     return new
     {
         id = userInfo.ID,
         displayName = DisplayUserSettings.GetFullUserName(userInfo),
         title = userInfo.Title,
         avatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID),
         avatarBig = UserPhotoManager.GetBigPhotoURL(userInfo.ID),
         profileUrl = CommonLinkUtility.ToAbsolute(CommonLinkUtility.GetUserProfile(userInfo.ID.ToString(), false)),
         groups = CoreContext.UserManager.GetUserGroups(userInfo.ID).Select(x => new
         {
             id = x.ID,
             name = x.Name,
             manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID)).UserName
         }).ToList(),
         isPending = userInfo.ActivationStatus == EmployeeActivationStatus.Pending,
         isActivated = userInfo.ActivationStatus == EmployeeActivationStatus.Activated,
         isVisitor = userInfo.IsVisitor(),
         isOutsider = userInfo.IsOutsider(),
         isAdmin = userInfo.IsAdmin(),
         isOwner = userInfo.IsOwner(),
         contacts = GetContacts(userInfo),
         created = userInfo.CreateDate,
         email = userInfo.Email
     };
 }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            Page.RegisterStyleControl(VirtualPathUtility.ToAbsolute("~/skins/page_default.less"));

            var defaultPageSettings = SettingsManager.Instance.LoadSettings<StudioDefaultPageSettings>(TenantProvider.CurrentTenantID);
            if (defaultPageSettings != null && defaultPageSettings.DefaultProductID != Guid.Empty)
            {
                if (defaultPageSettings.DefaultProductID == defaultPageSettings.FeedModuleID && !CurrentUser.IsOutsider())
                    Context.Response.Redirect("feed.aspx");

                var products = WebItemManager.Instance.GetItemsAll<IProduct>();
                foreach (var p in products)
                {
                    if (p.ID.Equals(defaultPageSettings.DefaultProductID))
                    {
                        var productInfo = WebItemSecurity.GetSecurityInfo(p.ID.ToString());
                        if (productInfo.Enabled && WebItemSecurity.IsAvailableForUser(p.ID.ToString(), CurrentUser.ID))
                        {
                            Context.Response.Redirect(p.StartURL);
                        }
                    }
                }
            }

            Master.DisabledSidePanel = true;

            Title = Resources.Resource.MainPageTitle;
            defaultListProducts = WebItemManager.Instance.GetItems(Web.Core.WebZones.WebZoneType.StartProductList);
            _showDocs = (Product)defaultListProducts.Find(r => r.ID == WebItemManager.DocumentsProductID);
            if (_showDocs != null)
            {
                defaultListProducts.RemoveAll(r => r.ID == _showDocs.ProductID);
            }


            var mailProduct = WebItemManager.Instance[WebItemManager.MailProductID];
            if (mailProduct != null && !mailProduct.IsDisabled()) {
                mailProduct.Context.LargeIconFileName = "product_logolarge.png";
                defaultListProducts.Add(mailProduct);
            }

            var  priority = new Dictionary<Guid, Int32>()
	        {
	            {WebItemManager.ProjectsProductID, 0},
	            {WebItemManager.CRMProductID, 1},
	            {WebItemManager.MailProductID, 2},
	            {WebItemManager.PeopleProductID, 3},
                {WebItemManager.CommunityProductID, 4}
	        };

            defaultListProducts = defaultListProducts.OrderBy(p => (priority.Keys.Contains(p.ID) ? priority[p.ID] : 10)).ToList();



            var collaboratorPopupSettings = SettingsManager.Instance.LoadSettingsFor<CollaboratorSettings>(CurrentUser.ID);

            if (CurrentUser.IsVisitor() && collaboratorPopupSettings.FirstVisit && !CurrentUser.IsOutsider())
            {
                AjaxPro.Utility.RegisterTypeForAjax(GetType());

                ShowWelcomePopupForCollaborator = true;
                _welcomePopupForCollaborators.Visible = true;
                _welcomeCollaboratorContainer.Options.IsPopup = true;

                Page.RegisterInlineScript("StudioBlockUIManager.blockUI('#studio_welcomeCollaboratorContainer', 500, 400, 0);");
            }

            if (CoreContext.Configuration.PartnerHosted)
            {
                IsAutorizePartner = false;
                var partner = CoreContext.PaymentManager.GetApprovedPartner();
                if (partner != null)
                {
                    IsAutorizePartner = !string.IsNullOrEmpty(partner.AuthorizedKey);
                    Partner = partner;
                }
            }
        }
        private static void ActivateMail(UserInfo user)
        {
            if (user.ActivationStatus == EmployeeActivationStatus.Activated) return;

            user.ActivationStatus = EmployeeActivationStatus.Activated;
            CoreContext.UserManager.SaveUserInfo(user);

            MessageService.Send(HttpContext.Current.Request,
                                user.IsVisitor() ? MessageAction.GuestActivated : MessageAction.UserActivated,
                                user.DisplayUserName(false));
        }