protected void Page_Init(object sender, System.EventArgs e) { // CHECK IF WISHLISTS DISABLED if (!AbleContext.Current.Store.Settings.WishlistsEnabled) { WishlistCaption.Visible = false; WishlistMultiView.SetActiveView(WishlistDisabledView); return; } string strViewCode = Request.QueryString["ViewCode"]; Guid viewCode = new Guid(); if (Guid.TryParse(strViewCode, out viewCode)) { _Wishlist = WishlistDataSource.LoadForViewCode(viewCode); } if (_Wishlist == null) { Response.Redirect(AbleCommerce.Code.NavigationHelper.GetHomeUrl()); return; } _WishlistId = _Wishlist.Id; _Wishlist.Recalculate(); IList <WishlistItem> items = _Wishlist.WishlistItems; Product product; WishlistItem item; var user = AbleContext.Current.User; List <int> groups = (from ug in AbleContext.Current.User.UserGroups select ug.GroupId).ToList <int>(); for (int i = items.Count - 1; i >= 0; i--) { item = items[i]; product = item.Product; if (product == null || product.Visibility == CatalogVisibility.Private || isVariantInvalid(item)) { items.RemoveAt(i); } else if (!user.IsAdmin) { if (product.EnableGroups) { if (groups.Count > 0) { bool isInGroup = product.ProductGroups.Any <ProductGroup>(pg => groups.Contains(pg.Group.Id)); if (!isInGroup) { items.RemoveAt(i); } } else { items.RemoveAt(i); } } } } WishlistGrid.DataSource = items; WishlistGrid.DataBind(); if (!string.IsNullOrEmpty(_Wishlist.ViewPassword)) { string currentPassword = (string)Session["Wishlist" + _WishlistId.ToString() + "_Password"]; if ((currentPassword == null) || (currentPassword != _Wishlist.ViewPassword)) { WishlistMultiView.SetActiveView(PasswordView); AbleCommerce.Code.PageHelper.SetDefaultButton(Password, CheckPasswordButton.ClientID); } } if (WishlistMultiView.ActiveViewIndex == 0) { WishlistCaption.Text = string.Format(_Caption, GetUserName(_Wishlist.User)); } else { WishlistCaption.Text = "Enter Wishlist Password"; } }