public static DialogueSettings Settings() { if (!HttpContext.Current.Items.Contains(AppConstants.SiteSettingsKey)) { var currentPage = AppHelpers.CurrentPage(); var forumNode = currentPage.AncestorOrSelf(AppConstants.DocTypeForumRoot); if (forumNode == null) { // Only do this is if we can't find the forum normally forumNode = currentPage.DescendantOrSelf(AppConstants.DocTypeForumRoot); } HttpContext.Current.Items.Add(AppConstants.SiteSettingsKey, Settings(forumNode)); } return(HttpContext.Current.Items[AppConstants.SiteSettingsKey] as DialogueSettings); }
public PartialViewResult CreateTopicButton(int pageId = -1) { var viewModel = new CreateTopicButtonViewModel { LoggedOnUser = CurrentMember, CategoryId = 0, PageId = pageId }; if (CurrentMember != null) { // Add all categories to a permission set var allCategories = ServiceFactory.CategoryService.GetAll(); using (UnitOfWorkManager.NewUnitOfWork()) { foreach (var category in allCategories) { // Now check to see if they have access to any categories // if so, check they are allowed to create topics - If no to either set to false viewModel.UserCanPostTopics = false; var permissionSet = ServiceFactory.PermissionService.GetPermissions(category, _membersGroups); if (permissionSet[AppConstants.PermissionCreateTopics].IsTicked) { viewModel.UserCanPostTopics = true; break; } } var currentPage = AppHelpers.CurrentPage(); var curentCategory = ServiceFactory.CategoryService.Get(currentPage.Id, true); if (curentCategory != null) { viewModel.HasSubCategories = curentCategory.ParentCategories.Any(); } // Now check current page if (AppHelpers.CurrentPage().DocumentTypeAlias == AppConstants.DocTypeForumCategory) { // In a category - So pass id to create button viewModel.CategoryId = CurrentPage.Id; } } } return(PartialView(PathHelper.GetThemePartialViewPath("CreateTopicButton"), viewModel)); }
public static DialogueSettings Settings() { if (!HttpContext.Current.Items.Contains(AppConstants.SiteSettingsKey) || HttpContext.Current.Items[AppConstants.SiteSettingsKey] == null) { var currentPage = AppHelpers.CurrentPage(); if (currentPage != null) { var forumNode = currentPage.AncestorOrSelf(DialogueConfiguration.Instance.DocTypeForumRoot); if (forumNode == null) { // Only do this is if we can't find the forum normally forumNode = currentPage.DescendantOrSelf(DialogueConfiguration.Instance.DocTypeForumRoot); if (forumNode == null) { try { forumNode = AppHelpers.UmbHelper().TypedContentAtRoot().FirstOrDefault().Descendant(DialogueConfiguration.Instance.DocTypeForumRoot); } catch (Exception e) { return(null); } } } if (HttpContext.Current.Items[AppConstants.SiteSettingsKey] == null) { HttpContext.Current.Items[AppConstants.SiteSettingsKey] = Settings(forumNode); } else { HttpContext.Current.Items.Add(AppConstants.SiteSettingsKey, Settings(forumNode)); } } else { return(null); } } return(HttpContext.Current.Items[AppConstants.SiteSettingsKey] as DialogueSettings); }