diff --git a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js index 7cf9c61111..72cbfe9cd2 100644 --- a/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js +++ b/src/Umbraco.Web.UI.Client/src/common/resources/content.resource.js @@ -531,8 +531,25 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) { */ publish: function (content, isNew, files) { return saveContentItem(content, "publish" + (isNew ? "New" : ""), files); + }, + + publishById: function(id){ + + if (!id) { + throw "id cannot be null"; + } + + return umbRequestHelper.resourcePromise( + $http.post( + umbRequestHelper.getApiUrl( + "contentApiBaseUrl", + "PostPublishById", + [{ id: id }])), + 'Failed to publish content with id ' + id); + } + }; } diff --git a/src/Umbraco.Web/Editors/ContentController.cs b/src/Umbraco.Web/Editors/ContentController.cs index 4c21914a5d..594f984de1 100644 --- a/src/Umbraco.Web/Editors/ContentController.cs +++ b/src/Umbraco.Web/Editors/ContentController.cs @@ -282,6 +282,30 @@ namespace Umbraco.Web.Editors return display; } + /// + /// Publishes a document with a given ID + /// + /// + /// + /// + /// The CanAccessContentAuthorize attribute will deny access to this method if the current user + /// does not have Publish access to this node. + /// + /// + [EnsureUserPermissionForContent("id", 'P')] + public HttpResponseMessage PostPublishById(int id) + { + var foundContent = Services.ContentService.GetById(id); + if (foundContent == null) + { + return HandleContentNotFound(id, false); + } + + Services.ContentService.Publish(foundContent, UmbracoUser.Id); + return Request.CreateResponse(HttpStatusCode.OK); + + } + /// /// Moves an item to the recycle bin, if it is already there then it will permanently delete it /// @@ -292,6 +316,7 @@ namespace Umbraco.Web.Editors /// does not have Delete access to this node. /// [EnsureUserPermissionForContent("id", 'D')] + [HttpDelete] public HttpResponseMessage DeleteById(int id) { //TODO: We need to check if the user is allowed to do this!