public virtual PartialViewResult CreateTopicButton() { var loggedOnReadOnlyUser = User.GetMembershipUser(MembershipService); var loggedOnloggedOnUsersRole = loggedOnReadOnlyUser.GetRole(RoleService); var viewModel = new CreateTopicButtonViewModel { LoggedOnUser = loggedOnReadOnlyUser }; if (loggedOnReadOnlyUser != null) { // Add all categories to a permission set var allCategories = _categoryService.GetAll(); 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 = RoleService.GetPermissions(category, loggedOnloggedOnUsersRole); if (permissionSet[ForumConfiguration.Instance.PermissionCreateTopics].IsTicked) { viewModel.UserCanPostTopics = true; break; } } } return(PartialView(viewModel)); }
public PartialViewResult CreateTopicButton() { var viewModel = new CreateTopicButtonViewModel { LoggedOnUser = LoggedOnUser }; if (LoggedOnUser != null) { // Add all categories to a permission set var allCategories = _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 = RoleService.GetPermissions(category, UsersRole); if (permissionSet[AppConstants.PermissionCreateTopics].IsTicked) { viewModel.UserCanPostTopics = true; break; } } } } return(PartialView(viewModel)); }
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 PartialViewResult CreateTopicButton() { var viewModel = new CreateTopicButtonViewModel { LoggedOnUser = LoggedOnReadOnlyUser }; if (LoggedOnReadOnlyUser != null) { // Add all categories to a permission set var allCategories = _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 = RoleService.GetPermissions(category, UsersRole); if (permissionSet[SiteConstants.Instance.PermissionCreateTopics].IsTicked) { viewModel.UserCanPostTopics = true; break; } } } } return PartialView(viewModel); }