mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00
16963: Tags: only keep manage tags permission
--HG-- branch : dev
This commit is contained in:
@@ -70,9 +70,6 @@ namespace Orchard.Tags.Controllers {
|
||||
ViewData["CreateTag"] = viewModel;
|
||||
return Index();
|
||||
}
|
||||
|
||||
if (!Services.Authorizer.Authorize(Permissions.CreateTag, T("Couldn't create tag")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
_tagService.CreateTag(viewModel.TagName);
|
||||
|
||||
|
@@ -34,17 +34,11 @@ namespace Orchard.Tags.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(TagsPart part, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, _orchardServices.WorkContext.CurrentUser, part))
|
||||
return null;
|
||||
|
||||
return ContentShape("Parts_Tags_Edit",
|
||||
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: BuildEditorViewModel(part), Prefix: Prefix));
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(TagsPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, _orchardServices.WorkContext.CurrentUser, part))
|
||||
return null;
|
||||
|
||||
var model = new EditTagsViewModel();
|
||||
updater.TryUpdateModel(model, Prefix, null, null);
|
||||
|
||||
|
@@ -5,16 +5,12 @@ using Orchard.Security.Permissions;
|
||||
namespace Orchard.Tags {
|
||||
public class Permissions : IPermissionProvider {
|
||||
public static readonly Permission ManageTags = new Permission { Description = "Manage tags", Name = "ManageTags" };
|
||||
public static readonly Permission CreateTag = new Permission { Description = "Create tag", Name = "CreateTag", ImpliedBy = new[] { ManageTags } };
|
||||
public static readonly Permission ApplyTag = new Permission { Description = "Applying a Tag", Name = "ApplyTag", ImpliedBy = new[] { ManageTags, CreateTag } };
|
||||
|
||||
public virtual Feature Feature { get; set; }
|
||||
|
||||
public IEnumerable<Permission> GetPermissions() {
|
||||
return new[] {
|
||||
ManageTags,
|
||||
CreateTag,
|
||||
ApplyTag,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,11 +30,9 @@ namespace Orchard.Tags {
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Author",
|
||||
Permissions = new[] {CreateTag, ApplyTag}
|
||||
},
|
||||
new PermissionStereotype {
|
||||
Name = "Contributor",
|
||||
Permissions = new[] {ApplyTag}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@@ -51,7 +51,6 @@ namespace Orchard.Tags.Services {
|
||||
public TagRecord CreateTag(string tagName) {
|
||||
var result = _tagRepository.Get(x => x.TagName == tagName);
|
||||
if (result == null) {
|
||||
_authorizationService.CheckAccess(Permissions.CreateTag, _orchardServices.WorkContext.CurrentUser, null);
|
||||
result = new TagRecord { TagName = tagName };
|
||||
_tagRepository.Create(result);
|
||||
}
|
||||
@@ -151,14 +150,12 @@ namespace Orchard.Tags.Services {
|
||||
if (contentItem.Id == 0)
|
||||
throw new OrchardException(T("Error adding tag to content item: the content item has not been created yet."));
|
||||
|
||||
var tags = tagNamesForContentItem.Select(name => CreateTag(name));
|
||||
var tags = tagNamesForContentItem.Select(CreateTag);
|
||||
var newTagsForContentItem = new List<TagRecord>(tags);
|
||||
var currentTagsForContentItem = _contentTagRepository.Fetch(x => x.TagsPartRecord.Id == contentItem.Id);
|
||||
|
||||
foreach (var tagContentItem in currentTagsForContentItem) {
|
||||
if (!newTagsForContentItem.Contains(tagContentItem.TagRecord)) {
|
||||
_authorizationService.CheckAccess(Permissions.ApplyTag, _orchardServices.WorkContext.CurrentUser, null);
|
||||
|
||||
_contentTagRepository.Delete(tagContentItem);
|
||||
}
|
||||
else {
|
||||
@@ -167,8 +164,6 @@ namespace Orchard.Tags.Services {
|
||||
}
|
||||
|
||||
foreach (var newTagForContentItem in newTagsForContentItem) {
|
||||
_authorizationService.CheckAccess(Permissions.ApplyTag, _orchardServices.WorkContext.CurrentUser, null);
|
||||
|
||||
_contentTagRepository.Create(new ContentTagRecord { TagsPartRecord = contentItem.As<TagsPart>().Record, TagRecord = newTagForContentItem });
|
||||
}
|
||||
}
|
||||
|
@@ -141,7 +141,6 @@ namespace Orchard.Tags.Services {
|
||||
|
||||
private void MetaWeblogUpdateTags(int contentItemId, string appKey, string userName, string password, XRpcStruct content, bool publish, ICollection<IXmlRpcDriver> drivers) {
|
||||
var user = _membershipService.ValidateUser(userName, password);
|
||||
_authorizationService.CheckAccess(Permissions.ApplyTag, user, null);
|
||||
|
||||
var rawTags = content.Optional<string>("mt_keywords");
|
||||
if (string.IsNullOrWhiteSpace(rawTags))
|
||||
|
Reference in New Issue
Block a user