Пример #1
0
        public ActionResult ListPOST(ContentOptions options, IEnumerable <int> itemIds, PagerParameters pagerParameters)
        {
            if (itemIds != null)
            {
                var checkedContentItems = _contentManager.GetMany <ContentItem>(itemIds, VersionOptions.Latest, QueryHints.Empty);
                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.PublishNow:
                    foreach (var item in checkedContentItems)
                    {
                        if (!_services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.PublishContent, item, T("Couldn't publish selected lists.")))
                        {
                            _transactionManager.Cancel();
                            return(new HttpUnauthorizedResult());
                        }
                        _contentManager.Publish(item);
                    }
                    _services.Notifier.Success(T("Lists successfully published."));
                    break;

                case ContentsBulkAction.Unpublish:
                    foreach (var item in checkedContentItems)
                    {
                        if (!_services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.PublishContent, item, T("Couldn't unpublish selected lists.")))
                        {
                            _transactionManager.Cancel();
                            return(new HttpUnauthorizedResult());
                        }
                        _contentManager.Unpublish(item);
                    }
                    _services.Notifier.Success(T("Lists successfully unpublished."));
                    break;

                case ContentsBulkAction.Remove:
                    foreach (var item in checkedContentItems)
                    {
                        if (!_services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.DeleteContent, item, T("Couldn't remove selected lists.")))
                        {
                            _transactionManager.Cancel();
                            return(new HttpUnauthorizedResult());
                        }
                        _contentManager.Remove(item);
                    }
                    _services.Notifier.Success(T("Lists successfully removed."));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(RedirectToAction("Index", new { page = pagerParameters.Page, pageSize = pagerParameters.PageSize }));
        }
Пример #2
0
        public ActionResult ListOrderPOST(ContentOptions options)
        {
            var routeValues = ControllerContext.RouteData.Values;

            if (options != null)
            {
                routeValues["Options.OrderBy"] = options.OrderBy;
            }
            return(RedirectToAction("List", routeValues));
        }
Пример #3
0
        public ActionResult ListPOST(ContentOptions options, IEnumerable <int> itemIds, int?targetContainerId, PagerParameters pagerParameters, string returnUrl)
        {
            if (itemIds != null)
            {
                switch (options.BulkAction)
                {
                case ContentsBulkAction.None:
                    break;

                case ContentsBulkAction.PublishNow:
                    if (!BulkPublishNow(itemIds))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                case ContentsBulkAction.Unpublish:
                    if (!BulkUnpublish(itemIds))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                case ContentsBulkAction.Remove:
                    if (!BulkRemove(itemIds))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                case ContentsBulkAction.RemoveFromList:
                    if (!BulkRemoveFromList(itemIds))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                case ContentsBulkAction.MoveToList:
                    if (!BulkMoveToList(itemIds, targetContainerId))
                    {
                        return(new HttpUnauthorizedResult());
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(this.RedirectLocal(returnUrl, () => RedirectToAction("List", new { page = pagerParameters.Page, pageSize = pagerParameters.PageSize })));
        }
Пример #4
0
        public ActionResult ListFilterPOST(ContentOptions options)
        {
            var routeValues = ControllerContext.RouteData.Values;

            if (options != null)
            {
                routeValues["Options.OrderBy"] = options.OrderBy;
                if (_containerService.GetContainerTypes().Any(ctd => string.Equals(ctd.Name, options.SelectedFilter, StringComparison.OrdinalIgnoreCase)))
                {
                    routeValues["id"] = options.SelectedFilter;
                }
                else
                {
                    routeValues.Remove("id");
                }
            }

            return(RedirectToAction("Index", routeValues));
        }
Пример #5
0
 public ListContentsViewModel() {
     Options = new ContentOptions();
 }
 public ListContentsViewModel()
 {
     Options = new ContentOptions();
 }
Пример #7
0
        public ActionResult ListPOST(ContentOptions options, IEnumerable<int> itemIds, int? targetContainerId, PagerParameters pagerParameters, string returnUrl) {
            if (itemIds != null) {
                switch (options.BulkAction) {
                    case ContentsBulkAction.None:
                        break;
                    case ContentsBulkAction.PublishNow:
                        if (!BulkPublishNow(itemIds)) {
                            return new HttpUnauthorizedResult();
                        }
                        break;
                    case ContentsBulkAction.Unpublish:
                        if (!BulkUnpublish(itemIds)) {
                            return new HttpUnauthorizedResult();
                        }
                        break;
                    case ContentsBulkAction.Remove:
                        if (!BulkRemove(itemIds)) {
                            return new HttpUnauthorizedResult();
                        }
                        break;
                    case ContentsBulkAction.RemoveFromList:
                        if (!BulkRemoveFromList(itemIds)) {
                            return new HttpUnauthorizedResult();
                        }
                        break;
                    case ContentsBulkAction.MoveToList:
                        if (!BulkMoveToList(itemIds, targetContainerId)) {
                            return new HttpUnauthorizedResult();
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }

            return this.RedirectLocal(returnUrl, () => RedirectToAction("List", new { page = pagerParameters.Page, pageSize = pagerParameters.PageSize }));
        }
Пример #8
0
 public ActionResult ListOrderPOST(ContentOptions options) {
     var routeValues = ControllerContext.RouteData.Values;
     if (options != null) {
         routeValues["Options.OrderBy"] = options.OrderBy;
     }
     return RedirectToAction("List", routeValues);
 }
Пример #9
0
        public ActionResult ListPOST(ContentOptions options, IEnumerable<int> itemIds, PagerParameters pagerParameters) {
            if (itemIds != null) {
                var checkedContentItems = _contentManager.GetMany<ContentItem>(itemIds, VersionOptions.Latest, QueryHints.Empty);
                switch (options.BulkAction) {
                    case ContentsBulkAction.None:
                        break;
                    case ContentsBulkAction.PublishNow:
                        foreach (var item in checkedContentItems) {
                            if (!_services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't publish selected lists."))) {
                                _transactionManager.Cancel();
                                return new HttpUnauthorizedResult();
                            }
                            _contentManager.Publish(item);
                        }
                        _services.Notifier.Information(T("Lists successfully published."));
                        break;
                    case ContentsBulkAction.Unpublish:
                        foreach (var item in checkedContentItems) {
                            if (!_services.Authorizer.Authorize(Permissions.PublishContent, item, T("Couldn't unpublish selected lists."))) {
                                _transactionManager.Cancel();
                                return new HttpUnauthorizedResult();
                            }
                            _contentManager.Unpublish(item);
                        }
                        _services.Notifier.Information(T("Lists successfully unpublished."));
                        break;
                    case ContentsBulkAction.Remove:
                        foreach (var item in checkedContentItems) {
                            if (!_services.Authorizer.Authorize(Permissions.DeleteContent, item, T("Couldn't remove selected lists."))) {
                                _transactionManager.Cancel();
                                return new HttpUnauthorizedResult();
                            }
                            _contentManager.Remove(item);
                        }
                        _services.Notifier.Information(T("Lists successfully removed."));
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }
            }

            return RedirectToAction("Index", new { page = pagerParameters.Page, pageSize = pagerParameters.PageSize });
        }
Пример #10
0
        public ActionResult ListFilterPOST(ContentOptions options) {
            var routeValues = ControllerContext.RouteData.Values;
            if (options != null) {
                routeValues["Options.OrderBy"] = options.OrderBy;
                if (_containerService.GetContainerTypes().Any(ctd => string.Equals(ctd.Name, options.SelectedFilter, StringComparison.OrdinalIgnoreCase))) {
                    routeValues["id"] = options.SelectedFilter;
                }
                else {
                    routeValues.Remove("id");
                }
            }

            return RedirectToAction("Index", routeValues);
        }