Removing the term Others from Blogs module permissions (for consistency with Contents module)

--HG--
branch : 1.x
This commit is contained in:
Louis DeJardin
2010-12-15 22:02:06 -08:00
parent 6358ad20ff
commit 49ef5a44a7
4 changed files with 25 additions and 25 deletions

View File

@@ -95,7 +95,7 @@ namespace Orchard.Blogs.Controllers {
if (post == null) if (post == null)
return HttpNotFound(); return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.EditOthersBlogPost, post, T("Couldn't edit blog post"))) if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, post, T("Couldn't edit blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
dynamic model = Services.ContentManager.BuildEditor(post); dynamic model = Services.ContentManager.BuildEditor(post);
@@ -124,7 +124,7 @@ namespace Orchard.Blogs.Controllers {
if (blogPost == null) if (blogPost == null)
return HttpNotFound(); return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.PublishOthersBlogPost, blogPost, T("Couldn't publish blog post"))) if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, blogPost, T("Couldn't publish blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
return EditPOST(blogId, postId, returnUrl, contentItem => Services.ContentManager.Publish(contentItem)); return EditPOST(blogId, postId, returnUrl, contentItem => Services.ContentManager.Publish(contentItem));
@@ -140,7 +140,7 @@ namespace Orchard.Blogs.Controllers {
if (blogPost == null) if (blogPost == null)
return HttpNotFound(); return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.EditOthersBlogPost, blogPost, T("Couldn't edit blog post"))) if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, blogPost, T("Couldn't edit blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
// Validate form input // Validate form input
@@ -167,7 +167,7 @@ namespace Orchard.Blogs.Controllers {
} }
// check edit permission // check edit permission
if (!Services.Authorizer.Authorize(Permissions.EditOthersBlogPost, draft, T("Couldn't discard blog post draft"))) if (!Services.Authorizer.Authorize(Permissions.EditBlogPost, draft, T("Couldn't discard blog post draft")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
// locate the published revision to revert onto // locate the published revision to revert onto
@@ -198,7 +198,7 @@ namespace Orchard.Blogs.Controllers {
[ValidateAntiForgeryTokenOrchard] [ValidateAntiForgeryTokenOrchard]
public ActionResult Delete(int blogId, int postId) { public ActionResult Delete(int blogId, int postId) {
//refactoring: test PublishBlogPost/PublishOthersBlogPost in addition if published //refactoring: test PublishBlogPost/PublishBlogPost in addition if published
var blog = _blogService.Get(blogId, VersionOptions.Latest); var blog = _blogService.Get(blogId, VersionOptions.Latest);
if (blog == null) if (blog == null)
@@ -208,7 +208,7 @@ namespace Orchard.Blogs.Controllers {
if (post == null) if (post == null)
return HttpNotFound(); return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.DeleteOthersBlogPost, post, T("Couldn't delete blog post"))) if (!Services.Authorizer.Authorize(Permissions.DeleteBlogPost, post, T("Couldn't delete blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
_blogPostService.Delete(post); _blogPostService.Delete(post);
@@ -227,7 +227,7 @@ namespace Orchard.Blogs.Controllers {
if (post == null) if (post == null)
return HttpNotFound(); return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.PublishOthersBlogPost, post, T("Couldn't publish blog post"))) if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, post, T("Couldn't publish blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
_blogPostService.Publish(post); _blogPostService.Publish(post);
@@ -246,7 +246,7 @@ namespace Orchard.Blogs.Controllers {
if (post == null) if (post == null)
return HttpNotFound(); return HttpNotFound();
if (!Services.Authorizer.Authorize(Permissions.PublishOthersBlogPost, post, T("Couldn't unpublish blog post"))) if (!Services.Authorizer.Authorize(Permissions.PublishBlogPost, post, T("Couldn't unpublish blog post")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
_blogPostService.Unpublish(post); _blogPostService.Unpublish(post);

View File

@@ -6,14 +6,14 @@ namespace Orchard.Blogs {
public class Permissions : IPermissionProvider { public class Permissions : IPermissionProvider {
public static readonly Permission ManageBlogs = new Permission { Description = "Manage blogs", Name = "ManageBlogs" }; public static readonly Permission ManageBlogs = new Permission { Description = "Manage blogs", Name = "ManageBlogs" };
public static readonly Permission PublishOthersBlogPost = new Permission { Description = "Publish or unpublish blog post for others", Name = "PublishOthersBlogPost", ImpliedBy = new[] { ManageBlogs } }; public static readonly Permission PublishBlogPost = new Permission { Description = "Publish or unpublish blog post for others", Name = "PublishBlogPost", ImpliedBy = new[] { ManageBlogs } };
public static readonly Permission PublishOwnBlogPost = new Permission { Description = "Publish or unpublish own blog post", Name = "PublishOwnBlogPost", ImpliedBy = new[] { PublishOthersBlogPost } }; public static readonly Permission PublishOwnBlogPost = new Permission { Description = "Publish or unpublish own blog post", Name = "PublishOwnBlogPost", ImpliedBy = new[] { PublishBlogPost } };
public static readonly Permission EditOthersBlogPost = new Permission { Description = "Edit any blog posts", Name = "EditOthersBlogPost", ImpliedBy = new[] { PublishOthersBlogPost } }; public static readonly Permission EditBlogPost = new Permission { Description = "Edit any blog posts", Name = "EditBlogPost", ImpliedBy = new[] { PublishBlogPost } };
public static readonly Permission EditOwnBlogPost = new Permission { Description = "Edit own blog posts", Name = "EditOwnBlogPost", ImpliedBy = new[] { EditOthersBlogPost, PublishOwnBlogPost } }; public static readonly Permission EditOwnBlogPost = new Permission { Description = "Edit own blog posts", Name = "EditOwnBlogPost", ImpliedBy = new[] { EditBlogPost, PublishOwnBlogPost } };
public static readonly Permission DeleteOthersBlogPost = new Permission { Description = "Delete blog post for others", Name = "DeleteOthersBlogPost", ImpliedBy = new[] { ManageBlogs } }; public static readonly Permission DeleteBlogPost = new Permission { Description = "Delete blog post for others", Name = "DeleteBlogPost", ImpliedBy = new[] { ManageBlogs } };
public static readonly Permission DeleteOwnBlogPost = new Permission { Description = "Delete own blog post", Name = "DeleteOwnBlogPost", ImpliedBy = new[] { DeleteOthersBlogPost } }; public static readonly Permission DeleteOwnBlogPost = new Permission { Description = "Delete own blog post", Name = "DeleteOwnBlogPost", ImpliedBy = new[] { DeleteBlogPost } };
public static readonly Permission MetaListOthersBlogs = new Permission { ImpliedBy = new[] { EditOthersBlogPost, PublishOthersBlogPost, DeleteOthersBlogPost } }; public static readonly Permission MetaListOthersBlogs = new Permission { ImpliedBy = new[] { EditBlogPost, PublishBlogPost, DeleteBlogPost } };
public static readonly Permission MetaListOwnBlogs = new Permission { ImpliedBy = new[] { EditOwnBlogPost, PublishOwnBlogPost, DeleteOwnBlogPost } }; public static readonly Permission MetaListOwnBlogs = new Permission { ImpliedBy = new[] { EditOwnBlogPost, PublishOwnBlogPost, DeleteOwnBlogPost } };
public virtual Feature Feature { get; set; } public virtual Feature Feature { get; set; }
@@ -22,11 +22,11 @@ namespace Orchard.Blogs {
return new[] { return new[] {
ManageBlogs, ManageBlogs,
EditOwnBlogPost, EditOwnBlogPost,
EditOthersBlogPost, EditBlogPost,
PublishOwnBlogPost, PublishOwnBlogPost,
PublishOthersBlogPost, PublishBlogPost,
DeleteOwnBlogPost, DeleteOwnBlogPost,
DeleteOthersBlogPost, DeleteBlogPost,
}; };
} }
@@ -38,7 +38,7 @@ namespace Orchard.Blogs {
}, },
new PermissionStereotype { new PermissionStereotype {
Name = "Editor", Name = "Editor",
Permissions = new[] {PublishOthersBlogPost,EditOthersBlogPost,DeleteOthersBlogPost} Permissions = new[] {PublishBlogPost,EditBlogPost,DeleteBlogPost}
}, },
new PermissionStereotype { new PermissionStereotype {
Name = "Moderator", Name = "Moderator",

View File

@@ -37,11 +37,11 @@ namespace Orchard.Blogs.Security {
} }
private static Permission GetOwnerVariation(Permission permission) { private static Permission GetOwnerVariation(Permission permission) {
if (permission.Name == Permissions.PublishOthersBlogPost.Name) if (permission.Name == Permissions.PublishBlogPost.Name)
return Permissions.PublishOwnBlogPost; return Permissions.PublishOwnBlogPost;
if (permission.Name == Permissions.EditOthersBlogPost.Name) if (permission.Name == Permissions.EditBlogPost.Name)
return Permissions.EditOwnBlogPost; return Permissions.EditOwnBlogPost;
if (permission.Name == Permissions.DeleteOthersBlogPost.Name) if (permission.Name == Permissions.DeleteBlogPost.Name)
return Permissions.DeleteOwnBlogPost; return Permissions.DeleteOwnBlogPost;
return null; return null;
} }

View File

@@ -239,7 +239,7 @@ namespace Orchard.Blogs.Services {
if (blogPost == null) if (blogPost == null)
throw new ArgumentException(); throw new ArgumentException();
_authorizationService.CheckAccess(Permissions.EditOthersBlogPost, user, blogPost); _authorizationService.CheckAccess(Permissions.EditBlogPost, user, blogPost);
var postStruct = CreateBlogStruct(blogPost, urlHelper); var postStruct = CreateBlogStruct(blogPost, urlHelper);
@@ -255,7 +255,7 @@ namespace Orchard.Blogs.Services {
if (blogPost == null) if (blogPost == null)
throw new ArgumentException(); throw new ArgumentException();
_authorizationService.CheckAccess(publish ? Permissions.PublishOthersBlogPost : Permissions.EditOthersBlogPost, user, blogPost); _authorizationService.CheckAccess(publish ? Permissions.PublishBlogPost : Permissions.EditBlogPost, user, blogPost);
var title = content.Optional<string>("title"); var title = content.Optional<string>("title");
var description = content.Optional<string>("description"); var description = content.Optional<string>("description");
@@ -290,7 +290,7 @@ namespace Orchard.Blogs.Services {
if (blogPost == null) if (blogPost == null)
throw new ArgumentException(); throw new ArgumentException();
_authorizationService.CheckAccess(Permissions.DeleteOthersBlogPost, user, blogPost); _authorizationService.CheckAccess(Permissions.DeleteBlogPost, user, blogPost);
foreach (var driver in drivers) foreach (var driver in drivers)
driver.Process(blogPost.Id); driver.Process(blogPost.Id);