mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
Adding setting to common part owner as well with default set to true. Removing incorrect permission check, adding missing UTC conversion.
--HG-- branch : 1.x
This commit is contained in:
@@ -73,7 +73,9 @@ namespace Orchard.Core.Common.Drivers {
|
||||
List<DriverResult> parts = new List<DriverResult>();
|
||||
CommonTypePartSettings commonTypePartSettings = GetTypeSettings(part);
|
||||
|
||||
parts.Add(OwnerEditor(part, updater, shapeHelper));
|
||||
if (commonTypePartSettings.ShowOwnerEditor) {
|
||||
parts.Add(OwnerEditor(part, updater, shapeHelper));
|
||||
}
|
||||
|
||||
if (commonTypePartSettings.ShowCreatedUtcEditor) {
|
||||
parts.Add(CreatedUtcEditor(part, updater, shapeHelper));
|
||||
@@ -114,12 +116,7 @@ namespace Orchard.Core.Common.Drivers {
|
||||
}
|
||||
|
||||
DriverResult CreatedUtcEditor(CommonPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var currentUser = _authenticationService.GetAuthenticatedUser();
|
||||
if (!_authorizationService.TryCheckAccess(StandardPermissions.SiteOwner, currentUser, part)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var model = new CreatedUtcEditorViewModel();
|
||||
CreatedUtcEditorViewModel model = new CreatedUtcEditorViewModel();
|
||||
if (part.CreatedUtc != null) {
|
||||
model.CreatedDate = part.CreatedUtc.Value.ToLocalTime().ToString(DatePattern, CultureInfo.InvariantCulture);
|
||||
model.CreatedTime = part.CreatedUtc.Value.ToLocalTime().ToString(TimePattern, CultureInfo.InvariantCulture);
|
||||
@@ -134,7 +131,7 @@ namespace Orchard.Core.Common.Drivers {
|
||||
|
||||
// use an english culture as it is the one used by jQuery.datepicker by default
|
||||
if (DateTime.TryParse(parseDateTime, CultureInfo.GetCultureInfo("en-US"), DateTimeStyles.AssumeLocal, out createdUtc)) {
|
||||
part.CreatedUtc = createdUtc;
|
||||
part.CreatedUtc = createdUtc.ToUniversalTime();
|
||||
}
|
||||
else {
|
||||
updater.AddModelError(Prefix, T("{0} is an invalid date and time", parseDateTime));
|
||||
|
@@ -7,7 +7,12 @@ using Orchard.ContentManagement.ViewModels;
|
||||
|
||||
namespace Orchard.Core.Common.Settings {
|
||||
public class CommonTypePartSettings {
|
||||
public CommonTypePartSettings() {
|
||||
ShowOwnerEditor = true;
|
||||
}
|
||||
|
||||
public bool ShowCreatedUtcEditor { get; set; }
|
||||
public bool ShowOwnerEditor { get; set; }
|
||||
}
|
||||
|
||||
public class CommonSettingsHooks : ContentDefinitionEditorEventsBase {
|
||||
@@ -26,6 +31,7 @@ namespace Orchard.Core.Common.Settings {
|
||||
var model = new CommonTypePartSettings();
|
||||
updateModel.TryUpdateModel(model, "CommonTypePartSettings", null, null);
|
||||
builder.WithSetting("CommonTypePartSettings.ShowCreatedUtcEditor", model.ShowCreatedUtcEditor.ToString());
|
||||
builder.WithSetting("CommonTypePartSettings.ShowOwnerEditor", model.ShowOwnerEditor.ToString());
|
||||
yield return DefinitionTemplate(model);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,12 @@
|
||||
@model Orchard.Core.Common.Settings.CommonTypePartSettings
|
||||
<fieldset>
|
||||
@Html.CheckBoxFor(m => m.ShowCreatedUtcEditor)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.ShowCreatedUtcEditor)">@T("Show editor for create date time")</label>
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.ShowCreatedUtcEditor)">@T("Show editor for creation date time")</label>
|
||||
@Html.ValidationMessageFor(m => m.ShowCreatedUtcEditor)
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
@Html.CheckBoxFor(m => m.ShowOwnerEditor)
|
||||
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.ShowOwnerEditor)">@T("Show editor for owner")</label>
|
||||
@Html.ValidationMessageFor(m => m.ShowOwnerEditor)
|
||||
</fieldset>
|
@@ -34,7 +34,7 @@
|
||||
}
|
||||
});
|
||||
$('#@ViewData.TemplateInfo.GetFullHtmlFieldId("CreatedDate")').datepicker({ showAnim: "" }).focus(function () { $('#@ViewData.TemplateInfo.GetFullHtmlFieldId("Command_Created")').attr("checked", "checked") });
|
||||
$('#@ViewData.TemplateInfo.GetFullHtmlFieldId("CreatedTime")').timepickr().focus(function () { $('#@ViewData.TemplateInfo.GetFullHtmlFieldId("Command_Created")').attr("checked", "checked") });
|
||||
$('#@ViewData.TemplateInfo.GetFullHtmlFieldId("CreatedTime")').timepickr({ showAnim: "" }).focus(function () { $('#@ViewData.TemplateInfo.GetFullHtmlFieldId("Command_Created")').attr("checked", "checked") });
|
||||
})
|
||||
//]]>
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user