public CustomNavigationItem CreateCustomNavigationItem(CustomNavigationItem item)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var settings = CustomNavigationSettings.Load();

            var exist = false;

            foreach (var existItem in settings.Items)
            {
                if (existItem.Id != item.Id)
                {
                    continue;
                }

                existItem.Label          = item.Label;
                existItem.Url            = item.Url;
                existItem.ShowInMenu     = item.ShowInMenu;
                existItem.ShowOnHomePage = item.ShowOnHomePage;

                if (existItem.SmallImg != item.SmallImg)
                {
                    StorageHelper.DeleteLogo(existItem.SmallImg);
                    existItem.SmallImg = StorageHelper.SaveTmpLogo(item.SmallImg);
                }

                if (existItem.BigImg != item.BigImg)
                {
                    StorageHelper.DeleteLogo(existItem.BigImg);
                    existItem.BigImg = StorageHelper.SaveTmpLogo(item.BigImg);
                }

                exist = true;
                break;
            }

            if (!exist)
            {
                item.Id       = Guid.NewGuid();
                item.SmallImg = StorageHelper.SaveTmpLogo(item.SmallImg);
                item.BigImg   = StorageHelper.SaveTmpLogo(item.BigImg);

                settings.Items.Add(item);
            }

            settings.Save();

            MessageService.Send(HttpContext.Current.Request, MessageAction.CustomNavigationSettingsUpdated);

            return(item);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Enabled = SetupInfo.IsVisibleSettings("CustomNavigation");

            if (!Enabled)
            {
                return;
            }

            Page
            .RegisterBodyScripts(
                "~/js/uploader/ajaxupload.js",
                "~/UserControls/Management/CustomNavigation/js/customnavigation.js")
            .RegisterStyle(
                "~/UserControls/Management/CustomNavigation/css/customnavigation.less");

            Items = CustomNavigationSettings.Load().Items;
        }
        public void DeleteCustomNavigationItem(Guid id)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var settings = CustomNavigationSettings.Load();

            var terget = settings.Items.FirstOrDefault(item => item.Id == id);

            if (terget == null)
            {
                return;
            }

            StorageHelper.DeleteLogo(terget.SmallImg);
            StorageHelper.DeleteLogo(terget.BigImg);

            settings.Items.Remove(terget);
            settings.Save();

            MessageService.Send(HttpContext.Current.Request, MessageAction.CustomNavigationSettingsUpdated);
        }
 public CustomNavigationItem GetCustomNavigationItem(Guid id)
 {
     return(CustomNavigationSettings.Load().Items.FirstOrDefault(item => item.Id == id));
 }
 public List <CustomNavigationItem> GetCustomNavigationItems()
 {
     return(CustomNavigationSettings.Load().Items);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            var currentProductId = string.IsNullOrEmpty(Request["productID"]) ? CommonLinkUtility.GetProductID() : new Guid(Request["productID"]);

            CurrentProduct = WebItemManager.Instance[currentProductId] as IProduct;

            if (CurrentProduct != null)
            {
                CurrentProductClassName = CurrentProduct.ProductClassName;
                CurrentProductName      = CurrentProduct.Name;
            }
            else
            {
                GetAddonNameAndClass();
            }

            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.EnableTariffSettings ||
                CoreContext.Configuration.Personal ||
                CurrentUser.IsVisitor() ||
                (!CurrentUser.IsAdmin() && (TariffSettings.HidePricingPage || CoreContext.Configuration.Standalone)))
            {
                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;

                Modules       = new List <IWebItem>();
                CustomModules = new List <IWebItem>();

                foreach (var webItem in productsList)
                {
                    if (webItem.ID != WebItemManager.DocumentsProductID &&
                        webItem.ID != WebItemManager.ProjectsProductID &&
                        webItem.ID != WebItemManager.CRMProductID &&
                        webItem.ID != WebItemManager.PeopleProductID &&
                        webItem.ID != WebItemManager.CommunityProductID)
                    {
                        CustomModules.Add(webItem);
                    }
                }

                var currentItem = productsList.Find(r => r.ID == WebItemManager.DocumentsProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }
                currentItem = productsList.Find(r => r.ID == WebItemManager.ProjectsProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }
                currentItem = productsList.Find(r => r.ID == WebItemManager.CRMProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }
                if (CurrentUser != null && !CurrentUser.IsOutsider())
                {
                    currentItem = _customNavItems.Find(r => r.ID == WebItemManager.MailProductID);
                    if (currentItem != null)
                    {
                        Modules.Add(currentItem);
                    }
                }
                currentItem = productsList.Find(r => r.ID == WebItemManager.PeopleProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }
                currentItem = productsList.Find(r => r.ID == WebItemManager.CommunityProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }

                var isEnabledTalk = ConfigurationManagerExtension.AppSettings["web.talk"] ?? "false";
                Addons = _customNavItems
                         .Where(item =>
                                (item.ID == WebItemManager.CalendarProductID ||
                                 (item.ID == WebItemManager.TalkProductID && isEnabledTalk == "true")))
                         .OrderBy(item => item.Context.DefaultSortOrder);

                CustomNavigationItems = CustomNavigationSettings.Load().Items.Where(x => x.ShowInMenu);
            }

            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)
                {
                    LogManager.GetLogger("ASC.Web.Studio").Error(ex);
                }
            }

            if (!DisableTariff)
            {
                var tariff = TenantExtra.GetCurrentTariff();
                TariffDays = tariff.DueDate.Date.Subtract(DateTime.Today).Days;

                if (tariff.State == TariffState.Trial && TariffDays >= 0)
                {
                    DisplayTrialCountDays = true;
                }
            }

            Settings = CompanyWhiteLabelSettings.Instance;

            ShowAppsNavItem = SetupInfo.IsVisibleSettings("AppsNavItem");

            ShowDesktopNavItem = !CoreContext.Configuration.CustomMode;

            if (!DisableGift)
            {
                DisableGift = !SecurityContext.IsAuthenticated ||
                              CoreContext.Configuration.Personal ||
                              !TenantExtra.Opensource ||
                              string.IsNullOrEmpty(SetupInfo.ControlPanelUrl) ||
                              OpensourceGiftSettings.LoadForCurrentUser().Readed;
            }

            Startup = !CoreContext.Configuration.CustomMode && TenantExtra.Saas && TenantExtra.GetTenantQuota().Free;
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            Page.RegisterStyle("~/skins/page_default.less");

            var defaultPageSettings = StudioDefaultPageSettings.Load();

            if (defaultPageSettings != null && defaultPageSettings.DefaultProductID != Guid.Empty)
            {
                if (defaultPageSettings.DefaultProductID == defaultPageSettings.FeedModuleID && !CurrentUser.IsOutsider())
                {
                    Response.Redirect("feed.aspx", true);
                }

                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))
                        {
                            var url = p.StartURL;
                            if (Request.DesktopApp())
                            {
                                url += "?desktop=true";
                                if (!string.IsNullOrEmpty(Request["first"]))
                                {
                                    url += "&first=true";
                                }
                            }
                            Response.Redirect(url, true);
                        }
                    }
                }
            }

            Master.DisabledSidePanel = true;

            Title = 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())
            {
                defaultListProducts.Add(mailProduct);
            }

            var calendarProduct = WebItemManager.Instance[WebItemManager.CalendarProductID];

            if (calendarProduct != null && !calendarProduct.IsDisabled())
            {
                defaultListProducts.Add(calendarProduct);
            }

            var talkProduct = WebItemManager.Instance[WebItemManager.TalkProductID];

            if (talkProduct != null && !talkProduct.IsDisabled())
            {
                defaultListProducts.Add(talkProduct);
            }

            var priority = GetStartProductsPriority();

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

            CustomNavigationItems = CustomNavigationSettings.Load().Items.Where(x => x.ShowOnHomePage);

            ProductsCount = defaultListProducts.Count() + CustomNavigationItems.Count() + (TenantExtra.EnableControlPanel ? 1 : 0);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            Page.RegisterStyle("~/skins/page_default.less");

            var defaultPageSettings = StudioDefaultPageSettings.Load();

            if (defaultPageSettings != null && defaultPageSettings.DefaultProductID != Guid.Empty)
            {
                if (defaultPageSettings.DefaultProductID == defaultPageSettings.FeedModuleID && !CurrentUser.IsOutsider())
                {
                    Response.Redirect("Feed.aspx", true);
                }

                var webItem = WebItemManager.Instance[defaultPageSettings.DefaultProductID];
                if (webItem != null && webItem.Visible)
                {
                    var securityInfo = WebItemSecurity.GetSecurityInfo(defaultPageSettings.DefaultProductID.ToString());
                    if (securityInfo.Enabled && WebItemSecurity.IsAvailableForMe(defaultPageSettings.DefaultProductID))
                    {
                        var url = webItem.StartURL;
                        if (Request.DesktopApp())
                        {
                            url += "?desktop=true";
                            if (!string.IsNullOrEmpty(Request["first"]))
                            {
                                url += "&first=true";
                            }
                        }
                        Response.Redirect(url, true);
                    }
                }
            }

            Master.DisabledSidePanel = true;

            Title = 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())
            {
                defaultListProducts.Add(mailProduct);
            }

            var calendarProduct = WebItemManager.Instance[WebItemManager.CalendarProductID];

            if (calendarProduct != null && !calendarProduct.IsDisabled())
            {
                defaultListProducts.Add(calendarProduct);
            }

            var talkProduct = WebItemManager.Instance[WebItemManager.TalkProductID];

            if (talkProduct != null && !talkProduct.IsDisabled())
            {
                defaultListProducts.Add(talkProduct);
            }

            var priority = GetStartProductsPriority();

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

            CustomNavigationItems = CustomNavigationSettings.Load().Items.Where(x => x.ShowOnHomePage);

            ProductsCount = defaultListProducts.Count() + CustomNavigationItems.Count() + (TenantExtra.EnableControlPanel ? 1 : 0);

            ResetCacheKey = ConfigurationManagerExtension.AppSettings["web.client.cache.resetkey"] ?? "";

            if (CurrentUser.IsOwner() && TenantExtra.Saas && !CoreContext.Configuration.CustomMode && !TenantExtra.GetTenantQuota().Free)
            {
                var collaboratorPopupSettings = CollaboratorSettings.LoadForCurrentUser();
                if (collaboratorPopupSettings.FirstVisit)
                {
                    WelcomePanelHolder.Controls.Add(LoadControl(WelcomeDashboard.Location));
                }
            }
        }