Adding modified by to common part

This commit is contained in:
Bing Huan Chio
2015-04-22 12:22:00 -07:00
parent 96b41fb9b7
commit df483c3a8e
4 changed files with 42 additions and 20 deletions

View File

@@ -97,6 +97,7 @@ namespace Orchard.Core.Common.Handlers {
part.ModifiedUtc = utcNow;
part.VersionCreatedUtc = utcNow;
part.VersionModifiedUtc = utcNow;
part.VersionModifiedBy = GetUserName();
}
private void AssignUpdateDates(UpdateEditorContext context, CommonPart part) {
@@ -104,6 +105,7 @@ namespace Orchard.Core.Common.Handlers {
part.ModifiedUtc = utcNow;
part.VersionModifiedUtc = utcNow;
part.VersionModifiedBy = GetUserName();
}
private void AssignRemovingDates(RemoveContentContext context, CommonPart part) {
@@ -111,6 +113,7 @@ namespace Orchard.Core.Common.Handlers {
part.ModifiedUtc = utcNow;
part.VersionModifiedUtc = utcNow;
part.VersionModifiedBy = GetUserName();
}
protected void AssignVersioningDates(VersionContentContext context, CommonPart existing, CommonPart building) {
@@ -120,6 +123,7 @@ namespace Orchard.Core.Common.Handlers {
building.VersionCreatedUtc = utcNow;
// assign modified date for the new version
building.VersionModifiedUtc = utcNow;
building.VersionModifiedBy = GetUserName();
// publish date should be null until publish method called
building.VersionPublishedUtc = null;
@@ -170,5 +174,9 @@ namespace Orchard.Core.Common.Handlers {
if (part.ContainerField.Value != null)
part.ContainerField.Value = part.ContainerField.Value;
}
private string GetUserName() {
var user = _authenticationService.GetAuthenticatedUser();
return (user == null) ? string.Empty : user.UserName;
}
}
}

View File

@@ -107,5 +107,9 @@ namespace Orchard.Core.Common {
return 4;
}
public int UpdateFrom4() {
SchemaBuilder.AlterTable("CommonPartVersionRecord", table => table.AddColumn<string>("ModifiedBy", command => command.Nullable()));
return 5;
}
}
}

View File

@@ -54,6 +54,15 @@ namespace Orchard.Core.Common.Models {
PartVersionRecord.CreatedUtc = value;
}
}
public string VersionModifiedBy {
get {
return PartVersionRecord == null ? null : PartVersionRecord.ModifiedBy;
}
set {
if (PartVersionRecord != null)
PartVersionRecord.ModifiedBy = value;
}
}
public DateTime? VersionPublishedUtc {
get {

View File

@@ -6,5 +6,6 @@ namespace Orchard.Core.Common.Models {
public virtual DateTime? CreatedUtc { get; set; }
public virtual DateTime? PublishedUtc { get; set; }
public virtual DateTime? ModifiedUtc { get; set; }
public virtual string ModifiedBy { get; set; }
}
}