diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Lists/Controllers/AdminController.cs index d00d09baf..8f7ffdf82 100644 --- a/src/Orchard.Web/Modules/Orchard.Lists/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Lists/Controllers/AdminController.cs @@ -63,6 +63,7 @@ namespace Lists.Controllers { if (container == null || !container.Has()) { return HttpNotFound(); } + var restrictedContentType = container.As().Record.ItemContentType; var hasRestriction = !string.IsNullOrEmpty(restrictedContentType); if (hasRestriction) { @@ -80,11 +81,9 @@ namespace Lists.Controllers { return new HttpNotFoundResult(); } - if (!hasRestriction) { - model.Options.FilterOptions = GetContainableTypes() - .Select(ctd => new KeyValuePair(ctd.Name, ctd.DisplayName)) - .ToList().OrderBy(kvp => kvp.Key); - } + model.Options.FilterOptions = GetContainableTypes() + .Select(ctd => new KeyValuePair(ctd.Name, ctd.DisplayName)) + .ToList().OrderBy(kvp => kvp.Key); var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count()); var pageOfContentItems = query.Slice(pager.GetStartIndex(), pager.PageSize).ToList(); @@ -97,8 +96,8 @@ namespace Lists.Controllers { .Pager(pagerShape) .ContainerId(model.ContainerId) .Options(model.Options) - .HasRestriction(hasRestriction) .ContainerDisplayName(model.ContainerDisplayName) + .HasRestriction(hasRestriction) .ContainerContentType(container.ContentType) .ContainerItemContentType(hasRestriction ? restrictedContentType : (model.FilterByContentType ?? "")) .OtherLists(_contentManager.Query(VersionOptions.Latest).List() @@ -301,6 +300,7 @@ namespace Lists.Controllers { Services.Notifier.Information(T("Please select the list to move the items to.")); return true; } + var itemContentType = targetContainer.Record.ItemContentType; foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) { @@ -309,6 +309,7 @@ namespace Lists.Controllers { } // ensure the item can be in that container. if (!string.IsNullOrEmpty(itemContentType) && item.ContentType != itemContentType) { + Services.TransactionManager.Cancel(); Services.Notifier.Information(T("One or more items could not be moved to '{0}' because it is restricted to containing items of type '{1}'.", _contentManager.GetItemMetadata(targetContainer).DisplayText, itemContentType)); return true; // todo: transactions } @@ -323,6 +324,7 @@ namespace Lists.Controllers { private bool BulkRemoveFromList(IEnumerable itemIds) { foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) { if (!Services.Authorizer.Authorize(Permissions.EditContent, item, T("Couldn't remove selected content from the list."))) { + Services.TransactionManager.Cancel(); return false; } item.As().Record.Container = null; @@ -334,6 +336,7 @@ namespace Lists.Controllers { private bool BulkRemove(IEnumerable itemIds) { foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) { if (!Services.Authorizer.Authorize(Permissions.DeleteContent, item, T("Couldn't remove selected content."))) { + Services.TransactionManager.Cancel(); return false; } @@ -346,6 +349,7 @@ namespace Lists.Controllers { private bool BulkUnpublish(IEnumerable itemIds) { foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) { if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't unpublish selected content."))) { + Services.TransactionManager.Cancel(); return false; } @@ -357,8 +361,10 @@ namespace Lists.Controllers { private bool BulkPublishNow(IEnumerable itemIds) { foreach (var item in itemIds.Select(itemId => _contentManager.GetLatest(itemId))) { - if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't publish selected content."))) + if (!Services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't publish selected content."))) { + Services.TransactionManager.Cancel(); return false; + } _contentManager.Publish(item); } diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/List.cshtml b/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/List.cshtml index 5c2c4fe58..807f752b3 100644 --- a/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/List.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Lists/Views/Admin/List.cshtml @@ -43,15 +43,13 @@
- @if(!Model.HasRestriction) { - @Html.SelectOption((string)Model.Options.SelectedFilter, "", T("any (show all)").ToString()) @foreach(var filterOption in Model.Options.FilterOptions) { @Html.SelectOption((string)Model.Options.SelectedFilter, (string)filterOption.Key, (string)filterOption.Value) } - }