--HG--
branch : dev
This commit is contained in:
Louis DeJardin
2010-07-22 15:41:41 -07:00
73 changed files with 338 additions and 258 deletions

View File

@@ -20,7 +20,7 @@ namespace Orchard.Core.Common {
new PermissionStereotype {
Name = "Administrator",
Permissions = new[] {ChangeOwner}
}
},
};
}
}

View File

@@ -0,0 +1,57 @@
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Common.Models;
using Orchard.Security;
using Orchard.Security.Permissions;
namespace Orchard.Core.Common.Security
{
[UsedImplicitly]
public class AuthorizationEventHandler : IAuthorizationServiceEventHandler
{
public void Checking(CheckAccessContext context) { }
public void Complete(CheckAccessContext context) { }
public void Adjust(CheckAccessContext context)
{
if (!context.Granted &&
context.Content.Is<CommonPart>() &&
OwnerVariationExists(context.Permission) &&
HasOwnership(context.User, context.Content))
{
context.Adjusted = true;
context.Permission = GetOwnerVariation(context.Permission);
}
}
private static bool HasOwnership(IUser user, IContent content)
{
if (user == null || content == null)
return false;
var common = content.As<ICommonPart>();
if (common == null || common.Owner == null)
return false;
return user.Id == common.Owner.Id;
}
private static bool OwnerVariationExists(Permission permission)
{
return GetOwnerVariation(permission) != null;
}
private static Permission GetOwnerVariation(Permission permission)
{
if (permission.Name == Contents.Permissions.PublishOthersContent.Name)
return Contents.Permissions.PublishContent;
if (permission.Name == Contents.Permissions.EditOthersContent.Name)
return Contents.Permissions.EditContent;
if (permission.Name == Contents.Permissions.DeleteOthersContent.Name)
return Contents.Permissions.DeleteContent;
return null;
}
}
}

View File

@@ -134,34 +134,38 @@ namespace Orchard.Core.Contents.Controllers {
[HttpPost, ActionName("List")]
[FormValueRequired("submit.BulkEdit")]
public ActionResult ListPOST(ContentOptions options, IEnumerable<int> itemIds, string returnUrl) {
var accessChecked = false;
switch (options.BulkAction) {
case ContentsBulkAction.None:
break;
case ContentsBulkAction.PublishNow:
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't publish selected content.")))
return new HttpUnauthorizedResult();
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
if (!accessChecked && !Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't publish selected content.")))
return new HttpUnauthorizedResult();
accessChecked = true;
_contentManager.Publish(item);
Services.ContentManager.Flush();
}
Services.Notifier.Information(T("Content successfully published."));
break;
case ContentsBulkAction.Unpublish:
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't unpublish selected content.")))
return new HttpUnauthorizedResult();
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
if (!accessChecked && !Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't unpublish selected content.")))
return new HttpUnauthorizedResult();
accessChecked = true;
_contentManager.Unpublish(item);
Services.ContentManager.Flush();
}
Services.Notifier.Information(T("Content successfully unpublished."));
break;
case ContentsBulkAction.Remove:
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't delete selected content.")))
return new HttpUnauthorizedResult();
foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) {
if (!accessChecked && !Services.Authorizer.Authorize(Permissions.DeleteContent, item, T("Couldn't remove selected content.")))
return new HttpUnauthorizedResult();
accessChecked = true;
_contentManager.Remove(item);
Services.ContentManager.Flush();
}
@@ -210,6 +214,10 @@ namespace Orchard.Core.Contents.Controllers {
return CreatableTypeList();
var contentItem = _contentManager.New(id);
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Cannot create content")))
return new HttpUnauthorizedResult();
var model = new CreateItemViewModel {
Id = id,
Content = _contentManager.BuildEditorModel(contentItem)
@@ -221,8 +229,11 @@ namespace Orchard.Core.Contents.Controllers {
[HttpPost]
public ActionResult Create(CreateItemViewModel model) {
//todo: need to integrate permissions into generic content management
var contentItem = _contentManager.New(model.Id);
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Couldn't create content")))
return new HttpUnauthorizedResult();
_contentManager.Create(contentItem, VersionOptions.Draft);
model.Content = _contentManager.UpdateEditorModel(contentItem, this);
@@ -246,6 +257,9 @@ namespace Orchard.Core.Contents.Controllers {
if (contentItem == null)
return new NotFoundResult();
if (!Services.Authorizer.Authorize(Permissions.EditOthersContent, contentItem, T("Cannot edit content")))
return new HttpUnauthorizedResult();
var model = new EditItemViewModel {
Id = id,
Content = _contentManager.BuildEditorModel(contentItem)
@@ -263,6 +277,9 @@ namespace Orchard.Core.Contents.Controllers {
if (contentItem == null)
return new NotFoundResult();
if (!Services.Authorizer.Authorize(Permissions.EditOthersContent, contentItem, T("Couldn't edit content")))
return new HttpUnauthorizedResult();
model.Content = _contentManager.UpdateEditorModel(contentItem, this);
if (!ModelState.IsValid) {
_transactionManager.Cancel();
@@ -280,6 +297,10 @@ namespace Orchard.Core.Contents.Controllers {
[HttpPost, ActionName("Remove")]
public ActionResult RemovePOST(int id, string returnUrl) {
var contentItem = _contentManager.Get(id, VersionOptions.Latest);
if (!Services.Authorizer.Authorize(Permissions.DeleteOthersContent, contentItem, T("Couldn't remove content")))
return new HttpUnauthorizedResult();
if (contentItem != null)
_contentManager.Remove(contentItem);
@@ -291,13 +312,13 @@ namespace Orchard.Core.Contents.Controllers {
[HttpPost]
public ActionResult Publish(int id, string returnUrl) {
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't publish content")))
return new HttpUnauthorizedResult();
var contentItem = _contentManager.GetLatest(id);
if (contentItem == null)
return new NotFoundResult();
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Couldn't publish content")))
return new HttpUnauthorizedResult();
_contentManager.Publish(contentItem);
Services.ContentManager.Flush();
Services.Notifier.Information(T("{0} successfully published.", contentItem.TypeDefinition.DisplayName));
@@ -310,13 +331,13 @@ namespace Orchard.Core.Contents.Controllers {
[HttpPost]
public ActionResult Unpublish(int id, string returnUrl) {
if (!Services.Authorizer.Authorize(Permissions.PublishContent, T("Couldn't unpublish content")))
return new HttpUnauthorizedResult();
var contentItem = _contentManager.GetLatest(id);
if (contentItem == null)
return new NotFoundResult();
if (!Services.Authorizer.Authorize(Permissions.PublishContent, contentItem, T("Couldn't unpublish content")))
return new HttpUnauthorizedResult();
_contentManager.Unpublish(contentItem);
Services.ContentManager.Flush();
Services.Notifier.Information(T("{0} successfully unpublished.", contentItem.TypeDefinition.DisplayName));

View File

@@ -19,7 +19,7 @@ namespace Orchard.Core.Contents {
}
public IEnumerable<Permission> GetPermissions() {
return new Permission[] {
return new [] {
EditContent,
EditOthersContent,
PublishContent,

View File

@@ -67,6 +67,7 @@
<Compile Include="Common\Drivers\TextFieldDriver.cs" />
<Compile Include="Common\Extensions\HtmlHelperExtensions.cs" />
<Compile Include="Common\Fields\TextField.cs" />
<Compile Include="Common\Security\AuthorizationEventHandler.cs" />
<Compile Include="ContentsLocation\Models\LocationDefinition.cs" />
<Compile Include="Common\Services\ICommonService.cs" />
<Compile Include="Common\Services\CommonService.cs" />

View File

@@ -39,7 +39,7 @@ namespace Orchard.Comments.Controllers {
options = new CommentIndexOptions();
// Filtering
IEnumerable<Comment> comments;
IEnumerable<CommentPart> comments;
try {
switch (options.Filter) {
case CommentIndexFilter.All:
@@ -129,7 +129,7 @@ namespace Orchard.Comments.Controllers {
options = new CommentDetailsOptions();
// Filtering
IEnumerable<Comment> comments;
IEnumerable<CommentPart> comments;
try {
switch (options.Filter) {
case CommentDetailsFilter.All:
@@ -261,14 +261,14 @@ namespace Orchard.Comments.Controllers {
public ActionResult Edit(int id) {
try {
Comment comment = _commentService.GetComment(id);
CommentPart commentPart = _commentService.GetComment(id);
var viewModel = new CommentsEditViewModel {
CommentText = comment.Record.CommentText,
Email = comment.Record.Email,
Id = comment.Record.Id,
Name = comment.Record.Author,
SiteName = comment.Record.SiteName,
Status = comment.Record.Status,
CommentText = commentPart.Record.CommentText,
Email = commentPart.Record.Email,
Id = commentPart.Record.Id,
Name = commentPart.Record.Author,
SiteName = commentPart.Record.SiteName,
Status = commentPart.Record.Status,
};
return View(viewModel);
@@ -319,10 +319,10 @@ namespace Orchard.Comments.Controllers {
}
}
private CommentEntry CreateCommentEntry(CommentRecord comment) {
private CommentEntry CreateCommentEntry(CommentPartRecord commentPart) {
return new CommentEntry {
Comment = comment,
CommentedOn = _commentService.GetDisplayForCommentedContent(comment.CommentedOn).DisplayText,
Comment = commentPart,
CommentedOn = _commentService.GetDisplayForCommentedContent(commentPart.CommentedOn).DisplayText,
IsChecked = false,
};
}

View File

@@ -61,9 +61,9 @@ namespace Orchard.Comments.Controllers {
CommentedOn = viewModel.CommentedOn
};
Comment comment = _commentService.CreateComment(context, CurrentSite.As<CommentSettings>().Record.ModerateComments);
CommentPart commentPart = _commentService.CreateComment(context, CurrentSite.As<CommentSettingsPart>().Record.ModerateComments);
if (comment.Record.Status == CommentStatus.Pending)
if (commentPart.Record.Status == CommentStatus.Pending)
Services.Notifier.Information(T("Your comment will appear after the site administrator approves it."));
return !String.IsNullOrEmpty(returnUrl)

View File

@@ -16,8 +16,8 @@ namespace Orchard.Comments.DataMigrations {
.Column<int>("ContentItemId")
);
//CREATE TABLE Orchard_Comments_CommentRecord (Id INTEGER not null, Author TEXT, SiteName TEXT, UserName TEXT, Email TEXT, Status TEXT, CommentDateUtc DATETIME, CommentText TEXT, CommentedOn INTEGER, CommentedOnContainer INTEGER, primary key (Id));
SchemaBuilder.CreateTable("CommentRecord", table => table
//CREATE TABLE Orchard_Comments_CommentPartRecord (Id INTEGER not null, Author TEXT, SiteName TEXT, UserName TEXT, Email TEXT, Status TEXT, CommentDateUtc DATETIME, CommentText TEXT, CommentedOn INTEGER, CommentedOnContainer INTEGER, primary key (Id));
SchemaBuilder.CreateTable("CommentPartRecord", table => table
.ContentPartRecord()
.Column<string>("Author")
.Column<string>("SiteName")
@@ -30,8 +30,8 @@ namespace Orchard.Comments.DataMigrations {
.Column<int>("CommentedOnContainer")
);
//CREATE TABLE Orchard_Comments_CommentSettingsRecord (Id INTEGER not null, ModerateComments INTEGER, EnableSpamProtection INTEGER, AkismetKey TEXT, AkismetUrl TEXT, primary key (Id));
SchemaBuilder.CreateTable("CommentSettingsRecord", table => table
//CREATE TABLE Orchard_Comments_CommentSettingsPartRecord (Id INTEGER not null, ModerateComments INTEGER, EnableSpamProtection INTEGER, AkismetKey TEXT, AkismetUrl TEXT, primary key (Id));
SchemaBuilder.CreateTable("CommentSettingsPartRecord", table => table
.ContentPartRecord()
.Column<bool>("ModerateComments")
.Column<bool>("EnableSpamProtection")
@@ -39,8 +39,8 @@ namespace Orchard.Comments.DataMigrations {
.Column<string>("AkismetUrl")
);
//CREATE TABLE Orchard_Comments_HasCommentsRecord (Id INTEGER not null, CommentsShown INTEGER, CommentsActive INTEGER, primary key (Id));
SchemaBuilder.CreateTable("HasCommentsRecord", table => table
//CREATE TABLE Orchard_Comments_CommentsPartRecord (Id INTEGER not null, CommentsShown INTEGER, CommentsActive INTEGER, primary key (Id));
SchemaBuilder.CreateTable("CommentsPartRecord", table => table
.ContentPartRecord()
.Column<bool>("CommentsShown")
.Column<bool>("CommentsActive")
@@ -52,20 +52,20 @@ namespace Orchard.Comments.DataMigrations {
public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("Comment",
cfg => cfg
.WithPart("Comment")
.WithPart("CommentPart")
.WithPart("CommonPart")
);
ContentDefinitionManager.AlterTypeDefinition("Blog",
cfg => cfg
.WithPart("HasCommentsContainer")
.WithPart("CommentsContainerPart")
);
return 2;
}
public int UpdateFrom2() {
ContentDefinitionManager.AlterPartDefinition(typeof(HasComments).Name, cfg => cfg
ContentDefinitionManager.AlterPartDefinition(typeof(CommentsPart).Name, cfg => cfg
.WithLocation(new Dictionary<string, ContentLocation> {
{"Default", new ContentLocation { Zone = "primary", Position = "before.5" }},
{"Detail", new ContentLocation { Zone = "primary", Position = "after.5" }},
@@ -74,7 +74,7 @@ namespace Orchard.Comments.DataMigrations {
{"Editor", new ContentLocation { Zone = "primary", Position = "10" }},
}));
ContentDefinitionManager.AlterPartDefinition(typeof(HasCommentsContainer).Name, cfg => cfg
ContentDefinitionManager.AlterPartDefinition(typeof(CommentsContainerPart).Name, cfg => cfg
.WithLocation(new Dictionary<string, ContentLocation> {
{"SummaryAdmin", new ContentLocation { Zone = "meta", Position = null }},
{"Summary", new ContentLocation { Zone = "meta", Position = null }},

View File

@@ -5,7 +5,7 @@ using Orchard.ContentManagement.Drivers;
namespace Orchard.Comments.Drivers {
[UsedImplicitly]
public class CommentDriver : ContentItemDriver<Comment> {
public class CommentPartDriver : ContentItemDriver<CommentPart> {
public readonly static ContentType ContentType = new ContentType {
Name = "Comment",
DisplayName = "Comment"

View File

@@ -9,8 +9,8 @@ using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Comments.Drivers {
[UsedImplicitly]
public class HasCommentsContainerDriver : ContentPartDriver<HasCommentsContainer> {
protected override DriverResult Display(HasCommentsContainer part, string displayType) {
public class CommentsContainerPartDriver : ContentPartDriver<CommentsContainerPart> {
protected override DriverResult Display(CommentsContainerPart part, string displayType) {
if (displayType == "SummaryAdmin") {
return ContentPartTemplate(CreateViewModel(part.ContentItem), "Parts/Comments.CountAdmin").Location(part.GetLocation("SummaryAdmin"));
}
@@ -27,8 +27,8 @@ namespace Orchard.Comments.Drivers {
.Where<CommonPartRecord>(rec => rec.Container == contentItem.Record).List();
// Count comments and create template
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<HasComments>() ? item.As<HasComments>().Comments.Count : 0));
int pendingCount = parts.Aggregate(0, (seed, item) => seed + (item.Has<HasComments>() ? item.As<HasComments>().PendingComments.Count : 0));
int count = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().Comments.Count : 0));
int pendingCount = parts.Aggregate(0, (seed, item) => seed + (item.Has<CommentsPart>() ? item.As<CommentsPart>().PendingComments.Count : 0));
return new CommentCountViewModel { Item = contentItem, CommentCount = count, PendingCount = pendingCount};
}

View File

@@ -7,8 +7,8 @@ using Orchard.Core.ContentsLocation.Models;
namespace Orchard.Comments.Drivers {
[UsedImplicitly]
public class HasCommentsDriver : ContentPartDriver<HasComments> {
protected override DriverResult Display(HasComments part, string displayType) {
public class CommentsPartDriver : ContentPartDriver<CommentsPart> {
protected override DriverResult Display(CommentsPart part, string displayType) {
if (part.CommentsShown == false) {
return null;
}
@@ -16,7 +16,7 @@ namespace Orchard.Comments.Drivers {
// todo: (heskew) need to be more flexible with displaying parts somehow. e.g. where should the...
// comment count go in any given skin or what if the skin builder doesn't want the count
if (displayType.StartsWith("Detail")) {
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(part.GetLocation("Detail"));
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Detail"));
}
else if (displayType == "SummaryAdmin") {
var model = new CommentCountViewModel(part);
@@ -32,13 +32,13 @@ namespace Orchard.Comments.Drivers {
}
}
protected override DriverResult Editor(HasComments part) {
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(part.GetLocation("Editor"));
protected override DriverResult Editor(CommentsPart part) {
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor"));
}
protected override DriverResult Editor(HasComments part, IUpdateModel updater) {
protected override DriverResult Editor(CommentsPart part, IUpdateModel updater) {
updater.TryUpdateModel(part, Prefix, null, null);
return ContentPartTemplate(part, "Parts/Comments.HasComments").Location(part.GetLocation("Editor"));
return ContentPartTemplate(part, "Parts/Comments.Comments").Location(part.GetLocation("Editor"));
}
}
}

View File

@@ -24,7 +24,7 @@ namespace Orchard.Comments.Feeds {
Localizer T { get; set; }
public void Populate(FeedContext context) {
foreach (var feedItem in context.Response.Items.OfType<FeedItem<Comment>>()) {
foreach (var feedItem in context.Response.Items.OfType<FeedItem<CommentPart>>()) {
var comment = feedItem.Item;
var commentedOn = _contentManager.Get(feedItem.Item.Record.CommentedOn);
var commentedOnInspector = new ItemInspector(

View File

@@ -30,7 +30,7 @@ namespace Orchard.Comments.Feeds {
limit = (int)limitValue.ConvertTo(typeof(int));
var comments = _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(x => x.CommentedOnContainer == commentedOnContainer && x.Status == CommentStatus.Approved)
.OrderByDescending(x => x.CommentDateUtc)
.Slice(0, limit);

View File

@@ -30,7 +30,7 @@ namespace Orchard.Comments.Feeds {
limit = (int)limitValue.ConvertTo(typeof(int));
var comments = _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(x => x.CommentedOn == commentedOn && x.Status == CommentStatus.Approved)
.OrderByDescending(x => x.CommentDateUtc)
.Slice(0, limit);

View File

@@ -7,8 +7,8 @@ using Orchard.Data;
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class CommentHandler : ContentHandler {
public CommentHandler(IRepository<CommentRecord> commentsRepository) {
public class CommentPartHandler : ContentHandler {
public CommentPartHandler(IRepository<CommentPartRecord> commentsRepository) {
Filters.Add(StorageFilter.For(commentsRepository));
}
}

View File

@@ -5,11 +5,11 @@ using Orchard.ContentManagement.Handlers;
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class CommentSettingsHandler : ContentHandler {
public CommentSettingsHandler(IRepository<CommentSettingsRecord> repository) {
Filters.Add(new ActivatingFilter<CommentSettings>("Site"));
public class CommentSettingsPartHandler : ContentHandler {
public CommentSettingsPartHandler(IRepository<CommentSettingsPartRecord> repository) {
Filters.Add(new ActivatingFilter<CommentSettingsPart>("Site"));
Filters.Add(StorageFilter.For(repository));
Filters.Add(new TemplateFilterForRecord<CommentSettingsRecord>("CommentSettings", "Parts/Comments.SiteSettings"));
Filters.Add(new TemplateFilterForRecord<CommentSettingsPartRecord>("CommentSettingsPart", "Parts/Comments.SiteSettings"));
}
}
}

View File

@@ -8,32 +8,32 @@ using Orchard.ContentManagement.Handlers;
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class HasCommentsHandler : ContentHandler {
public HasCommentsHandler(
public class CommentsPartHandler : ContentHandler {
public CommentsPartHandler(
IContentManager contentManager,
IRepository<HasCommentsRecord> hasCommentsRepository,
IRepository<CommentsPartRecord> commentsRepository,
ICommentService commentService) {
Filters.Add(StorageFilter.For(hasCommentsRepository));
Filters.Add(StorageFilter.For(commentsRepository));
OnInitializing<HasComments>((ctx, x) => {
OnInitializing<CommentsPart>((ctx, x) => {
x.CommentsActive = true;
x.CommentsShown = true;
});
OnLoading<HasComments>((context, comments) => {
OnLoading<CommentsPart>((context, comments) => {
comments._comments.Loader(list => contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Approved)
.List().ToList());
comments._pendingComments.Loader(list => contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(x => x.CommentedOn == context.ContentItem.Id && x.Status == CommentStatus.Pending)
.List().ToList());
});
OnRemoved<HasComments>(
OnRemoved<CommentsPart>(
(context, c) => {
foreach (var comment in commentService.GetCommentsForCommentedContent(context.ContentItem.Id)) {
contentManager.Remove(comment.ContentItem);

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {
public class Comment : ContentPart<CommentRecord> {
public class CommentPart : ContentPart<CommentPartRecord> {
}
}

View File

@@ -3,7 +3,7 @@ using Orchard.ContentManagement.Records;
using Orchard.Data.Conventions;
namespace Orchard.Comments.Models {
public class CommentRecord : ContentPartRecord {
public class CommentPartRecord : ContentPartRecord {
public virtual string Author { get; set; }
public virtual string SiteName { get; set; }
public virtual string UserName { get; set; }

View File

@@ -1,6 +0,0 @@
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {
public class CommentSettings : ContentPart<CommentSettingsRecord> {
}
}

View File

@@ -0,0 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {
public class CommentSettingsPart : ContentPart<CommentSettingsPartRecord> {
}
}

View File

@@ -1,7 +1,7 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Comments.Models {
public class CommentSettingsRecord : ContentPartRecord {
public class CommentSettingsPartRecord : ContentPartRecord {
public virtual bool ModerateComments { get; set; }
public virtual bool EnableSpamProtection { get; set; }
public virtual string AkismetKey { get; set; }

View File

@@ -1,6 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {
public class HasCommentsContainer : ContentPart {
public class CommentsContainerPart : ContentPart {
}
}

View File

@@ -0,0 +1,28 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Utilities;
namespace Orchard.Comments.Models {
public class CommentsPart : ContentPart<CommentsPartRecord> {
public CommentsPart() {
Comments = new List<CommentPart>();
PendingComments = new List<CommentPart>();
}
public readonly LazyField<IList<CommentPart>> _comments = new LazyField<IList<CommentPart>>();
public readonly LazyField<IList<CommentPart>> _pendingComments = new LazyField<IList<CommentPart>>();
public IList<CommentPart> Comments { get { return _comments.Value; } set { _comments.Value = value; } }
public IList<CommentPart> PendingComments { get { return _pendingComments.Value; } set { _pendingComments.Value = value; } }
public bool CommentsShown {
get { return Record.CommentsShown; }
set { Record.CommentsShown = value; }
}
public bool CommentsActive {
get { return Record.CommentsActive; }
set { Record.CommentsActive = value; }
}
}
}

View File

@@ -1,7 +1,7 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Comments.Models {
public class HasCommentsRecord : ContentPartRecord {
public class CommentsPartRecord : ContentPartRecord {
public virtual bool CommentsShown { get; set; }
public virtual bool CommentsActive { get; set; }
}

View File

@@ -1,28 +0,0 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Utilities;
namespace Orchard.Comments.Models {
public class HasComments : ContentPart<HasCommentsRecord> {
public HasComments() {
Comments = new List<Comment>();
PendingComments = new List<Comment>();
}
public readonly LazyField<IList<Comment>> _comments = new LazyField<IList<Comment>>();
public readonly LazyField<IList<Comment>> _pendingComments = new LazyField<IList<Comment>>();
public IList<Comment> Comments { get { return _comments.Value; } set { _comments.Value = value; } }
public IList<Comment> PendingComments { get { return _pendingComments.Value; } set { _pendingComments.Value = value; } }
public bool CommentsShown {
get { return Record.CommentsShown; }
set { Record.CommentsShown = value; }
}
public bool CommentsActive {
get { return Record.CommentsActive; }
set { Record.CommentsActive = value; }
}
}
}

View File

@@ -73,28 +73,28 @@
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Controllers\CommentController.cs" />
<Compile Include="DataMigrations\CommentsDataMigration.cs" />
<Compile Include="Drivers\CommentDriver.cs" />
<Compile Include="Drivers\HasCommentsContainerDriver.cs" />
<Compile Include="Drivers\HasCommentsDriver.cs" />
<Compile Include="Drivers\CommentPartDriver.cs" />
<Compile Include="Drivers\CommentsContainerPartDriver.cs" />
<Compile Include="Drivers\CommentsPartDriver.cs" />
<Compile Include="Extensions\HtmlHelperExtensions.cs" />
<Compile Include="Models\ClosedCommentsRecord.cs" />
<Compile Include="Models\Comment.cs" />
<Compile Include="Handlers\CommentHandler.cs" />
<Compile Include="Models\CommentPart.cs" />
<Compile Include="Handlers\CommentPartHandler.cs" />
<Compile Include="Models\CommentStatus.cs" />
<Compile Include="Models\HasCommentsContainer.cs" />
<Compile Include="Models\CommentsContainerPart.cs" />
<Compile Include="Feeds\CommentedOnContainerFeedQuery.cs" />
<Compile Include="Feeds\CommentedOnFeedQuery.cs" />
<Compile Include="Feeds\CommentFeedItemBuilder.cs" />
<Compile Include="Models\CommentRecord.cs" />
<Compile Include="Models\HasCommentsRecord.cs" />
<Compile Include="Models\CommentPartRecord.cs" />
<Compile Include="Models\CommentsPartRecord.cs" />
<Compile Include="Services\CreateCommentContext.cs" />
<Compile Include="Services\ICommentService.cs" />
<Compile Include="ViewModels\CommentCountViewModel.cs" />
<Compile Include="Models\CommentSettings.cs" />
<Compile Include="Handlers\CommentSettingsHandler.cs" />
<Compile Include="Models\CommentSettingsRecord.cs" />
<Compile Include="Handlers\HasCommentsHandler.cs" />
<Compile Include="Models\HasComments.cs" />
<Compile Include="Models\CommentSettingsPart.cs" />
<Compile Include="Handlers\CommentSettingsPartHandler.cs" />
<Compile Include="Models\CommentSettingsPartRecord.cs" />
<Compile Include="Handlers\CommentsPartHandler.cs" />
<Compile Include="Models\CommentsPart.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\CommentService.cs" />
@@ -111,11 +111,11 @@
<Content Include="Views\Admin\Details.aspx" />
<Content Include="Views\Admin\Edit.aspx" />
<Content Include="Views\Admin\Index.aspx" />
<Content Include="Views\DisplayTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Comments.Count.ascx" />
<Content Include="Views\DisplayTemplates\Parts\Comments.CountAdmin.ascx" />
<Content Include="Views\EditorTemplates\Parts\Comments.SiteSettings.ascx" />
<Content Include="Views\EditorTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Views\EditorTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Views\ListOfComments.ascx" />
<Content Include="Web.config" />
<Content Include="Views\Web.config" />

View File

@@ -32,36 +32,36 @@ namespace Orchard.Comments.Services {
public ILogger Logger { get; set; }
protected virtual IUser CurrentUser { get; [UsedImplicitly] private set; }
public IEnumerable<Comment> GetComments() {
public IEnumerable<CommentPart> GetComments() {
return _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.List();
}
public IEnumerable<Comment> GetComments(CommentStatus status) {
public IEnumerable<CommentPart> GetComments(CommentStatus status) {
return _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(c => c.Status == status)
.List();
}
public IEnumerable<Comment> GetCommentsForCommentedContent(int id) {
public IEnumerable<CommentPart> GetCommentsForCommentedContent(int id) {
return _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(c => c.CommentedOn == id || c.CommentedOnContainer == id)
.List();
}
public IEnumerable<Comment> GetCommentsForCommentedContent(int id, CommentStatus status) {
public IEnumerable<CommentPart> GetCommentsForCommentedContent(int id, CommentStatus status) {
return _contentManager
.Query<Comment, CommentRecord>()
.Query<CommentPart, CommentPartRecord>()
.Where(c => c.CommentedOn == id || c.CommentedOnContainer == id)
.Where(ctx => ctx.Status == status)
.List();
}
public Comment GetComment(int id) {
return _contentManager.Get<Comment>(id);
public CommentPart GetComment(int id) {
return _contentManager.Get<CommentPart>(id);
}
public ContentItemMetadata GetDisplayForCommentedContent(int id) {
@@ -71,8 +71,8 @@ namespace Orchard.Comments.Services {
return _contentManager.GetItemMetadata(content);
}
public Comment CreateComment(CreateCommentContext context, bool moderateComments) {
var comment = _contentManager.Create<Comment>(CommentDriver.ContentType.Name);
public CommentPart CreateComment(CreateCommentContext context, bool moderateComments) {
var comment = _contentManager.Create<CommentPart>(CommentPartDriver.ContentType.Name);
comment.Record.Author = context.Author;
comment.Record.CommentDateUtc = _clock.UtcNow;
@@ -95,27 +95,27 @@ namespace Orchard.Comments.Services {
}
public void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status) {
Comment comment = GetComment(id);
comment.Record.Author = name;
comment.Record.Email = email;
comment.Record.SiteName = siteName;
comment.Record.CommentText = commentText;
comment.Record.Status = status;
CommentPart commentPart = GetComment(id);
commentPart.Record.Author = name;
commentPart.Record.Email = email;
commentPart.Record.SiteName = siteName;
commentPart.Record.CommentText = commentText;
commentPart.Record.Status = status;
}
public void ApproveComment(int commentId) {
Comment comment = GetComment(commentId);
comment.Record.Status = CommentStatus.Approved;
CommentPart commentPart = GetComment(commentId);
commentPart.Record.Status = CommentStatus.Approved;
}
public void PendComment(int commentId) {
Comment comment = GetComment(commentId);
comment.Record.Status = CommentStatus.Pending;
CommentPart commentPart = GetComment(commentId);
commentPart.Record.Status = CommentStatus.Pending;
}
public void MarkCommentAsSpam(int commentId) {
Comment comment = GetComment(commentId);
comment.Record.Status = CommentStatus.Spam;
CommentPart commentPart = GetComment(commentId);
commentPart.Record.Status = CommentStatus.Spam;
}
public void DeleteComment(int commentId) {

View File

@@ -25,11 +25,11 @@ namespace Orchard.Comments.Services {
public Localizer T { get; set; }
protected virtual ISite CurrentSite { get; [UsedImplicitly] private set; }
public bool ValidateComment(Comment comment) {
CommentSettingsRecord commentSettingsRecord = CurrentSite.As<CommentSettings>().Record;
string akismetKey = commentSettingsRecord.AkismetKey;
string akismetUrl = commentSettingsRecord.AkismetUrl;
bool enableSpamProtection = commentSettingsRecord.EnableSpamProtection;
public bool ValidateComment(CommentPart commentPart) {
CommentSettingsPartRecord commentSettingsPartRecord = CurrentSite.As<CommentSettingsPart>().Record;
string akismetKey = commentSettingsPartRecord.AkismetKey;
string akismetUrl = commentSettingsPartRecord.AkismetUrl;
bool enableSpamProtection = commentSettingsPartRecord.EnableSpamProtection;
if (enableSpamProtection == false) {
return true;
}
@@ -42,11 +42,11 @@ namespace Orchard.Comments.Services {
}
Akismet akismetApi = new Akismet(akismetKey, akismetUrl, null);
AkismetComment akismetComment = new AkismetComment {
CommentAuthor = comment.Record.Author,
CommentAuthorEmail = comment.Record.Email,
Blog = comment.Record.SiteName,
CommentAuthorUrl = comment.Record.SiteName,
CommentContent = comment.Record.CommentText,
CommentAuthor = commentPart.Record.Author,
CommentAuthorEmail = commentPart.Record.Email,
Blog = commentPart.Record.SiteName,
CommentAuthorUrl = commentPart.Record.SiteName,
CommentContent = commentPart.Record.CommentText,
UserAgent = HttpContext.Current.Request.UserAgent,
};

View File

@@ -4,13 +4,13 @@ using Orchard.ContentManagement;
namespace Orchard.Comments.Services {
public interface ICommentService : IDependency {
IEnumerable<Comment> GetComments();
IEnumerable<Comment> GetComments(CommentStatus status);
IEnumerable<Comment> GetCommentsForCommentedContent(int id);
IEnumerable<Comment> GetCommentsForCommentedContent(int id, CommentStatus status);
Comment GetComment(int id);
IEnumerable<CommentPart> GetComments();
IEnumerable<CommentPart> GetComments(CommentStatus status);
IEnumerable<CommentPart> GetCommentsForCommentedContent(int id);
IEnumerable<CommentPart> GetCommentsForCommentedContent(int id, CommentStatus status);
CommentPart GetComment(int id);
ContentItemMetadata GetDisplayForCommentedContent(int id);
Comment CreateComment(CreateCommentContext commentRecord, bool moderateComments);
CommentPart CreateComment(CreateCommentContext commentRecord, bool moderateComments);
void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status);
void ApproveComment(int commentId);
void PendComment(int commentId);

View File

@@ -2,6 +2,6 @@ using Orchard.Comments.Models;
namespace Orchard.Comments.Services {
public interface ICommentValidator : IDependency {
bool ValidateComment(Comment comment);
bool ValidateComment(CommentPart commentPart);
}
}

View File

@@ -6,7 +6,7 @@ namespace Orchard.Comments.ViewModels {
public CommentCountViewModel() {
}
public CommentCountViewModel(HasComments part) {
public CommentCountViewModel(CommentsPart part) {
Item = part.ContentItem;
CommentCount = part.Comments.Count;
PendingCount = part.PendingComments.Count;

View File

@@ -9,7 +9,7 @@ namespace Orchard.Comments.ViewModels {
}
public class CommentEntry {
public CommentRecord Comment { get; set; }
public CommentPartRecord Comment { get; set; }
public string CommentedOn { get; set; }
public bool IsChecked { get; set; }
}

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentsPart>" %>
<%@ Import Namespace="Orchard.Comments"%>
<%@ Import Namespace="Orchard.Security" %>
<%@ Import Namespace="Orchard.Comments.Models" %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentsPart>" %>
<%@ Import Namespace="Orchard.Comments.Extensions"%>
<%@ Import Namespace="Orchard.Localization" %>
<%@ Import Namespace="Orchard.Comments.Models" %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentSettingsRecord>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentSettingsPartRecord>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<fieldset>
<legend><%: T("Comments")%></legend>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Comment>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<CommentPart>>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<ul class="comments"><%
foreach (var comment in Model) { %>

View File

@@ -5,7 +5,7 @@ namespace Orchard.Media.DataMigrations {
public int Create() {
//CREATE TABLE Orchard_Media_MediaSettingsRecord (Id INTEGER not null, RootMediaFolder TEXT, primary key (Id));
SchemaBuilder.CreateTable("MediaSettingsRecord", table => table
SchemaBuilder.CreateTable("MediaSettingsPartRecord", table => table
.ContentPartRecord()
.Column<string>("RootMediaFolder")
);
@@ -14,7 +14,7 @@ namespace Orchard.Media.DataMigrations {
}
public int UpdateFrom1() {
// Filters.Add(new ActivatingFilter<MediaSettings>("Site"));
// Filters.Add(new ActivatingFilter<MediaSettingsPart>("Site"));
return 2;
}

View File

@@ -1,18 +0,0 @@
using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Media.Models;
namespace Orchard.Media.Handlers {
[UsedImplicitly]
public class MediaSettingsHandler : ContentHandler {
public MediaSettingsHandler(IRepository<MediaSettingsRecord> repository) {
Filters.Add(StorageFilter.For(repository) );
OnInitializing<MediaSettings>(DefaultSettings);
}
private static void DefaultSettings(InitializingContentContext context, MediaSettings settings) {
settings.Record.RootMediaFolder = "~/Media";
}
}
}

View File

@@ -0,0 +1,18 @@
using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Media.Models;
namespace Orchard.Media.Handlers {
[UsedImplicitly]
public class MediaSettingsPartHandler : ContentHandler {
public MediaSettingsPartHandler(IRepository<MediaSettingsPartRecord> repository) {
Filters.Add(StorageFilter.For(repository) );
OnInitializing<MediaSettingsPart>(DefaultSettings);
}
private static void DefaultSettings(InitializingContentContext context, MediaSettingsPart settingsPart) {
settingsPart.Record.RootMediaFolder = "~/Media";
}
}
}

View File

@@ -1,6 +0,0 @@
using Orchard.ContentManagement;
namespace Orchard.Media.Models {
public class MediaSettings : ContentPart<MediaSettingsRecord> {
}
}

View File

@@ -0,0 +1,6 @@
using Orchard.ContentManagement;
namespace Orchard.Media.Models {
public class MediaSettingsPart : ContentPart<MediaSettingsPartRecord> {
}
}

View File

@@ -1,7 +1,7 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Media.Models {
public class MediaSettingsRecord : ContentPartRecord {
public class MediaSettingsPartRecord : ContentPartRecord {
public virtual string RootMediaFolder { get; set; }
}
}

View File

@@ -73,9 +73,9 @@
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="DataMigrations\MediaDataMigration.cs" />
<Compile Include="Helpers\MediaHelpers.cs" />
<Compile Include="Models\MediaSettings.cs" />
<Compile Include="Handlers\MediaSettingsHandler.cs" />
<Compile Include="Models\MediaSettingsRecord.cs" />
<Compile Include="Models\MediaSettingsPart.cs" />
<Compile Include="Handlers\MediaSettingsPartHandler.cs" />
<Compile Include="Models\MediaSettingsPartRecord.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Models\FolderNavigation.cs" />
<Compile Include="Models\MediaFile.cs" />

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<MediaSettingsRecord>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<MediaSettingsPartRecord>" %>
<%@ Import Namespace="Orchard.Media.Models"%>
<fieldset>
<legend><%: T("Media")%></legend>

View File

@@ -27,7 +27,7 @@ namespace Orchard.Roles.DataMigrations {
);
//CREATE TABLE Orchard_Roles_UserRolesRecord (Id integer, UserId INTEGER, Role_id INTEGER, primary key (Id));
SchemaBuilder.CreateTable("UserRolesRecord", table => table
SchemaBuilder.CreateTable("UserRolesPartRecord", table => table
.Column<int>("Id", column => column.PrimaryKey().Identity())
.Column<int>("UserId")
.Column<int>("Role_id")

View File

@@ -12,15 +12,15 @@ using Orchard.UI.Notify;
namespace Orchard.Roles.Drivers {
[UsedImplicitly]
public class UserRolesDriver : ContentPartDriver<UserRoles> {
private readonly IRepository<UserRolesRecord> _userRolesRepository;
public class UserRolesPartDriver : ContentPartDriver<UserRolesPart> {
private readonly IRepository<UserRolesPartRecord> _userRolesRepository;
private readonly IRoleService _roleService;
private readonly INotifier _notifier;
private readonly IAuthenticationService _authenticationService;
private readonly IAuthorizationService _authorizationService;
public UserRolesDriver(
IRepository<UserRolesRecord> userRolesRepository,
public UserRolesPartDriver(
IRepository<UserRolesPartRecord> userRolesRepository,
IRoleService roleService,
INotifier notifier,
IAuthenticationService authenticationService,
@@ -41,9 +41,9 @@ namespace Orchard.Roles.Drivers {
public Localizer T { get; set; }
protected override DriverResult Editor(UserRoles userRoles) {
protected override DriverResult Editor(UserRolesPart userRolesPart) {
// don't show editor without apply roles permission
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRoles))
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart))
return null;
var roles =
@@ -51,25 +51,25 @@ namespace Orchard.Roles.Drivers {
x => new UserRoleEntry {
RoleId = x.Id,
Name = x.Name,
Granted = userRoles.Roles.Contains(x.Name)
Granted = userRolesPart.Roles.Contains(x.Name)
});
var model = new UserRolesViewModel {
User = userRoles.As<IUser>(),
UserRoles = userRoles,
User = userRolesPart.As<IUser>(),
UserRoles = userRolesPart,
Roles = roles.ToList(),
};
return ContentPartTemplate(model, "Parts/Roles.UserRoles");
}
protected override DriverResult Editor(UserRoles userRoles, IUpdateModel updater) {
protected override DriverResult Editor(UserRolesPart userRolesPart, IUpdateModel updater) {
// don't apply editor without apply roles permission
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRoles))
if (!_authorizationService.TryCheckAccess(Permissions.ApplyRoles, _authenticationService.GetAuthenticatedUser(), userRolesPart))
return null;
var model = new UserRolesViewModel {
User = userRoles.As<IUser>(),
UserRoles = userRoles,
User = userRolesPart.As<IUser>(),
UserRoles = userRolesPart,
};
if (updater.TryUpdateModel(model, Prefix, null, null)) {
@@ -79,12 +79,12 @@ namespace Orchard.Roles.Drivers {
var targetRoleRecords = model.Roles.Where(x => x.Granted).Select(x => _roleService.GetRole(x.RoleId));
foreach (var addingRole in targetRoleRecords.Where(x => !currentRoleRecords.Contains(x))) {
_notifier.Warning(T("Adding role {0} to user {1}", addingRole.Name, userRoles.As<IUser>().UserName));
_userRolesRepository.Create(new UserRolesRecord { UserId = model.User.Id, Role = addingRole });
_notifier.Warning(T("Adding role {0} to user {1}", addingRole.Name, userRolesPart.As<IUser>().UserName));
_userRolesRepository.Create(new UserRolesPartRecord { UserId = model.User.Id, Role = addingRole });
}
foreach (var removingRole in currentUserRoleRecords.Where(x => !targetRoleRecords.Contains(x.Role))) {
_notifier.Warning(T("Removing role {0} from user {1}", removingRole.Role.Name, userRoles.As<IUser>().UserName));
_notifier.Warning(T("Removing role {0} from user {1}", removingRole.Role.Name, userRolesPart.As<IUser>().UserName));
_userRolesRepository.Delete(removingRole);
}

View File

@@ -6,14 +6,14 @@ using Orchard.Roles.Models;
namespace Orchard.Roles.Handlers {
[UsedImplicitly]
public class UserRolesHandler : ContentHandler {
private readonly IRepository<UserRolesRecord> _userRolesRepository;
public class UserRolesPartHandler : ContentHandler {
private readonly IRepository<UserRolesPartRecord> _userRolesRepository;
public UserRolesHandler(IRepository<UserRolesRecord> userRolesRepository) {
public UserRolesPartHandler(IRepository<UserRolesPartRecord> userRolesRepository) {
_userRolesRepository = userRolesRepository;
Filters.Add(new ActivatingFilter<UserRoles>("User"));
OnLoaded<UserRoles>((context, userRoles) => {
Filters.Add(new ActivatingFilter<UserRolesPart>("User"));
OnLoaded<UserRolesPart>((context, userRoles) => {
userRoles.Roles = _userRolesRepository
.Fetch(x => x.UserId == context.ContentItem.Id)
.Select(x => x.Role.Name).ToList();

View File

@@ -2,8 +2,8 @@ using System.Collections.Generic;
using Orchard.ContentManagement;
namespace Orchard.Roles.Models {
public class UserRoles : ContentPart, IUserRoles {
public UserRoles() {
public class UserRolesPart : ContentPart, IUserRoles {
public UserRolesPart() {
Roles = new List<string>();
}

View File

@@ -1,5 +1,5 @@
namespace Orchard.Roles.Models {
public class UserRolesRecord {
public class UserRolesPartRecord {
public virtual int Id { get; set; }
public virtual int UserId { get; set; }
public virtual RoleRecord Role { get; set; }

View File

@@ -9,3 +9,4 @@ features:
Orchard.Roles:
Description: Standard user roles.
Category: Core
Dependencies: Orchard.Users

View File

@@ -68,17 +68,17 @@
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="DataMigrations\RolesDataMigration.cs" />
<Compile Include="Drivers\UserRolesDriver.cs" />
<Compile Include="Drivers\UserRolesPartDriver.cs" />
<Compile Include="DefaultRoleUpdater.cs" />
<Compile Include="Models\IUserRoles.cs" />
<Compile Include="Models\UserSimulation.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Models\PermissionRecord.cs" />
<Compile Include="Models\RoleRecord.cs" />
<Compile Include="Models\UserRoles.cs" />
<Compile Include="Handlers\UserRolesHandler.cs" />
<Compile Include="Models\UserRolesPart.cs" />
<Compile Include="Handlers\UserRolesPartHandler.cs" />
<Compile Include="Models\RolesPermissionsRecord.cs" />
<Compile Include="Models\UserRolesRecord.cs" />
<Compile Include="Models\UserRolesPartRecord.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\IRoleService.cs" />
<Compile Include="Services\RolesBasedAuthorizationService.cs" />

View File

@@ -191,7 +191,7 @@ namespace Orchard.Setup.Services {
var contentDefinitionManager = environment.Resolve<IContentDefinitionManager>();
contentDefinitionManager.AlterTypeDefinition("BlogPost", cfg => cfg
.DisplayedAs("Blog Post")
.WithPart("HasComments")
.WithPart("CommentsPart")
.WithPart("HasTags")
.WithPart("Localized")
.Indexed());
@@ -201,7 +201,7 @@ namespace Orchard.Setup.Services {
.WithPart("PublishLaterPart")
.WithPart("IsRoutable")
.WithPart("BodyPart")
.WithPart("HasComments")
.WithPart("CommentsPart")
.WithPart("HasTags")
.WithPart("Localized")
.Indexed());
@@ -215,8 +215,8 @@ namespace Orchard.Setup.Services {
page.As<IsRoutable>().Path = "home";
page.As<IsRoutable>().Title = T("Home").ToString();
page.As<CommonPart>().Owner = user;
if (page.Has<HasComments>()) {
page.As<HasComments>().CommentsShown = false;
if (page.Has<CommentsPart>()) {
page.As<CommentsPart>().CommentsShown = false;
}
contentManager.Publish(page);
siteSettings.Record.HomePage = "RoutableHomePageProvider;" + page.Id;

View File

@@ -195,7 +195,7 @@
<Content Include="Themes\Contoso\Views\DisplayTemplates\Items\Blogs.BlogPost.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Items\Pages.Page.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Items\Blogs.BlogPost.ListByArchive.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Pages.Page.Metadata.ascx" />
<Content Include="Themes\Contoso\Views\DisplayTemplates\Parts\Tags.ShowTags.ascx" />
<Content Include="Themes\Contoso\Views\Header.ascx" />
@@ -239,7 +239,7 @@
<Content Include="Themes\Corporate\Views\DisplayTemplates\Items\Blogs.BlogPost.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Items\Blogs.BlogPost.ListByArchive.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Items\Pages.Page.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Pages.Page.Metadata.ascx" />
<Content Include="Themes\Corporate\Views\DisplayTemplates\Parts\Tags.ShowTags.ascx" />
<Content Include="Themes\Corporate\Views\Footer.ascx" />

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<h1><%: Html.TitleForPage(Model.Item.Title)%></h1>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPartPart>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Core.Common.Extensions" %><%

View File

@@ -1,3 +1,3 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<h1><%: Html.TitleForPage(Model.Item.Title)%></h1>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPartPart>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Core.Common.Extensions" %><%

View File

@@ -1,3 +1,3 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentsPart>" %>
<%@ Import Namespace="Orchard.Comments"%>
<%@ Import Namespace="Orchard.Security" %>
<%@ Import Namespace="Orchard.Comments.Models" %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Comment>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<CommentPart>>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<ul class="comments"><%
foreach (var comment in Model) { %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<CommentsPart>" %>
<%@ Import Namespace="Orchard.Comments"%>
<%@ Import Namespace="Orchard.Security" %>
<%@ Import Namespace="Orchard.Comments.Models" %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Comment>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<CommentPart>>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<ul class="comments"><%
foreach (var comment in Model) { %>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPartPart>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ContentItemViewModel<BlogPart>>" %>
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<h1><%: Html.TitleForPage(Model.Item.Title)%></h1>

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPartPart>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<BlogPart>" %>
<%@ Import Namespace="Orchard.Blogs.Extensions"%>
<%@ Import Namespace="Orchard.Blogs.Models"%>
<%@ Import Namespace="Orchard.Core.Common.Extensions" %><%

View File

@@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<Comment>>" %>
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<IEnumerable<CommentPart>>" %>
<%@ Import Namespace="Orchard.Comments.Models"%>
<ul class="comments"><%
foreach (var comment in Model) { %>

View File

@@ -198,7 +198,7 @@
<Content Include="Themes\Green\Views\DisplayTemplates\Items\Blogs.Blog.Summary.ascx" />
<Content Include="Themes\Green\Views\DisplayTemplates\Items\Blogs.BlogPost.Summary.ascx" />
<Content Include="Themes\Green\Views\DisplayTemplates\Items\Pages.Page.ascx" />
<Content Include="Themes\Green\Views\DisplayTemplates\Parts\Comments.HasComments.ascx" />
<Content Include="Themes\Green\Views\DisplayTemplates\Parts\Comments.Comments.ascx" />
<Content Include="Themes\Green\Views\Footer.ascx" />
<Content Include="Themes\Green\Views\Layout.ascx" />
<Content Include="Themes\Green\Views\ListOfComments.ascx" />