#19404: Applying content item permissions on blog

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2013-05-20 15:29:26 -07:00
parent a59aae4871
commit ec7f4446be

View File

@@ -4,6 +4,7 @@ using Orchard.Blogs.Extensions;
using Orchard.Blogs.Services;
using Orchard.Core.Feeds;
using Orchard.DisplayManagement;
using Orchard.Localization;
using Orchard.Logging;
using Orchard.Mvc;
using Orchard.Themes;
@@ -36,13 +37,17 @@ namespace Orchard.Blogs.Controllers {
_siteService = siteService;
Logger = NullLogger.Instance;
Shape = shapeFactory;
T = NullLocalizer.Instance;
}
dynamic Shape { get; set; }
protected ILogger Logger { get; set; }
public Localizer T { get; set; }
public ActionResult List() {
var blogs = _blogService.Get().Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
var blogs = _blogService.Get()
.Where(b => _services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent,b))
.Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));
var list = Shape.List();
list.AddRange(blogs);
@@ -61,6 +66,11 @@ namespace Orchard.Blogs.Controllers {
if (blogPart == null)
return HttpNotFound();
if (!_services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.ViewContent, blogPart, T("Cannot view content"))) {
return new HttpUnauthorizedResult();
}
_feedManager.Register(blogPart);
var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize)
.Select(b => _services.ContentManager.BuildDisplay(b, "Summary"));