protected void Page_Load(object sender, EventArgs e)
        {
            debugInfoPopUpContainer.Options.IsPopup = true;

            aboutCompanyPopupContainer.Options.IsPopup = true;

            if (!DisableSearch)
            {
                RenderSearchProducts();
                DisableSearch = DisableSearch || !SearchProducts.Any() || CoreContext.Configuration.Personal;
            }


            if (SecurityContext.IsAuthenticated)
            {
                CurrentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

                if (CurrentUser.IsOutsider())
                    DisableUserInfo = true;

                UserInfoVisible = !DisableUserInfo.HasValue || !DisableUserInfo.Value;
            }

            if (!SecurityContext.IsAuthenticated || !TenantExtra.EnableTarrifSettings || CoreContext.Configuration.Personal || CurrentUser.IsVisitor())
            {
                DisableTariff = true;
            }

            _customNavItems = WebItemManager.Instance.GetItems(WebZoneType.CustomProductList, ItemAvailableState.Normal);

            if (DisableProductNavigation && SecurityContext.IsAuthenticated)
                _productListHolder.Visible = false;
            else
            {
                var productsList = WebItemManager.Instance.GetItems(WebZoneType.TopNavigationProductList, ItemAvailableState.Normal);
                DisplayModuleList = productsList.Any() && !CoreContext.Configuration.Personal;
                _productRepeater.DataSource = productsList;

                _productRepeater.DataBind();

                var addons = _customNavItems.Where(pr => ((pr.ID == WebItemManager.CalendarProductID || pr.ID == WebItemManager.TalkProductID || pr.ID == WebItemManager.MailProductID)));
                _addonRepeater.DataSource = addons.ToList();
                _addonRepeater.DataBind();
            }

            foreach (var item in _customNavItems)
            {
                var render = WebItemManager.Instance[item.ID] as IRenderCustomNavigation;
                if (render == null) continue;

                try
                {
                    var control = render.LoadCustomNavigationControl(Page);
                    if (control != null)
                    {
                        _customNavControls.Controls.Add(control);
                    }
                }
                catch (Exception ex)
                {
                    log4net.LogManager.GetLogger("ASC.Web.Studio").Error(ex);
                }
            }
            if (CoreContext.Configuration.PartnerHosted)
            {
                IsAuthorizedPartner = false;
                var partner = CoreContext.PaymentManager.GetApprovedPartner();
                if (partner != null)
                {
                    IsAuthorizedPartner = !string.IsNullOrEmpty(partner.AuthorizedKey);
                    Partner = partner;
                }
            }

            if (VoipNavigation.VoipEnabled)
                _voipPhonePlaceholder.Controls.Add(LoadControl(VoipPhoneControl.Location));
        }
Beispiel #2
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 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
     };
 }