Exemplo n.º 1
0
        private List <Item> GetDataSource()
        {
            var data = new List <Item>();

            foreach (var p in Products)
            {
                var item = new Item
                {
                    ID                     = p.ID,
                    Name                   = p.Name,
                    IconUrl                = p.GetIconAbsoluteURL(),
                    DisabledIconUrl        = p.GetDisabledIconAbsoluteURL(),
                    SubItems               = new List <Item>(),
                    ItemName               = p.GetSysName(),
                    UserOpportunitiesLabel = String.Format(Resource.AccessRightsProductUsersCan, p.Name),
                    UserOpportunities      = p.GetUserOpportunities(),
                    CanNotBeDisabled       = p.CanNotBeDisabled()
                };

                if (p.HasComplexHierarchyOfAccessRights())
                {
                    item.UserOpportunitiesLabel = String.Format(Resource.AccessRightsProductUsersWithRightsCan, item.Name);
                }

                var productInfo = WebItemSecurity.GetSecurityInfo(item.ID.ToString());
                item.Disabled       = !productInfo.Enabled;
                item.SelectedGroups = productInfo.Groups.ToList();
                item.SelectedUsers  = productInfo.Users.ToList();

                data.Add(item);
            }

            return(data);
        }
        private void InitProperties()
        {
            Products = new List <Item>();
            Modules  = new List <Item>();

            var managementPage = Page as Studio.Management;

            TenantAccessAnyone = managementPage != null ?
                                 managementPage.TenantAccess.Anyone :
                                 TenantAccessSettings.Load().Anyone;

            var webItems = WebItemManager.Instance.GetItems(WebZoneType.All, ItemAvailableState.All)
                           .Where(item => !item.IsSubItem() && !item.CanNotBeDisabled() && item.Visible)
                           .ToList();

            foreach (var webItem in webItems)
            {
                var item = new Item
                {
                    ID              = webItem.ID,
                    Name            = webItem.Name,
                    IconUrl         = webItem.GetIconAbsoluteURL(),
                    DisabledIconUrl = webItem.GetDisabledIconAbsoluteURL(),
                    SubItems        = new List <Item>(),
                    ItemName        = webItem.GetSysName(),
                    Disabled        = !WebItemSecurity.GetSecurityInfo(webItem.ID.ToString()).Enabled
                };

                foreach (var m in WebItemManager.Instance.GetSubItems(webItem.ID, ItemAvailableState.All))
                {
                    if ((m as Module) == null)
                    {
                        continue;
                    }

                    var subItem = new Item
                    {
                        ID              = m.ID,
                        Name            = m.Name,
                        DisplayedAlways = (m as Module).DisplayedAlways,
                        ItemName        = m.GetSysName(),
                        Disabled        = !WebItemSecurity.GetSecurityInfo(m.ID.ToString()).Enabled
                    };

                    item.SubItems.Add(subItem);
                }

                if (webItem is IProduct)
                {
                    Products.Add(item);
                }
                else
                {
                    Modules.Add(item);
                }
            }
        }
        private void InitProperties()
        {
            Products = new List <Item>();
            Modules  = new List <Item>();

            var webItems = WebItemManager.Instance.GetItems(WebZoneType.All, ItemAvailableState.All)
                           .Where(item => !item.IsSubItem() && !item.CanNotBeDisabled())
                           .ToList();

            foreach (var webItem in webItems)
            {
                var item = new Item
                {
                    ID              = webItem.ID,
                    Name            = webItem.Name,
                    IconUrl         = webItem.GetIconAbsoluteURL(),
                    DisabledIconUrl = webItem.GetDisabledIconAbsoluteURL(),
                    SubItems        = new List <Item>(),
                    ItemName        = webItem.GetSysName()
                };

                var productInfo = WebItemSecurity.GetSecurityInfo(item.ID.ToString());
                item.Disabled = !productInfo.Enabled;

                foreach (var m in WebItemManager.Instance.GetSubItems(webItem.ID, ItemAvailableState.All))
                {
                    if ((m as Module) == null)
                    {
                        continue;
                    }

                    var subItem = new Item
                    {
                        ID              = m.ID,
                        Name            = m.Name,
                        DisplayedAlways = (m as Module).DisplayedAlways,
                        ItemName        = m.GetSysName()
                    };

                    var moduleInfo = WebItemSecurity.GetSecurityInfo(subItem.ID.ToString());
                    subItem.Disabled = !moduleInfo.Enabled;

                    item.SubItems.Add(subItem);
                }

                if (webItem is IProduct)
                {
                    Products.Add(item);
                }
                else
                {
                    Modules.Add(item);
                }
            }
        }
Exemplo n.º 4
0
        protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context)
        {
            var admins = CoreContext.UserManager.GetUsersByGroup(Constants.GroupAdmin.ID).ToList();

            admins.AddRange(WebItemSecurity.GetProductAdministrators(ProductEntryPoint.ID).ToList());

            var securityInfo = WebItemSecurity.GetSecurityInfo(ProductEntryPoint.ID.ToString());
            var crmAvailable = securityInfo.Users.ToList();

            foreach (var group in securityInfo.Groups)
            {
                crmAvailable.AddRange(CoreContext.UserManager.GetUsersByGroup(group.ID));
            }

            var crmAvailableWithAdmins = new List <UserInfo>();

            crmAvailableWithAdmins.AddRange(crmAvailable);
            crmAvailableWithAdmins.AddRange(admins);
            crmAvailableWithAdmins = crmAvailableWithAdmins.Distinct().SortByUserName().ToList();

            using (var scope = DIHelper.Resolve())
            {
                var taskCategories = scope.Resolve <DaoFactory>().ListItemDao.GetItems(ListType.TaskCategory);
                Converter <UserInfo, object> converter = item =>
                                                         new
                {
                    avatarSmall = item.GetSmallPhotoURL(),
                    displayName = item.DisplayUserName(),
                    id          = item.ID,
                    title       = item.Title.HtmlEncode()
                };

                var categoryConverter = GetCategoryConverter("task_category");

                return(new List <KeyValuePair <string, object> >(1)
                {
                    RegisterObject(
                        new
                    {
                        crmAdminList = admins.ConvertAll(converter),
                        isCrmAvailableForAllUsers = crmAvailable.Count == 0,
                        crmAvailableWithAdminList = crmAvailableWithAdmins.ConvertAll(converter),
                        smtpSettings = Global.TenantSettings.SMTPServerSetting,
                        taskCategories = taskCategories.ConvertAll(categoryConverter)
                    })
                });
            }
        }
Exemplo n.º 5
0
        public IEnumerable <SecurityWrapper> SetAccessToWebItems(IEnumerable <ItemKeyValuePair <String, Boolean> > items)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var itemList = new ItemDictionary <String, Boolean>();

            foreach (ItemKeyValuePair <String, Boolean> item in items)
            {
                if (!itemList.ContainsKey(item.Key))
                {
                    itemList.Add(item.Key, item.Value);
                }
            }

            var defaultPageSettings = StudioDefaultPageSettings.Load();

            foreach (var item in itemList)
            {
                Guid[] subjects  = null;
                var    productId = new Guid(item.Key);

                if (item.Value)
                {
                    var webItem = WebItemManager.Instance[productId] as IProduct;
                    if (webItem != null)
                    {
                        var productInfo    = WebItemSecurity.GetSecurityInfo(item.Key);
                        var selectedGroups = productInfo.Groups.Select(group => group.ID).ToList();
                        var selectedUsers  = productInfo.Users.Select(user => user.ID).ToList();
                        selectedUsers.AddRange(selectedGroups);
                        if (selectedUsers.Count > 0)
                        {
                            subjects = selectedUsers.ToArray();
                        }
                    }
                }
                else if (productId == defaultPageSettings.DefaultProductID)
                {
                    (defaultPageSettings.GetDefault() as StudioDefaultPageSettings).Save();
                }

                WebItemSecurity.SetSecurity(item.Key, item.Value, subjects);
            }

            MessageService.Send(Request, MessageAction.ProductsListUpdated);

            return(GetWebItemSecurityInfo(itemList.Keys.ToList()));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.RegisterBodyScripts("~/UserControls/Management/DefaultPageSettings/js/defaultpage.js");

            DefaultPages = new List <DefaultStartPageWrapper>();

            var defaultPageSettings = StudioDefaultPageSettings.Load();

            DefaultProductID = defaultPageSettings.DefaultProductID;

            var products = WebItemManager.Instance.GetItemsAll <IProduct>().Where(p => p.Visible);

            foreach (var p in products)
            {
                var productInfo = WebItemSecurity.GetSecurityInfo(p.ID.ToString());
                if (productInfo.Enabled)
                {
                    DefaultPages.Add(new DefaultStartPageWrapper
                    {
                        ProductID   = p.ID,
                        DisplayName = p.Name,
                        ProductName = p.GetSysName(),
                        IsSelected  = DefaultProductID.Equals(p.ID)
                    });
                }
            }

            DefaultPages.Add(new DefaultStartPageWrapper
            {
                ProductID   = defaultPageSettings.FeedModuleID,
                DisplayName = Resources.UserControlsCommonResource.FeedTitle,
                ProductName = "feed",
                IsSelected  = DefaultProductID.Equals(defaultPageSettings.FeedModuleID)
            });

            DefaultPages.Add(new DefaultStartPageWrapper
            {
                ProductID   = Guid.Empty,
                DisplayName = Resources.Resource.DefaultPageSettingsChoiseOfProducts,
                ProductName = string.Empty,
                IsSelected  = DefaultProductID.Equals(Guid.Empty)
            });

            HelpLink = CommonLinkUtility.GetHelpLink();
        }
Exemplo n.º 7
0
        private IEnumerable <Item> GetProductItemListForSerialization()
        {
            var data = new List <Item>();

            foreach (var p in Products)
            {
                if (String.IsNullOrEmpty(p.Name))
                {
                    continue;
                }

                var userOpportunities = p.GetUserOpportunities();

                var item = new Item
                {
                    ID                     = p.ID,
                    Name                   = p.Name.HtmlEncode(),
                    IconUrl                = p.GetIconAbsoluteURL(),
                    DisabledIconUrl        = p.GetDisabledIconAbsoluteURL(),
                    SubItems               = new List <Item>(),
                    ItemName               = p.GetSysName(),
                    UserOpportunitiesLabel = String.Format(CustomNamingPeople.Substitute <Resource>("AccessRightsProductUsersCan"), p.Name).HtmlEncode(),
                    UserOpportunities      = userOpportunities != null?userOpportunities.ConvertAll(uo => uo.HtmlEncode()) : null,
                                                 CanNotBeDisabled = p.CanNotBeDisabled()
                };

                if (p.HasComplexHierarchyOfAccessRights())
                {
                    item.UserOpportunitiesLabel = String.Format(CustomNamingPeople.Substitute <Resource>("AccessRightsProductUsersWithRightsCan"), item.Name).HtmlEncode();
                }

                var productInfo = WebItemSecurity.GetSecurityInfo(item.ID.ToString());
                item.Disabled       = !productInfo.Enabled;
                item.SelectedGroups = productInfo.Groups.Select(g => new SelectedItem {
                    ID = g.ID, Name = g.Name
                });
                item.SelectedUsers = productInfo.Users.Select(g => new SelectedItem {
                    ID = g.ID, Name = g.DisplayUserName()
                });

                data.Add(item);
            }

            return(data);
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AjaxPro.Utility.RegisterTypeForAjax(GetType());
            Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/management/defaultpagesettings/js/defaultpage.js"));

            DefaultPages = new List <DefaultStartPageWrapper>();

            var defaultPageSettings = SettingsManager.Instance.LoadSettings <StudioDefaultPageSettings>(TenantProvider.CurrentTenantID);

            DefaultProductID = defaultPageSettings.DefaultProductID;

            var products = WebItemManager.Instance.GetItemsAll <IProduct>();

            foreach (var p in products)
            {
                var productInfo = WebItemSecurity.GetSecurityInfo(p.ID.ToString());
                if (productInfo.Enabled)
                {
                    DefaultPages.Add(new DefaultStartPageWrapper
                    {
                        ProductID   = p.ID,
                        DisplayName = p.Name,
                        ProductName = p.GetSysName(),
                        IsSelected  = DefaultProductID.Equals(p.ID)
                    });
                }
            }

            DefaultPages.Add(new DefaultStartPageWrapper
            {
                ProductID   = defaultPageSettings.FeedModuleID,
                DisplayName = Resources.UserControlsCommonResource.FeedTitle,
                ProductName = "feed",
                IsSelected  = DefaultProductID.Equals(defaultPageSettings.FeedModuleID)
            });

            DefaultPages.Add(new DefaultStartPageWrapper
            {
                ProductID   = Guid.Empty,
                DisplayName = Resources.Resource.DefaultPageSettingsChoiseOfProducts,
                ProductName = string.Empty,
                IsSelected  = DefaultProductID.Equals(Guid.Empty)
            });
        }
Exemplo n.º 9
0
        public IEnumerable <SecurityWrapper> GetWebItemSecurityInfo(IEnumerable <string> ids)
        {
            if (ids == null || !ids.Any())
            {
                ids = WebItemManager.Instance.GetItemsAll().Select(i => i.ID.ToString());
            }

            var subItemList = WebItemManager.Instance.GetItemsAll().Where(item => item.IsSubItem()).Select(i => i.ID.ToString());

            return(ids.Select(id => WebItemSecurity.GetSecurityInfo(id))
                   .Select(i => new SecurityWrapper
            {
                WebItemId = i.WebItemId,
                Enabled = i.Enabled,
                Users = i.Users.Select(u => EmployeeWraper.Get(u)),
                Groups = i.Groups.Select(g => new GroupWrapperSummary(g)),
                IsSubItem = subItemList.Contains(i.WebItemId),
            }).ToList());
        }
Exemplo n.º 10
0
        public IEnumerable <SecurityWrapper> SetAccessToWebItems(IEnumerable <ItemKeyValuePair <String, Boolean> > items)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var itemList = new ItemDictionary <String, Boolean>();

            foreach (ItemKeyValuePair <String, Boolean> item in items)
            {
                if (!itemList.ContainsKey(item.Key))
                {
                    itemList.Add(item.Key, item.Value);
                }
            }
            foreach (var item in itemList)
            {
                Guid[] subjects = null;

                if (item.Value)
                {
                    var webItem = WebItemManager.Instance[new Guid(item.Key)] as IProduct;
                    if (webItem != null)
                    {
                        var productInfo    = WebItemSecurity.GetSecurityInfo(item.Key);
                        var selectedGroups = productInfo.Groups.Select(group => group.ID).ToList();
                        var selectedUsers  = productInfo.Users.Select(user => user.ID).ToList();
                        selectedUsers.AddRange(selectedGroups);
                        if (selectedUsers.Count > 0)
                        {
                            subjects = selectedUsers.ToArray();
                        }
                    }
                }

                WebItemSecurity.SetSecurity(item.Key, item.Value, subjects);
            }

            return(GetWebItemSecurityInfo(itemList.Keys.ToList()));
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            Page.RegisterStyle("~/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())
                {
                    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();
        }
Exemplo n.º 12
0
        private List <Item> GetDataSource()
        {
            var data    = new List <Item>();
            var modules = WebItemManager.Instance.GetItems(WebZoneType.All, ItemAvailableState.All).Where(item => !item.IsSubItem()).ToList();

            foreach (var p in Products)
            {
                foreach (var m in modules)
                {
                    if (Guid.Equals(m.ID, p.ID))
                    {
                        modules.Remove(m);
                        break;
                    }
                }

                var item = new Item
                {
                    ID                     = p.ID,
                    Name                   = p.Name,
                    IconUrl                = p.GetIconAbsoluteURL(),
                    DisabledIconUrl        = p.GetDisabledIconAbsoluteURL(),
                    SubItems               = new List <Item>(),
                    ItemName               = p.GetSysName(),
                    UserOpportunitiesLabel = String.Format(Resources.Resource.AccessRightsProductUsersCan, p.Name),
                    UserOpportunities      = p.GetUserOpportunities(),
                    HasPermissionSettings  = true,
                    CanNotBeDisabled       = p.CanNotBeDisabled()
                };

                if (p.HasComplexHierarchyOfAccessRights())
                {
                    item.UserOpportunitiesLabel = String.Format(Resources.Resource.AccessRightsProductUsersWithRightsCan, item.Name);
                }

                var productInfo = WebItemSecurity.GetSecurityInfo(item.ID.ToString());
                item.Disabled       = !productInfo.Enabled;
                item.SelectedGroups = productInfo.Groups.ToList();
                item.SelectedUsers  = productInfo.Users.ToList();

                foreach (var m in p.Modules)
                {
                    if ((m as Module) != null && (m as IWebItem) != null)
                    {
                        var subItem = new Item
                        {
                            Name            = m.Name,
                            ID              = m.ID,
                            DisplayedAlways = (m as Module).DisplayedAlways,
                            ItemName        = m.GetSysName()
                        };

                        var moduleInfo = WebItemSecurity.GetSecurityInfo(subItem.ID.ToString());
                        subItem.Disabled       = !moduleInfo.Enabled;
                        subItem.SelectedGroups = moduleInfo.Groups.ToList();
                        subItem.SelectedUsers  = moduleInfo.Users.ToList();

                        item.SubItems.Add(subItem);
                    }
                }

                data.Add(item);
            }

            foreach (var m in modules)
            {
                var item = new Item
                {
                    ID              = m.ID,
                    Name            = m.Name,
                    IconUrl         = m.GetIconAbsoluteURL(),
                    DisabledIconUrl = m.GetDisabledIconAbsoluteURL(),
                    SubItems        = new List <Item>(),
                    ItemName        = m.GetSysName()
                };

                var moduleInfo = WebItemSecurity.GetSecurityInfo(item.ID.ToString());
                item.Disabled       = !moduleInfo.Enabled;
                item.SelectedGroups = moduleInfo.Groups.ToList();
                item.SelectedUsers  = moduleInfo.Users.ToList();

                data.Add(item);
            }

            return(data);
        }
Exemplo n.º 13
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;
                }
            }
        }
Exemplo n.º 14
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"] ?? "";
        }
Exemplo n.º 15
0
        public void SendBirthdayReminders(DateTime scheduleDate)
        {
            try
            {
                scheduleDate = scheduleDate.AddDays(1);
                List <Tenant> tenants;
                using (var db = new DbManager("core"))
                    using (var command = db.Connection.CreateCommand())
                    {
                        command.CommandTimeout = 30 * 10;
                        var q = new SqlQuery("core_user")
                                .Select("tenant")
                                .Where(!Exp.Eq("bithdate", null))
                                .Where("date_format(bithdate, '%m%d')", scheduleDate.ToString("MMdd"))
                                .Where("removed", 0)
                                .Where("status", EmployeeStatus.Active)
                                .GroupBy(1);
                        tenants = command.ExecuteList(q, DbRegistry.GetSqlDialect(db.DatabaseId))
                                  .ConvertAll(r => Convert.ToInt32(r[0]))
                                  .Select(id => CoreContext.TenantManager.GetTenant(id))
                                  .ToList();
                    }

                foreach (var tenant in tenants)
                {
                    if (tenant == null ||
                        tenant.Status != TenantStatus.Active ||
                        TariffState.NotPaid <= CoreContext.PaymentManager.GetTariff(tenant.TenantId).State)
                    {
                        continue;
                    }

                    CoreContext.TenantManager.SetCurrentTenant(tenant);

                    if (!WebItemSecurity.GetSecurityInfo(WebItemManager.CommunityProductID.ToString()).Enabled ||
                        !WebItemSecurity.GetSecurityInfo(WebItemManager.BirthdaysProductID.ToString()).Enabled)
                    {
                        continue;
                    }

                    var users                = CoreContext.UserManager.GetUsers(EmployeeStatus.Active, EmployeeType.User);
                    var birthdays            = users.Where(u => u.BirthDate.HasValue && u.BirthDate.Value.Month == scheduleDate.Month && u.BirthDate.Value.Day == scheduleDate.Day);
                    var subscriptionProvider = NotifySource.GetSubscriptionProvider();

                    foreach (var user in users)
                    {
                        if (WebItemManager.Instance[WebItemManager.CommunityProductID].IsDisabled(user.ID))
                        {
                            continue;
                        }

                        var allSubscription = subscriptionProvider.IsSubscribed(Event_BirthdayReminder, user, null);
                        foreach (var birthday in birthdays)
                        {
                            if (user.Equals(birthday))
                            {
                                continue;
                            }

                            if ((allSubscription && !subscriptionProvider.IsUnsubscribe(user, Event_BirthdayReminder, birthday.ID.ToString())) ||
                                (!allSubscription && subscriptionProvider.IsSubscribed(Event_BirthdayReminder, user, birthday.ID.ToString())))
                            {
                                client.SendNoticeToAsync(
                                    Event_BirthdayReminder,
                                    birthday.ID.ToString(),
                                    new[] { user },
                                    true,
                                    new TagValue("BirthdayUserName", birthday.DisplayUserName(false)),
                                    new TagValue("BirthdayUserUrl", CommonLinkUtility.GetUserProfile(birthday.ID)),
                                    new TagValue("BirthdayDate", birthday.BirthDate.Value.ToShortDayMonth()),
                                    new TagValue(CommonTags.Priority, 1));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.GetLogger("ASC").Error(ex);
            }
        }
Exemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.RegisterBodyScripts("~/UserControls/Management/DefaultPageSettings/js/defaultpage.js");

            DefaultPages = new List <DefaultStartPageWrapper>();

            var defaultPageSettings = StudioDefaultPageSettings.Load();

            DefaultProductID = defaultPageSettings.DefaultProductID;

            var products = WebItemManager.Instance.GetItemsAll <IProduct>().Where(p => p.Visible);

            foreach (var p in products)
            {
                var productInfo = WebItemSecurity.GetSecurityInfo(p.ID.ToString());
                if (productInfo.Enabled)
                {
                    DefaultPages.Add(new DefaultStartPageWrapper
                    {
                        ProductID   = p.ID,
                        DisplayName = p.Name,
                        ProductName = p.GetSysName(),
                        IsSelected  = DefaultProductID.Equals(p.ID)
                    });
                }
            }

            var addons        = WebItemManager.Instance.GetItemsAll <IAddon>().Where(a => a.Visible && a.ID != WebItemManager.VoipModuleID);
            var isEnabledTalk = ConfigurationManagerExtension.AppSettings["web.talk"] ?? "false";

            foreach (var a in addons)
            {
                var productInfo = WebItemSecurity.GetSecurityInfo(a.ID.ToString());
                if (a.GetSysName() == "talk" && isEnabledTalk == "false")
                {
                    continue;
                }
                if (productInfo.Enabled)
                {
                    DefaultPages.Add(new DefaultStartPageWrapper
                    {
                        ProductID   = a.ID,
                        DisplayName = a.Name,
                        ProductName = a.GetSysName(),
                        IsSelected  = DefaultProductID.Equals(a.ID)
                    });
                }
            }

            DefaultPages.Add(new DefaultStartPageWrapper
            {
                ProductID   = defaultPageSettings.FeedModuleID,
                DisplayName = UserControlsCommonResource.FeedTitle,
                ProductName = "feed",
                IsSelected  = DefaultProductID.Equals(defaultPageSettings.FeedModuleID)
            });

            DefaultPages.Add(new DefaultStartPageWrapper
            {
                ProductID   = Guid.Empty,
                DisplayName = Resource.DefaultPageSettingsChoiseOfProducts,
                ProductName = string.Empty,
                IsSelected  = DefaultProductID.Equals(Guid.Empty)
            });

            HelpLink = CommonLinkUtility.GetHelpLink();
        }
Exemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            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)
                {
                    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(), SecurityContext.CurrentAccount.ID))
                        {
                            Context.Response.Redirect(p.StartURL);
                        }
                    }
                }
            }

            Master.DisabledSidePanel = true;

            Title = Resources.Resource.MainPageTitle;
            var items = WebItemManager.Instance.GetItems(Web.Core.WebZones.WebZoneType.StartProductList);

            _showDocs = (Product)items.Find(r => r.ID == WebItemManager.DocumentsProductID);
            if (_showDocs != null)
            {
                items.RemoveAll(r => r.ID == _showDocs.ProductID);
            }
            _productRepeater.DataSource = items;
            _productRepeater.DataBind();

            var isVisitor = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor();
            var collaboratorPopupSettings = SettingsManager.Instance.LoadSettingsFor <CollaboratorSettings>(SecurityContext.CurrentAccount.ID);

            if (isVisitor && collaboratorPopupSettings.FirstVisit)
            {
                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;
                }
            }
        }
Exemplo n.º 18
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                _context = context;

                SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem);

                if (!CheckPermission())
                {
                    throw new Exception(CRMSettingResource.WebToLeadsForm_InvalidKeyException);
                }

                var productInfo = WebItemSecurity.GetSecurityInfo(ProductEntryPoint.ID.ToString());
                if (!productInfo.Enabled)
                {
                    throw new Exception(CRMCommonResource.CRMProductIsDisabled);
                }

                Contact contact;

                var fieldCollector = new NameValueCollection();

                var addressTemplate = new JObject();
                foreach (String addressPartName in Enum.GetNames(typeof(AddressPart)))
                {
                    addressTemplate.Add(addressPartName.ToLower(), "");
                }
                var addressTemplateStr = addressTemplate.ToString();

                var isCompany = false;

                var isCompanyString = GetValue("is_company");
                var firstName       = GetValue("firstName");
                var lastName        = GetValue("lastName");
                var companyName     = GetValue("companyName");

                if (!String.IsNullOrEmpty(isCompanyString))
                {
                    if (!Boolean.TryParse(isCompanyString, out isCompany))
                    {
                        throw new ArgumentException();
                    }
                }
                else //old scheme
                {
                    if (!(String.IsNullOrEmpty(firstName) || String.IsNullOrEmpty(lastName)))
                    {
                        isCompany = false;
                    }
                    else if (!String.IsNullOrEmpty(companyName))
                    {
                        isCompany = true;
                    }
                    else
                    {
                        throw new ArgumentException();
                    }
                }


                if (isCompany)
                {
                    contact = new Company();

                    ((Company)contact).CompanyName = companyName;

                    fieldCollector.Add(CRMContactResource.CompanyName, companyName);
                }
                else
                {
                    contact = new Person();

                    ((Person)contact).FirstName = firstName;
                    ((Person)contact).LastName  = lastName;
                    ((Person)contact).JobTitle  = GetValue("jobTitle");

                    fieldCollector.Add(CRMContactResource.FirstName, firstName);
                    fieldCollector.Add(CRMContactResource.LastName, lastName);

                    if (!String.IsNullOrEmpty(GetValue("jobTitle")))
                    {
                        fieldCollector.Add(CRMContactResource.JobTitle, ((Person)contact).JobTitle);
                    }
                }

                contact.About = GetValue("about");

                if (!String.IsNullOrEmpty(contact.About))
                {
                    fieldCollector.Add(CRMContactResource.About, contact.About);
                }

                if (!String.IsNullOrEmpty(GetValue("is_shared")))
                {
                    contact.ShareType = Convert.ToBoolean(GetValue("is_shared")) ? ShareType.ReadWrite : ShareType.None;
                }
                else
                {
                    contact.ShareType = (ShareType)(Convert.ToInt32(GetValue("share_type")));
                }

                contact.ID = Global.DaoFactory.GetContactDao().SaveContact(contact);

                var messageAction = contact is Company ? MessageAction.CompanyCreatedWithWebForm : MessageAction.PersonCreatedWithWebForm;
                MessageService.Send(HttpContext.Current.Request, MessageInitiator.System, messageAction, contact.GetTitle());

                var contactInfos = new List <ContactInfo>();

                foreach (var key in _context.Request.Form.AllKeys)
                {
                    if (key.StartsWith("customField_"))
                    {
                        var    fieldID    = Convert.ToInt32(key.Split(new[] { '_' })[1]);
                        String fieldValue = GetValue(key);

                        if (String.IsNullOrEmpty(fieldValue))
                        {
                            continue;
                        }

                        var customField = Global.DaoFactory.GetCustomFieldDao().GetFieldDescription(fieldID);

                        if (customField == null ||
                            !(customField.EntityType == EntityType.Contact ||
                              customField.EntityType == EntityType.Company && isCompany ||
                              customField.EntityType == EntityType.Person && !isCompany))
                        {
                            continue;
                        }

                        if (customField.FieldType == CustomFieldType.CheckBox)
                        {
                            fieldValue = fieldValue == "on" || fieldValue == "true" ? "true" : "false";
                        }
                        fieldCollector.Add(customField.Label, fieldValue);

                        Global.DaoFactory.GetCustomFieldDao().SetFieldValue(isCompany ? EntityType.Company : EntityType.Person, contact.ID, fieldID, fieldValue);
                    }
                    else if (key.StartsWith("contactInfo_"))
                    {
                        var nameParts       = key.Split(new[] { '_' }).Skip(1).ToList();
                        var contactInfoType = (ContactInfoType)Enum.Parse(typeof(ContactInfoType), nameParts[0]);
                        var category        = Convert.ToInt32(nameParts[1]);

                        bool categoryIsExists = Enum.GetValues(ContactInfo.GetCategory(contactInfoType)).Cast <object>()
                                                .Any(categoryEnum => (int)categoryEnum == category);
                        if (!categoryIsExists)
                        {
                            throw new ArgumentException(String.Format("Category for {0} not found", nameParts[0]));
                        }

                        if (contactInfoType == ContactInfoType.Address)
                        {
                            var addressPart = (AddressPart)Enum.Parse(typeof(AddressPart), nameParts[2]);

                            var findedAddress = contactInfos.Find(item => (category == item.Category) && (item.InfoType == ContactInfoType.Address));

                            if (findedAddress == null)
                            {
                                findedAddress = new ContactInfo
                                {
                                    Category  = category,
                                    InfoType  = contactInfoType,
                                    Data      = addressTemplateStr,
                                    ContactID = contact.ID
                                };

                                contactInfos.Add(findedAddress);
                            }

                            var addressParts = JObject.Parse(findedAddress.Data);

                            addressParts[addressPart.ToString().ToLower()] = GetValue(key);

                            findedAddress.Data = addressParts.ToString();

                            continue;
                        }

                        var fieldValue = GetValue(key);

                        if (String.IsNullOrEmpty(fieldValue))
                        {
                            continue;
                        }

                        contactInfos.Add(new ContactInfo
                        {
                            Category  = category,
                            InfoType  = contactInfoType,
                            Data      = fieldValue,
                            ContactID = contact.ID,
                            IsPrimary = true
                        });
                    }
                    else if (String.Compare(key, "tag", true) == 0)
                    {
                        var tags = _context.Request.Form.GetValues("tag");

                        Global.DaoFactory.GetTagDao().SetTagToEntity(EntityType.Contact, contact.ID, tags);
                    }
                }

                contactInfos.ForEach(item => fieldCollector[item.InfoType.ToLocalizedString()] = PrepareteDataToView(item.InfoType, item.Data));

                Global.DaoFactory.GetContactInfoDao().SaveList(contactInfos);

                var notifyList = GetValue("notify_list");

                if (!String.IsNullOrEmpty(notifyList))
                {
                    NotifyClient.Instance.SendAboutCreateNewContact(
                        notifyList
                        .Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(item => new Guid(item)).ToList(), contact.ID, contact.GetTitle(), fieldCollector);
                }

                var managersList = GetValue("managers_list");
                SetPermission(contact, managersList);

                if (contact is Person && !String.IsNullOrEmpty(companyName))
                {
                    AssignPersonToCompany((Person)contact, companyName, managersList);
                }

                if (contact is Company && !String.IsNullOrEmpty(firstName) && !String.IsNullOrEmpty(lastName))
                {
                    AssignCompanyToPerson((Company)contact, firstName, lastName, managersList);
                }

                SecurityContext.Logout();

                var newURL = new UriBuilder(GetValue("return_url")).Uri.AbsoluteUri;
                context.Response.Buffer = true;
                context.Response.Status = "302 Object moved";
                context.Response.AddHeader("Location", newURL);
                context.Response.Write("<HTML><Head>");
                context.Response.Write(String.Format("<META HTTP-EQUIV=Refresh CONTENT=\"0;URL={0}\">", newURL));
                context.Response.Write(String.Format("<Script>window.location='{0}';</Script>", newURL));
                context.Response.Write("</Head>");
                context.Response.Write("</HTML>");
            }
            catch (Exception error)
            {
                LogManager.GetLogger("ASC.CRM").Error(error);
                context.Response.StatusCode = 400;
                context.Response.Write(HttpUtility.HtmlEncode(error.Message));
            }
        }
Exemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            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)
                {
                    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(), SecurityContext.CurrentAccount.ID))
                        {
                            Context.Response.Redirect(p.StartURL);
                        }
                    }
                }
            }

            Master.DisabledSidePanel = true;
            Master.TopStudioPanel.DisableProductNavigation = true;

            Title = Resources.Resource.MainPageTitle;
            var items = WebItemManager.Instance.GetItems(Web.Core.WebZones.WebZoneType.StartProductList);

            _showDocs = (Product)items.Find(r => r.ID == WebItemManager.DocumentsProductID);
            if (_showDocs != null)
            {
                items.RemoveAll(r => r.ID == _showDocs.ProductID);
            }
            _productRepeater.DataSource = items;
            _productRepeater.DataBind();



            _welcomeBoxContainer.Options.IsPopup = true;
            var showWelcomePopup = ((Request["first"] ?? "") == "1");

            if (showWelcomePopup && Session["first"] == null)
            {
                Session["first"] = new object();
            }
            else
            {
                showWelcomePopup = false;
            }

            _afterRegistryWelcomePopupBoxHolder.Visible = showWelcomePopup;

            var isVisitor = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor();
            var collaboratorPopupSettings = SettingsManager.Instance.LoadSettingsFor <CollaboratorSettings>(SecurityContext.CurrentAccount.ID);

            if (showWelcomePopup)
            {
                Page.RegisterInlineScript("StudioBlockUIManager.blockUI('#studio_welcomeMessageBox', 400, 300, 0);");
            }

            if (isVisitor && collaboratorPopupSettings.FirstVisit)
            {
                AjaxPro.Utility.RegisterTypeForAjax(GetType());

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

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