private bool IsHomePage() { if (_webpage == null) { return(false); } string homePageUrl = NavigationHelper.GetHomeUrl(); string webpageUrl = _webpage.CustomUrl; if (!webpageUrl.StartsWith("~/")) { webpageUrl = "~/" + webpageUrl; } return(string.Compare(webpageUrl, homePageUrl) == 0); }
protected void Page_PreInit(object sender, EventArgs e) { _link = LinkDataSource.Load(PageHelper.GetLinkId()); if (_link != null) { if ((_link.Visibility == CatalogVisibility.Private) && (!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles))) { Response.Redirect(NavigationHelper.GetHomeUrl()); } } else { NavigationHelper.Trigger404(Response, "Invalid Link"); } }
protected void Page_PreInIt() { _category = CategoryDataSource.Load(PageHelper.GetCategoryId()); if (_category != null) { if ((_category.Visibility == CatalogVisibility.Private) && (!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles))) { Response.Redirect(NavigationHelper.GetHomeUrl()); } } else { NavigationHelper.Trigger404(Response, "Invalid Category"); } // INITIALIZE TO DEFAULT LAYOUT string layout = AbleContext.Current.Store.Settings.CategoriesDefaultLayout; _webpage = _category.Webpage; if (_webpage == null) { _webpage = WebpageDataSource.Load(AbleContext.Current.Store.Settings.CategoryWebpageId); } if (_webpage != null) { // CHECK FOR LAYOUT OVERRIDE if (_webpage.Layout != null) { layout = _webpage.Layout.FilePath; } // CHECK FOR THEME OVERRIDE if (!string.IsNullOrEmpty(_webpage.Theme) && CommerceBuilder.UI.Theme.Exists(_webpage.Theme)) { this.Theme = _webpage.Theme; } } // SET THE LAYOUT if (!string.IsNullOrEmpty(layout)) { this.MasterPageFile = layout; } }
protected void Page_PreInit(object sender, EventArgs e) { _webpage = WebpageDataSource.Load(PageHelper.GetWebpageId()); if (_webpage != null) { if ((_webpage.Visibility == CatalogVisibility.Private) && (!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles))) { if (!IsHomePage()) { Response.Redirect(NavigationHelper.GetHomeUrl()); } else { Server.Transfer(NavigationHelper.GetHomeUrl()); } } } else { NavigationHelper.Trigger404(Response, "Invalid Webpage"); } // INITIALIZE TO DEFAULT LAYOUT string layout = AbleContext.Current.Store.Settings.WebpagesDefaultLayout; // CHECK FOR LAYOUT OVERRIDE if (_webpage.Layout != null) { layout = _webpage.Layout.FilePath; } // CHECK FOR THEME OVERRIDE if (!string.IsNullOrEmpty(_webpage.Theme) && CommerceBuilder.UI.Theme.Exists(_webpage.Theme)) { this.Theme = _webpage.Theme; } // SET THE LAYOUT if (!string.IsNullOrEmpty(layout)) { this.MasterPageFile = layout; } }
protected void Page_PreInit(object sender, EventArgs e) { int productId = PageHelper.GetProductId(); _product = ProductDataSource.Load(productId); if (_product != null) { // DELAYED QUERIES TO EAGER LOAD RELATED DATA FOR PERFORMANCE BOOST. var futureQuery = NHibernateHelper.QueryOver <Product>() .Where(p => p.Id == productId) .Fetch(p => p.ProductKitComponents).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .Where(p => p.Id == productId) .Fetch(p => p.ProductOptions).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .Where(p => p.Id == productId) .Fetch(p => p.ProductTemplates).Eager .Future <Product>(); NHibernateHelper.QueryOver <Product>() .Where(p => p.Id == productId) .Fetch(p => p.Specials).Eager .Future <Product>(); if (_product.IsKit) { NHibernateHelper.QueryOver <KitComponent>() .Fetch(kc => kc.KitProducts).Eager .JoinQueryOver <ProductKitComponent>(kc => kc.ProductKitComponents) .Where(pkc => pkc.ProductId == productId) .Future <KitComponent>(); NHibernateHelper.QueryOver <KitProduct>() .Fetch(kp => kp.Product).Eager .Fetch(kp => kp.Product.Specials).Eager .JoinQueryOver <KitComponent>(kp => kp.KitComponent) .JoinQueryOver <ProductKitComponent>(kc => kc.ProductKitComponents) .Where(pkc => pkc.ProductId == productId) .Future <KitProduct>(); } // TRIGGER QUEUED FUTURE QUERIES futureQuery.ToList <Product>(); if ((_product.Visibility == CatalogVisibility.Private) && (!AbleContext.Current.User.IsInRole(Role.CatalogAdminRoles))) { Response.Redirect(NavigationHelper.GetHomeUrl()); } var user = AbleContext.Current.User; if (!user.IsAdmin) { if (_product.EnableGroups) { List <int> groups = (from ug in AbleContext.Current.User.UserGroups select ug.GroupId).ToList <int>(); if (groups.Count > 0) { bool isInGroup = _product.ProductGroups.Any <ProductGroup>(pg => groups.Contains(pg.Group.Id)); if (!isInGroup) { Response.Redirect(NavigationHelper.GetHomeUrl()); } } else { Response.Redirect(NavigationHelper.GetHomeUrl()); } } } } else { NavigationHelper.Trigger404(Response, "Invalid Product"); } // INITIALIZE TO DEFAULT LAYOUT string layout = AbleContext.Current.Store.Settings.ProductsDefaultLayout; _webpage = _product.Webpage; if (_webpage == null) { _webpage = WebpageDataSource.Load(AbleContext.Current.Store.Settings.ProductWebpageId); } if (_webpage != null) { // CHECK FOR LAYOUT OVERRIDE if (_webpage.Layout != null) { layout = _webpage.Layout.FilePath; } // CHECK FOR THEME OVERRIDE if (!string.IsNullOrEmpty(_webpage.Theme) && CommerceBuilder.UI.Theme.Exists(_webpage.Theme)) { this.Theme = _webpage.Theme; } } // SET THE LAYOUT if (!string.IsNullOrEmpty(layout)) { this.MasterPageFile = layout; } }