Fixes usages of IUserService.GetPermission since before it was doing a FirstOrDefault() since that's just how the old APIs worked, now we need to get all permissions based on groups. Also updated the usages of ToString for char for the permissions to be culture invariant everywhere.

This commit is contained in:
Shannon
2017-07-13 14:32:43 +10:00
parent 69a6a80ffd
commit 6e89202002
9 changed files with 21 additions and 21 deletions

View File

@@ -135,7 +135,7 @@ namespace Umbraco.Web.Models.Mapping
Label = localizedText.Localize("content/releaseDate"),
Value = display.ReleaseDate.HasValue ? display.ReleaseDate.Value.ToIsoString() : null,
//Not editible for people without publish permission (U4-287)
View = display.AllowedActions.Contains(ActionPublish.Instance.Letter) ? "datepicker" : PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias).ValueEditor.View,
View = display.AllowedActions.Contains(ActionPublish.Instance.Letter.ToString(CultureInfo.InvariantCulture)) ? "datepicker" : PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias).ValueEditor.View,
Config = new Dictionary<string, object>
{
{"offsetTime", "1"}
@@ -148,7 +148,7 @@ namespace Umbraco.Web.Models.Mapping
Label = localizedText.Localize("content/unpublishDate"),
Value = display.ExpireDate.HasValue ? display.ExpireDate.Value.ToIsoString() : null,
//Not editible for people without publish permission (U4-287)
View = display.AllowedActions.Contains(ActionPublish.Instance.Letter) ? "datepicker" : PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias).ValueEditor.View,
View = display.AllowedActions.Contains(ActionPublish.Instance.Letter.ToString(CultureInfo.InvariantCulture)) ? "datepicker" : PropertyEditorResolver.Current.GetByAlias(Constants.PropertyEditors.NoEditAlias).ValueEditor.View,
Config = new Dictionary<string, object>
{
{"offsetTime", "1"}
@@ -213,10 +213,9 @@ namespace Umbraco.Web.Models.Mapping
}
/// <summary>
//TODO: This is horribly inneficient
/// Creates the list of action buttons allowed for this user - Publish, Send to publish, save, unpublish returned as the button's 'letter'
/// </summary>
private class ActionButtonsResolver : ValueResolver<IContent, IEnumerable<char>>
private class ActionButtonsResolver : ValueResolver<IContent, IEnumerable<string>>
{
private readonly Lazy<IUserService> _userService;
@@ -225,12 +224,12 @@ namespace Umbraco.Web.Models.Mapping
_userService = userService;
}
protected override IEnumerable<char> ResolveCore(IContent source)
protected override IEnumerable<string> ResolveCore(IContent source)
{
if (UmbracoContext.Current == null)
{
//cannot check permissions without a context
return Enumerable.Empty<char>();
return Enumerable.Empty<string>();
}
var svc = _userService.Value;
@@ -242,11 +241,9 @@ namespace Umbraco.Web.Models.Mapping
// Here we need to do a special check since this could be new content, in which case we need to get the permissions
// from the parent, not the existing one otherwise permissions would be coming from the root since Id is 0.
source.HasIdentity ? source.Id : source.ParentId)
.FirstOrDefault();
.GetAllPermissions();
return permissions == null
? Enumerable.Empty<char>()
: permissions.AssignedPermissions.Where(x => x.Length == 1).Select(x => x.ToUpperInvariant()[0]);
return permissions;
}
}
}