public override void Init()
        {
            context = new ProductContext
            {
                MasterPageFile = String.Concat(PathProvider.BaseVirtualPath, "Masters/BasicTemplate.Master"),
                DisabledIconFileName = "product_disabled_logo.png",
                IconFileName = "product_logo.png",
                LargeIconFileName = "product_logolarge.png",
                DefaultSortOrder = 30,
                SubscriptionManager = new ProductSubscriptionManager(),
                SpaceUsageStatManager = new CRMSpaceUsageStatManager(),
                AdminOpportunities = () => CRMCommonResource.ProductAdminOpportunities.Split('|').ToList(),
                UserOpportunities = () => CRMCommonResource.ProductUserOpportunities.Split('|').ToList(),
            };

            if (!FilesIntegration.IsRegisteredFileSecurityProvider("crm", "crm_common"))
            {
                FilesIntegration.RegisterFileSecurityProvider("crm", "crm_common", new FileSecurityProvider());
            }
            if (!FilesIntegration.IsRegisteredFileSecurityProvider("crm", "opportunity"))
            {
                FilesIntegration.RegisterFileSecurityProvider("crm", "opportunity", new FileSecurityProvider());
            }

            SearchHandlerManager.Registry(new SearchHandler());
        }
        public override void Init(ProductContext context)
        {
            modules = ModuleManager.LoadModules(HttpContext.Current.Server.MapPath("~/products/community/modules"));

            var globalHandlers = new List<IGlobalHandler>(0);
            context.GlobalHandler = new GlobalHandlerComposite(globalHandlers);

            foreach (var module in modules)
            {
                if (module.Context.GlobalHandler != null) globalHandlers.Add(module.Context.GlobalHandler);
            }

            context.MasterPageFile = "~/products/community/community.master";
            context.ImageFolder = "images";
            context.ThemesFolderVirtualPath = "~/products/community/app_themes";
            context.DisabledIconFileName = "product_disabled_logo.png";
            context.IconFileName = "product_logo.png";
            context.LargeIconFileName = "product_logolarge.png";

            context.UserActivityControlLoader = new UserActivityControlLoader();
            context.DefaultSortOrder = 40;

            context.SubscriptionManager = new CommunitySubscriptionManager();

            context.WhatsNewHandler = new CommunityWhatsNewHandler();
            context.SpaceUsageStatManager = new CommunitySpaceUsageStatManager();

            context.AdminOpportunities = GetAdminOpportunities;
            context.UserOpportunities = GetUserOpportunities;

            ctx = context;
        }
        public override void Init()
        {
            _context = new ProductContext
            {
                MasterPageFile = "~/products/people/PeopleBaseTemplate.Master",
                DisabledIconFileName = "product_disabled_logo.png",
                IconFileName = "product_logo.png",
                LargeIconFileName = "product_logolarge.png",
                DefaultSortOrder = 50,
            };

            SearchHandlerManager.Registry(new SearchHandler());
        }
        private void RegisterProduct(IProduct product, Assembly assembly)
        {
            try
            {
                var productContext = new ProductContext { AssemblyName = assembly.FullName };

                product.Init(productContext);
                ProductContexts.Add(product.ID, productContext);
                WebItemManager.Instance.RegistryItem(product);

                if (productContext.GlobalHandler != null)
                {
                    GlobalHandlers.Add(productContext.GlobalHandler);
                }
                foreach (var module in product.Modules)
                {
                    try
                    {
                        if (module.Context != null && module.Context.UserActivityPublishers != null)
                        {
                            module.Context.UserActivityPublishers.ForEach(p => p.DoUserActivity += DoUserActivityHandler);
                        }
                        if (module.Context != null && module.Context.SearchHandler != null)
                        {
                            SearchHandlerManager.Registry(module.Context.SearchHandler);
                        }
                    }
                    catch (Exception exc)
                    {
                        log.Error(string.Format("Couldn't load module activity publisher {0}", module.Name), exc);
                    }
                }
                if (product.Context.UserActivityPublishers != null)
                {
                    product.Context.UserActivityPublishers.ForEach(p => p.DoUserActivity += DoUserActivityHandler);
                }

                Products.Add(product);
                Products.Sort((p1, p2) => p1.Context.DefaultSortOrder.CompareTo(p2.Context.DefaultSortOrder));

                log.DebugFormat("product {0} loaded", product.Name);
            }
            catch (Exception exc)
            {
                log.Error(string.Format("Couldn't load product {0}", product.Name), exc);
            }
        }
 public override void Init()
 {
     _productContext =
         new ProductContext
             {
                 MasterPageFile = CommonLinkUtility.FilesBaseVirtualPath + "masters/basictemplate.master",
                 DisabledIconFileName = "product_disabled_logo.png",
                 IconFileName = "product_logo.png",
                 LargeIconFileName = "product_logolarge.png",
                 DefaultSortOrder = 10,
                 SubscriptionManager = new SubscriptionManager(),
                 SpaceUsageStatManager = new FilesSpaceUsageStatManager(),
                 AdminOpportunities = () => FilesCommonResource.ProductAdminOpportunities.Split('|').ToList(),
                 UserOpportunities = () => FilesCommonResource.ProductUserOpportunities.Split('|').ToList(),
                 CanNotBeDisabled = true,
             };
     SearchHandlerManager.Registry(new SearchHandler());
 }
        public override void Init()
        {
            ctx = new ProductContext
            {
                MasterPageFile = "~/products/community/community.master",
                DisabledIconFileName = "product_disabled_logo.png",
                IconFileName = "product_logo.png",
                LargeIconFileName = "product_logolarge.png",
                DefaultSortOrder = 40,

                SubscriptionManager = new CommunitySubscriptionManager(),

                SpaceUsageStatManager = new CommunitySpaceUsageStatManager(),

                AdminOpportunities = () => CommunityResource.ProductAdminOpportunities.Split('|').ToList(),
                UserOpportunities = () => CommunityResource.ProductUserOpportunities.Split('|').ToList(),
            };
        }
        public override void Init(ProductContext productContext)
        {
            productContext.ThemesFolderVirtualPath = String.Concat(PathProvider.BaseVirtualPath, "App_Themes");
            productContext.ImageFolder = "images";
            productContext.MasterPageFile = String.Concat(PathProvider.BaseVirtualPath, "Masters/BasicTemplate.Master").ToLower();
            productContext.DisabledIconFileName = "product_disabled_logo.png";
            productContext.IconFileName = "product_logo.png";
            productContext.LargeIconFileName = "product_logolarge.png";
            productContext.DefaultSortOrder = 30;

            productContext.UserActivityControlLoader = new UserActivityControlLoader();
            productContext.UserActivityPublishers = new List<IUserActivityPublisher> {new FilesActivityPublisher()};
            UserActivityManager.AddFilter(new FilesActivityPublisher());
            productContext.SubscriptionManager = new SubscriptionManager();
            productContext.SpaceUsageStatManager = new FilesSpaceUsageStatManager();
            productContext.AdminOpportunities = GetAdminOpportunities;
            productContext.UserOpportunities = GetUserOpportunities;
            productContext.CanNotBeDisabled = true;

            _moduleContext = new ModuleContext {SearchHandler = new SearchHandler(), StatisticProvider = new StatisticProvider()};
            _productContext = productContext;
        }
        public override void Init(ProductContext productContext)
        {
            productContext.ThemesFolderVirtualPath = String.Concat(PathProvider.BaseVirtualPath, "App_Themes");
            productContext.ImageFolder = "images";
            productContext.MasterPageFile = String.Concat(PathProvider.BaseVirtualPath, "Masters/BasicTemplate.Master");
            productContext.DisabledIconFileName = "product_disabled_logo.png";
            productContext.IconFileName = "product_logo.png";
            productContext.LargeIconFileName = "product_logolarge.png";
            productContext.UserActivityPublishers = new List<IUserActivityPublisher>() { new TimeLinePublisher() };
            productContext.DefaultSortOrder = 20;
            productContext.SubscriptionManager = new ProductSubscriptionManager();
            productContext.SpaceUsageStatManager = new CRMSpaceUsageStatManager();
            productContext.AdminOpportunities = GetAdminOpportunities;
            productContext.UserOpportunities = GetUserOpportunities;
           
            if (!FilesIntegration.IsRegisteredFileSecurityProvider("crm", "crm_common"))
                FilesIntegration.RegisterFileSecurityProvider("crm", "crm_common", new FileSecurityProvider());
            
            _productContext = productContext;

            SearchHandlerManager.Registry(new SearchHandler());
         
        }
        public override void Init()
        {
            _productContext =
                new ProductContext
                    {
                        MasterPageFile = FilesLinkUtility.FilesBaseVirtualPath + "masters/basictemplate.master",
                        DisabledIconFileName = "product_disabled_logo.png",
                        IconFileName = "product_logo.png",
                        LargeIconFileName = "product_logolarge.png",
                        DefaultSortOrder = 10,
                        SubscriptionManager = new SubscriptionManager(),
                        SpaceUsageStatManager = new FilesSpaceUsageStatManager(),
                        AdminOpportunities = () => FilesCommonResource.ProductAdminOpportunities.Split('|').ToList(),
                        UserOpportunities = () => FilesCommonResource.ProductUserOpportunities.Split('|').ToList(),
                        CanNotBeDisabled = true,
                    };
            SearchHandlerManager.Registry(new SearchHandler());

            GlobalConfiguration.Configuration.Routes.MapHttpRoute(
                name: "FileStorageService",
                routeTemplate: "products/files/services/wcfservice/service.svc/{action}",
                defaults: new { controller = "FileStorageService" });
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;
        }
        public override void Init(ProductContext productContext)
        {
            if (!DbRegistry.IsDatabaseRegistered(Global.DB_ID))
                DbRegistry.RegisterDatabase(Global.DB_ID, WebConfigurationManager.ConnectionStrings[Global.DB_ID]);

            new SearchHandler();

            ConfigurationManager.Configure(ID, PathProvider.BaseVirtualPath, String.Empty, Global.FileStorageModule);

            productContext.ThemesFolderVirtualPath = String.Concat(PathProvider.BaseVirtualPath, "App_Themes");
            productContext.ImageFolder = "images";
            productContext.MasterPageFile = String.Concat(PathProvider.BaseVirtualPath, "Masters/BasicTemplate.Master");
            productContext.DisabledIconFileName = "product_disabled_logo.png";
            productContext.IconFileName = "product_logo.png";
            productContext.LargeIconFileName = "product_logolarge.png";
            productContext.SubscriptionManager = new ProductSubscriptionManager();
            productContext.UserActivityControlLoader = new ProjectActivity();
            productContext.WhatsNewHandler = new WhatsNewHandler();
            productContext.UserActivityPublishers = new List<IUserActivityPublisher>() { new TimeLinePublisher() };
            productContext.DefaultSortOrder = 10;
            productContext.SpaceUsageStatManager = new ProjectsSpaceUsageStatManager();
            productContext.AdminOpportunities = GetAdminOpportunities;
            productContext.UserOpportunities = GetUserOpportunities;
            productContext.HasComplexHierarchyOfAccessRights = true;

            context = productContext;

            NotifyClient.Instance.Client.RegisterSendMethod(SendMsgMilestoneDeadline, TimeSpan.FromDays(1), DateTime.UtcNow.Date.AddHours(7));
            NotifyClient.Instance.Client.RegisterSendMethod(ReportHelper.SendAutoReports, TimeSpan.FromHours(1), DateTime.UtcNow.Date.AddHours(DateTime.UtcNow.Hour));
            NotifyClient.Instance.Client.RegisterSendMethod(TaskHelper.SendAutoReminderAboutTask, TimeSpan.FromHours(1), DateTime.UtcNow.Date.AddHours(DateTime.UtcNow.Hour));

            NotifyClient.Instance.Client.AddInterceptor(InterceptorSecurity);

            UserActivityManager.AddFilter(new WhatsNewHandler());

            FilesIntegration.RegisterFileSecurityProvider("projects", "project", new SecurityAdapterProvider());
            SearchHandlerManager.Registry(new SearchHandler());
        }
        public override void Init()
        {
            context = new ProductContext
                          {
                              MasterPageFile = String.Concat(PathProvider.BaseVirtualPath, "Masters/BasicTemplate.Master"),
                              DisabledIconFileName = "product_disabled_logo.png",
                              IconFileName = "product_logo.png",
                              LargeIconFileName = "product_logolarge.png",
                              SubscriptionManager = new ProductSubscriptionManager(),
                              DefaultSortOrder = 20,
                              SpaceUsageStatManager = new ProjectsSpaceUsageStatManager(),
                              AdminOpportunities = () => ProjectsCommonResource.ProductAdminOpportunities.Split('|').ToList(),
                              UserOpportunities = () => ProjectsCommonResource.ProductUserOpportunities.Split('|').ToList(),
                              HasComplexHierarchyOfAccessRights = true,
                          };

            FilesIntegration.RegisterFileSecurityProvider("projects", "project", new SecurityAdapterProvider());
            SearchHandlerManager.Registry(new SearchHandler());

            var securityInterceptor = new SendInterceptorSkeleton(
                "ProjectInterceptorSecurity",
                InterceptorPlace.DirectSend,
                InterceptorLifetime.Global,
                (r, p) =>
                    {
                        try
                        {
                            var data = r.ObjectID.Split('_');
                            var entityType = data[0];
                            var entityId = Convert.ToInt32(data[1]);

                            var projectId = 0;
                            
                            if(data.Length == 3)
                                projectId = Convert.ToInt32(r.ObjectID.Split('_')[2]);

                            switch (entityType)
                            {
                                case "Task":
                                    var task = Global.EngineFactory.GetTaskEngine().GetByID(entityId, false);

                                    if (task == null && projectId != 0)
                                    {
                                        var project = Global.EngineFactory.GetProjectEngine().GetByID(projectId, false);
                                        return !ProjectSecurity.CanRead(project, new Guid(r.Recipient.ID));
                                    }

                                    return !ProjectSecurity.CanRead(task, new Guid(r.Recipient.ID));
                                case "Message":
                                    var discussion = Global.EngineFactory.GetMessageEngine().GetByID(entityId, false);

                                    if (discussion == null && projectId != 0)
                                    {
                                        var project = Global.EngineFactory.GetProjectEngine().GetByID(projectId, false);
                                        return !ProjectSecurity.CanRead(project, new Guid(r.Recipient.ID));
                                    }

                                    return !ProjectSecurity.CanRead(discussion, new Guid(r.Recipient.ID));
                                case "Milestone":
                                    var milestone = Global.EngineFactory.GetMilestoneEngine().GetByID(entityId, false);

                                    if (milestone == null && projectId != 0)
                                    {
                                        var project = Global.EngineFactory.GetProjectEngine().GetByID(projectId, false);
                                        return !ProjectSecurity.CanRead(project, new Guid(r.Recipient.ID));
                                    }

                                    return !ProjectSecurity.CanRead(milestone, new Guid(r.Recipient.ID));
                            }
                        }
                        catch (Exception ex)
                        {
                            LogManager.GetLogger("ASC.Projects.Tasks").Error("Send", ex);
                        }
                        return false;
                    });

            NotifyClient.Instance.Client.AddInterceptor(securityInterceptor);
        }