// GET: Admin public ActionResult AnonymousViewEditor() { var types = _contentDefinitionService.GetTypes(); var permissions = _roleService.GetInstalledPermissions(); var simulation = UserSimulation.Create("Anonymous"); var effectivePermissions = permissions .SelectMany(group => group.Value) .Where(permission => _authorizationService.TryCheckAccess(permission, simulation, null)) .Select(permission => permission.Name) .Distinct() .ToList(); var viewModel = new AnonymousViewEditorViewModel(); foreach (var type in types) { viewModel.TypesSecuritySettings.Add(new TypeSecuritySettings() { TypeName = type.Name, IsSecurable = type.Settings.GetModel <ContentTypeSettings>().Securable, Permission = "View_" + type.Name, CanView = effectivePermissions.Contains("View_" + type.Name) }); } viewModel.AllowViewAllContent = effectivePermissions.Contains("ViewContent"); return(View(viewModel)); }
public ActionResult List() { if (!Services.Authorizer.Authorize(Permissions.ViewContentTypes, T("Not allowed to view content types."))) { return(new HttpUnauthorizedResult()); } return(View("List", new ListContentTypesViewModel { Types = _contentDefinitionService.GetTypes() })); }
public async Task <ActionResult> List() { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ViewContentTypes)) { return(Unauthorized()); } return(View("List", new ListContentTypesViewModel { Types = _contentDefinitionService.GetTypes() })); }
public IEnumerable <StereotypeDescription> GetStereotypes() { // Harvest all available stereotypes by finding out about the stereotype of all content types var stereotypes = _contentDefinitionService.GetTypes().Where(x => x.Settings["Stereotype"] != null).Select(x => x.Settings["Stereotype"].ToString()).Distinct(); return(stereotypes.Select(x => new StereotypeDescription { DisplayName = x, Stereotype = x })); }
public ActionResult Settings() { if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Yout have to be an Administrator to edit ContentTypePermission settings!"))) { return(new HttpUnauthorizedResult()); } var model = _contentTypePermissionSettingsService.ReadSettings(); var listconttype = _contentDefinitionService.GetTypes().Select(x => new SelectListItem() { Text = x.DisplayName, Value = x.Name }).ToList(); listconttype.Insert(0, new SelectListItem { Text = " ", Value = " " }); ViewData["ListContentTypes"] = new SelectList(listconttype, "Value", "Text"); //_orchardServices..ContentManager.GetContentTypeDefinitions() var tmplistpermissions = _roleService.GetInstalledPermissions(); List <SelectListItem> listpermissions = new List <SelectListItem>(); foreach (IEnumerable <Permission> sad in tmplistpermissions.Values) { foreach (Permission perm in sad) { listpermissions.Add(new SelectListItem { Text = perm.Name, Value = perm.Name }); } } listpermissions.Insert(0, new SelectListItem { Text = "", Value = "" }); ViewData["ListPermissions"] = new SelectList(listpermissions.OrderBy(x => x.Text), "Value", "Text"); // var listpermissions = _permissionProvider.GetPermissions(); // listpermissions.Select(x => new SelectListItem() { Text = x.Name, Value = x.Name }); // IDictionary<string, IEnumerable<Orchard.Security.Permissions.Permission>> // .Select(x => new SelectListItem() { Text = x.Key, Value = x.Key }); //_orchardServices.ContentManager.GetContentTypeDefinitions().Select(x => x.Name).ToList(); // var listpermissions = _contentDefinitionService.GetTypes().Select(x => new SelectListItem() { Text = x.DisplayName, Value = x.Name }); //_orchardServices..ContentManager.GetContentTypeDefinitions() // ViewData["ListContentTypes"] = new SelectList(listconttype, "Value", "Text"); ContentTypePermissionRecord cpr = new ContentTypePermissionRecord(); cpr.Id = 0; model.ListContPermission.Add(cpr); return(View(model)); }
public async Task <ActionResult> List(string definitiontype = "") { if (!await _authorizationService.AuthorizeAsync(User, Permissions.ViewContentTypes)) { return(Forbid()); } var contentTypeDefinitions = new ListContentTypesViewModel { Types = _contentDefinitionService.GetTypes() }; string listTitle = "Content Types"; //filter by definition IEnumerable <EditTypeViewModel> contentTypeDefinitionsSpecific; if (string.IsNullOrEmpty(definitiontype)) { listTitle = "Content Types"; contentTypeDefinitionsSpecific = contentTypeDefinitions.Types.Where(x => String.IsNullOrWhiteSpace(x.TypeDefinition.GetSettings <ContentTypeSettings>().Stereotype)); } else if (definitiontype == "Other") { listTitle = definitiontype; var blackList = new[] { null, "", "Widget", "MenuItem", "ActionCommand" }; //get all custom stereotypes not included in standard ones contentTypeDefinitionsSpecific = contentTypeDefinitions.Types.Where(x => !blackList.Contains(x.TypeDefinition.GetSettings <ContentTypeSettings>().Stereotype)); } else { listTitle = definitiontype; contentTypeDefinitionsSpecific = contentTypeDefinitions.Types.Where(x => x.TypeDefinition.GetSettings <ContentTypeSettings>().Stereotype == definitiontype); } return(View("List", new ListContentTypesViewModel { Types = contentTypeDefinitionsSpecific, ListTitle = listTitle.CamelCaseToHumanCase() })); }
public ActionResult List() { return(View("List", new ListContentTypesViewModel { Types = _contentDefinitionService.GetTypes() })); }