public async Task <IActionResult> Create(string id, string menuContentItemId, string menuItemId) { if (String.IsNullOrWhiteSpace(id)) { return(NotFound()); } if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageMenu)) { return(Unauthorized()); } var contentItem = _contentManager.New(id); var model = await _contentItemDisplayManager.BuildEditorAsync(contentItem, this); model.MenuContentItemId = menuContentItemId; model.MenuItemId = menuItemId; return(View(model)); }
public async Task <IActionResult> Create(string id) { if (String.IsNullOrWhiteSpace(id)) { return(NotFound()); } var contentItem = await _contentManager.NewAsync(id); // Set the current user as the owner to check for ownership permissions on creation contentItem.Owner = User.Identity.Name; if (!await _authorizationService.AuthorizeAsync(User, Permissions.EditContent, contentItem)) { return(Forbid()); } var model = await _contentItemDisplayManager.BuildEditorAsync(contentItem, _updateModelAccessor.ModelUpdater, true); return(View(model)); }
public async Task <IActionResult> Create(string id, string menuContentItemId, string menuItemId) { if (String.IsNullOrWhiteSpace(id)) { return(NotFound()); } if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageMenu)) { return(Forbid()); } var contentItem = await _contentManager.NewAsync(id); dynamic model = await _contentItemDisplayManager.BuildEditorAsync(contentItem, _updateModelAccessor.ModelUpdater, true); model.MenuContentItemId = menuContentItemId; model.MenuItemId = menuItemId; return(View(model)); }
public async Task <IActionResult> Create(string id, string taxonomyContentItemId, string taxonomyItemId) { if (String.IsNullOrWhiteSpace(id)) { return(NotFound()); } if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageTaxonomies)) { return(Unauthorized()); } var contentItem = await _contentManager.NewAsync(id); dynamic model = await _contentItemDisplayManager.BuildEditorAsync(contentItem, this, true); model.TaxonomyContentItemId = taxonomyContentItemId; model.TaxonomyItemId = taxonomyItemId; return(View(model)); }
public async Task <ActionResult> Edit(string contentItemId) { var contentItem = await _contentManager.GetAsync(contentItemId); if (contentItem == null) { return(NotFound()); } var shape = await _contentDisplay.BuildEditorAsync(contentItem, this); return(View(shape)); }
public async Task <ActionResult> Edit(string contentItemId) { var contentItem = await _contentManager.GetAsync(contentItemId); if (contentItem == null) { return(NotFound()); } var shape = await _contentDisplay.BuildEditorAsync(contentItem, _updateModelAccessor.ModelUpdater, false); return(View(shape)); }
public async Task <IActionResult> Create(string id, string taxonomyContentItemId, string taxonomyItemId) { if (String.IsNullOrWhiteSpace(id)) { return(NotFound()); } if (!await _authorizationService.AuthorizeAsync(User, Permissions.ManageTaxonomies)) { return(Forbid()); } var contentItem = await _contentManager.NewAsync(id); contentItem.Weld <TermPart>(); contentItem.Alter <TermPart>(t => t.TaxonomyContentItemId = taxonomyContentItemId); dynamic model = await _contentItemDisplayManager.BuildEditorAsync(contentItem, _updateModelAccessor.ModelUpdater, true); model.TaxonomyContentItemId = taxonomyContentItemId; model.TaxonomyItemId = taxonomyItemId; return(View(model)); }
public async Task <ActionResult> Edit(string contentItemId) { var contentItem = await _contentManager.GetAsync(contentItemId); if (contentItem == null) { return(NotFound()); } if (!await _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, CommonPermissions.EditContent, contentItem)) { return(Forbid()); } var shape = await _contentDisplay.BuildEditorAsync(contentItem, _updateModelAccessor.ModelUpdater, false); return(View(shape)); }
public async Task <IActionResult> Create(string id) { if (String.IsNullOrWhiteSpace(id)) { return(NotFound()); } var contentItem = await _contentManager.NewAsync(id); if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.EditContent, contentItem)) { return(Unauthorized()); } var model = await _contentItemDisplayManager.BuildEditorAsync(contentItem, this, true); return(View(model)); }
public async Task <IActionResult> Create(string contentType) { if (String.IsNullOrWhiteSpace(contentType)) { return(NotFound()); } var contentItem = await contentManager.NewAsync(contentType); contentItem.Owner = User.Identity.Name; if (!await authorizationService.AuthorizeAsync(User, Permissions.AddCommentsAccess)) { return(this.ChallengeOrForbid()); } var model = await contentItemDisplayManager.BuildEditorAsync(contentItem, updateModelAccessor.ModelUpdater, true); return(PartialView(model)); }
public override async Task <IDisplayResult> EditAsync(ISite site, BuildEditorContext context) { JToken property; var contentTypeDefinition = _contentTypeDefinitions.Value.FirstOrDefault(x => x.Name == context.GroupId); if (contentTypeDefinition == null) { return(null); } var user = _httpContextAccessor.HttpContext?.User; if (!await _authorizationService.AuthorizeAsync(user, Permissions.CreatePermissionForType(contentTypeDefinition))) { return(null); } ContentItem contentItem; bool isNew; if (!site.Properties.TryGetValue(contentTypeDefinition.Name, out property)) { contentItem = await _contentManager.NewAsync(contentTypeDefinition.Name); isNew = true; } else { // Create existing content item contentItem = property.ToObject <ContentItem>(); isNew = false; } var shape = Initialize <CustomSettingsEditViewModel>("CustomSettings", async ctx => { ctx.Editor = await _contentItemDisplayManager.BuildEditorAsync(contentItem, context.Updater, isNew); }).Location("Content:3").OnGroup(contentTypeDefinition.Name); return(shape); }
public async Task <ActionResult> Display(string auditTrailEventId) { var auditTrailContentEvent = (await _session.Query <AuditTrailEvent, AuditTrailEventIndex>(collection: AuditTrailEvent.Collection) .Where(index => index.EventId == auditTrailEventId) .FirstOrDefaultAsync()) ?.As <AuditTrailContentEvent>(); if (auditTrailContentEvent == null || auditTrailContentEvent.ContentItem == null) { return(NotFound()); } var contentItem = auditTrailContentEvent.ContentItem; contentItem.Id = 0; contentItem.ContentItemVersionId = ""; contentItem.Published = false; contentItem.Latest = false; contentItem = await _contentManager.LoadAsync(contentItem); if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.EditContent, contentItem)) { return(Forbid()); } var auditTrailPart = contentItem.As <AuditTrailPart>(); if (auditTrailPart != null) { auditTrailPart.ShowComment = true; } var model = await _contentItemDisplayManager.BuildEditorAsync(contentItem, _updateModelAccessor.ModelUpdater, false); model.Properties["VersionNumber"] = auditTrailContentEvent.VersionNumber; return(View(model)); }
public async Task <IActionResult> BuildEditor(string id, string prefix, string prefixesName, string contentTypesName, string targetId, bool flowmetadata) { if (String.IsNullOrWhiteSpace(id)) { return(NotFound()); } var contentItem = _contentManager.New(id); // Does this editor need the flow metadata editor? if (flowmetadata) { contentItem.Weld(new FlowMetadata()); } var editor = await _contentItemDisplayManager.BuildEditorAsync(contentItem, this, htmlFieldPrefix : prefix); editor.PrefixesName = prefixesName; editor.ContentTypesName = contentTypesName; editor.TargetId = targetId; editor.Inline = true; var model = new BuildEditorViewModel { EditorShape = editor }; if (flowmetadata) { model.EditorShape.Metadata.Alternates.Add("Widget_Edit__Flow"); } else { model.EditorShape.Metadata.Alternates.Add("Widget_Edit__Bag"); } return(View("Display", model)); }
public override async Task <IDisplayResult> EditAsync(ISite site, BuildEditorContext context) { var contentTypeDefinition = _customSettingsService.GetSettingsType(context.GroupId); if (contentTypeDefinition == null) { return(null); } if (!await _customSettingsService.CanUserCreateSettingsAsync(contentTypeDefinition)) { return(null); } var isNew = false; var contentItem = await _customSettingsService.GetSettingsAsync(site, contentTypeDefinition, () => isNew = true); var shape = Initialize <CustomSettingsEditViewModel>("CustomSettings", async ctx => { ctx.Editor = await _contentItemDisplayManager.BuildEditorAsync(contentItem, context.Updater, isNew); }).Location("Content:3").OnGroup(contentTypeDefinition.Name); return(shape); }
public async Task <IActionResult> BuildEditor(string id, string prefix, string prefixesName, string contentTypesName, string targetId) { if (String.IsNullOrWhiteSpace(id)) { return(NotFound()); } var contentItem = _contentManager.New(id); contentItem.Weld(new FlowMetadata()); var editor = await _contentItemDisplayManager.BuildEditorAsync(contentItem, this, htmlFieldPrefix : prefix); editor.PrefixesName = prefixesName; editor.ContentTypesName = contentTypesName; editor.TargetId = targetId; var model = new BuildEditorViewModel { EditorShape = editor }; return(View("Display", model)); }